<?php $__env->startSection('title', 'Manage Shipments'); ?>

<?php $__env->startSection('content'); ?>
<div class="container mx-auto px-4">
    <!-- Header Section -->
    <div class="mb-6 flex justify-between items-center">
        <h1 class="text-2xl font-bold text-gray-900">Manage Shipments</h1>
        <a href="<?php echo e(route('admin.shipments.create')); ?>" 
           class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-md flex items-center">
            <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
            </svg>
            Add New Shipment
        </a>
    </div>

    <!-- Search and Filter Section -->
    <div class="mb-6 bg-white rounded-lg shadow p-4">
        <form action="<?php echo e(route('admin.shipments.index')); ?>" method="GET" class="grid grid-cols-1 md:grid-cols-4 gap-4">
            <div>
                <label for="search" class="block text-sm font-medium text-gray-700">Search</label>
                <input type="text" name="search" id="search" 
                       value="<?php echo e(request('search')); ?>"
                       placeholder="Tracking number, name, email..."
                       class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
            </div>
            
            <div>
                <label for="status" class="block text-sm font-medium text-gray-700">Status</label>
                <select name="status" id="status" 
                        class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
                    <option value="">All Status</option>
                    <option value="pending" <?php echo e(request('status') == 'pending' ? 'selected' : ''); ?>>Pending</option>
                    <option value="in_transit" <?php echo e(request('status') == 'in_transit' ? 'selected' : ''); ?>>In Transit</option>
                    <option value="delivered" <?php echo e(request('status') == 'delivered' ? 'selected' : ''); ?>>Delivered</option>
                </select>
            </div>

            <div>
                <label for="date_range" class="block text-sm font-medium text-gray-700">Date Range</label>
                <input type="date" name="date_range" id="date_range" 
                       value="<?php echo e(request('date_range')); ?>"
                       class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
            </div>

            <div class="flex items-end">
                <button type="submit" 
                        class="w-full bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-md">
                    Filter Results
                </button>
            </div>
        </form>
    </div>

    <!-- Flash Messages -->
    <?php if(session('success')): ?>
        <div class="mb-4 bg-green-50 border border-green-200 text-green-700 px-4 py-3 rounded relative">
            <?php echo e(session('success')); ?>

        </div>
    <?php endif; ?>

    <!-- Shipments Table -->
    <div class="bg-white rounded-lg shadow overflow-hidden">
        <div class="overflow-x-auto">
            <table class="min-w-full divide-y divide-gray-200">
                <thead class="bg-gray-50">
                    <tr>
                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                            Tracking Number
                        </th>
                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                            From / To
                        </th>
                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                            Status
                        </th>
                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                            Dates
                        </th>
                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                            Amount
                        </th>
                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                            Actions
                        </th>
                    </tr>
                </thead>
                <tbody class="bg-white divide-y divide-gray-200">
                    <?php $__empty_1 = true; $__currentLoopData = $shipments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $shipment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr class="hover:bg-gray-50">
                            <td class="px-6 py-4 whitespace-nowrap">
                                <div class="text-sm font-medium text-gray-900">
                                    <?php echo e($shipment->tracking_number); ?>

                                </div>
                                <div class="text-sm text-gray-500">
                                    <?php echo e($shipment->carrier); ?>

                                </div>
                            </td>
                            <td class="px-6 py-4">
                                <div class="text-sm text-gray-900">
                                    From: <?php echo e($shipment->sender_name); ?>

                                </div>
                                <div class="text-sm text-gray-500">
                                    To: <?php echo e($shipment->receiver_name); ?>

                                </div>
                            </td>
                            <td class="px-6 py-4 whitespace-nowrap">
                                <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full 
                                    <?php echo e($shipment->status === 'delivered' ? 'bg-green-100 text-green-800' : 
                                       ($shipment->status === 'in_transit' ? 'bg-yellow-100 text-yellow-800' : 
                                       'bg-gray-100 text-gray-800')); ?>">
                                    <?php echo e(ucfirst($shipment->status)); ?>

                                </span>
                                <?php if($shipment->current_location): ?>
                                    <div class="text-xs text-gray-500 mt-1">
                                        <?php echo e($shipment->current_location); ?>

                                    </div>
                                <?php endif; ?>
                            </td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                                <div>Dispatch: <?php echo e($shipment->dispatch_date); ?></div>
                                <div>Delivery: <?php echo e($shipment->delivery_date); ?></div>
                            </td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
                                $<?php echo e($shipment->total_f); ?>

                            </td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
                                <div class="flex space-x-3">
                                    <a href="<?php echo e(route('admin.tracking-updates.create', $shipment)); ?>" 
                                        class="text-green-600 hover:text-green-700">
                                            Add Tracking Update
                                    </a>
                                    <a href="<?php echo e(route('admin.shipments.updates.index', $shipment)); ?>" 
                                class="text-indigo-600 hover:text-indigo-700">
                                View Tracking Updates
                                </a>
                                    <a href="<?php echo e(route('admin.shipments.show', $shipment)); ?>" 
                                       class="text-indigo-600 hover:text-indigo-900">
                                        View
                                    </a>
                                    <a href="<?php echo e(route('admin.shipments.edit', $shipment)); ?>" 
                                       class="text-yellow-600 hover:text-yellow-900">
                                        Edit
                                    </a>
                                    <form action="<?php echo e(route('admin.shipments.destroy', $shipment)); ?>" 
                                          method="POST" 
                                          onsubmit="return confirm('Are you sure you want to delete this shipment?');"
                                          class="inline">
                                        <?php echo csrf_field(); ?>
                                        <?php echo method_field('DELETE'); ?>
                                        <button type="submit" class="text-red-600 hover:text-red-900">
                                            Delete
                                        </button>
                                    </form>
                                </div>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="6" class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 text-center">
                                No shipments found.
                            </td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>

        <!-- Pagination -->
        <?php if($shipments->hasPages()): ?>
            <div class="px-6 py-4 border-t border-gray-200">
                <?php echo e($shipments->links()); ?>

            </div>
        <?php endif; ?>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/sfcmchxq/public_html/expressdeliveryfreight.com/resources/views/admin/shipments/index.blade.php ENDPATH**/ ?>