<?php $__env->startSection('title', 'Pesanan Masuk'); ?>
<?php $__env->startSection('page-title', 'Pesanan Masuk'); ?>

<?php $__env->startSection('content'); ?>


<?php if(session('success')): ?>
    <div class="mb-4 px-4 py-3 rounded-lg bg-green-100 text-green-700 flex items-center gap-2">
        <i class="bi bi-check-circle-fill"></i> <?php echo e(session('success')); ?>

    </div>
<?php endif; ?>

<?php if(session('error')): ?>
    <div class="mb-4 px-4 py-3 rounded-lg bg-red-100 text-red-700 flex items-center gap-2">
        <i class="bi bi-exclamation-triangle-fill"></i> <?php echo e(session('error')); ?>

    </div>
<?php endif; ?>

<!-- HEADER -->
<div class="flex flex-col md:flex-row md:items-center md:justify-between gap-4 mb-6">

    <div>
        <h2 class="text-xl font-bold text-gray-800">Pesanan Masuk</h2>
        <p class="text-sm text-gray-500">
            Daftar pesanan yang siap dikirim dan belum diambil kurir
        </p>
    </div>

    <!-- SEARCH -->
    <form method="GET" class="flex gap-2">
        <input 
            type="text" 
            name="search" 
            value="<?php echo e(request('search')); ?>"
            placeholder="Cari ID, nama, kota..."
            class="px-4 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"
        >
        <button class="px-4 py-2 bg-blue-500 text-white rounded-lg text-sm hover:bg-blue-600">
            <i class="bi bi-search"></i>
        </button>
    </form>

</div>

<!-- TABLE -->
<div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">

    <?php if($pesanans->isEmpty()): ?>

        <div class="p-10 text-center text-gray-500">
            <i class="bi bi-inbox text-3xl mb-2 block"></i>
            Tidak ada pesanan
            <?php if(request('search')): ?>
                untuk "<?php echo e(request('search')); ?>"
            <?php endif; ?>
        </div>

    <?php else: ?>

    <div class="overflow-x-auto">
        <table class="w-full text-sm">

            <thead class="bg-gray-50 text-gray-500 uppercase text-xs">
                <tr>
                    <th class="px-6 py-3 text-left">ID</th>
                    <th class="px-6 py-3 text-left">Pelanggan</th>
                    <th class="px-6 py-3 text-left">Tujuan</th>
                    <th class="px-6 py-3 text-left">Tanggal</th>
                    <th class="px-6 py-3 text-left">Total</th>
                    <th class="px-6 py-3 text-left">Aksi</th>
                </tr>
            </thead>

            <tbody class="divide-y">

                <?php $__currentLoopData = $pesanans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr class="hover:bg-gray-50">

                    <!-- ID -->
                    <td class="px-6 py-4 font-semibold text-blue-600">
                        #<?php echo e($p->id); ?>

                    </td>

                    <!-- USER -->
                    <td class="px-6 py-4">
                        <div class="font-medium text-gray-800">
                            <?php echo e($p->user->name ?? '-'); ?>

                        </div>
                        <div class="text-xs text-gray-500">
                            <?php echo e($p->user->email ?? ''); ?>

                        </div>
                    </td>

                    <!-- TUJUAN -->
                    <td class="px-6 py-4">
                        <div class="font-medium text-gray-800">
                            <?php echo e($p->alamat_tujuan ?? '-'); ?>

                        </div>
                        <div class="text-xs text-gray-500">
                            <?php echo e($p->kota ?? '-'); ?>

                        </div>
                    </td>

                    <!-- TANGGAL -->
                    <td class="px-6 py-4">
                        <div>
                            <?php echo e(\Carbon\Carbon::parse($p->tanggal_pesanan)->format('d M Y')); ?>

                        </div>
                        <div class="text-xs text-gray-500">
                            <?php echo e($p->created_at->diffForHumans()); ?>

                        </div>
                    </td>

                    <!-- TOTAL -->
                    <td class="px-6 py-4 font-medium">
                        Rp <?php echo e(number_format($p->total_harga, 0, ',', '.')); ?>

                    </td>

                    <!-- AKSI -->
                    <td class="px-6 py-4">
                        <form method="POST" action="<?php echo e(route('ekspedisi.ambil', $p->id)); ?>">
                            <?php echo csrf_field(); ?>
                            <button class="px-3 py-1.5 text-xs bg-blue-500 text-white rounded-md hover:bg-blue-600">
                                <i class="bi bi-truck"></i> Ambil
                            </button>
                        </form>
                    </td>

                </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

            </tbody>
        </table>
    </div>

    <!-- PAGINATION -->
    <?php if($pesanans->hasPages()): ?>
        <div class="p-4 border-t">
            <?php echo e($pesanans->links()); ?>

        </div>
    <?php endif; ?>

    <?php endif; ?>

</div>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.ekspedisi', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\Toko-miftah\resources\views/ekspedisi/pesanan_masuk.blade.php ENDPATH**/ ?>