<?php $__env->startSection('content'); ?>
<div class="container">
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box box-primary">
                    <div class="box-header">
                        <h3 class="box-title">Ticket Lists </i></h3>
                        <div class="box-tools pull-right">
                    		<a href="<?php echo e(url('ticket/create')); ?>" class="btn btn-primary btn-flat"> <i class="fa fa-plus"></i> Create Ticket</a>
                    	</div>
                    </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>Cus. Name</th>
                                        <th>Phone No</th>
                                        <th>Cus. Address</th>
                                        <th>CreatedBy</th>
                                        <th>CreatedAt</th>
                                        <th>TicketAge</th>
                                        <th>Edit</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");
                                    ?>
                                    <tr>
                                        <td><?php echo e(++$i); ?></td>
                                        <td><b><a href="<?php echo e(url('/ticket/' . $ticket->id)); ?>"><?php echo e($ticket->id); ?></a></b></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><?php echo e($ticket->ticketStatus->name); ?></td>
                                        <?php else: ?>
                                            <td></td>
                                        <?php endif; ?>
                                        <td><?php echo e($ticket->customer_name); ?></td>
                                        <td><?php echo e($ticket->phone_number); ?></td>
                                        <td><?php echo e($ticket->customer_address); ?></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>
                                        <td><?php echo Html::link("ticket/$ticket->id/edit",' Edit', ['class' => 'fa fa-edit btn btn-primary btn-xs']); ?></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(); ?>