@extends('layouts.master')

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

    <style type="text/css">
        .cls-show-time{
        color: #000;
        font-style: italic;
        font-size: 12px;
        }
    </style>
@endsection

@section('content')
<section class="content">
    <div class="row">
        <div class="col-md-6">
        @if(!empty($pm_created_task))
            <section class="panel tasks-widget">
                <header class="panel-heading" style="color:#34BCA0;">
                    <b>PM # all created task</b>
                </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>
                            @foreach($pm_created_task as $pt)
                                <tr>
                                    <td>
                                        <a style="color: #333;" href="{{url("user/uproject_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->assign_time))}}</td>
                                </tr>
                            @endforeach
                        </tbody>
                    </table>
                    <hr>
                    </hr>
                </div>
            </section>
        @endif
        </div>
        <div class="col-md-6">
        @if(!empty($pm_inprocess_task))
            <section class="panel tasks-widget">
                <header class="panel-heading" style="color:#34BCA0;">
                    <b>PM # all in-process task</b>
                </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>
                            @foreach($pm_inprocess_task as $pt)
                                <tr>
                                    <td>
                                        <a style="color: #333;" href="{{url("user/uproject_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
                        </tbody>
                    </table>
                    <hr>
                    </hr>
                </div>
            </section>
        @endif
        </div>
    </div>
    <div class="row">
        <div class="col-md-6">
            <section class="panel tasks-widget">
                <header class="panel-heading">
                    <b>Pending Tasks</b>
                </header>
                <div class="table-responsive project-list">
                    <table class="table table-striped">
                        @foreach($tasks as $tsk)
                            <tr>
                                <td>
                                    <a style="color:#333333;" href="{{url("user/uproject_details/$tsk->proj_id")}}">
                                        <b>Task:</b> {{$tsk->name}} 
                                        <b>-{{$tsk->proj_name->name}}</b>
                                    </a>
                                </td>
                            </tr>
                        @endforeach
                    </table>
                </div>
            </section>
        </div>
        <div class="col-md-6">
            <section class="panel tasks-widget">
                <header class="panel-heading">
                    Projects you assigned
                </header>
                <div class="table-responsive project-list">
                    <table class="table table-striped">
                        <thead>
                            <tr>
                                <th colspan="2">
                                    Project Name
                                </th>
                                <th>
                                    Assigned By
                                </th>
                                <th>
                                    Description
                                </th>
                                {{-- 
                                <th>
                                    Action
                                </th> 
                                --}}
                            </tr>
                        </thead>
                        <tbody>
                        @if (session('data'))
                            <div class="alert alert-success">
                                {{ session('data') }}
                            </div>
                        @endif
                        @if(!empty($projj))
                            @foreach($projj as $proj)
                                <tr>
                                    <td>
                                        <div class="task-checkbox">
                                            <input class="flat-grey" type="checkbox"/>
                                        </div>
                                    </td>
                                    <td>
                                        <a href="{{url("user/uproj_inprocess_pending_task/$proj->proj_id")}}">
                                            {{$proj->proj_name->name}}
                                        </a>
                                        <span class="cls-show-time">
                                            @if(count($proj->proj_name->tasks) > 0)
                                                <?php 
                                                    $pend = 0;
                                                    $donee = 0;
                                                    $not_assign = 0;
                                                ?>

                                                @foreach($proj->proj_name->tasks as $pt)
                                                    @if($pt->user_id == 0)
                                                        <?php $not_assign++; ?>
                                                    @elseif($pt->status < 6 && $pt->user_id == $login_user_id)
                                                        <?php $pend++; ?>
                                                    @elseif($pt->status == 6 && $pt->user_id == $login_user_id)
                                                        <?php $donee++; ?>
                                                    @endif
                                                @endforeach
                                                <br>
                                                Not Assigned: {{$not_assign}},
                                                Pending: {{$pend}},
                                                Done: {{$donee++}}
                                            @else
                                                {{"No tasks added"}}
                                            @endif
                                        </span>
                                        <br>
                                            <small>
                                                <i class="fa fa-clock-o">
                                                </i>
                                                Assigned in {{$proj->assign_time}}
                                            </small>
                                        </br>
                                    </td>
                                    <td>
                                        {{$proj->assigned->name}}
                                    </td>
                                    <td>
                                        {{str_limit($proj->proj_name->description, $limit = 30, $end = '...')}}
                                    </td>
                                    {{-- <td>
                                        <a href="" style="color: #7dcc93;">
                                            <i class="fa fa-pencil-square-o" aria-hidden="true"></i>
                                        </a>
                                        &nbsp;  &nbsp;
                                        <a onclick="return confirm ('want to delete?')" href="{{url("admin/remove_proj/$proj->id")}}" style="color:#FD4B39;">
                                            <i class="fa fa-times" aria-hidden="true"></i>
                                        </a>
                                    </td> --}}
                                </tr>   
                            @endforeach
                        @endif
                        </tbody>
                    </table>
                    <hr>
                    </hr>
                </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="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("user/change_note_status/$nott->id")}}">
                                                <i style="color:green;" class="fa fa-check-square-o" aria-hidden="true"></i>
                                            </a>
                                        @else
                                            <a href="{{url("user/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("user/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('user/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
