<?php $__env->startSection('content'); ?>
<div class="container-fluid">
	<section class="content">
	    <div class="row">
	    	<div class="col-md-12">
	        	<div class="box box-primary">
	            	<div class="box-header">
	                	<h3 class="box-title">Online Payment Wise Ticket Information From <i><?php echo e($startDate); ?></i> To <i><?php echo e($endDate); ?></i></h3>
	            	</div>
	            	<div class="box-body">
	                    <div class="table-responsive"> 
	                        <table id="example" class="table table-bordered table-striped">
	                            <thead>
	                                <tr>
                                        <!-- <th>SL</th> -->
                                        <th>TID</th>
                                        <th>Assigned</th>
                                        <th>Subject</th>
                                        <th>Ticket Type</th>
                                        <th>Ticket Status</th>
                                        <th>Delivery Status</th>
                                        <th>Delivery Boy</th>
                                        <th>Delivery Time</th>
                                        <th>Online</th>
                                        <th>Cus. Name</th>
                                        <th>Phone No</th>
                                        <th>Cus. Address</th>
                                        <!-- <th>Edit</th> -->
                                        <th>CreatedBy</th>
                                        <th>CreatedAt</th>
                                        <th>TicketAge</th>
                                        
                                    </tr>
	                            </thead>
	                            <tbody>
	                            <?php
	                                $i = 0;
	                            ?>
	                            <?php foreach($tickets as $ticket): ?>
	                            	<?php
                                        $interval = date_diff(date_create(), date_create($ticket->created_at));
                                        $ticketAge = $interval->format("%yy, %mm, %dd");

                                        if ($ticket->delivery_status == 'Order collected from depot') {
                                            $bgCSS = 'background-color: #FFA500;';
                                        } else if ($ticket->delivery_status == 'On the way for order deliver') {
                                            $bgCSS = 'background-color: #FFFF00;';
                                        } else if ($ticket->delivery_status == 'Order delivered (cash payment)') {
                                            $bgCSS = 'background-color: #008000;';
                                        } else if ($ticket->delivery_status == 'Order delivered (card payment)') {
                                            $bgCSS = 'background-color: #008000;';
                                        } else if ($ticket->delivery_status == 'Order cancelled') {
                                            $bgCSS = 'background-color: #FF0000;';
                                        } else {
                                            $bgCSS = '';
                                        }

                                        if ($ticket->ticket_status_id == 3) {
                                            $bgTsCSS = 'background-color: #008000;';
                                        } else if ($ticket->ticket_status_id == 5) {
                                            $bgTsCSS = 'background-color: #FF0000;';
                                        } else {
                                            $bgTsCSS = '';
                                        }
                                    ?>
                                    <tr>
                                        <!-- <td><?php echo e(++$i); ?></td> -->
                                        <td><a class="btn btn-primary btn-xs" href="<?php echo e(url('/ticket/' . $ticket->id)); ?>"><?php echo e($ticket->id); ?></a></td>
                                        <?php if(isset($ticket->assigned->name)): ?>
                                            <td><?php echo e($ticket->assigned->name); ?></td>
                                        <?php else: ?>
                                            <td></td>
                                        <?php endif; ?>
                                        <td><?php echo e($ticket->subject); ?></td>
                                        <?php if(isset($ticket->ticketType->name)): ?>
                                            <td><?php echo e($ticket->ticketType->name); ?></td>
                                        <?php else: ?>
                                            <td></td>
                                        <?php endif; ?>
                                        <?php if(isset($ticket->ticketStatus->name)): ?>
                                            <td style="<?php echo e($bgTsCSS); ?>"><?php echo e($ticket->ticketStatus->name); ?></td>
                                        <?php else: ?>
                                            <td></td>
                                        <?php endif; ?>
                                        <td style="<?php echo e($bgCSS); ?>"><?php echo e($ticket->delivery_status); ?></td>
                                        <?php if(isset($ticket->dbAssigned)): ?>
                                            <td><?php echo e($ticket->dbAssigned->name); ?></td>
                                        <?php else: ?>
                                            <td class="text-red">Doesn't assigned</td>
                                        <?php endif; ?>
                                        <td><?php echo e($ticket->delivery_time); ?></td>
                                        <td><?php echo e($ticket->online_payment); ?></td>
                                        <td><?php echo e($ticket->customer_name); ?></td>
                                        <td><?php echo e($ticket->phone_number); ?></td>
                                        <td><?php echo e($ticket->customer_address); ?></td>
                                        <!-- <td><?php echo Html::link("ticket/$ticket->id/edit",' Edit', ['class' => 'fa fa-edit btn btn-primary btn-xs']); ?></td> -->
                                        <?php if(isset($ticket->createdBy->name)): ?>
                                            <td><?php echo e($ticket->createdBy->name); ?></td>
                                        <?php else: ?>
                                            <td></td>
                                        <?php endif; ?>
                                        <td><?php echo e($ticket->created_at); ?></td>
                                        <td><?php echo e($ticketAge); ?></td>
                                        
                                    </tr>
	                            <?php endforeach; ?>
	                            </tbody>
	                        </table>
	                    </div>
	            	</div>
	      		</div>
	    	</div>
	  	</div>
	</section>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('style'); ?>
    <link rel="stylesheet" href="<?php echo e(asset('assets/css/dataTables.bootstrap.min.css')); ?>">
<?php $__env->stopSection(); ?>

<?php $__env->startSection('script'); ?>
    <script src="<?php echo e(asset('assets/js/jquery.dataTables.min.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/js/dataTables.bootstrap.min.js')); ?>"></script>

    <script type="text/javascript">
        $(document).ready(function() {
            $('#example').DataTable();
        } );
    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>