@extends('backend._partials.app')
@section('maincontent')
    <style type="text/css">
        .btn-simple.btn-icon{
            padding: 1px !important;
        }
    </style>
    <div class="card col-md-6 col-md-offset-3">
        <div class="content">
            <div class="row">
                {!! Form::open(['url'=>'my-report']) !!}
                {!! Form::hidden('search','yes') !!}
                <div class="col-md-5">
                    <label>FROM</label>
                    <div class="form-group">
                        <input type="text" name="from_date" class="form-control fromdatepicker" placeholder="From Date here"/>
                    </div>
                </div>
                <div class="col-md-5">
                    <label>TO</label>
                    <div class="form-group">
                        <input type="text" name="to_date" class="form-control todatepicker" placeholder="To Date Here"/>
                    </div>
                </div>
                <div class="col-md-2">
                    <label>&nbsp;</label>
                    <div class="form-group">
                        <button class="btn btn-info btn-fill" type="submit">Search</button>
                    </div>
                </div>
                {!! Form::close() !!}
            </div>
        </div>
    </div>
    <div class="card col-md-12">
        <div class="header text-center">
            <h4 class="title">Report: <strong>{{$from_date}}</strong> to <strong>{{$to_date }}</strong></h4>
            <p class="category"><strong class="text-success">Present:</strong> <span id="present">0</span> Days, <strong class="text-danger">Absent:</strong> <span id="absent">0</span> days, <strong class="text-warning">Leave:</strong> <span id="leave">0</span> days</p>
        </div>
        <div class="content">
            <div class="fresh-datatables">
                <table id="datatable-report" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%" style="width:100%">
                    <thead>
                    <tr>
                        <th>SL</th>
                        <th>Date</th>
                        <th>IN</th>
                        <th>Out</th>
                        <th>Works</th>
                        <th>Task</th>
                        <th>Status</th>
                        <th>Action</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php $i=0; $totalWorks=[]; ?>
                    @foreach($result as $data)
                        <tr>
                            <td>{{++$i}}</td>
                            <td>{{$data['in_out']['date']}}</td>
                            <td>{{$data['in_out']['min_time']}}</td>
                            <td>{{$data['in_out']['max_time']}}</td>
                            <td>{{$works = $data['in_out']['timediff']}}</td>
                            <td><span>{{ strip_tags(substr($data['task']['details'],0,40))}}</span></td>
                            <td>

                            </td>
                            <td>
                                <a href="#" data-toggle="modal" data-target="#modal" onclick="loadModalEdit('details-view-report','{{$data['in_out']['date']}}','details')" title="Detail" class="btn btn-simple btn-info btn-icon"><i class="fa fa-search-plus" style="font-size: 20px;"></i></a>
                            </td>

                        </tr>
                    @endforeach
                    </tbody>
                    <tfoot>
                    <tr>
                        <td colspan="3"></td>
                        <th>Total</th>
                        <td colspan="3"></td>
                    </tr>
                    </tfoot>
                </table>
            </div>
        </div>
    </div>

    <script>
        $().ready(function(){

            $("#present").text($('.my-present').length);
            $("#absent").text($('.my-absent').length);
            $("#leave").text($('.my-leave').length);

            var table= $('#datatable-report').DataTable({
                "pagingType": "full_numbers",
                "lengthMenu": [[31, 60, 120, -1], [31, 60, 120, "All"]],
                responsive: true,
                language: {
                    search: "_INPUT_",
                    searchPlaceholder: "Search records",
                }

            });
        });
    </script>
    <script src="{{asset('public/vendor/unisharp/laravel-ckeditor/ckeditor.js')}}"></script>

@endsection