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

<main id="main" class="main">
   <div class="container">
         <div class="card" style="width: 100%;">          
            <div class="card-body">
            <h5 class="card-title">AGENT NAME :<?php echo e($agents->name); ?> </h5> 
                <h5 class="card-title">PRODUCT DETAILS </h5> 
                    <?php if($agent_assinged->status=='P'): ?>
                        <div class="alert alert-danger" role="alert" style="width: 20%;text-align:center;">PENDING</div>
                        <?php elseif($agent_assinged->status=='PC'): ?>
                        <div class="alert alert-secondary" role="alert" style="width: 20%;text-align:center;">PROGRESS</div>
                        <?php elseif($agent_assinged->status=='CL'): ?>
                        <div class="alert alert-info" role="alert" style="width: 20%;text-align:center;">CANCEL</div>
                        <?php elseif($agent_assinged->status=='H'): ?>
                        <div class="alert alert-dark" role="alert" style="width: 20%;text-align:center;">HOLD</div>
                        <?php elseif($agent_assinged->status=='D'): ?>
                        <div class="alert alert-success" role="alert" style="width: 20%;text-align:center;">DELIVERED</div>
                        <?php elseif($agent_assinged->status=='S'): ?>
                        <div class="alert alert-success" role="alert" style="width: 20%;text-align:center;">Shipped</div>
                    <?php endif; ?>
                <h6 class="card-subtitle mb-2 text-body-secondary">ORDER NO : <?php echo e($agent_assinged->agent_order_id); ?></h6>
                    <div style="text-align:right">
                           
                    </div>
                <p class="card-text"><b>Products</b></p>
                <ol>
                    <?php $__currentLoopData = $agent_product_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <?php if($product->agent_id == $agentId): ?>
                                <li><?php echo e($product->item); ?></li>
                        <?php endif; ?>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </ol>
                <p><b>Delivery Address :</b> <?php echo e($orders->delivery_address); ?></p>
                <p><b>Customer Contact :</b> <?php echo e($orders->billing_mobile); ?></p>
                <?php $price=0; ?>
                <form action="<?php echo e(url('/admin/dashboard')); ?>/<?php echo e($agent_assinged->agent_order_id); ?>/<?php echo e($agentId); ?>" method="post">
                    <?php echo csrf_field(); ?>
                    <table class="table">
                        <thead>
                            <tr>
                                <th></th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td  colspan="2">
                                <b>Total Price:</b>
                                    <?php echo e($agent_assinged->totalPrice); ?>

                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>Extra</b>
                                    <input class="form-control" name="extra" id="extra" placeholder="Ask For Extra Charge" value="<?php echo e($agent_assinged->extra); ?>"/>
                                </td>
                                <td>
                                    <b>Delivery Charge</b> <input class="form-control" id="deliveryCharge" name="deliveryCharge" value="<?php echo e($agent_assinged->Deliver_charge); ?>"/>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                <b>Enter The Reason</b>
                                    <textarea name="reason" rows="4" cols="50" id="reason" placeholder="Reason" class="form-control"><?php echo e($agent_assinged->reason); ?>

                                    </textarea>
                                </td>
                            </tr>
                            <tr>
                                <?php if($agent_assinged->status == 'PC' || $agent_assinged->track_no != ""): ?>
                                    <td colspan="2"><input class="form-control" name="track_no" value="<?php echo e($agent_assinged->track_no); ?>" style="width:100%;" placeholder="Enter Tracking Number" ></td>
                                <?php endif; ?>
                            </tr>
                            <tr>
                                <td colspan="2" style="text-align: center!important;display:flex;margin-left: 81%;">
                                <?php if($agent_assinged->status == "P"): ?>
                                    <input type="radio" id="accept" name="status" value="PC">
                                    <label for="accept">Accept</label><br>
                                    <input type="radio" id="hold" name="status" value="H">
                                    <label for="hold">Hold</label><br>
                                    <input type="radio" id="reject" name="status" value="CL">
                                    <label for="reject">Reject</label>
                                <?php elseif($agent_assinged->status == "PC"): ?>
                                    <input type="radio" id="accept" name="status" value="S">
                                    <label for="accept">Shipped</label><br>
                                    <input type="radio" id="hold" name="status" value="H">
                                    <label for="hold">Hold</label><br>
                                    <input type="radio" id="reject" name="status" value="CL">
                                    <label for="reject">Reject</label>
                                <?php elseif($agent_assinged->status == "S"): ?>
                                    <input type="radio" id="accept" name="status" value="D">
                                    <label for="accept">Delivered</label><br>
                                    <input type="radio" id="hold" name="status" value="H">
                                    <label for="hold">Hold</label><br>
                                <?php elseif($agent_assinged->status == "CL"): ?>

                                <?php elseif($agent_assinged->status == "H"): ?>
                                    <input type="radio" id="accept" name="status" value="PC">
                                    <label for="accept">Accept</label><br>
                                    <input type="radio" id="reject" name="status" value="CL">
                                    <label for="reject">Reject</label>
                                    <?php elseif($agent_assinged->status == "H"): ?>

                                <?php endif; ?>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <?php $__errorArgs = ['status'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <label  class="alert alert-danger" role="alert"><?php echo e($message); ?></label>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    <?php $__errorArgs = ['track_no'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <label class="alert alert-danger" role="alert"><?php echo e($message); ?></label>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    <?php $__errorArgs = ['reason'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <label class="alert alert-danger" role="alert"><?php echo e($message); ?></label>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </td>
                            </tr>
                            <tr>
                            <?php if($agent_assinged->status == 'CL' || $agent_assinged->status == 'D'): ?>
                            <?php else: ?>
                            <td colspan="2" style="text-align:center">
                                    <button type="submit" class="btn btn-primary">Submit</button>
                                </td>
                            <?php endif; ?>
                            </tr>
                        </tbody>
                    </table>
                </form>
            </div>
        </div>
   </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>

<script>
    $(document).ready(function(){
       $('.btn_submit').click(function(){
            var orderId = <?php echo json_encode($agent_assinged->agent_order_id, 15, 512) ?>;
            var extra = $('#extra').val();
            var deliVery = $('#deliveryCharge').val();
            var reason = $('#reason').val();
            var status = $(this).attr('ds-value');
            console.log(status);
            $.ajax({
                url:"<?php echo e(url('/agent/updateStatus')); ?>",
                type:'GET',
                data:{
                    orderId:orderId,
                    extra:extra,
                    deliVery:deliVery,
                    reason:reason,
                    status:status,
                },
                success:function(response){
                    console.log(response);
                },
                error:function(error){
                    console.log(error);
                },
            });
       });
    });
</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/OrderDetails.blade.php ENDPATH**/ ?>