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

<?php $__env->startSection('header_title', 'Warehouse'); ?>
<?php $__env->startSection('header_subtitle', 'Manage order shipping'); ?>

<?php $__env->startSection('content'); ?>
    <div class="container-fluid">
        <div class="card shadow">
            <div class="card-body">
                <div class="d-flex justify-content-between align-items-center mb-3">
                    <form action="<?php echo e(route('admin.warehouse.index')); ?>" method="GET" class="d-flex align-items-center">
                        <div class="input-group">
                            <input type="text" name="search" class="form-control form-control-sm"
                                placeholder="Search orders..." value="<?php echo e(request('search')); ?>">
                            <button type="submit" class="btn btn-sm btn-outline-secondary"><i class="bi bi-search"></i></button>
                        </div>
                    </form>
                </div>

                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th>Order Code</th>
                                <th>Customer</th>
                                <th>Items</th>
                                <th>Shipping</th>
                                <th>Status</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $orders; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $order): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td><?php echo e($order->order_code); ?></td>
                                    <td><?php echo e($order->user->name); ?></td>
                                    <td>
                                        <?php $__currentLoopData = $order->items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <div><?php echo e($item->product->name); ?> x <?php echo e($item->quantity); ?></div>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </td>
                                    <td><?php echo e($order->shippingCost->destination ?? '-'); ?></td>
                                    <td><span class="badge bg-<?php echo e($order->status_color); ?>"><?php echo e($order->status); ?></span></td>
                                    <td>
                                        <form action="<?php echo e(route('admin.warehouse.send', $order)); ?>" method="POST"
                                            class="d-inline">
                                            <?php echo csrf_field(); ?>
                                            <button type="submit" class="btn btn-sm btn-success"
                                                onclick="return confirm('Mark order <?php echo e($order->order_code); ?> as dikirim?')">
                                                <i class="bi bi-truck"></i> Kirim
                                            </button>
                                        </form>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="6" class="text-center py-4">
                                        <p class="text-muted">No orders to ship</p>
                                    </td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                    <div class="mt-4"><?php echo e($orders->links()); ?></div>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
    <script>
        <?php if(session('success')): ?>
            Swal.fire({ icon: 'success', title: 'Success!', text: "<?php echo e(session('success')); ?>", showConfirmButton: false, timer: 3000, toast: true, position: 'top-end' });
        <?php endif; ?>
        <?php if(session('error')): ?>
            Swal.fire({ icon: 'error', title: 'Error!', text: "<?php echo e(session('error')); ?>", showConfirmButton: true });
        <?php endif; ?>
    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.layout-admin', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\e-commerce\resources\views/admin/warehouse.blade.php ENDPATH**/ ?>