@extends('template.app')

@section('meta')
@endsection

@section('title')
    Pricelist
@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>
     .highlight {
        background-color: #ffff99; /* Change to desired highlight color */
    }
    #data-table.dataTable tbody td {
        padding: 0px !important;
        height: 20px !important;
        line-height: 35px !important;
        font-size: 15px !important;
        text-align: center;
    }
    #data-table th {
        text-align: center;
    }
    .mt-2
    {
        font-size: 15px;
        margin-left: 15px;
    }
    .custom-form-spacing {
      margin-bottom: -19px;
    }
    .custom-select {
        height: 32px;
        font-size: 14px;
        margin-left: 10px;
        margin-right: 150px;
    }
    .form-group .custom_color {
        background-color: lightgrey !important;
    }
</style>
@endsection

@section('content')
<style>
    #data-table th, td { 
        white-space: nowrap;
        padding-bottom:0.50 rem !important;
    }
    .custom_height {
        height: 50px;
    }
    /*.width_150 {*/
    /*    width: 150px;*/
    /*}*/
    /*.width_200 {*/
    /*    width: 200px;*/
    /*}*/
    /*.width_250 {*/
    /*    width: 250px;*/
    /*}*/
    /*.width_300 {*/
    /*    width: 300px;*/
    /*}*/
    /*.table {*/
    /*    min-height: 600px;*/
    /*}*/
</style>
<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">Pricelist Manager</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('pricelist') }}" class="text-muted">Pricelist</a></li>
                        <li class="breadcrumb-item text-muted active" aria-current="page">List</li>
                    </ol>
                </nav>
            </div>
        </div>
        <div class="col-5 align-self-center">
        <div class="customize-input float-right">
                  <!-- Import -->
                    <a class="btn waves-effect waves-light btn-rounded btn-outline-primary pull-right" data-toggle="modal" data-target="#exampleModal" href="Javascript:void(0)">Import</a>
                <!-- Import -->
                <!-- Export -->
                    <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>
                    <a class="btn waves-effect waves-light btn-rounded btn-outline-primary pull-right" href="{{ route('pricelist.create') }}">Add New</a>
                <!-- Export Sample File-->    
                    <a class="btn waves-effect waves-light btn-rounded btn-outline-primary pull-right" id="export_excel_model">Example Excel</a>
               
            </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('pricelist.export') }}" 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" style="min-width:100% !important;">
                
              <!--  <form action="#" name="form" id="form" method="post" enctype="multipart/form-data">-->
              <!--      @csrf-->
              <!--      @method('POST')-->
              <!--   <div class="row">-->
                      
              <!--        <div class="col-md-3 custom-form-spacing"> -->
              <!--          <label>Model </label>-->
              <!--          <select class="custom-select js-example-basic-single" name="product" id="product">-->
              <!--              <option value="">Select Product </option>-->
              <!--              @foreach($product as $name)-->
              <!--              <option value="{{$name->name}}">{{$name->name}}</option>-->
              <!--          @endforeach -->
              <!--          </select> -->
              <!--        </div>-->
              <!--        <div class="col-md-3 custom-form-spacing">-->
              <!--          <label>On Road Price </label>-->
              <!--          <select class="custom-select js-example-basic-single" name="road_price" id="road_price">  -->
              <!--              <option value="">Select On Road Price</option>-->
              <!--              @foreach($price as $name)-->
              <!--              <option value="{{$name->on_road_price}}">{{$name->on_road_price}}</option>-->
              <!--          @endforeach -->
              <!--          </select> -->
              <!--        </div>-->
              <!--        <div class="col-md-3 custom-form-spacing">-->
              <!--          <label>Variant </label>-->
              <!--          <select class="custom-select js-example-basic-single" name="variant" id="variant">                   -->
              <!--              <option value="">Select Variant </option>         -->
              <!--              @foreach($varient as $name)-->
              <!--              <option value="{{$name->name}}">{{$name->name}}</option>-->
              <!--          @endforeach -->
              <!--          </select> -->
              <!--        </div>          -->
              <!--</div>-->
              
              <!--  </form>   -->
                
                
                <div class="card-body table-responsive">
                    
                    <table class="table table-bordered data-table" id="data-table">
                        <thead>
                            <tr>
                            <th>No</th>
                            <!--<th>Date</th>-->
                            <th>Price List Name</th>
                            <th>CSD</th>
                            <th>RTO Type</th>
                            <th>Car Model</th>
                            <th>Fuel Type</th>
                            <th>Car Variant</th>
                            <th>RTO Custom Handling Charges</th>
                            <th>Tone Selection</th>
                            <th>Location</th>
                            <th>Transmission</th>
                            <th>Basic</th>
                            <th>CSD Selling Price</th>
                            <th>LS Order Amount</th>
                            <th>GST(%)</th>
                            <th>GST Amount</th>
                            <th>CESS(%)</th>
                            <th>CESS Amount</th>
                            <th>Ex Showroom Price</th>
                            <th>TCS</th>
                            <th>Registration individual charges</th>
                            <th>Registration corporate charges</th>
                            <th>Insurance</th>
                            <th>Fastag</th>
                            <th>On Road individual charges</th>
                            <th>On Road Corporate charges</th>
                            <th>RSA Master</th>
                            <th>Extended Warranty</th>
                            <th>My Convinience Program</th>
                            <th>Other Details 1</th>
                            <th>Other Details 2</th>
                            <th>Final On Road Price Individual</th>
                            <th>Final On Road Price Corporate</th>
                            <!--<th>Invoice Date</th>-->
                            <th>Date</th>
                            <th>Status</th>
                            <th>Action</th>
                                
                            </tr>
                            <tr class="filterrow">
                                <th></th>
                                <!--<th>-->
                                <!--    <div class="search-box-container datatable-form-filter">-->
                                <!--        <div class="form-group is-empty">-->
                                <!--            <input type="text" name="booking_date" value="{{ request()->get('booking_date', '') }}" class="form-control text-capitalize" autocomplete="off" tabindex="1" id="booking_date" placeholder="DD-MM-YYYY to DD-MM-YYYY">-->
                                <!--        </div>-->
                                <!--    </div>-->
                                <!--</th>-->
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="price_list_name" value="{{ request()->get('price_list_name', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="1">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="is_csd" value="{{ request()->get('is_csd', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="1">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="rtotype" value="{{ request()->get('rtotype', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="1">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="product" value="{{ request()->get('product', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="2">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="fuel_type" value="{{ request()->get('fuel_type', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="1">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="car_variant_name" value="{{ request()->get('car_variant_name', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="3">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="rto_custome_handling_charges" value="{{ request()->get('rto_custome_handling_charges', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="1">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="color_type" value="{{ request()->get('color_type', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="location" value="{{ request()->get('location', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="t_name" value="{{ request()->get('t_name', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="basic" value="{{ request()->get('basic', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="csd_selling_price" value="{{ request()->get('csd_selling_price', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="ls_order_amount" value="{{ request()->get('ls_order_amount', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="gst_percentage" value="{{ request()->get('gst_percentage', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="gst_amount" value="{{ request()->get('gst_amount', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="cess_percentage" value="{{ request()->get('cess_percentage', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="cess_amount" value="{{ request()->get('cess_amount', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="number" name="ex_showroom_price" value="{{ request()->get('ex_showroom_price', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="tcs" value="{{ request()->get('tcs', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="number" name="registration_individual_charges" value="{{ request()->get('registration_individual_charges', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="number" name="registration_corporate_charges" value="{{ request()->get('registration_corporate_charges', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="insurance" value="{{ request()->get('insurance', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="fasttags_nm" value="{{ request()->get('fasttags_nm', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="on_road_individual_charges" value="{{ request()->get('on_road_individual_charges', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="on_road_corporate_charges" value="{{ request()->get('on_road_corporate_charges', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="rsa_nm" value="{{ request()->get('rsa_nm', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="ew_name" value="{{ request()->get('ew_name', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="mcp_nm" value="{{ request()->get('mcp_nm', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="other_1" value="{{ request()->get('other_1', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="other_2" value="{{ request()->get('other_2', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="on_road_price_individual" value="{{ request()->get('on_road_price_individual', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">
                                        </div>
                                    </div>
                                </th>
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                        <div class="form-group is-empty">
                                            <input type="text" name="on_road_price_corporate" value="{{ request()->get('on_road_price_corporate', '') }}" class="form-control text-capitalize custom_color" 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="created_at" value="{{ request()->get('created_at', '') }}" class="form-control text-capitalize" autocomplete="off" tabindex="1" id="min">
                                        </div>
                                    </div>
                                </th>
                                <!--<th>-->
                                <!--    <div class="search-box-container datatable-form-filter">-->
                                <!--        <div class="form-group is-empty">-->
                                <!--            <input type="text" name="invoice_date" value="{{ request()->get('invoice_date', '') }}" class="form-control text-capitalize custom_color" autocomplete="off" autofocus tabindex="4">-->
                                <!--        </div>-->
                                <!--    </div>-->
                                <!--</th>-->
                                <th>
                                    <div class="search-box-container datatable-form-filter">
                                    <div class="form-group">
                                    <select name="status" class="form-control text-capitalize custom_color" tabindex="15">
                                        <option value="">-- Select Status --</option>
                                        <option value="active" {{ request()->get('status') == 'active' ? 'selected' : '' }}>Active</option>
                                        <option value="inactive" {{ request()->get('status') == 'inactive' ? 'selected' : '' }}>InActive</option>
                                        <option value="deleted" {{ request()->get('status') == 'deleted' ? 'selected' : '' }}>Deleted</option>
                                    </select>
                                    </div>
                                    </div>
                                </th>
                                <th></th>
                            </tr>
                        </thead>
                    </table>
                    
                </div>
            </div>
        </div>

        <!-- Modal -->
        <div class="modal fade" id="exampleModal" role="dialog">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h3 class="modal-title">Import</h3>
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>

                    </div>
                    <form action="{{ route('pricelist.import') }}" name="form" id="form" method="post" enctype="multipart/form-data">
                        @csrf
                        <div class="modal-body">
                            <div class="row">
                                <div class="form-group col-sm-12">
                                    <label for="first_name">Upload File Here</label>
                                    <input type="file" name="file" id="file" class="form-control" placeholder="Plese upload file here" required>
                                    <span class="kt-form__help error file"></span>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="submit" class="btn btn-default">Submit!</button>
                            <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
                        </div>
                    </form>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal-dialog -->
        </div>
        
        <!-- Sample Excel Export Modal Structure -->
        <div class="modal fade" id="sampleExcelModal" tabindex="-1" role="dialog" aria-labelledby="sampleExcelModalLabel" aria-hidden="true">
          <div class="modal-dialog" role="document">
            <div class="modal-content">
              <div class="modal-header">
                <h5 class="modal-title" id="sampleExcelModalLabel">Download Sample Excel</h5>
                <button type="button" class="btn-close btn-close-white close" data-bs-dismiss="modal" aria-label="Close">&times;</button>
              </div>
              <div class="modal-body custom_height">
                <p><b>Click the button below to download a sample Excel file.</b></p>
              </div>
              <div class="modal-footer">
                <div class="row col-sm-12">
                    <div class="col-sm-2"></div>
                    <div class="col-sm-4">
                        <a href="{{ url('/example-xlsx/Pricelist_sample_is_csd_yes.xlsx') }}" class="btn btn-outline-primary btn-bg">IS CSD</a>
                    </div>
                    <div class="col-sm-5">
                        <a href="{{ url('/example-xlsx/Pricelist_sample_is_csd_no.xlsx') }}" class="btn btn-outline-primary btn-bg">Without IS CSD</a>
                    </div>
                    <div class="col-sm-1"></div>
                </div>
              </div>
            </div>
          </div>
        </div>

        <!-- Modal -->

    </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">
    // var datatable;

    // $(document).ready(function() {
    //     if ($('#data-table').length > 0) {
    //         datatable = $('#data-table').DataTable({
    //         processing: true,
    //         serverSide: true,

    //         "pageLength": 25,
    //         "iDisplayLength": 25,
    //         "responsive": true,
    //         "aaSorting": [],
    //             // "order": [], //Initial no order.
    //             //     "aLengthMenu": [
    //             //     [5, 10, 25, 50, 100, -1],
    //             //     [5, 10, 25, 50, 100, "All"]
    //             // ],

    //             // "scrollX": true,
    //             // "scrollY": '',
    //             // "scrollCollapse": false,
    //             // scrollCollapse: true,

    //             // lengthChange: false,

    //             "ajax": {
    //                 "url": "{{ route('pricelist') }}",
    //                 "type": "POST",
    //                 "dataType": "json",
    //                 "data": {
    //                     _token: "{{csrf_token()}}"
    //                 }
    //             },
    //             "columnDefs": [{
    //                 //"targets": [0, 5], //first column / numbering column
    //                 "orderable": true, //set not orderable
    //             }, ],
    //             columns: [{
    //                     data: 'DT_RowIndex',
    //                     searchable: false,
    //                     name: 'DT_RowIndex',
    //                     "bSortable": false
    //                 },    
    //                 {
    //                     data: 'price_list_name',
    //                     name: 'price_list_name'
    //                 },
    //                 {
    //                     data: 'product',
    //                     name: 'car_model.name'
    //                 },
    //                 {
    //                     data: 'car_variant_name',
    //                     name: 'car_varient.name'
    //                 },
    //                 {
    //                     data: 't_name',
    //                     name: 'transmission.name'
    //                 },
    //                 {
    //                     data: 'color_type',
    //                     name: 'colortone.name'
    //                 },
    //                 {
    //                     data: 'ex_showroom_price',
    //                     name: 'ex_showroom_price'
    //                 },
                    
                   
    //                 // {
    //                 //     data: 'tcs',
    //                 //     name: 'tcs'
    //                 // },
                   
                   
    //                 // {
    //                 //     data: 'insurance',
    //                 //     name: 'insurance'
    //                 // },
    //                 // {
    //                 //     data: 'fasttag',
    //                 //     name: 'fasttag'
    //                 // },
    //                 // {
    //                 //     data: 'extended_warranty',
    //                 //     name: 'extended_warranty'
    //                 // },
    //                 // {
    //                 //     data: 'accessories_kit',
    //                 //     name: 'accessories_kit'
    //                 // },
    //                 /*{
    //                     data: 'total_road_individual_charges',
    //                     name: 'total_road_individual_charges'
    //                 },*/
    //                 // {
    //                 //     data: 'road_corporate_charges',
    //                 //     name: 'road_corporate_charges'
    //                 // },
    //                 // {
    //                 //     data: 'status',
    //                 //     name: 'status'
    //                 // },
                   
    //                 //  {
    //                 //     data: 'statutory_charges',
    //                 //     name: 'statutory_charges'
    //                 // },
    //                   {
    //                 data: 'registration_individual_charges',
    //                  name: 'registration_individual_charges'
    //                  },
    //                 {
    //                     data: 'registration_corporate_charges',
    //                     name: 'registration_corporate_charges'
    //                 },
    //                  {
    //                     data: 'created_at',
    //                     name: 'created_at'
    //                 },
    //                 {
    //                     data: 'status',
    //                     name: 'status'
    //                 },
    //                  {
    //                     data: 'action',
    //                     name: 'action',
    //                     orderable: false
    //                 },
    //             ]
    //         });
    //     }
        
        
    //         $('#client,#kec,#product,#road_price,#variant,#location').change(function(){
    //             //alert(this.value);
    //             //datatable.draw();
    //             datatable.search( this.value ).draw();
    //         });
    //         // Highlight row on mouseover
    //         $('#data-table tbody').on('mouseover', 'tr', function() {
    //             $(this).addClass('highlight');
    //         });

    //         // Remove highlight on mouseout
    //         $('#data-table tbody').on('mouseout', 'tr', function() {
    //             $(this).removeClass('highlight');
    //         });
            
    //     $('#export_excel_model').on('click', function (e) {
    //         e.preventDefault();
    //         $('#sampleExcelModal').modal('show');
    //     });    
            
    // });

    window.change_status = function(object) {
        var id = $(object).data("id");
        var status = $(object).data("status");

        if (confirm('Are you sure?')) {
            $.ajax({
                "url": "{!! route('pricelist.change.status') !!}",
                "dataType": "json",
                "type": "POST",
                "data": {
                    id: id,
                    status: status,
                    _token: "{{ csrf_token() }}"
                },
                success: function(response) {
                    if (response.code == 200) {
                        datatable.ajax.reload();
                        toastr.success('Status changed successfully', 'Success');
                        location.reload();
                    } else {
                        toastr.error('Failed to change status', 'Error');
                    }
                }
            });
        }
    }
</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();
        });
            (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": ""
                    },
                    paging: true,
                    searching: false,
                    bSortCellsTop: true,
                    scrollX: true,
                    scrollY: "450px", 
                    scrollCollapse: true, 
                    ajax: {
                        url: '{!! route("pricelist") !!}',
                        type: 'POST',
                        data: function (d) {
                            // d.booking_date = jQuery(".datatable-form-filter input[name='booking_date']").val();
                            d.price_list_name = jQuery(".datatable-form-filter input[name='price_list_name']").val();
                            d.is_csd = jQuery(".datatable-form-filter input[name='is_csd']").val();
                            d.rtotype = jQuery(".datatable-form-filter input[name='rtotype']").val();
                            d.product = jQuery(".datatable-form-filter input[name='product']").val();
                            d.fuel_type = jQuery(".datatable-form-filter input[name='fuel_type']").val();
                            d.car_variant_name = jQuery(".datatable-form-filter input[name='car_variant_name']").val();
                            d.rto_custome_handling_charges = jQuery(".datatable-form-filter input[name='rto_custome_handling_charges']").val();
                            d.color_type = jQuery(".datatable-form-filter input[name='color_type']").val();
                            d.location = jQuery(".datatable-form-filter input[name='location']").val();
                            d.t_name = jQuery(".datatable-form-filter input[name='t_name']").val();
                            d.basic = jQuery(".datatable-form-filter input[name='basic']").val();
                            d.csd_selling_price = jQuery(".datatable-form-filter input[name='csd_selling_price']").val();
                            d.ls_order_amount = jQuery(".datatable-form-filter input[name='ls_order_amount']").val();
                            d.gst_percentage = jQuery(".datatable-form-filter input[name='gst_percentage']").val();
                            d.gst_amount = jQuery(".datatable-form-filter input[name='gst_amount']").val();
                            d.cess_percentage = jQuery(".datatable-form-filter input[name='cess_percentage']").val();
                            d.cess_amount = jQuery(".datatable-form-filter input[name='cess_amount']").val();
                            d.ex_showroom_price = jQuery(".datatable-form-filter input[name='ex_showroom_price']").val();
                            d.tcs = jQuery(".datatable-form-filter input[name='tcs']").val();
                            d.registration_individual_charges = jQuery(".datatable-form-filter input[name='registration_individual_charges']").val();
                            d.registration_corporate_charges = jQuery(".datatable-form-filter input[name='registration_corporate_charges']").val();
                            d.insurance = jQuery(".datatable-form-filter input[name='insurance']").val();
                            d.fasttags_nm = jQuery(".datatable-form-filter input[name='fasttags_nm']").val();
                            d.on_road_individual_charges = jQuery(".datatable-form-filter input[name='on_road_individual_charges']").val();
                            d.on_road_corporate_charges = jQuery(".datatable-form-filter input[name='on_road_corporate_charges']").val();
                            d.rsa_nm = jQuery(".datatable-form-filter input[name='rsa_nm']").val();
                            d.ew_name = jQuery(".datatable-form-filter input[name='ew_name']").val();
                            d.mcp_nm = jQuery(".datatable-form-filter input[name='mcp_nm']").val();
                            d.other_1 = jQuery(".datatable-form-filter input[name='other_1']").val();
                            d.other_2 = jQuery(".datatable-form-filter input[name='other_2']").val();
                            d.on_road_price_individual = jQuery(".datatable-form-filter input[name='on_road_price_individual']").val();
                            d.on_road_price_corporate = jQuery(".datatable-form-filter input[name='on_road_price_corporate']").val();
                            d.created_at = jQuery(".datatable-form-filter input[name='created_at']").val();
                            // d.invoice_date = jQuery(".datatable-form-filter input[name='invoice_date']").val();
                            d.status = jQuery(".datatable-form-filter select[name='status']").val();
                        },
                        error: function(d) {}
                    },
                    columns: [
                        { data: 'DT_RowIndex', name: 'DT_RowIndex', class: 'text-center DT_RowIndex', title: 'No.', orderable: false, width: 100 },
                        // {data: 'booking_date', name: 'booking_date',class:'text-center booking_date',title: 'Date', orderable: false,default: true},
                        {data: 'price_list_name', name: 'price_list_name', class: 'text-center price_list_name', title: 'Price List Name', orderable: false, default: true},
                        {data: 'is_csd', name: 'is_csd', class: 'text-center is_csd', title: 'CSD', orderable: false, default: true},
                        {data: 'rtotype', name: 'rtotype', class: 'text-center rtotype', title: 'RTO Type', orderable: false, default: true},
                        {data: 'product', name: 'product', class: 'text-center product', title: 'Model', orderable: false, default: true},
                        {data: 'fuel_type', name: 'fuel_type', class: 'text-center fuel_type', title: 'Fule Type', orderable: false, default: true},
                        {data: 'car_variant_name', name: 'car_variant_name', class: 'text-center car_variant_name', title: 'Car Variant', orderable: false, default: true},
                        {data: 'rto_custome_handling_charges', name: 'rto_custome_handling_charges', class: 'text-center rto_custome_handling_charges', title: 'RTO Custom Handling Charges', orderable: false, default: true},
                        {data: 'color_type', name: 'color_type', class: 'text-center color_type', title: 'Tone Selection', orderable: false, default: true},
                        {data: 'location', name: 'location', class: 'text-center location', title: 'Location', orderable: false, default: true},
                        {data: 't_name', name: 't_name', class: 'text-center t_name', title: 'Transmission ', orderable: false, default: true},
                        {data: 'basic', name: 'basic', class: 'text-center basic', title: 'Basic ', orderable: false, default: true},
                        {data: 'csd_selling_price', name: 'csd_selling_price', class: 'text-center csd_selling_price', title: 'CSD Selling Price ', orderable: false, default: true},
                        {data: 'ls_order_amount', name: 'ls_order_amount', class: 'text-center ls_order_amount', title: 'LS Order Amount', orderable: false, default: true},
                        {data: 'gst_percentage', name: 'gst_percentage', class: 'text-center gst_percentage', title: 'GST(%)', orderable: false, default: true},
                        {data: 'gst_amount', name: 'gst_amount', class: 'text-center gst_amount', title: 'GST Amount', orderable: false, default: true},
                        {data: 'cess_percentage', name: 'cess_percentage', class: 'text-center cess_percentage', title: 'CESS(%)', orderable: false, default: true},
                        {data: 'cess_amount', name: 'cess_amount', class: 'text-center cess_amount', title: 'CESS Amount', orderable: false, default: true},
                        {data: 'ex_showroom_price', name: 'ex_showroom_price', class: 'text-center ex_showroom_price', title: 'Ex Showroom Price', orderable: false, default: true},
                        {data: 'tcs', name: 'tcs', class: 'text-center tcs', title: 'TCS', orderable: false, default: true},
                        {data: 'registration_individual_charges', name: 'registration_individual_charges', class: 'text-center registration_individual_charges', title: 'Registration Individual Charges', orderable: false, default: true},
                        {data: 'registration_corporate_charges', name: 'registration_corporate_charges', class: 'text-center registration_corporate_charges', title: 'Registration Corporate Charges', orderable: false, default: true},
                        {data: 'insurance', name: 'insurance', class: 'text-center insurance', title: 'Insurance', orderable: false, default: true},
                        {data: 'fasttags_nm', name: 'fasttags_nm', class: 'text-center fasttags_nm', title: 'Fasttag', orderable: false, default: true},
                        {data: 'on_road_individual_charges', name: 'on_road_individual_charges', class: 'text-center on_road_individual_charges', title: 'On Road Individual Charges', orderable: false, default: true},
                        {data: 'on_road_corporate_charges', name: 'on_road_corporate_charges', class: 'text-center on_road_corporate_charges', title: 'On Road Corporate Charges', orderable: false, default: true},
                        {data: 'rsa_nm', name: 'rsa_nm', class: 'text-center rsa_nm', title: 'RSA Master', orderable: false, default: true},
                        {data: 'ew_name', name: 'ew_name', class: 'text-center ew_name', title: 'Extended Warranty', orderable: false, default: true},
                        {data: 'mcp_nm', name: 'mcp_nm', class: 'text-center mcp_nm', title: 'Convinience Program', orderable: false, default: true},
                        {data: 'other_1', name: 'other_1', class: 'text-center other_1', title: 'Other Details 1', orderable: false, default: true},
                        {data: 'other_2', name: 'other_2', class: 'text-center other_2', title: 'Other Details 2', orderable: false, default: true},
                        {data: 'on_road_price_individual', name: 'on_road_price_individual', class: 'text-center on_road_price_individual', title: 'Final On Road Price Individual', orderable: false, default: true},
                        {data: 'on_road_price_corporate', name: 'on_road_price_corporate', class: 'text-center on_road_price_corporate', title: 'Final On Road Price Corporate', orderable: false, default: true},
                        {data: 'created_at', name: 'created_at', class: 'text-center created_at', title: 'Date', orderable: false, default: true},
                        // {data: 'invoice_date', name: 'invoice_date', class: 'text-center invoice_date', title: 'Invoice Date', orderable: false, default: true},
                        {data: 'status', name: 'status', class: 'text-center status', title: 'Status', orderable: false, default: true},
                        {data: 'action', name: 'action', class: 'text-center action', title: 'Action' },
                    ],
                    lengthMenu: [
                        [25, 50, 100, -1], ['25', '50', '100', 'Show all']
                    ],
                    order: [],
                    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();
            });
        
            //function change_status(object) {
                // $(document).on('click', '.change-status', function () {
                //     var id = $(this).data("id");
                //     var status = $(this).data("status");
        
                //     if (confirm('Are you sure?')) {
                //         $.ajax({
                //             "url": "{!! route('pricelist.change.status') !!}",
                //             "dataType": "json",
                //             "type": "POST",
                //             "data": {
                //                 id: id,
                //                 status: status,
                //                 _token: "{{ csrf_token() }}" 
                //             },
                //             success: function(response) {
                //                 if (response.code == 200) {
                //                     $('#datatable').DataTable().ajax.reload();
                //                     toastr.success('Status changed successfully', 'Success');
                //                 } else {
                //                     toastr.error('Failed to change status', 'Error');
                //                 }
                //             }
                //         });
                //     }
                // });    
            //}
        
            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();
            });
            
            $('#export_excel_model').on('click', function (e) {
                e.preventDefault();
                $('#sampleExcelModal').modal('show');
            }); 
        });

    </script>
@endsection