<?php $__env->startPush('css'); ?>
    <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<?php $__env->stopPush(); ?>

<?php $__env->startSection('content'); ?>
    <div class="card">
        <div class="card-header">
            <h3>Truck Sale Register Report</h3>
        </div>
        <div class="card-body">
            <?php if($errors->any()): ?>
                <div style="border:1px solid red; padding:10px; margin-bottom:20px; background-color:#fdd;">
                    <strong>Errors:</strong>
                    <ul>
                        <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <li><?php echo e($error); ?></li>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </ul>
                </div>
            <?php endif; ?>

            <form id="filterForm" class="row" method="GET" action="<?php echo e(route('truck-sale-register.report.print')); ?>">

                <div class="row">
                    <div class="col-md-3">
                        <div class="form-group mt-3">
                            <label for="from_date">From Date</label>
                            <input type="date" name="date" id="from_date" readonly class="date form-control"
                                value="<?php echo e(request('date')); ?>">
                        </div>
                    </div>

                    <div class="col-md-9">
                        <div class="form-group mt-3">
                            <label>Select Truck</label>
                            <select id="trucks" name="truck_id" class="form-control select2">
                                
                                <?php $__currentLoopData = $trucks; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $customer): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($customer->id_truck); ?>"><?php echo e($customer->truck_no); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>

                            
                        </div>
                    </div>

                    <div class="row mt-5">
                        <div class="col-md-12 text-center">
                            <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> Print
                                View</button>
                        </div>
                    </div>
            </form>
            <hr />

        </div>
    </div>
<?php $__env->stopSection(); ?>
<?php $__env->startPush('scripts'); ?>
    <script>
        $('.select2').select2();
    </script>
    <script>
        $(document).ready(function() {
            $(function() {
                $(".date").datepicker({
                    dateFormat: "yy-mm-dd"
                });
            });
            $('.select2').select2();

            $(document).ready(function() {

                $('.select2').select2();

                $('#toggleSelectBtn').click(function() {

                    let totalOptions = $('#trucks option').length;
                    let selectedCount = $('#trucks').val() ? $('#trucks').val().length : 0;


                    if (selectedCount === totalOptions) {

                        $('#trucks').val(null).trigger('change');

                        $('#toggleSelectBtn')
                            .text('Select All')
                            .removeClass('btn-danger')
                            .addClass('btn-primary');

                    } else {

                        let allValues = [];

                        $('#trucks option').each(function() {
                            let val = $(this).val();
                            if (val !== "") allValues.push(val);
                        });

                        $('#trucks').val(allValues).trigger('change');

                        $('#toggleSelectBtn')
                            .text('Deselect All')
                            .removeClass('btn-primary')
                            .addClass('btn-danger');
                    }

                });

            });

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

<?php echo $__env->make('layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/mdskssye/crm.mdskarachi.com/resources/views/reports/truck_sale_register.blade.php ENDPATH**/ ?>