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

    <main id="main" class="main">
        <div class="container">
            <form action="<?php echo e(url('/admin/productAssign')); ?>" method="post">
                <?php echo csrf_field(); ?>
                <table class="table" styla="margin-top:10%;">
                    <thead>
                        <tr>
                            <th>From Date</th>
                            <th>To Date</th>
                            <th>Select the Status</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td><input type="date" name="fromDate" id="FromDate" class="form-control"/></td>
                            <td><input type="date" name="toDate" id="toDate" class="form-control"/></td>
                            <td>
                                <select name="status" id="status" class="form-control">
                                    <option value="" selected>SELECT STATUS</option>
                                    <option value="P">PENDING</option>
                                    <option value="PC">PROCESSED</option>
                                    <option value="S">SHIPPED</option>
                                    <option value="D">DELIVERED</option>
                                    <option value="H">HOLD</option>
                                    <option value="CL">CANCELED</option>
                                </select>
                            </td>
                            <td><button class="btn btn-primary" type="submit">Search</button></td>
                        </tr>
                    </tbody>
                </table>
            </form>
            <table class="table">
                <thead>
                    <tr>
                        <th scope="col">Sr No</th>
                        <th scope="col">Order Id</th>
                        <th scope="col">Oredered Product</th>
                        <th scope="col">Client Name</th>
                        <th scope="col">Order Staus</th>
                        <th scope="col">View</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $i = 0; ?>
                    <?php $__currentLoopData = $order; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $orders): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <?php
                            // Get all order_details for this order
                            $orderDetails = $order_details->where('order_id', $orders->id);

                            // Get unique product names for this order
                            $productsForOrder = $products->whereIn('id', $orderDetails->pluck('product_id'));
                        ?>

                        <?php if($orderDetails->isNotEmpty()): ?>
                            <?php $i++; ?>
                            <tr>
                                <th scope="row"><?php echo e($i); ?></th>
                                <td><?php echo e($orders->unique_order_id); ?></td>
                                <td><?php echo e($orders->created_at); ?></td>
                                <td><?php echo e($orders->user_id); ?></td>
                                <td>
                                    <?php if($orders->order_delivery_status == 'P'): ?>
                                        <div class="alert alert-warning" role="alert" style="text-align: center">PENDING</div>
                                    <?php elseif($orders->order_delivery_status == 'PC'): ?>
                                        <div class="alert alert-primary" role="alert" style="text-align: center">PROCESS</div>
                                    <?php elseif($orders->order_delivery_status == 'CL'): ?>
                                        <div class="alert alert-danger" role="alert" style="text-align: center">CANCELED</div>
                                    <?php elseif($orders->order_delivery_status == 'H'): ?>
                                        <div class="alert alert-dark" role="alert" style="text-align: center">HOLD</div>
                                    <?php elseif($orders->order_delivery_status == 'D'): ?>
                                        <div class="alert alert-success" role="alert" style="text-align: center">Delivered</div>
                                    <?php elseif($orders->order_delivery_status == 'S'): ?>
                                        <div class="alert alert-success" role="alert" style="text-align: center">Shipped</div>
                                    <?php endif; ?>
                                </td>
                                <td>
                                    <!-- Display all associated products for this order -->
                                    <?php echo $productsForOrder->pluck('product_name')->implode('<br>'); ?>

                                </td>
                                <td><a href="<?php echo e(url('/viewProduct')); ?>/<?php echo e($orders->id); ?>" class="btn btn-primary">VIEW</a></td>
                            </tr>
                        <?php endif; ?>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
            </table>
        </div>
    </main>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>

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