@extends('layouts.master')

@section('content')
<!-- Main content -->
<section class="content">
    <!-- Main row -->
    <div class="row">
        <div class="col-md-12">
            <form class="form-inline" action="{{url('admin/search_completed_task_by_user')}}" method="POST">

                {{ csrf_field() }}

              <div class="form-group">
                <input type="text" required="required" name="fromdate" class="form-control" id="fromdate" placeholder="From date">
              </div>
              <div class="form-group">
                <input type="text" required="required" name="todate" class="form-control" id="todate" placeholder="To date">
              </div>
              <div class="form-group">
                <select class="form-control" name="user_id">
                    <option value="0">Select User</option>
                    @foreach($users as $u)
                        <option value="{{$u->id}}">{{$u->name}}</option>
                    @endforeach
                </select>
              </div>
              <button type="submit" class="btn btn-success">Search</button>
            </form>
            <br>
            <section class="panel tasks-widget">
                <header class="panel-heading" style="height:40px;">
                    <div class="pull-left">
                        {{$title}}
                        @if(!empty($user_name))
                            OF
                            <span class="txt-color">
                                 {{$user_name}} 
                            </span>
                            Between ({{$fdate}} to {{$tdate}})
                        @endif
                    </div>
                </header>
                <div class="table-responsive project-list">
                    <table class="table table-striped">
                        <thead>
                            <tr>
                                <th colspan="2">
                                    Task Name
                                </th>
                                <th>
                                    Project Name
                                </th>
                                <th>
                                    Assign Time
                                </th>
                                <th>
                                    Start Time
                                </th>
                                <th>
                                    Closing Time
                                </th>
                                <th>
                                    Estimated Time
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                        @if(!empty($all))
                            <?php $count=1; ?>
                            @foreach($all as $info)
                                <tr>
                                    <td>
                                        {{$count++}}
                                    </td>
                                    <td>
                                        {{$info->name}}
                                    </td>
                                    <td>
                                        {{$info->proj_name->name}}
                                    </td>
                                    <td>
                                        {{$info->assign_time}}
                                    </td>
                                    <td>
                                        {{$info->start_time}}
                                    </td>
                                    <td>
                                        {{$info->closing_time}}
                                    </td>
                                    <td>
                                        {{$info->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>
</section>
<!-- row end -->
@endsection


@section('script')
<script type="text/javascript">
    
    $( function() {
        $( "#fromdate" ).datepicker({
          changeMonth: true,
          changeYear: true
        });
        $( "#fromdate" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
    } );

    $( function() {
        $( "#todate" ).datepicker({
          changeMonth: true,
          changeYear: true
        });
        $( "#todate" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
    } );

    jQuery(document).ready(function($)
    {
        $('.chk-active').click(function(event)
        {
            var id = $(this).val();
            var stat;
            
            if($(this).is(':checked'))
            {
                stat = 1;
            }
            else
            {
                stat = 0;
            }

            $.ajax({
                url: '{{url('admin/user_active')}}',
                type: 'POST',
                data: {id: id,stat: stat},
            })
            .done(function(data){
                alert(data);
            });
            
        });

        $('.change-pass').click(function(event) {
            
            var id = $(this).parent('.parent-action-cls').children('input').val();
            $('.change-pass-user-id').val(id);
            
        });
    });
</script>
@endsection
