@extends('layouts.master')

@section('style')
    <link href="{{URL::asset('assets/css/jquery.datetimepicker.css')}}" rel="stylesheet" type="text/css"/>

    <style type="text/css">
        .cls-overflow{
            height: 800px;
            overflow: scroll;
        }

        .cls-overflow-one{
            height: 200px;
            overflow: scroll;
        }
    </style>
@endsection

@section('content')
<!-- Main content -->
<section class="content">
    <!-- Main row -->
    <div class="row">
        <div class="col-md-6">
            <section class="panel">
                <header class="panel-heading">
                    Latest Support Acctivity
                </header>
                <div class="cls-overflow-one table-responsive project-list">
                	@if($tickets)
			@foreach($tickets as $ticket)
			<div class='media'>
			 <div class="media-body" style="padding:10px">
			 	<?php 
			 	$priority='';
			 	switch ($ticket->priority) {
			 		case '1':
			 			$priority="<span class='label label-default'>Low</span>";
			 			break;
			 		case '2':
			 			$priority="<span class='label label-info'>Medium</span>";
			 			break;

			 		case '3':
			 			$priority="<span class='label label-warning'>High</span>";
			 			break;

			 		case '4':
			 			$priority="<span class='label label-danger'>Urgent</span>";
			 			break;
			 		
			 		default:
			 			
			 			break;
			 	}

			 	?>
			 	<h4 class="media-heading">{{ $ticket->title }} {!! $priority !!}</h4>
			 	
			
			 	 <a href="{{ url('ticket/show'.'/'.$ticket->id) }}" class='btn btn-xs btn-link'>Details</a>

				<br>
				<p style='margin-left: 2px; padding-top:5px;'>
					<i class="fa fa-user"></i> {{ $ticket->user?$ticket->user->name:'' }} &nbsp;&nbsp;&nbsp;&nbsp;
					<i class="fa fa-user"></i> {{ $ticket->created_user?$ticket->created_user->name:'' }} &nbsp;
					<i class="fa fa-clock-o"></i> {{ date('d M, Y',strtotime($ticket->created_at)) }}
					&nbsp;&nbsp;
					<?php 
					$status='';
					switch ($ticket->status) {
						case '0':
							$status='Initiated';
							break;
						case '1':
							$status='In Process';
							break;
						case '2':
							$status='Onhold';
							break;
						case '3':
							$status='Closed';
							break;
						
						default:
							# code...
							break;
					}
					?>
					<i class="fa fa-tags"></i> {{ $status }}
				</p>
				<hr>
			 </div>
		</div>
		@endforeach
	@endif    
                    
        </div>
        </div>
        <div class="col-md-6">
            <section class="panel tasks-widget">
                <header class="panel-heading">
                    Latest Notifications
                </header>
                <div class="cls-overflow-one table-responsive project-list">
	                    @if($noti)
				@foreach($noti as $noti_details)
					<div class='media'>
						 <div class="media-body" style="padding:10px">
						 	
						 	<h4 class="media-heading">{{ $noti_details->msg}}</h4>
							
						 </div>
					</div>
					 <hr>
				@endforeach
			@endif  
                </div>
                
            </section>
        </div>
    </div>
    <div class="row">
        <div class="col-md-6">
            <section class="panel tasks-widget">
                <header class="panel-heading">
                    Created Task
                </header>
                <div class="cls-overflow table-responsive project-list">
                    <table class="table table-striped">
                        <thead>
                            <tr>
                                <th>
                                    Task
                                </th>
                                <th>
                                    Project
                                </th>
                                <th>
                                    Name
                                </th>
                                <th>
                                    Assigned time
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            @if(!empty($created_task))
                                @foreach($created_task as $pt)
                                    <tr>
                                        <td>
                                            <a style="color: #333;" href="{{url("client/cproject_details/$pt->proj_id")}}">
                                            {{$pt->name}}
                                            </a>
                                        </td>
                                        <td>{{$pt->proj_name->name}}</td>
                                        <td>
                                            @if(!empty($pt->user->name))
                                                {{$pt->user->name}}
                                                <?php $showw_time = $pt->assign_time; ?>
                                            @else
                                                <span style="color:#FF6000;">
                                                {{"Not assigned"}}
                                                <?php $showw_time = $pt->created_time; ?>
                                                </span>
                                            @endif
                                        </td>
                                        <td>{{date("d-m-Y H:i", strtotime($showw_time))}}</td>
                                    </tr>
                                @endforeach
                            @endif
                        </tbody>
                    </table>
                    <hr>
                    </hr>
                </div>
                <div class="panel-body">
                    <div class=" add-task-row">
                    </div>
                    <div class="table-foot">
                       
                    </div>
                </div>
            </section>
        </div>
        <div class="col-md-6">
            <section class="panel tasks-widget">
                <header class="panel-heading">
                    In-Process Task
                </header>
                <div class="cls-overflow table-responsive project-list">
                    <table class="table table-striped">
                        <thead>
                            <tr>
                                <th>
                                    Task
                                </th>
                                <th>
                                    Project
                                </th>
                                <th>
                                    Name
                                </th>
                                <th>
                                    Start time
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            @if(!empty($inprocess_task))
                                @foreach($inprocess_task as $pt)
                                    <tr>
                                        <td>
                                            <a style="color: #333;" href="{{url("client/cproject_details/$pt->proj_id")}}">
                                            {{$pt->name}}
                                            </a>
                                        </td>
                                        <td>{{$pt->proj_name->name}}</td>
                                        <td>
                                            @if(!empty($pt->user->name))
                                                {{$pt->user->name}}
                                            @else
                                                <span style="color:#FF6000;">
                                                {{"Not assigned"}}
                                                </span>
                                            @endif
                                        </td>
                                        <td>{{date("d-m-Y H:i", strtotime($pt->start_time))}} # {{$pt->estimated_time}}</td>
                                    </tr>
                                @endforeach
                            @endif
                        </tbody>
                    </table>
                    <hr>
                    </hr>
                </div>
                <div class="panel-body">
                    <div class=" add-task-row">
                    </div>
                    <div class="table-foot">
                       
                    </div>
                </div>
            </section>
        </div>
    </div>
    <div class="row">
        <div class="col-md-6">
            <section class="panel tasks-widget">
                <header class="panel-heading">
                    Important Notes

                    <button class="btn btn-success btn-xs pull-right" data-toggle="modal" data-target="#myModal2"><i class="fa fa-plus-circle" data-toggle="modal" data-target="#myModal2" aria-hidden="true"></i> Add Note</button>
                </header>
                <div class="cls-overflow-one table-responsive project-list">
                    <table class="table table-striped">
                        <thead>
                            <tr>
                                <th>
                                    Note
                                </th>
                                <th>
                                    Date Time
                                </th>
                                <th>
                                    Status
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            @if(!empty($notes))
                            @foreach($notes as $nott)
                                <tr>
                                    <td>{{$nott->note}}</td>
                                    <td>{{$nott->time}}</td>
                                    <td style="cursor:pointer;">
                                        @if($nott->status > 0)
                                            <a href="{{url("admin/change_note_status/$nott->id")}}">
                                                <i style="color:green;" class="fa fa-check-square-o" aria-hidden="true"></i>
                                            </a>
                                        @else
                                            <a href="{{url("admin/change_note_status/$nott->id")}}">
                                                <i class="fa fa-square-o" aria-hidden="true"></i>
                                            </a>
                                        @endif
                                        &nbsp; &nbsp;
                                        <a onclick="return confirm ('want to delete?')" href="{{url("admin/remove_note/$nott->id")}}">
                                            <i style="color:red" class="fa fa-times" aria-hidden="true"></i>
                                        </a>
                                    </td>
                                </tr>
                            @endforeach
                            @endif
                        </tbody>
                    </table>
                    <hr>
                    </hr>
                </div>
                
            </section>
        </div>
    </div>
    
</section>
<!-- row end -->
<!-- /.content -->


<!-- Add note modal -->
<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
     <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="gridSystemModalLabel">Add User</h4>
          </div>
          <div class="modal-body">

            <form role="form" action="{{url('admin/add_note')}}" method="POST">
                {!! csrf_field() !!}
                <div class="form-group">
                    <label for="Add new Project">
                        Note
                    </label>
                    <textarea name="note" rows="5" class="form-control" id="new-project" placeholder="Write down your important notes..." ></textarea>
                </div>
                <div class="form-group">
                    <label for="Add new Project">
                        Select Date Time
                    </label>
                    <input name="date_time" class="form-control" id="datetimepicker" type="text">
                </div>
                <div class="form-group">
                    <button class="btn btn-info" type="submit">
                    Submit
                    </button>
                </div>
            </form> 
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          </div> 
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>

@endsection

@section('script')
    <script src="{{URL::asset('assets/js/jquery.datetimepicker.full.min.js')}}" type="text/javascript"></script>
    <script type="text/javascript">
        //jQuery('#datetimepicker').datetimepicker();

        jQuery('#datetimepicker').datetimepicker({
          format:'Y-m-d H:i:s',
          lang:'ru'
        });
    </script>
@endsection
