<?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" required /></td>
                                <td><input type="date" name="toDate" id="toDate" class="form-control" required /></td>
                                <td>
                                    <select name="status" id="status" class="form-control" required>
                                        <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">
                <?php if($agent_assigned->isEmpty()): ?>
                    No Data Found
                <?php else: ?>
                    <thead>
                        <tr>
                            <th scope="col">Sr No</th>
                            <th scope="col">Assign Order Id</th>
                            <th scope="col">Order id</th>
                            <th scope="col">Agent Name</th>
                            <th scope="col">Product Name</th>
                            <th scope="col">Delivery Date</th>
                            <th scope="col">status</th>
                            
                            <th scope="col">view</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $i = 0; ?>
                        <?php $__currentLoopData = $agent_assigned; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $agent_assigneds): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <?php $i++; ?>
                            <tr>
                                <th scope="row"><?php echo e($i); ?></th>
                                <td><?php echo e($agent_assigneds->agent_order_id); ?></td>
                                <td>
                                    <?php
                                        $orderId = null;
                                    ?>
                                    <?php $__currentLoopData = $assined; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $assineds): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <?php $__currentLoopData = $orders; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $order): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <?php if($assineds->OID == $order->id): ?>
                                                <?php echo e($order->unique_order_id); ?>

                                                <?php
                                                    $orderId = $order->id;
                                                    break 2;
                                                ?>
                                            <?php endif; ?>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </td>
                                <td>
                                    <?php $__currentLoopData = $agents; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $agent): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <?php if($agent_assigneds->agent_id == $agent->id): ?>
                                            <?php echo e($agent->name); ?>

                                            <?php break; ?>
                                        <?php endif; ?>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </td>
                                <td>
                                    <?php
                                        $printedProducts = [];
                                    ?>
                                    <?php $__currentLoopData = $product_maped; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product_mapeds): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <?php if($product_mapeds->agent_assinged_id == $agent_assigneds->id): ?>
                                            <?php $__currentLoopData = $agent_product_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <?php if($product->id == $product_mapeds->product_id && !in_array($product->id, $printedProducts)): ?>
                                                    <?php echo e($product->item); ?><br>
                                                    <?php
                                                        $printedProducts[] = $product->id; 
                                                    ?>
                                                <?php endif; ?>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        <?php endif; ?>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </td>
                                <td>
                                    <?php
                                        $founddetails = false;
                                    ?>
                                    <?php $__currentLoopData = $order_details; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $order_detail): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <?php if($order_detail->order_id == $agent_assigneds->OID): ?>
                                            <?php echo e($order_detail->delivery_date); ?>

                                            <?php
                                                $founddetails = true;
                                                break;
                                            ?>
                                        <?php endif; ?>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </td>
                                <td>
                                    <?php if($agent_assigneds->status=='P'): ?>
                                        <div class="alert alert-danger" role="alert" style="width: 80%;text-align: center;">PENDING</div>
                                        <?php elseif($agent_assigneds->status=='PC'): ?>
                                        <div class="alert alert-secondary" role="alert" style="width: 80%;text-align: center;">PROGRESS</div>
                                        <?php elseif($agent_assigneds->status=='CL'): ?>
                                        <div class="alert alert-info" role="alert" style="width: 80%;text-align: center;">CANCEL</div>
                                        <?php elseif($agent_assigneds->status=='H'): ?>
                                        <div class="alert alert-dark" role="alert" style="width: 80%;text-align: center;">HOLD</div>
                                        <?php elseif($agent_assigneds->status=='D'): ?>
                                        <div class="alert alert-success" role="alert" style="width: 80%;text-align: center;">DELIVERED</div>
                                        <?php elseif($agent_assigneds->status=='S'): ?>
                                        <div class="alert alert-success" role="alert" style="width: 80%;text-align: center;">Shipped</div>
                                    <?php endif; ?>
                                </td>
                                
                                <td><a href="<?php echo e(url('/admin/dashboard')); ?>/<?php echo e($agent_assigneds->agent_order_id); ?>/<?php echo e($agent_assigneds->agent_id); ?>" class="btn btn-primary">VIEW</a></td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                <?php endif; ?>    
            </table>
            <a class="btn btn-danger" href="<?php echo e(url('/admin/main')); ?>">Back</a>
        </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>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></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/main.blade.php ENDPATH**/ ?>