

<?php $__env->startSection('title', 'Pricing'); ?>

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

    <div class="card">

        <div class="card-header">

            <div class="d-flex justify-content-between align-items-center">

                <h4 class="mb-0">
                    Pricing Configuration
                </h4>

                <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addPricingModal">

                    <i class="bi bi-plus-circle"></i>
                    Add Pricing

                </button>

            </div>

        </div>

        <div class="card-body">

            <div class="table-responsive">

                <table class="table table-bordered table-striped align-middle" id="pricingTable">

                    <thead class="table-light">

                        <tr>

                            <th width="60">
                                S/N
                            </th>

                            <th>
                                Cargo Type
                            </th>

                            <th>
                                Device Type
                            </th>

                            <th class="text-end">
                                Amount (TZS)
                            </th>

                            <th width="120">
                                Status
                            </th>

                            <th width="90" class="text-center">
                                Action
                            </th>

                        </tr>

                    </thead>

                    <tbody>

                        <?php $__currentLoopData = $pricings; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $pricing): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>

                                <td>
                                    <?php echo e($loop->iteration); ?>

                                </td>

                                <td>
                                    <span class="fw-bold">
                                        <?php echo e($pricing->cargo_type); ?>

                                    </span>
                                </td>

                                <td>

                                    <?php if($pricing->device_type == 'MASTER'): ?>
                                        <span class="badge bg-primary">
                                            MASTER
                                        </span>
                                    <?php else: ?>
                                        <span class="badge bg-info">
                                            SLAVE
                                        </span>
                                    <?php endif; ?>

                                </td>

                                <td class="text-end fw-bold">

                                    <?php echo e(number_format($pricing->amount, 2)); ?>


                                </td>

                                <td>

                                    <?php if($pricing->status): ?>
                                        <span class="badge bg-success">
                                            ACTIVE
                                        </span>
                                    <?php else: ?>
                                        <span class="badge bg-danger">
                                            DISABLED
                                        </span>
                                    <?php endif; ?>

                                </td>

                                <td class="text-center">

                                    <button class="btn btn-primary btn-sm edit-pricing" data-id="<?php echo e($pricing->id); ?>"
                                        data-cargo_type="<?php echo e($pricing->cargo_type); ?>"
                                        data-device_type="<?php echo e($pricing->device_type); ?>" data-amount="<?php echo e($pricing->amount); ?>"
                                        data-status="<?php echo e($pricing->status); ?>" data-bs-toggle="modal"
                                        data-bs-target="#editPricingModal">

                                        <i class="bi bi-pencil"></i>

                                    </button>

                                </td>

                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                    </tbody>

                </table>

            </div>

        </div>

    </div>

    <?php echo $__env->make('pricings.partials.add-pricing-modal', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
    <?php echo $__env->make('pricings.partials.edit-pricing-modal', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
    <script>
        $(function() {

            $('#pricingTable').DataTable({

                order: [
                    [1, 'asc'],
                    [2, 'asc']
                ],

                pageLength: 25,

            });

        });

        $(document).on(
            'click',
            '.edit-pricing',
            function() {

                let id = $(this).data('id');

                $('#editPricingForm').attr(
                    'action',
                    '/pricings/' + id
                );

                $('#edit_cargo_type').val(
                    $(this).data('cargo_type')
                );

                $('#edit_device_type').val(
                    $(this).data('device_type')
                );

                $('#edit_amount').val(
                    $(this).data('amount')
                );

                $('#edit_status').val(
                    $(this).data('status')
                );

            }
        );
    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.master', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH D:\Projects\lms-ects\resources\views/pricings/index.blade.php ENDPATH**/ ?>