<?php $id = $id ?? null; ?>
<?php echo e(Form::open(['route' => 'order.assign', 'method' => 'post','id' => 'assign_order_form'])); ?>

<?php echo e(Form::hidden('type','courier_assigned')); ?>

<?php echo e(Form::hidden('status','courier_assigned')); ?>

<?php echo e(Form::hidden('id',$id)); ?>

<div class="modal-dialog modal-dialog-centered  modal-xl" role="document">
    <div class="modal-content">
        <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel"><?php echo e(__($pageTitle)); ?></h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
            </button>
        </div>
        <div class="modal-body">
            <div class="row">
                <div class="card-body">
                    <div class="card-body p-0">
                        <div class="table-responsive mt-4">
                            <table id="basic-table" class="table mb-0  text-center" role="grid">
                                <thead>
                                    <tr>
                                        <th scope='col'><?php echo e(__('message.id')); ?></th>
                                        <th scope='col'><?php echo e(__('message.delivery_man')); ?></th>
                                        <th scope='col'><?php echo e(__('message.city_name')); ?></th>
                                        <th scope='col'><?php echo e(__('message.assign')); ?></th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php if( count($deliveryMen) > 0): ?>
                                        <?php $__currentLoopData = $deliveryMen; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <tr>
                                                <td><?php echo e(optional($value)->id ?? '-'); ?></td>
                                                <td><?php echo e(optional($value)->name ?? '-'); ?></td>
                                                <td><?php echo e(optional($value->city)->name ?? '-'); ?></td>
                                                <?php if($order->delivery_man_id === null): ?>
                                                <td><a style="background-color: #4b0082; border-color: #4b0082; color: #ffffff" class="btn btn-sm assign-btn" data-id="<?php echo e(optional($value)->id); ?>"><?php echo e(__('message.assign_order')); ?></a></td>
                                                <?php else: ?>
                                                <td><a style="background-color: #4b0082; border-color: #4b0082; color: #ffffff" class="btn btn-sm assign-btn" data-id="<?php echo e(optional($value)->id); ?>"><?php echo e(__('message.order_transfer')); ?></a></td>
                                                <?php endif; ?>
                                            </tr>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <?php else: ?>
                                        <tr>
                                            <td colspan="9"><?php echo e(__('message.no_record_found')); ?></td>
                                        </tr>
                                    <?php endif; ?>
                                </tbody>
                                <?php echo Form::hidden('delivery_man_id','', ['id' => 'delivery_man_id_input']); ?>


                            </table>
                        </div>
                    </div>
                    <?php echo e(Form::close()); ?>

                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(document).ready(function($) {
        $(document).on('click', '.assign-btn', function() {
            var deliveryManId = $(this).data('id');
            $('#delivery_man_id_input').val(deliveryManId);
            $('#assign_order_form').submit();
        });

        $("#basic-table").DataTable({
            "dom":  '<"row align-items-center"<"col-md-2"><"col-md-6" B><"col-md-4"f>><"table-responsive my-3" rt><"d-flex" <"flex-grow-1" l><"p-2" i><"mt-4" p>><"clear">',
            "order": [[0, "desc"]]
        });
    });
</script>

<?php /**PATH /home/atharvatek/mxunzo.atharvatek.com/resources/views/order/assgin.blade.php ENDPATH**/ ?>