@extends('template.app')



@section('meta') @endsection

@section('title') RTO Report @endsection



@section('styles')

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">

<link href="https://cdn.jsdelivr.net/npm/select2@4.0.13/dist/css/select2.min.css" rel="stylesheet">

<link rel="stylesheet" href="https://cdn.datatables.net/1.13.7/css/jquery.dataTables.min.css">

<style>

    table {

        font-family: Arial, sans-serif;

        border-collapse: collapse;

        width: 100%;

    }



    td, th {

        border: 1px solid #dddddd;

        text-align: left;

        padding: 8px;

    }



    /*tr:nth-child(even) {*/

    /*    background-color: #313762;*/

    /*}*/



    div.dataTables_wrapper div.dataTables_filter label {

        font-weight: normal;

        white-space: nowrap;

        margin-left: auto;

        margin-right: auto;

    }



    .table-responsive {

        overflow-x: auto;

        max-width: 100%;

    }


    /* Commented by Kerav */

    /*.card-body {

        overflow-x: auto;

        max-width: 100%;

        margin-right: 40px;

        margin-left: 40px;

    }



    .card-header {

        margin-right: 40px;

        margin-left: 40px;

    }


    .card.mt-4, .card {

        margin: 20px 40px;

    }*/

    /* Commented by Kerav */



    .dataTables_wrapper {

        width: 100%;

        max-width: 100%;

        overflow-x: auto;

    }

</style>

@endsection



@section('content')

<div class="page-breadcrumb">

    <div class="row">

        <div class="col-7 align-self-center">

            <h4 class="page-title text-truncate text-dark font-weight-medium mb-1">RTO Report</h4>

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

                <nav aria-label="breadcrumb">

                    <ol class="breadcrumb m-0 p-0">

                        <li class="breadcrumb-item"><a href="{{ route('dashboard') }}" class="text-muted">Dashboard</a></li>
                        <li class="breadcrumb-item"><a href="{{ route('allReport') }}" class="text-muted">Mis Report</a></li>
                        <li class="breadcrumb-item text-muted active" aria-current="page">RTO Report</li>

                    </ol>

                </nav>

            </div>

        </div>

        <div class="col-5 align-self-center">

            <div class="customize-input float-right">

                <button class="btn waves-effect waves-light btn-rounded btn-outline-primary pull-right" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">

                    Export

                </button>

            </div>

        </div>

        <div class="col-sm-8"></div>

        <div class="col-sm-4">

            <div class="col-md-12 align-self-center collapse" id="collapseExample">

                <div class="customize-input float-right">

                    <form action="{{ route('RTOExport') }}" method="get">

                        @csrf

                        <div class="row">

                            <div class="form-group col-md-6">

                                <select name="slug" class="form-control" required>

                                    <option value="">Select Status</option>

                                    <option value="all">All</option>

                                </select>

                            </div>

                            <div class="form-group col-md-6">

                                <button class="btn btn-primary" type="submit">Submit</button>

                            </div>

                        </div>

                    </form>

                </div>

            </div>

        </div>

    </div>

</div>



<div class="container-fluid">

  <div class="row">

        <div class="col-12">

            <div class="card">

                <div class="col-md-4 mt-2">

                    <input type="text" class="form-control" id="vin-input" placeholder="Enter VIN Number">

                </div>

                <div class="col-md-4 mt-2">

                    <button type="button" id="submit-btn" class="btn btn-primary">Submit</button>

                </div>

            </div>

        </div>

        <div class="col-12 mt-4">

            <div class="card">

                <div class="card-body table-responsive" id="datatable" style="text-align: center;">

                    <table class="table table-bordered data-table tables" id="data-table" cellspacing="0" width="100%">

                        <thead>

                            <tr>

                                <th>No</th>

                                <th>Model</th>

                                <th>Variant</th>

                                <th>Status</th>

                                <th>Team Leader</th>

                                <th>KEC Name</th>

                                <th>RTO Status</th>

                                <th>RTO Type</th>

                                <th>Number Plate</th>

                                <th>Registration Date</th>

                                <th>Application Number</th>

                                <th>Temporary Number</th>

                                <th>Final Amount</th>

                                <th>Vehicle Number</th>

                                <th>RTO Invoice</th>

                                <th>RTO Invoice Date</th>

                                <th>DMS Invoice No</th>

                                <th>DMS Invoice Date</th>

                                <th>DMS Gatepass Date</th>

                                <th>DMS Location</th>

                                <th>DMS RTO Create Date</th>

                                <th>RTO Certificate</th>

                                <th>RTO Process Status</th>

                            </tr>

                            <tr class="filterrow">

                                <th></th>

                                <th>

                                    <div class="search-box-container datatable-form-filter width_150">

                                        <div class="form-group is-empty">

                                            <input type="text" name="product" value="{{ request()->get('product', '') }}" class="form-control text-capitalize" id="product" autocomplete="off" tabindex="1">

                                        </div>

                                    </div>

                                </th>

                                <th>

                                    <div class="search-box-container datatable-form-filter width_150">

                                        <div class="form-group is-empty">

                                            <input type="text" name="car_varient_name" value="{{ request()->get('car_varient_name', '') }}" class="form-control text-capitalize" id="car_varient_name" autocomplete="off" tabindex="1">

                                        </div>

                                    </div>

                                </th>



                                <th>

                                    <div class="search-box-container datatable-form-filter width_250">

                                        <div class="form-group is-empty">

                                            <input type="text" name="status" value="{{ request()->get('status', '') }}" class="form-control text-capitalize custom_color" id="status" autocomplete="off" autofocus tabindex="2">

                                        </div>

                                    </div>

                                </th>

                                <th>

                                    <div class="search-box-container datatable-form-filter width_150">

                                        <div class="form-group is-empty">

                                            <input type="text" name="team_name" value="{{ request()->get('team_name', '') }}" class="form-control text-capitalize custom_color" id="team_name" autocomplete="off" autofocus tabindex="4">

                                        </div>

                                    </div>

                                </th>

                                <th>

                                    <div class="search-box-container datatable-form-filter width_150">

                                        <div class="form-group is-empty">

                                            <input type="text" name="sales_person_name" value="{{ request()->get('sales_person_name', '') }}" class="form-control text-capitalize custom_color" id="sales_person_name" autocomplete="off" autofocus tabindex="4">

                                        </div>

                                    </div>

                                </th>

                                <th>

                                    <div class="search-box-container datatable-form-filter width_150">

                                        <div class="form-group is-empty">

                                            <input type="text" name="rto_status" value="{{ request()->get('rto_status', '') }}" class="form-control text-capitalize custom_color" id="rto_status" autocomplete="off" autofocus tabindex="4">

                                        </div>

                                    </div>

                                </th>

                                <th>

                                    <div class="search-box-container datatable-form-filter width_150">

                                        <div class="form-group is-empty">

                                            <input type="text" name="rto_type" value="{{ request()->get('rto_type', '') }}" class="form-control text-capitalize custom_color" id="rto_type" autocomplete="off" autofocus tabindex="4">

                                        </div>

                                    </div>

                                </th>

                                <th>

                                    <div class="search-box-container datatable-form-filter width_150">

                                        <div class="form-group is-empty">

                                            <input type="text" name="number_plate" value="{{ request()->get('number_plate', '') }}" class="form-control text-capitalize custom_color" id="number_plate" autocomplete="off" autofocus tabindex="4">

                                        </div>

                                    </div>

                                </th>

                                <th>

                                    <div class="search-box-container datatable-form-filter width_150">

                                        <div class="form-group is-empty">

                                            <input type="date" name="registration_date" value="{{ request()->get('registration_date', '') }}" class="form-control text-capitalize custom_color" id="registration_date" autocomplete="off" autofocus tabindex="4">

                                        </div>

                                    </div>

                                </th>

                                <th>

                                    <div class="search-box-container datatable-form-filter width_150">

                                        <div class="form-group is-empty">

                                            <input type="text" name="application_number" value="{{ request()->get('application_number', '') }}" class="form-control text-capitalize custom_color" id="application_number" autocomplete="off" autofocus tabindex="4">

                                        </div>

                                    </div>

                                </th>

                                <th>

                                    <div class="search-box-container datatable-form-filter width_150">

                                        <div class="form-group is-empty">

                                            <input type="text" name="temporary_number" value="{{ request()->get('temporary_number', '') }}" class="form-control text-capitalize custom_color" id="temporary_number" autocomplete="off" autofocus tabindex="4">

                                        </div>

                                    </div>

                                </th>

                                <th>

                                    <div class="search-box-container datatable-form-filter width_150">

                                        <div class="form-group is-empty">

                                            <input type="text" name="final_amount" value="{{ request()->get('final_amount', '') }}" class="form-control text-capitalize custom_color" id="final_amount" autocomplete="off" autofocus tabindex="4">

                                        </div>

                                    </div>

                                </th>

                                <th>

                                    <div class="search-box-container datatable-form-filter width_150">

                                        <div class="form-group is-empty">

                                            <input type="text" name="vehicle_number" value="{{ request()->get('vehicle_number', '') }}" class="form-control text-capitalize custom_color" id="vehicle_number" autocomplete="off" autofocus tabindex="4">

                                        </div>

                                    </div>

                                </th>

                                <th>

                                    <div class="search-box-container datatable-form-filter width_150">

                                        <div class="form-group is-empty">

                                            <input type="text" name="rto_invoice" value="{{ request()->get('rto_invoice', '') }}" class="form-control text-capitalize custom_color" id="rto_invoice" autocomplete="off" autofocus tabindex="4">

                                        </div>

                                    </div>

                                </th>

                                <th>

                                    <div class="search-box-container datatable-form-filter width_150">

                                        <div class="form-group is-empty">

                                            <input type="date" name="rto_invoice_date" value="{{ request()->get('rto_invoice_date', '') }}" class="form-control text-capitalize custom_color" id="rto_invoice_date" autocomplete="off" autofocus tabindex="4">

                                        </div>

                                    </div>

                                </th>

                                <th>

                                    <div class="search-box-container datatable-form-filter width_150">

                                        <div class="form-group is-empty">

                                            <input type="text" name="dms_invoice_no" value="{{ request()->get('dms_invoice_no', '') }}" class="form-control text-capitalize custom_color" id="dms_invoice_no" autocomplete="off" autofocus tabindex="4">

                                        </div>

                                    </div>

                                </th>

                                <th>

                                    <div class="search-box-container datatable-form-filter width_150">

                                        <div class="form-group is-empty">

                                            <input type="date" name="dms_invoice_date" value="{{ request()->get('dms_invoice_date', '') }}" class="form-control text-capitalize custom_color" id="dms_invoice_date" autocomplete="off" autofocus tabindex="4">

                                        </div>

                                    </div>

                                </th>

                                <th>

                                    <div class="search-box-container datatable-form-filter width_150">

                                        <div class="form-group is-empty">

                                            <input type="date" name="dms_gatepass_date" value="{{ request()->get('dms_gatepass_date', '') }}" class="form-control text-capitalize custom_color" id="dms_gatepass_date" autocomplete="off" autofocus tabindex="4">

                                        </div>

                                    </div>

                                </th>

                                <th>

                                    <div class="search-box-container datatable-form-filter width_150">

                                        <div class="form-group is-empty">

                                            <input type="text" name="dms_location" value="{{ request()->get('dms_location', '') }}" class="form-control text-capitalize custom_color" id="dms_location" autocomplete="off" autofocus tabindex="4">

                                        </div>

                                    </div>

                                </th>

                                <th>

                                    <div class="search-box-container datatable-form-filter width_150">

                                        <div class="form-group is-empty">

                                            <input type="date" name="dms_rto_create_date" value="{{ request()->get('dms_rto_create_date', '') }}" class="form-control text-capitalize custom_color" id="dms_rto_create_date" autocomplete="off" autofocus tabindex="4">

                                        </div>

                                    </div>

                                </th>

                                <th>

                                    <div class="search-box-container datatable-form-filter width_150">

                                        <div class="form-group is-empty">

                                            <input type="text" name="dms_rto_certificate" value="{{ request()->get('dms_rto_certificate', '') }}" class="form-control text-capitalize custom_color" id="dms_rto_certificate" autocomplete="off" autofocus tabindex="4">

                                        </div>

                                    </div>

                                </th>

                                <th>

                                    <div class="search-box-container datatable-form-filter width_150">

                                        <div class="form-group is-empty">

                                            <input type="text" name="rto_process_status" value="{{ request()->get('rto_process_status', '') }}" class="form-control text-capitalize custom_color" id="rto_process_status" autocomplete="off" autofocus tabindex="4">

                                        </div>

                                    </div>

                                </th>

                            </tr>

                        </thead>

                    </table>

                </div>

            </div>

        </div>

@endsection



@section('scripts')

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>

<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>

<script src="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap5.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>

<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>

<script src="https://cdn.datatables.net/1.13.7/js/jquery.dataTables.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/select2@4.0.13/dist/js/select2.min.js"></script>

<script src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>



<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />

<script src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>



<script type="text/javascript">

    $.ajaxSetup({

        headers: {

            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

        }

    });

</script>

<script type="text/javascript">

    



    $(document).ready(function() {

        $('#booking_date').daterangepicker({

            autoUpdateInput: false,

            locale: {

                format: 'DD-MM-YYYY',

                cancelLabel: 'Clear'

            }

        });

    

        $('#booking_date').on('apply.daterangepicker', function(ev, picker) {

            $(this).val(picker.startDate.format('DD-MM-YYYY') + ' to ' + picker.endDate.format('DD-MM-YYYY'));

            $('#data-table').DataTable().draw();

        });

    

        $('#booking_date').on('cancel.daterangepicker', function(ev, picker) {

            $(this).val('');

            $('#data-table').DataTable().draw();

        });

        

        let rowCount = $("table tbody tr").length;

        if (rowCount < 3) {

            $(".table").css("height", "600px");

        }



        $('.js-example-basic-single').select2();



        var tableColumns = [

            { data: 'obf_id', name: 'obf_id'},

            { data: 'product', name: 'product' }, 

            { data: 'car_varient_name', name: 'car_varient_name' },

            { data: 'status', name: 'status' },

            { data: 'team_name', name: 'team_name'},

            { data: 'sales_person_name', name: 'sales_person_name'},

            { data: 'rto_status', name: 'rto_status'},

            { data: 'rto_type', name: 'rto_type' },

            { data: 'number_plate', name: 'number_plate' }, 

            { data: 'registration_date', name: 'registration_date' }, 

            { data: 'application_number', name: 'application_number' }, 

            { data: 'temporary_number', name: 'temporary_number' },

            { data: 'final_amount', name: 'final_amount' },

            { data: 'vehicle_number', name: 'vehicle_number' },

            { data: 'rto_invoice', name: 'rto_invoice' },  

            { data: 'rto_invoice_date', name: 'rto_invoice_date' },  

            { data: 'dms_invoice_no', name: 'dms_invoice_no' },  

            { data: 'dms_invoice_date', name: 'dms_invoice_date' },  

            { data: 'dms_gatepass_date', name: 'dms_gatepass_date' },  

            { data: 'dms_location', name: 'dms_location' },  

            { data: 'dms_rto_create_date', name: 'dms_rto_create_date' },  

            { data: 'dms_rto_certificate', name: 'dms_rto_certificate', render: function(data) {

                return `<a href="${data}" target="_blank">View Certificate</a>`;

            }},  

            { data: 'rto_process_status', name: 'rto_process_status' }, 

        ];



        (function(window, $) {

            window.LaravelDataTables = window.LaravelDataTables || {};

            window.LaravelDataTables["dataTableBuilder"] = $("#data-table").DataTable({

                processing: true,

                serverSide: true,

                language: {

                    "info": "_START_ - _END_ of _TOTAL_",

                    "lengthMenu": "_MENU_ ",

                    "infoFiltered": ""

                },

                // scrollY: '400px',

                scrollCollapse: true,

                paging: true,

                searching: false,



                bSortCellsTop : true,

                ajax: {

                    url: '{!! route("getRto") !!}',

                    method: "POST",

                    data: function (d) {

                        d.product = jQuery(".datatable-form-filter input[name='product']").val();

                        d.car_varient_name = jQuery(".datatable-form-filter input[name='car_varient_name']").val();

                        d.status = jQuery(".datatable-form-filter input[name='status']").val();

                        d.sales_person_name = jQuery(".datatable-form-filter input[name='sales_person_name']").val();

                        d.rto_status = jQuery(".datatable-form-filter input[name='rto_status']").val();

                        d.rto_type = jQuery(".datatable-form-filter input[name='rto_type']").val();

                        d.number_plate = jQuery(".datatable-form-filter input[name='number_plate']").val();

                        d.registration_date = jQuery(".datatable-form-filter input[name='registration_date']").val();

                        d.application_number = jQuery(".datatable-form-filter input[name='application_number']").val();

                        d.temporary_number = jQuery(".datatable-form-filter input[name='temporary_number']").val();

                        d.final_amount = jQuery(".datatable-form-filter input[name='final_amount']").val();

                        d.vehicle_number = jQuery(".datatable-form-filter input[name='vehicle_number']").val();

                        d.rto_invoice = jQuery(".datatable-form-filter input[name='rto_invoice']").val();

                        d.rto_invoice_date = jQuery(".datatable-form-filter input[name='rto_invoice_date']").val();

                        d.dms_invoice_no = jQuery(".datatable-form-filter input[name='dms_invoice_no']").val();

                        d.dms_invoice_date = jQuery(".datatable-form-filter input[name='dms_invoice_date']").val();

                        d.dms_gatepass_date = jQuery(".datatable-form-filter input[name='dms_gatepass_date']").val();

                        d.dms_location = jQuery(".datatable-form-filter input[name='dms_location']").val();

                        d.dms_rto_create_date = jQuery(".datatable-form-filter input[name='dms_rto_create_date']").val();

                        d.dms_rto_certificate = jQuery(".datatable-form-filter input[name='dms_rto_certificate']").val();

                        d.rto_process_status = jQuery(".datatable-form-filter input[name='rto_process_status']").val();

                    },

                    error : function(d) {}

                },

                columns: tableColumns,

                lengthMenu: [

                    [25, 50,100, -1 ],['25', '50','100', 'Show all' ]

                ],

                order: [ [0,'DESC'] ],

                responsive: true,

                colReorder:{

                    enable: false,

                },

                dom: '<"top"f>rt<"bottom"ipl><"clear">',

                fnInitComplete: function(settings, json) {

                    jQuery('table.table input:checkbox').map(function() {

                        if(jQuery(this).prop("checked") != true){

                            var column = table.column( jQuery(this).attr('data-column') );

                            column.visible(false);

                        }

                    });

                },

                pageLength: 25,

            });

        })(window, jQuery);



        $("#min").flatpickr({ onSelect: function () { window.LaravelDataTables["dataTableBuilder"].draw(); }, changeMonth: true, changeYear: true });



        $(document).on("change", "#min", function () {

            window.LaravelDataTables["dataTableBuilder"].draw();

        });







    jQuery('.datatable-form-filter input').on('keyup', function (e) {

        if(jQuery(this).val().length >= 3 || e.keyCode == 13 || !jQuery(this).val()) {

            window.LaravelDataTables["dataTableBuilder"].draw();

            e.preventDefault();

        }

    });



    jQuery('.datatable-form-filter select').on('change', function (e) {

        window.LaravelDataTables["dataTableBuilder"].draw();

        e.preventDefault();

    });



    jQuery('input:checkbox[name="name_sort_asc"],input:checkbox[name="name_sort_desc"]').on('click', function (e) {

        window.LaravelDataTables["dataTableBuilder"].draw();

        e.preventDefault();

    });

}); 

</script>

@endsection