@extends('backend._partials.app')
@section('maincontent')
    @include('backend.reports.reportHeader')
    <div class="col-md-12">
        <div class="card">
            <div class="header">
                Details Report:: Calendar
                <p class="category">See date wise events</p>
            </div>
            <div class="content">
                <div class="row">
                    <div class="col-md-6 col-md-offset-3">
                        {!! Form::open(['url'=>'calendar-details']) !!}
                        {!! 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 class="col-md-12">
                        <div class="fresh-datatables">
                            <table id="datatable" class="table table-striped table-bordered table-hover" cellspacing="0"
                                   width="100%" style="width:100%">
                                <thead>
                                <tr>
                                    <th>Sl</th>
                                    <th>Date</th>
                                    <th>Event Title</th>
                                    <th>Event Type</th>
                                    <th>Details</th>
                                    <th>Time Zone</th>
                                    <th>Office Status</th>
                                    <th>Created at</th>
                                    <th>Created by</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php $i=0; ?>
                                @forelse($calendar as $cal)
                                    <tr onclick="getDetails('{{$cal->start}}','{{$cal->title}}','{{$cal->details}}')" style="cursor: pointer;">
                                        <td>{{++$i}}</td>
                                        <td>{{$cal->start}}</td>
                                        <td>{{$cal->title}}</td>
                                        <td>{{$cal->eventType->type}}</td>
                                        <td>
                                            @if(strlen($cal->details)>2)
                                                {{substr($cal->details,0,25)}}....
                                            @else
                                                {{$cal->details}}
                                            @endif
                                        </td>
                                        <td>
                                            {{$cal->timezone->title}}
                                        </td>
                                        <td>
                                            @if($cal->office_status=='1')
                                                <label class="label label-success">Open</label>
                                            @elseif($cal->office_status=='0')
                                                <label class="label label-danger">Closed</label>
                                            @endif
                                        </td>
                                        <td>
                                            {{$cal->created_at}}
                                        </td>
                                        <td>
                                            {{$cal->createdBy->first_name}}
                                        </td>

                                    </tr>
                                @empty
                                    <tr>
                                        <td colspan="9">No request yet</td>
                                    </tr>
                                @endforelse
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        function getDetails(start,title,details) {
            swal({  title: 'Event Details',
                html:'<b>Date:</b>'+start+'<br>'+
                '<p style="text-align: justify;"><b>Title: </b>'+title+'</p>'+
                '<p style="text-align: justify;"><b>Details: </b>'+details+'</p>'
            });
        }
    </script>
@endsection