@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 tasks-widget">
                <header class="panel-heading">
                    In-Process Task
                </header>
                <div class="cls-overflow table-responsive project-list">
                    <table class="table table-striped">
                        
                        <tbody>
                            @if(!empty($in_process_task))
                                <?php $count=1; ?>
                                @foreach($in_process_task as $pt)
                                    <tr>
                                        <td>
                                            {{$count++ .") "}}
                                            <a style="color: #1ab394;" href="{{url("admin/project_details/$pt->proj_id")}}">
                                                {{$pt->name}} - 
                                            </a>
                                            <span style="color:green;">
                                                {{$pt->proj_name->name}} - 
                                            </span>

                                            <span style="color:red;">
                                            @if(!empty($pt->user->name))
                                                {{$pt->user->name}}
                                            @else
                                                {{"Not assigned"}}
                                            @endif
                                            </span> - 
                                        
                                            {{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 class="col-md-6">
            <section class="panel tasks-widget">
                <header class="panel-heading">
                    Today's Completed Tasks
                </header>
                <div class="cls-overflow table-responsive project-list">
                    <table class="table table-striped">
                        
                        <tbody>
                            @if(!empty($pending_task))
                                <?php $count = 1; ?>
                                @foreach($pending_task as $pt)
                                    <tr>
                                        <td>
                                            {{$count++ .") "}}
                                            <a style="color: #1ab394;" href="{{url("admin/project_details/$pt->proj_id")}}">
                                            {{$pt->name}}
                                            </a> - 
                                            <span style="color: green;">
                                                {{$pt->proj_name->name}} - 
                                            </span>
                                            <span style="color:red;">
                                            @if(!empty($pt->user->name))
                                                {{$pt->user->name}} - 
                                            @else
                                                <span style="color:#FF6000;">
                                                {{"Not assigned"}} - 
                                                </span>
                                            @endif
                                            </span>
                                        
                                            {{date("d-m-Y H:i", strtotime($pt->closing_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'
        });

        $(document).ready(function() {
            var timeout = setTimeout("location.reload(true);",600000);
            function resetTimeout() {
                clearTimeout(timeout);
                timeout = setTimeout("location.reload(true);",600000);
            }
        });
    </script>
@endsection
