<?php echo $__env->make('layouts.head', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
<body>
<?php echo $__env->make('layouts.topbar', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
<?php echo $__env->make('layouts.Adminnavbar', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

<div class="container py-5">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h2 class="fw-bold text-primary">Orders Report</h2>
        <!-- Optional date filter form -->
<form class="d-flex ms-2" method="GET" action="<?php echo e(route('admin.report.download')); ?>">
    <input type="hidden" name="from" value="<?php echo e(request('from')); ?>">
    <input type="hidden" name="to" value="<?php echo e(request('to')); ?>">
    <button type="submit" class="btn btn-success">
        <i class="bi bi-download"></i> Download Report
    </button>
</form>


    </div>

    <div class="table-responsive shadow-sm rounded-3">
        <table class="table table-striped table-hover align-middle">
            <thead class="table-primary">
                <tr>
                    <th>#ID</th>
                    <th>Customer</th>
                    <th>Phone</th>
                    <th>Items</th>
                    <th>Total (Tsh)</th>
                    <th>Status</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->id); ?></td>
                        <td><?php echo e($order->name); ?></td>
                        <td><?php echo e($order->phone); ?></td>
                        <td>
                            <?php if(!empty($order->items)): ?>
                                <?php echo e(collect($order->items)->pluck('name')->join(', ')); ?>

                            <?php else: ?>
                                N/A
                            <?php endif; ?>
                        </td>
                        <td><?php echo e(number_format($order->total, 2)); ?></td>
                        <td>
                            <span class="badge bg-<?php echo e($order->status == 'completed' ? 'success' : 'warning'); ?>">
                                <?php echo e(ucfirst($order->status)); ?>

                            </span>
                        </td>

                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr>
                        <td colspan="7" class="text-center text-muted">No orders found.</td>
                    </tr>
                <?php endif; ?>
            </tbody>
        </table>

        <div class="d-flex justify-content-center mt-4">
            <?php echo e($orders->links('pagination::bootstrap-5')); ?>

        </div>
    </div>
</div>

<?php echo $__env->make('layouts.footer', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
<?php echo $__env->make('layouts.links', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
</body>
</html>
<?php /**PATH /Users/dope/Documents/kaukaPortal/kaukamedics/resources/views/admin/report/index.blade.php ENDPATH**/ ?>