<?php $__env->startSection('maincontent'); ?>
    <div class="col-md-12">
        <div class="card">
            <div class="header">
                Details Report:: Leave
                <p class="category">Including approved &amp; pending </p>
            </div>
            <div class="content">
                <div class="row">
                    <div class="col-md-6 col-md-offset-3">
                        <?php echo Form::open(['url'=>'leave-reports']); ?>

                        <?php echo 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>
                        <?php echo Form::close(); ?>

                    </div>

                    <div class="col-md-12">
                        <div class="header text-center">
                            <h5 class="title"><strong><?php echo e($from_date); ?></strong> to <strong><?php echo e($to_date); ?></strong></h5>
                        </div>
                        <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>Image</th>
                                    <th>Name</th>
                                    <th>Leave Type</th>
                                    <th>Message</th>
                                    <th>Desire Date</th>
                                    <th>Duration</th>
                                    <th>Apply date</th>
                                    <th>Action date</th>
                                    <th>Status</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php $i=0; ?>
                                <?php $__empty_1 = true; $__currentLoopData = $leaves; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $leave): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <tr>
                                        <td><?php echo e(++$i); ?></td>
                                        <td><?php if(empty($leave->user->image)): ?>
                                                <img src="<?php echo e(asset("public/img/users/default-avatar.png")); ?>" height="40">
                                            <?php else: ?>
                                                <img src="<?php echo e(asset("public/img/users")."/".$leave->user->image); ?>" height="40">

                                            <?php endif; ?></td>
                                        <td><?php echo e($leave->user->first_name." ".$leave->user->last_name); ?></td>
                                        <td><?php echo e($leave->leaveType->title); ?></td>
                                        <td onclick="getDetails(<?php echo e($leave); ?>)" style="cursor: pointer;">

                                            <?php if(strlen($leave->message)>2): ?>
                                                <?php echo e(strip_tags(substr($leave->message,0,25))); ?>....
                                            <?php else: ?>
                                                <?php echo e(strip_tags($leave->message)); ?>

                                            <?php endif; ?>
                                        </td>
                                        <td><?php echo e($leave->from_date); ?> <?php echo e($leave->to_date); ?></td>
                                        <td><?php
                                            $duration= date_diff(date_create($leave->from_date),date_create($leave->to_date));
                                            echo $duration->days+1 ."days";
                                            ?></td>
                                        <td><?php echo e($leave->created_at); ?></td>
                                        <td><?php echo e($leave->action_at); ?></td>
                                        <td>
                                            <?php if($leave->status=='1'): ?>
                                                <label class="label label-success">Approved</label>
                                            <?php elseif($leave->status=='0'): ?>
                                                <label class="label label-danger">Pending</label>
                                            <?php else: ?>
                                                <label class="label label-warning">Denied</label>
                                            <?php endif; ?>
                                        </td>
                                        <td>
                                            <a title="Delete" onclick="deleteConfirm('leave-apply-delete',<?php echo e($leave->id); ?>)" href="javascript:void(0)"
                                               class="btn btn-simple btn-danger btn-icon remove"><i
                                                        class="fa fa-times"></i></a>
                                        </td>

                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr>
                                        <td colspan="10" align="center">No record found!</td>
                                    </tr>
                                <?php endif; ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        function getDetails(leave) {
            var reply= (leave.reply==null)?'No reply':leave.reply;
            swal({  title: 'Leave Application',
                confirmButtonText: 'Close',
                confirmButtonClass: "btn btn-danger",
                html:'<b>Message:</b><p style="text-align: justify; float:left">'+leave.message+'</p>'+
                    '<b>Reply:</b><p style="text-align: justify;">'+reply+'</p>'
            });
        }
        </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('backend._partials.app', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>