<div class="card-body">
<?php echo e(Form::open(['method' => 'GET', 'route' => 'report-deliverymanEarning', 'id' => 'filter-form'])); ?>

    <div class="row justify-content-end align-items-end">
        <div class="form-group col-auto">
            <?php echo e(Form::label('from_date', __('message.from_date').' <span class="text-danger">*</span>', ['class' => 'form-control-label error'],false)); ?>

            <span class="text-danger" id = "form_validation_from_date"></span>
            <?php echo e(Form::date('from_date', $params['from_date'] ?? old('from_date'), ['placeholder' => __('message.date'), 'class' => 'form-control datepicker select2Clear error', 'id' => 'from_date_main'])); ?>

        </div>
        <div class="form-group col-auto">
            <?php echo e(Form::label('to_date', __('message.to').' <span class="text-danger">*</span>', ['class' => 'form-control-label error'],false)); ?>

            <span class="text-danger" id = "form_validation_to_date"></span>
            <?php echo e(Form::date('to_date', $params['to_date'] ?? old('to_date'), ['placeholder' => __('message.date'), 'class' => 'form-control datepicker select2Clear error', 'id' => 'to_date_main'])); ?>

        </div>
        <div class="form-group col-sm-0">
            <button type="submit" class="btn btn-sm btn-primary text-white pt-2 pb-2 clearListPropertynumber"><?php echo e(__('message.apply_filter')); ?></button>
        </div>
        <div class="form-group col-md-auto text-right">
            <a href="<?php echo e(route('report-deliverymanEarning')); ?>" class="btn btn-light text-dark pt-2 pb-2">
                <i class="ri-repeat-line" style="font-size:12px"></i> <?php echo e(__('message.reset_filter')); ?>

            </a>
            <div class="dropdown d-inline">
                <button class="btn btn-success dropdown-toggle pt-2 pb-2" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    <?php echo e(__('message.export')); ?>

                </button>
                <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
                    <a class="dropdown-item" href="<?php echo e(route('download-deliveryman-earning', request()->all())); ?>">
                        <i class="fas fa-file-csv"></i> <?php echo e(__('message.excel')); ?>

                    </a>
                    <a class="dropdown-item" href="<?php echo e(route('download-deliverymanearningpdf', request()->all())); ?>">
                        <i class="fas fa-file-pdf"></i> <?php echo e(__('message.pdf')); ?>

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

</div>
<script src="<?php echo e(asset('frontend-website/assets/js/jquery.min.js')); ?>"></script>
<script src="<?php echo e(asset('js/jquery.validate.min.js')); ?>"></script>
<script>
    $(document).ready(function () {
        $.validator.addMethod('greaterThan', function (value, element, param) {
            var fromDateValue = $(param).val();
            if (!value || !fromDateValue) {
                return true; 
            }
            return new Date(value) > new Date(fromDateValue);
        });

        $.validator.addMethod('lessThan', function (value, element, param) {
            var toDateValue = $(param).val();
            if (!value || !toDateValue) {
                return true; 
            }
            return new Date(value) < new Date(toDateValue);
        });

        $('#filter-form').validate({
            rules: {
                from_date: {
                    required: true
                },
                to_date: {
                    greaterThanEqual: '#from_date_main'
                }
            },
            messages: {
                from_date: {
                    required: "<?php echo e(__('message.from_date_required')); ?>"
                },
                to_date: {
                    required: "<?php echo e(__('message.to_date_required')); ?>",
                    greaterThanEqual: "<?php echo e(__('message.to_date_must_be_greater_than_from_date')); ?>"
                }
            },
            errorPlacement: function (error, element) {
                error.addClass('text-danger');
                    if (element.attr("name") == "from_date") {
                        $('#form_validation_from_date').prepend(error);
                       
                    } else if (element.attr("name") == "to_date") {
                        $('#form_validation_to_date').prepend(error);
                    } else {
                        error.insertAfter(element);
                    }
            },
            highlight: function (element) {
                $(element).addClass('is-invalid');
            },
            unhighlight: function (element) {
                $(element).removeClass('is-invalid');
            }
        });
    });
</script>




<?php /**PATH /www/wwwroot/mxunzo.mimeld.com/resources/views/report/deliverymandatefilter.blade.php ENDPATH**/ ?>