@extends('template.app') 

@section('meta')
@endsection

@section('title')
Obf View
@endsection

@section('styles')
<link href="{{ asset('assets/css/dropify.min.css') }}" rel="stylesheet">
<link href="{{ asset('assets/css/sweetalert2.bundle.css') }}" rel="stylesheet">
<link href="{{ asset('assets/css/select2.css') }}" rel="stylesheet">
<style type="text/css">
    /*#galeria{
        display: flex;
    }*/
    #galeria img{
        width: 85px;
        height: 85px;
        border-radius: 10px;
        box-shadow: 0 0 8px rgba(0,0,0,0.2);
        opacity: 85%;
        padding: 3px;
    }

   /* #pan_image_multi{
        display: flex;
    }*/
    #pan_image_multi img{
        width: 85px;
        height: 85px;
        border-radius: 10px;
        box-shadow: 0 0 8px rgba(0,0,0,0.2);
        opacity: 85%;
        padding: 3px;
    }

    /*#adhar_image_multi{
        display: flex;
    }*/
    #adhar_image_multi img{
        width: 85px;
        height: 85px;
        border-radius: 10px;
        box-shadow: 0 0 8px rgba(0,0,0,0.2);
        opacity: 85%;
        padding: 3px;
    }

    /*#documents_multi{
        display: flex;
    }*/
    #documents_multi img{
        width: 85px;
        height: 85px;
        border-radius: 10px;
        box-shadow: 0 0 8px rgba(0,0,0,0.2);
        opacity: 85%;
        padding: 3px;
    }

    /*#licance_image_multi{
        display: flex;
    }*/
    #licance_image_multi img{
        width: 85px;
        height: 85px;
        border-radius: 10px;
        box-shadow: 0 0 8px rgba(0,0,0,0.2);
        opacity: 85%;
        padding: 3px;
    }


    .row > .column {
      padding: 0 8px;
    }

    .row:after {
      content: "";
      display: table;
      clear: both;
    }

    /* Create four equal columns that floats next to eachother */
    .column {
      float: left;
      width: 25%;
    }

    /* The Modal (background) */
    .modal {
      display: none;
      position: fixed;
      z-index: 1;
      padding-top: 100px;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      overflow: auto;
      background-color: black;
    }

    /* Modal Content */
    .modal-content {
      position: relative;
      background-color: #fefefe;
      margin: auto;
      padding: 0;
      width: 100%;
      max-width: 700px;
    }

    /* The Close Button */
    .close {
      color: white;
      position: absolute;
      top: 10px;
      right: 25px;
      font-size: 35px;
      font-weight: bold;
    }

    .close:hover,
    .close:focus {
      color: #999;
      text-decoration: none;
      cursor: pointer;
    }

    /* Hide the slides by default */
    .mySlides {
      display: none;
    }

    /* Next & previous buttons */
    .prev,
    .next {
      cursor: pointer;
      position: absolute;
      top: 50%;
      width: auto;
      padding: 16px;
      margin-top: -50px;
      color: white;
      font-weight: bold;
      font-size: 20px;
      transition: 0.6s ease;
      border-radius: 0 3px 3px 0;
      user-select: none;
      -webkit-user-select: none;
    }

    /* Position the "next button" to the right */
    .next {
      right: 0;
      border-radius: 3px 0 0 3px;
    }

    /* On hover, add a black background color with a little bit see-through */
    .prev:hover,
    .next:hover {
      background-color: rgba(0, 0, 0, 0.8);
    }

    /* Number text (1/3 etc) */
    .numbertext {
      color: #f2f2f2;
      font-size: 12px;
      padding: 8px 12px;
      position: absolute;
      top: 0;
    }

    /* Caption text */
    .caption-container {
      text-align: center;
      background-color: black;
      padding: 2px 16px;
      color: white;
    }

    img.demo {
      opacity: 0.6;
    }

    .active,
    .demo:hover {
      opacity: 1;
    }

    /*img.hover-shadow {
      transition: 0.3s;
      height: 100px;
      width: 100px;
    }*/

    .uploaded_images {
        border: 1px dashed white;
        margin-bottom: 20px;
        border-radius: 5px;
        padding: 10px;
        display: inline-block; /* Keeps size tight to content */
    }
    
    .custom-width {
        max-width: 250px; /* Adjust as needed */
    }
    .hover-shadow:hover {
      box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
    }

    .modal {
        position: fixed!important;
        z-index: 1!important;
        padding-top: 100px!important;
        left: 0!important;
        top: 0!important;
        width: 100%!important;
        height: 100%!important;
        overflow: auto!important;
        background-color: #00000091!important;
    }
   
   .modal-content {
        position: relative!important;
        background-color: #fefefe!important;
        margin: auto!important;
        padding: 0!important;
        width: 1300px!important;
        max-width: 1300px!important;
        margin-left: -50px!important;
    }
    
    .btn-outline-primary {
        color: #ffffff!important;
        border-color: #ffffff!important;
    } 
    
    #makeDealModal table {
        color: black;
    }
    
    input[type="number"]::-webkit-inner-spin-button,
    input[type="number"]::-webkit-outer-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }

    input[type="number"] {
        -moz-appearance: textfield; /* For Firefox */
    }
    
    .right-align{
        text-align:right!important;
    }
</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">OBF View</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('obf') }}" class="text-muted">OBF</a></li>
                        <li class="breadcrumb-item text-muted active" aria-current="page">View</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" onclick="openMakeDealModal('this')">Make Deal Details</button>
            </div>
        </div>
    </div>
</div>
<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-body">
                    <div class="stepwizard col-md-offset-3">
                        <div class="stepwizard-row setup-panel">
                            <div class="stepwizard-step">
                                <a href="#step-1" type="button" class="btn btn-primary btn-circle text-white">1</a>
                                <p>Personal Details</p>
                            </div>
                            <div class="stepwizard-step">
                                <a href="#step-2" type="button" class="btn btn-default btn-circle text-white" disabled="disabled">2</a>
                                <p>Car Details</p>
                            </div>
                             @canany(['Process Municipal Tax'])
                             <div class="stepwizard-step">
                                <a href="#step-3" id="thrid_new" type="button" class="btn btn-default btn-circle text-white" disabled="disabled">3</a>
                                <p>Municiple Tax Details</p>
                            </div>
                            @endcanany  
                        </div>
                    </div>
                    <form method="POST" action="{{ route('obf.processmunicipledms') }}" enctype="multipart/form-data">
                        @csrf
                        <input type="hidden" name="id" value="{{ $data->id }}" >
                        <div class="row setup-content" id="step-1">
                            <div class="col-lg-12 ">
                                <div class="col-md-12">
                                    <h3> Personal Details</h3>
                                    <div class="row">
                                        
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Booking Date</label>
                                            <input type="date" id="booking_date" class="form-control" value="{{ $data->booking_date ?? '' }}" disabled>
                                            <span class="kt-form__help error booking_date"></span>
                                        </div>
                                        
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Customer Name</label>
                                            <input type="text"  id="customer_name" class="form-control" placeholder="Enter Customer Name" value="{{ $data->customer_name ?? '' }}" disabled>
                                            <span class="kt-form__help error customer_name"></span>
                                        </div>

                                        <div class="form-group col-md-3">
                                            <label class="control-label">Branch</label>
                                            <select id="branch" class="form-control" disabled>
                                                <option value="">Select Branch</option>
                                                @if(isset($branch) && $branch->isNotEmpty())
                                                    @foreach($branch AS $branch)
                                                        <option value="{{ $branch->id }}" @if($data->branch_id == $branch->id) selected @endif >{{ $branch->name }}</option>
                                                    @endforeach
                                                @endif
                                            </select>
                                            <span class="kt-form__help error branch"></span>
                                        </div>

                                        <div class="form-group col-md-3">
                                            <label class="control-label">RTO Type</label>
                                            <select  name="customer_type" id="customer_type" class="form-control" placeholder="Enter RTO Type" disabled>
                                                <option value="regular_rto" @if($data->rto_type == 'regular_rto') selected @endif>Regular RTO</option>
                                                <option value="handicap" @if($data->rto_type == 'handicap') selected @endif>Handicap</option>
                                                <option value="taxi" @if($data->rto_type == 'taxi') selected @endif>M-Drive(Taxi)</option>
                                                <option value="electric" @if($data->rto_type == 'electric') selected @endif>Electric</option>
                                                <option value="crtem" @if($data->rto_type == 'crtem') selected @endif>Crtem</option>
                                                <option value="bh_parsing" @if($data->rto_type == 'bh_parsing') selected @endif>BH Parsing</option>
                                            </select>
                                            <span class="kt-form__help error customer_type"></span>
                                        </div>

                                        <div class="form-group col-md-3">
                                            <label class="control-label">Customer Type</label>
                                            <select id="customer_type_new" class="form-control" disabled>
                                             <option value="">Please Customer Type</option>
                                                @if(isset($CustomerTypeMaster) && $CustomerTypeMaster->isNotEmpty())
                                                    @foreach($CustomerTypeMaster AS $row)
                                                        <option value="{{ $row->id }}" @if($data->customer_type_new == $row->id) selected @endif>{{ $row->name ??'' }}</option>
                                                    @endforeach
                                                @endif
                                            </select>
                                            <span class="kt-form__help error customer_type_new"></span>
                                        </div>

                                        <div class="form-group col-md-3">
                                            <label class="control-label">Company Name</label>
                                            <input type="text"  id="company_name" class="form-control" placeholder="Enter Company Name" value="{{ $data->company_name ?? '' }}" disabled>
                                            <span class="kt-form__help error company_name"></span>
                                        </div>
                                       
                                        <div class="form-group col-md-3">
                                            <!-- <label class="control-label">EInvoicing Applicable</label> -->
                                            <label class="control-label">e-Invoice Applicable</label>
                                            <select id="einvoapp" class="form-control" disabled>
                                                 <option value="{{ $data->einvoicing_applicable }}">{{ $data->einvoicing_applicable ?? '' }}</option>
                                            </select>
                                            <span class="kt-form__help error einvoapp"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">GST</label>
                                            <input type="text"  id="gst" class="form-control" placeholder="Enter GSTIN" value="{{ $data->gst ?? '' }}" disabled>
                                            <span class="kt-form__help error gst"></span>
                                        </div>
                                        
                                        <div class="form-group col-md-3">
                                            <label class="control-label mt-3">Address Correspondence</label>
                                            <textarea  id="address_1" class="form-control" placeholder="Enter Address Correspondence" disabled>{{ $data->address ?? '' }}</textarea>
                                            <span class="kt-form__help error address_1"></span>
                                        </div>
                                        
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Registration Correspondence</label>
                                            <span class="btn btn-outline-secondary ml-5 mb-2">&nbsp;&nbsp;&nbsp;<input id="chek_address" type="checkbox" class="form-check-input mr-0" value=""><b>Same AS Above</b></span>
                                            <textarea  id="address_2" class="form-control" placeholder="Enter Registration Correspondence" disabled>{{ $data->registration ?? '' }}</textarea>
                                            <span class="kt-form__help error address_2"></span>
                                        </div>

                                        

                                        <div class="form-group col-md-3">
                                            <!-- <label class="control-label">Email</label> -->
                                            <label class="control-label">e-Mail</label>
                                            <input type="email"  id="email" class="form-control" placeholder="Enter Email Address" value="{{ $data->email ?? '' }}" disabled>
                                            <span class="kt-form__help error email"></span>
                                        </div>

                                        <div class="form-group col-md-3">
                                            <label class="control-label">Mobile Number</label>
                                            <input type="number"  id="contact_number" class="form-control" placeholder="Enter Mobile Number" value="{{ $data->contact_number ?? '' }}" disabled>
                                            <span class="kt-form__help error contact_number"></span>
                                        </div>

                                        <div class="form-group col-md-3">
                                            <label class="control-label">PAN No.</label>
                                            <input type="pannumber"  id="pan_number" class="form-control" placeholder="Enter PAN Number" value="{{ $data->pan_number ?? '' }}" disabled>
                                            <span class="kt-form__help error pan_number"></span>
                                        </div>

                                        <div class="form-group col-md-3">
                                            <label class="control-label">Aadhar No.</label>
                                            <input type="number"  id="aadhar_number" class="form-control" placeholder="Enter Aadhar Number" value="{{ $data->adhar_number ?? '' }}" disabled>
                                            <span class="kt-form__help error aadhar_number"></span>
                                        </div>

                                        <div class="form-group col-md-3">
                                            <label class="control-label">License No.</label>
                                            <input type="text"  id="license_number" class="form-control" placeholder="Enter License Number" value="{{ $data->licance_number ?? '' }}" disabled>
                                            <span class="kt-form__help error license_number"></span>
                                        </div>

                                        <div class="form-group col-md-3">
                                            <label class="control-label">Date of Birth</label>
                                            <input type="date"  id="dob" class="form-control" value="{{ $data->dob ?? '' }}" disabled>
                                            <span class="kt-form__help error dob"></span>
                                        </div>

                                        <div class="form-group col-md-3">
                                            <label class="control-label">Nominee Name</label>
                                            <input type="text"  id="nominee_name" class="form-control" placeholder="Enter Nominee Name" value="{{ $data->nominee_name ?? '' }}" disabled>
                                            <span class="kt-form__help error nominee_name"></span>
                                        </div>

                                        <div class="form-group col-md-3">
                                            <label class="control-label">Nominee Relation</label>
                                            <input type="text"  id="nominee_relation" class="form-control" placeholder="Enter Nominee Relation" value="{{ $data->nominee_reletion ?? ''}}" disabled>
                                            <span class="kt-form__help error nominee_relation"></span>
                                        </div>

                                        <div class="form-group col-md-3">
                                            <label class="control-label">Nominee Age</label>
                                            <input type="number"  id="nominee_age" class="form-control" placeholder="Enter Nominee Age" value="{{ $data->nominee_age ?? '' }}" disabled>
                                            <span class="kt-form__help error nominee_age"></span>
                                        </div>

                                        <div class="form-group col-md-3">
                                            <label class="control-label">Occupation</label>
                                            <input type="text"  id="occupation" class="form-control" placeholder="Enter Occupation" value="{{ $data->occupation ?? '' }}" disabled>
                                            <span class="kt-form__help error occupation"></span>
                                        </div>
                                        
                                        <div class="form-group col-md-3">
                                            <div class="row">
                                                <div class="form-group col-md-12">
                                                     <p>Upload PAN</p>
                                                </div>
                                                <div class="form-group col-md-12">
                                                    <div id="pan_image_multi">
                                                    <?php
                                                         if(!empty($data->pan_image))
                                                        {
                                                            $other_documents_arr = explode(',', $data->pan_image);
                                                            foreach ($other_documents_arr as $value) {
                                                                if(file_exists(public_path('/uploads/kyc/'.$value))) { ?>
                                                                    <img src="{{asset('uploads/kyc/'. $value )}}" class="hover-shadow">
                                                                <?php }
                                                            }
                                                        }
                                                    ?>
                                                    </div>
                                                </div>
                                            </div>                                           
                                        </div>
                                        
                                        <div id="myModal" class="modal">
                                          <span class="close cursor" onclick="closeModal()">&times;</span>
                                          <div class="modal-content">
                                             <img class="image_set" src="" style="width:100%;height:470px;">
                                          </div>
                                        </div>    
                                        
                                        <div class="form-group col-md-3">
                                            <div class="row">
                                                <div class="form-group col-md-12">
                                                     <p>Upload Aadhar</p>
                                                </div>
                                                <div class="form-group col-md-12">
                                                    <div id="adhar_image_multi">
                                                    <?php
                                                         if(!empty($data->adhar_image))
                                                            {
                                                                $other_documents_arr = explode(',', $data->adhar_image);
                                                                foreach ($other_documents_arr as $value) {
                                                                    if(file_exists(public_path('/uploads/kyc/'.$value))) { ?>
                                                                        <img src="{{asset('uploads/kyc/'. $value )}}" class="hover-shadow">
                                                                    <?php }
                                                                }
                                                            }
                                                    ?>
                                                    </div>
                                                </div>
                                            </div>                                           
                                        </div>

                                        <div class="form-group col-md-3">
                                            <div class="row">
                                                <div class="form-group col-md-12">
                                                     <p>Upload Voter ID</p>
                                                </div>
                                                <div class="form-group col-md-12">
                                                    <div id="licance_image_multi">
                                                    <?php
                                                        if(!empty($data->licance_image))
                                                        {
                                                            $other_documents_arr = explode(',', $data->licance_image);
                                                            foreach ($other_documents_arr as $value) {
                                                                if(file_exists(public_path('/uploads/kyc/'.$value))) { ?>
                                                                    <img src="{{asset('uploads/kyc/'. $value )}}" class="hover-shadow">
                                                                <?php }
                                                            }
                                                        }
                                                    ?>
                                                    </div>
                                                </div>
                                            </div>                                           
                                        </div>

                                        <div class="form-group col-md-3">
                                            <div class="row">
                                                <div class="form-group col-md-12">
                                                     <p>Upload Other Documents</p>
                                                </div>
                                                <div class="form-group col-md-12">
                                                    <div id="galeria">
                                                    <?php
                                                        if(!empty($data->other_documents))
                                                        {
                                                            $other_documents_arr = explode(',', $data->other_documents);
                                                            foreach ($other_documents_arr as $value) {
                                                                if(file_exists(public_path('/uploads/kyc/'.$value))) { ?>
                                                                    <img src="{{asset('uploads/kyc/'. $value )}}" class="hover-shadow">
                                                                <?php }
                                                            }
                                                        }
                                                    ?>
                                                    </div>
                                                </div>
                                            </div>                                           
                                        </div>
                                    </div>
                                    <a href="{{ route('obf') }}"><button class="btn btn-outline-secondary btn-lg pull-right" type="button">Back</button></a>
                                    <button class=" btn waves-effect waves-light btn-rounded btn-outline-secondary nextBtn btn-lg pull-right" type="button">Next</button>
                                </div>
                            </div>
                        </div>
                        <div class="row setup-content" id="step-2">
                            <div class="col-lg-12 ">
                                <div class="col-md-12">
                                    <h3> Car Details</h3>
                                    <div class="row">
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Sales Person Name</label>
                                            <select id="sales_person_name" class="form-control" disabled>
                                                <?php
                                                $user_new = auth()->user(); 
                                                if($data->sales_person_id == ''){
                                                    $data->sales_person_id = $user_new->id;
                                                }
                                                ?>
                                                <option value="">Select Sales Person</option>
                                                @if(isset($sales) && $sales->isNotEmpty())
                                                    @foreach($sales AS $row)
                                                        <option value="{{ $row->id }}"  @if($data->sales_person_id == $row->id) selected @endif>{{ $row->sales_person_name ??'' }}</option>
                                                        @endforeach
                                                @else        
                                                    <option value="1" selected>Super Admin</option>
                                                @endif
                                            </select>
                                            <span class="kt-form__help error sales_person_name"></span>
                                        </div>
                                        
                                        <!-- <div class="form-group col-sm-3">
                                <label for="name">Select Car</label>
                                <select class="form-control" id="name" onchange="car_mveriant(this);" disabled>
                                    <option value="">Select Car</option>
                                    @if(isset($carmodel))
                                        @foreach($carmodel as $car_model)
                                          <option value="{{ $car_model->car_id }}" @if(!empty($data) && $data->product_id == $car_model->car_id) selected @endif> {{ $car_model->car_name }} | {{$car_model->varient_name}} {{$car_model->exterior_color}} {{$car_model->interior_color}} </option>
                                        @endforeach
                                    @endif
                                </select>
                                <span class="kt-form__help error branch_id"></span>
                            </div> -->
                            <div class="form-group col-sm-3">
                                <label for="car_name">Car Model</label>
                                <input type="text" class="form-control" id="car_name" value="{{$Cardata->car_name}}" readonly>
                                <span class="kt-form__help error car_name"></span>
                            </div>

                            <!-- <div class="form-group col-sm-3">
                                <label for="fule_type">Fuel Type</label>
                                <input type="text" class="form-control" id="fule_type" value="{{ $data->fule_type_name ?? '' }}" readonly>
                                <span class="kt-form__help error fule_type"></span>
                            </div> -->

                            <div class="form-group col-sm-3">
                                <label for="veriant">Car Variant</label>
                                <input type="text" class="form-control" id="veriant" value="{{$Cardata->varient_name}}" readonly>
                                <span class="kt-form__help error veriant"></span>
                            </div>

                            <div class="form-group col-sm-3" id="fule_type">
                                <label for="fule_type">Fuel Type</label>  
                                <input type="text"  id="fule_type" value="{{$fule->fule_name}}" class="form-control" placeholder="Fuel Type" readonly>
                                <span class="kt-form__help error fule_type"></span>
                            </div>


                            <div class="form-group col-sm-3">
                                <label for="exterior_color">Exterior Color</label>
                                <input type="text" class="form-control" id="exterior_color" value="{{$Cardata->exterior_color}}" readonly>
                                <span class="kt-form__help error exterior_color"></span>
                            </div>
                            <div class="form-group col-sm-3">
                                <label for="interior_color">Interior Color</label>
                                <input type="text" class="form-control" id="interior_color" value="{{$Cardata->interior_color}}" readonly>
                                <span class="kt-form__help error interior_color"></span>
                            </div>  
                            <div class="form-group col-md-3" >
                                            <label class="control-label">Pricelist</label>
                                            <select id="pricelist_manager_id" class="form-control" onchange="Getpricelist(this);" readonly>
                                                <option value="">Select pricelist</option>
                                                <!-- @if(isset($pricelist_master) && $pricelist_master->isNotEmpty())
                                                    @foreach($pricelist_master AS $pricelist_master_row)
                                                        <option value="{{ $pricelist_master_row->id }}" @if($data->pricelist_id == $pricelist_master_row->id) selected @endif> </option>
                                                    @endforeach
                                                @endif -->
                                            </select>
                                            <span class="kt-form__help error pricelist_manager_id"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Standard Ex-Showroom Price</label>
                                            <input type="number"  id="ex_showroom_price" class="form-control" placeholder="Enter Standard Ex-Showroom Price" value="{{ $data->ex_showroom_price ?? '' }}" disabled>
                                            <span class="kt-form__help error ex_showroom_price"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Registration Tax</label>
                                            <input type="text"  id="registration_tax" class="form-control" placeholder="Enter Registration Tax" value="{{ $data->registration_tax_id ?? '' }}" disabled>
                                            <span class="kt-form__help error registration_tax"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Insurance</label>
                                            <input type="text"  id="insurance" class="form-control" placeholder="Enter Insurance" value="{{ $data->insurance_id ?? '' }}" disabled>
                                            <span class="kt-form__help error insurance"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Municipal Tax</label>
                                            <input type="text"  id="municipal_tax" class="form-control" placeholder="Enter Municipal Tax" value="{{ $data->municipal_tax_id ?? '' }}" disabled>
                                            <span class="kt-form__help error municipal_tax"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">1% for TCS Tax</label>
                                            <input type="text"  id="tcs_tax" class="form-control" placeholder="Enter TCS Tax" value="{{ $data->tcs_tax_id ?? '' }}" disabled>
                                            <span class="kt-form__help error tcs_tax"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Accessories</label>
                                      
                                            <select" id="accessories" class="form-control select2 disabled" style="width:100%" multiple disabled>
                                            <option value="">Select Accessory</option>
                                                @if(isset($accessory) && $accessory->isNotEmpty())
                                                <option value="">Select Accessory</option>
                                                    @foreach($accessory AS $row)
                                                        <option value="{{ $row->id }}" @if( in_array($row->id, explode(" ," ,$data->accessory_id))) selected @endif data-price="{{ $row->price }}">{{ $row->name ??'' }} - {{ $row->price }}</option>
                                                    @endforeach
                                                @endif
                                            </select>
                                            <span class="kt-form__help error accessories"></span>
                                            <span>Accessories Total -</span>
                                             <span id="total">{{$accessory_sum+$data->other_accesssories_prise}}</span>
                                        </div>
                                        
                                         <div class="form-group col-md-3">
                                              <label class="control-label">Other Accessories Detail</label>
                                               <input type="text"  readonly id="other_accesssories_detail" class="form-control" placeholder="Enter Trade In Car Name" value="{{ $data->other_accesssories_detail ?? '' }}">

                                         </div>
                                         
                                         <div class="form-group col-md-3">
                                              <label class="control-label">Other Accessories Prise</label>
                                               <input type="text"  readonly id="other_accesssories_prise" class="form-control" placeholder="Enter Trade In Car Name" value="{{ $data->other_accesssories_prise ?? '' }}">

                                         </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Fastag</label>
                                            <select id="fasttag_brand_name" class="form-control" disabled >
                                                <option value="">Select FastTag</option>
                                                @if(isset($fasttag) && $fasttag->isNotEmpty())
                                                    @foreach($fasttag AS $row)
                                                        <option value="{{ $row->id }}" @if($data->fasttag_brand_name == $row->id) selected @endif >{{ $row->brand_name ??'' }} - {{ $row->amount }}</option>
                                                    @endforeach
                                                @endif
                                            </select>
                                            <span class="kt-form__help error fasttag_brand_name"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Trade In Car Name</label>
                                            <input type="text"  id="trade_car_name" class="form-control" placeholder="Enter Trade In Car Name" value="{{ $data->trade_car_name ?? '' }}" disabled>
                                            
                                            <span class="kt-form__help error trade_car_name"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Trade In Car Value</label>
                                            <input type="text"  id="trade_car_value" class="form-control" placeholder="Enter Trade In Car Value" value="{{ $data->trade_car_value ?? '' }}" disabled>
                                            <span class="kt-form__help error trade_car_value"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">On Road Price</label>
                                            <input type="number" id="on_road_price" class="form-control" placeholder="Enter On Road Price" value="{{ $data->on_road_price ?? '' }}" disabled>
                                            <span class="kt-form__help error on_road_price"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">On Road Price (In Words)</label>
                                            <input type="text" id="on_road_price_word" class="form-control" placeholder="Enter On Road Price In Words" value="{{ $data->on_road_price_word ?? '' }}" disabled>
                                            <span class="kt-form__help error on_road_price_word"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Extended Warranty</label>
                                            <select id="extended_warranty" class="form-control"disabled >
                                                <option value="">Select Extanded Warranty</option>
                                                @if(isset($extanded_warranty) && $extanded_warranty->isNotEmpty())
                                                    @foreach($extanded_warranty AS $row)
                                                        <option value="{{ $row->id }}" @if($data->extanded_warranty_id == $row->id) selected @endif>{{ $row->years ??'' }} - {{ $row->amount }}</option>
                                                    @endforeach
                                                @endif
                                            </select>
                                            <span class="kt-form__help error extended_warranty"></span>
                                        </div>
                                        <!-- <div class="form-group col-md-3">
                                            <label class="control-label">Finance Bank Name</label>
                                            <select id="finance_name" class="form-control" disabled>
                                                <option value="">Select Finance Bank Name</option>
                                                @if(isset($finance) && $finance->isNotEmpty())
                                                    @foreach($finance AS $row)
                                                        <option value="{{ $row->id }}" @if($data->finance_id == $row->id) selected @endif>{{ $row->name ??'' }}</option>
                                                    @endforeach
                                                @endif
                                            </select>
                                            <span class="kt-form__help error finance_bank_name"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Finance Branch Name</label>
                                            <select id="finance_branch_name" class="form-control" disabled>
                                                <option value="">Select Finance Branch Name</option>
                                                @if(isset($finance) && $finance->isNotEmpty())
                                                    @foreach($finance AS $row)
                                                        <option value="{{ $row->branch_id }}" @if($data->finance_id == $row->id) selected @endif>{{ $row->branch_name ??'' }}</option>
                                                    @endforeach
                                                @endif
                                            </select>
                                            <span class="kt-form__help error finance_branch_name"></span>
                                        </div> -->
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Lead Source</label>
                                            <select id="lead" class="form-control" disabled >
                                                <option value="">Select Lead Source</option>
                                                @if(isset($lead) && $lead->isNotEmpty())
                                                    @foreach($lead AS $row)
                                                        <option value="{{ $row->id }}" @if($data->lead_id == $row->id) selected @endif>{{ $row->name ??'' }}</option>
                                                    @endforeach
                                                @endif
                                            </select>
                                            <span class="kt-form__help error lead_source"></span>
                                        </div>

                                        <div class="form-group col-md-3">
                                            <label class="control-label">Sub Lead Source</label>
                                            <select id="sub_lead_id" class="form-control" disabled>
                                            </select>
                                            <span class="kt-form__help error sub_lead_id"></span>
                                        </div>

                                        <div class="form-group col-md-3">
                                            <label class="control-label">Mode of Payment</label>
                                            <select id="mode_of_payment" class="form-control" disabled>
                                                <option value="">Select Mode Of Payment</option>
                                                <option value="cash_on_delivery"@if($data->mode_of_payment == 'cash_on_delivery') selected @endif>Cash On Delivery</option>
                                                <option value="online" @if($data->mode_of_payment == 'online') selected @endif>Online/Cradit Card/Debit Card/UPI</option>
                                            </select>
                                            <span class="kt-form__help error mode_of_payment"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Tentative Delivery Date</label>
                                            <input type="date" name="tentative_delivery_date" id="tentative_delivery_date" class="form-control" value="{{ $data->tentetive_delivery_date ?? '' }}" disabled>
                                            <span class="kt-form__help error tentative_delivery_date"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Booking Amount</label>
                                            <input type="number"   id="booking_amount" class="form-control" placeholder="Enter Booking Amount" value="{{ $data->booking_amount ?? '' }}" disabled>
                                            <span class="kt-form__help error booking_amount"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Other Details 1</label>
                                            <select id="other_details_1" class="form-control select2 disabled" style="width:100%" multiple disabled>
                                            <option value="">Select Data</option>
                                                @if(isset($OtherOne) && $OtherOne->isNotEmpty())
                                                <option value="">Select Data</option>
                                                    @foreach($OtherOne AS $row)
                                                        <option value="{{ $row->id }}" @if( in_array($row->id, explode("," ,$data->other_details_1))) selected @endif">{{ $row->name }}</option>
                                                    @endforeach
                                                @endif
                                            </select>
                                            <span class="kt-form__help error other_details_1"></span>
                                            
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Other Details 2</label>
                                            <select id="other_details_2" class="form-control select2 disabled" style="width:100%" multiple disabled>
                                            <option value="">Select Data</option>
                                                @if(isset($OtherTwo) && $OtherTwo->isNotEmpty())
                                                <option value="">Select Data</option>
                                                    @foreach($OtherTwo AS $row)
                                                        <option value="{{ $row->id }}" @if( in_array($row->id, explode("," ,$data->other_details_2))) selected @endif">{{ $row->name }}</option>
                                                    @endforeach
                                                @endif
                                            </select>
                                            <span class="kt-form__help error other_details_2"></span>
                                            
                                        </div>

                                        <div class="form-group col-md-3">
                                            <label class="control-label">RSA MASTER</label>
                                            <select  id="rsa_master_obf" class="form-control" disabled>
                                                <option value="">Select RSA</option>
                                                @if(isset($rsa) && $rsa->isNotEmpty())
                                                    @foreach($rsa AS $row)
                                                        <option value="{{ $row->id }}" @if($data->rsa_master_obf == $row->id) selected @endif>{{ $row->amount ??'' }} - {{ $row->name }}</option>
                                                    @endforeach
                                                @endif
                                            </select>
                                            <span class="kt-form__help error rsa_master_obf"></span>
                                        </div>
                                        
                                        <div class="form-group col-md-3"> 
                                            <label class="control-label">My Convinience Program</label>
                                            <select  id="convinience_program" class="form-control" disabled>
                                                @if(isset($mcp) && $mcp->isNotEmpty())
                                                    @foreach($mcp AS $row)
                                                        <option value="{{ $row->id }}" @if($data->convinience_program == $row->id) selected @endif>{{ $row->name ??'' }}</option>
                                                    @endforeach
                                                @endif
                                            </select>
                                            <input type="checkbox">
                                            <span class="kt-form__help error convinience_program"></span>
                                        </div>
                                    </div>
                                    <button class="btn  btn-outline-secondary prevBtn btn-lg pull-left" type="button">Previous</button>
                                    <button class="btn waves-effect waves-light btn-rounded btn-outline-secondary nextBtn btn-lg pull-right" type="button">Next</button>
                                </div>
                            </div>
                        </div>
                        <div class="row setup-content" id="step-3">
                            <div class="col-lg-12 ">
                                <div class="col-md-12">
                                    <h3> Municiple Tax Details</h3>
                                    <div class="row">
                                        
                                        <div class="form-group col-sm-3">
                                            <label for="mt_invoice">Invoice No.</label>  
                                            <input type="text" class="form-control" name="mt_invoice" id="mt_invoice" value="{{ (!empty($data->mt_invoice)) ? $data->mt_invoice : ((!empty($data->order_invoice_no)) ? $data->order_invoice_no : '') }}" readonly>
                                            <span class="kt-form__help error mt_invoice"></span>
                                        </div>

                                        <div class="form-group col-sm-3">
                                            <label for="mt_invoice_date">Invoice Date</label> 
                                            <input type="date"  name="mt_invoice_date" id="mt_invoice_date" class="form-control"  value="{{ (!empty($data->mt_invoice_date)) ? $data->mt_invoice_date : ((!empty($data->order_invoice_date)) ? $data->order_invoice_date : '') }}" readonly>
                                            <span class="kt-form__help error mt_invoice_date"></span> 
                                        </div>

                                        <div class="form-group col-sm-3">
                                            <label for="rmc_receipt_no">Municipal Receipt No</label>
                                            <input type="text" name="rmc_receipt_no" id="rmc_receipt_no" class="form-control" value="{{$data->rmc_receipt_no}}">
                                            <span class="kt-form__help error rmc_receipt_no"></span>
                                        </div>
                                        <div class="form-group col-sm-3">
                                            <label for="municiple_date">Municipal Date</label>
                                            <input type="date" name="municiple_date" id="municiple_date" class="form-control"  value="{{ (!empty($data->municiple_date)) ? $data->municiple_date : date('Y-m-d') }}">
                                            <span class="kt-form__help error municiple_date"></span>
                                        </div>  

                                        <div class="form-group col-sm-3">
                                            <label for="tax_type">Tax Type</label> 
                                            <select name="tax_type" id="tax_type" class="form-control">
                                                <option value="" disabled>Select Municipal Tax Type</option>
                                                <option value="self" @if($data->municipal_tax_type == 'self') selected @endif disabled>Self</option>
                                                <option value="in_house" @if($data->municipal_tax_type == 'in_house') selected @endif disabled>In-house</option>
                                            </select>
                                            <span class="kt-form__help error tax_type"></span>
                                        </div> 
                                        
                                        <div class="form-group col-sm-3">
                                            <label class="control-label">Municipal Tax</label> 
                                            <input type="checkbox" name="municipal_tax_applicable" id="municipal_tax_applicable" value="1" @if($data->municipal_tax_applicable == 1) checked @endif style="display: none;">
                                            <input type="number"  name="municipal_tax" id="municipal_tax" class="form-control" placeholder="Enter Municipal Tax" value="{{ $data->municipal_tax_id ?? '' }}" readonly>
                                            <span class="kt-form__help error municipal_tax"></span>
                                            <span class="kt-form__help error tax_type"></span>
                                        </div>
                                        
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Municipal Custom Handling Charges</label>
                                            <input type="number" name="municipal_custom_handling_charges" id="municipal_custom_handling_charges" class="form-control"  value="{{ (!empty($data->municipal_custom_handling_charges)) ? $data->municipal_custom_handling_charges : 0 }}" readonly>
                                            <span class="kt-form__help error municipal_custom_handling_charges"></span>
                                        </div>
                                        
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Municipal Amount</label>
                                            <input type="number" name="amount" id="amount" class="form-control"  value="{{ (!empty($data->amount)) ? $data->amount : 0 }}">
                                            <span class="kt-form__help error amount"></span>
                                        </div>
                                        
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Remarks</label>
                                            <textarea  name="remarks" id="remarks" class="form-control">{{ $data->remarks ?? '' }}</textarea>
                                            <span class="kt-form__help error remarks"></span>
                                        </div>
                                        
                                        @if(auth()->user()->roles[0]['name'] == 'Municipal' || auth()->user()->roles[0]['name'] == 'admin' || auth()->user()->roles[0]['name'] == 'RTO')
                                            <div class="form-group col-md-3">
                                                <label class="control-label">Status</label>
                                                <select name="status" id="status" class="form-control">
                                                    <option value="municiple_tax_completed" @if($data->status == 'municiple_tax_completed') selected @endif>Municiple Tax Completed</option>
                                                    <option value="municiple_tax_in_progress" @if($data->status == 'municiple_tax_in_progress') selected @endif>Municiple Tax In-progress</option>
                                                </select>
                                                <span class="kt-form__help error rto_type"></span>
                                            </div> 
                                        @endif    
                                        
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Upload Documents</label>
                                            <input type="file" name="municiple_image[]" id="municiple_image" onchange="previewMultiple(event,'municiple_image_multi','municiple_image')" class="form-control dropify" data-default-file=""  data-max-file-size-preview="2M" multiple>
                                            <span class="kt-form__help error municiple_image"></span>
                                        </div>

                                    </div>
                                            
                                    <div class="col-lg-12 ">
                                        <div class="col-md-12">
                                            <div class="uploaded_images">
                                                <div class="row justify-content-start">
                                                    <div id="municiple_image_multi" class="form-group custom-width mt-2 ml-3">
                                                        @php
                                                            if (!empty($data->municiple_image)) {
                                                                $other_documents_arr = explode(',', $data->municiple_image);
                                                                foreach ($other_documents_arr as $value) {
                                                                    $image_path = public_path('/uploads/kyc/' . $value);
                                                                    if (file_exists($image_path)) {
                                                        @endphp
                                                                <div class="mb-2 text-center">
                                                                    <img src="{{ asset('uploads/kyc/' . $value) }}" style="max-width:80%; height:auto;" alt="Municiple Image">
                                                                    <p class="mt-1">Municiple Image</p>
                                                                </div>
                                                        @php
                                                                    }
                                                                }
                                                            }
                                                        @endphp
                                                    </div>
                                                </div>
                                            </div>
                                        <div id="municiple_image_multi" class="form-group col-md-3"></div>
                                        <button class="btn  btn-outline-secondary prevBtn btn-lg pull-left" type="button">Previous</button>
                                        <button class="btn waves-effect waves-light btn-rounded btn-outline-secondary nextBtn btn-lg pull-right" type="submit">Submit</button>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
       <div class="modal fade" id="makeDealModal" role="dialog">
    <div class="modal-dialog modal-xl">
        <div class="modal-content">
            <div class="modal-header">
                <h3 class="modal-title" id="Cancel_module_title">Make Deal Details</h3> 
                <button type="button" class="btn btn-outline-dark" data-bs-dismiss="modal" aria-label="Close">&times;</button>
            </div> 
            <div class="modal-body" style="max-height: 800px; overflow-y: auto; overflow-x: auto;">
               
                <div class="row">
                    <div class="col-md-12">
                        <table class="table table-bordered table-striped" style="color:black!important;">
                            <tr> 
                                <td colspan="6" class="text-center"><b>Reverse Calculation</b></td>
                            </tr>
                            <tr>
                                <td><b>Booking Date</b></td>
                                <td colspan="2">{!! \Carbon\Carbon::parse($make_deal_data->booking_date)->format('d-m-Y') !!}</td>
                                <td><b>KEC</b></td>
                                <td colspan="2">{!! $make_deal_data->sales_person_name !!}</td>
                            </tr>
                            <tr>
                                <td><b>Customer Name</b></td>
                                <td colspan="2">{!! $make_deal_data->customer_name !!}</td>
                                <td><b>TL</b></td>
                                <td colspan="2">{!! strtoupper($make_deal_data->team_name) !!}</td>
                            </tr>
                            <tr>
                                <td><b>Location (Branch)</b></td>
                                <td colspan="5">{!! strtoupper($make_deal_data->branch_name) !!}</td>
                            </tr>
                            <tr>
                                <td><b>Vin No.</b></td>
                                <td colspan="5">{!! $make_deal_data->vin_number !!}</td>
                            </tr>
                            <tr class="light_gray">
                                <td class="text-center"><b>{!! $make_deal_data->car_model_name !!}</b></td>
                                <td class="text-center"><b>Purchase Price</b></td>
                                <td class="text-center"><b>Aging Days</b></td>
                                <td class="text-center"><b>Remark</b></td>
                                <td class="text-center"><b>Ex Showroom Price</b></td>
                                <td class="text-center"><b>Deal</b></td>
                            </tr>
                            <tr>
                                <td><b>{!! $make_deal_data->car_varient_name !!}</b></td>
                                <td class="right-align purchase_price">{!! $make_deal_data->purchase_price !!}</td>
                                <td class="right-align">{!! $make_deal_data->aging_days !!}</td>
                                <td class="right-align">{!! $make_deal_data->remark !!}</td>
                                <td class="right-align ex_showroom_price">{!! $price_list_name_data->basic ?? 0 !!}</td>
                                <td class="right-align ex_showroom_price_deal">{{ $make_deal_data->deal_amt ?? 0 }}</td>
                                
                            </tr>
                            <tr>
                                <input type="hidden" name="gst_tax" id="hidden_gst_tax" value="{{ rtrim($price_list_name_data->gst_percentage, '.0') }}">
                                <td><b>GST @ {!! $price_list_name_data->gst_percentage !!}%</b></td>
                                <td class="right-align">{{ $make_deal_data->purchase_gst_tax_deal ?? 0 }}</td>
                                <td class="right-align gst_price" colspan="3">{!! $price_list_name_data->gst_amount !!}</td>
                                <td class="right-align gst_tax_deal">{{ $make_deal_data->gst_tax_deal ?? 0 }}</td>
                            </tr>
                            <tr>
                                <input type="hidden" name="cess_tax" id="hidden_cess_tax" value="{{ rtrim($price_list_name_data->cess_percentage, '.0') }}">
                                <td><b>Cess @ {!! $price_list_name_data->cess_percentage !!}%</b></td>
                                <td class="right-align cess_price" colspan="4">{!! $price_list_name_data->cess_amount !!}</td>
                                <td class="right-align cess_tax_deal">{{ $make_deal_data->cess_tax_deal ?? 0 }}</td>
                            </tr>
                            <tr>
                                <input type="hidden" name="tcs_tax_amt" id="hidden_tcs_tax_amt" value="{{ $make_deal_data->tcs_tax_id }}">
                                <input type="hidden" name="tcs_tax" id="hidden_tcs_tax" value="1">
                                <td><b>TCS @ 1%</b></td>
                                <td class="right-align tcs_price" colspan="4">{!! $make_deal_data->tcs_tax_id !!}</td>
                                <td class="right-align tcs_tax_deal">{{ $make_deal_data->tcs_tax_deal ?? 0 }}</td>
                            </tr>
                            <tr>
                                <td><b>Municipal Tax</b></td>
                                <td class="right-align municipal_price" colspan="4">{!! $make_deal_data->municipal_tax_id !!}</td>
                                <td class="right-align municipal_tax_deal">{{ $make_deal_data->municipal_tax_deal ?? 0 }}</td>
                            </tr>
                            <tr>
                                <td><b>Municipal Custom Handling Charges</b></td>
                                <td class="right-align municipal_custom_handling_charges" colspan="4">{!! $make_deal_data->municipal_custom_handling_charges !!}</td>
                                <td class="right-align municipal_custom_handling_charges_deal">{{ $make_deal_data->municipal_custom_handling_charges_deal ?? 0 }}</td>
                            </tr>
                            <tr>
                                <td><b>RTO</b></td>
                                <td class="right-align rto_price" colspan="4">{!! $make_deal_data->registration_tax_id !!}</td>
                                <td class="right-align rto_deal">{{ $make_deal_data->rto_deal ?? 0 }}</td>
                            </tr>
                            <tr>
                                <td><b>RTO Custom Handling Charges</b></td>
                                <td class="right-align rto_custom_handling_charges_price" colspan="4">{!! $make_deal_data->rto_custom_handling_charges ?? 0 !!}</td>
                                <td class="right-align rto_custom_handling_charges_deal">{{ $make_deal_data->rto_cutom_handling_charges_deal  ?? '' }}</td>
                            </tr>
                            <tr>
                                <td><b>INSURANCE</b></td>
                                <td class="right-align insurance_price" colspan="4">{!! $make_deal_data->insurance_id ?? 0 !!}</td>
                                <td class="right-align insurance_deal">{{ $make_deal_data->insurance_deal ?? 0 }}</td>
                            </tr>
                            <tr>
                                <td><b>Fastag</b></td>
                                <td class="right-align fastage_price" colspan="4">{!! $make_deal_data->fasttag_amount_new ?? 0 !!}</td>
                                <td class="right-align fastage_amt_deal">{!! $make_deal_data->fasttag_amount_new ?? 0 !!}</td>
                            </tr>
                            <tr>
                                <td><b>EW</b></td>
                                <td class="right-align extended_warranty" colspan="4">{!! $make_deal_data->extand_warranties_amount ?? 0!!}</td>
                                <td class="right-align ew_deal">{!! $make_deal_data->extand_warranties_amount ?? 0 !!}</td>
                            </tr>
                            <tr>
                                <td><b>Accessories</b></td>
                                <td class="right-align accessories_price" colspan="4">{!! $accessory_sum ?? 0 !!}</td>
                                <td class="right-align accessories_deal">{!! $accessory_sum ?? 0 !!}</td>
                            </tr>
                            <tr>
                                <td><b>Other Accessories</b></td>
                                <td class="right-align other_price" colspan="4">{!! $make_deal_data->other_accesssories_prise ?? 0 !!}</td>
                                <td class="right-align other_deal">{!! $make_deal_data->other_accesssories_prise ?? 0 !!}</td>
                            </tr>
                            <tr>
                                <td><b>
                                    {{ $make_deal_data->rsa_type == 'RSA' ? 'RSA' : ($make_deal_data->rsa_type == 'CCS' ? 'CCS' : 'RSA / CCS') }}
                                </b></td>
                            
                                <td class="right-align rsa_price" colspan="4">{!! $make_deal_data->rsa_amount ?? 0 !!}</td>
                                <td class="right-align rsa_deal">{!! $make_deal_data->rsa_amount ?? 0 !!}</td> 
                            </tr>
                            <tr>
                                <td><b>MCP</b></td>
                                <td class="right-align mcp_price" colspan="4">{!! $make_deal_data->mcp_amount ?? 0 !!}</td>
                                <td class="right-align mcp_deal">{!! $make_deal_data->mcp_amount ?? 0 !!}</td>
                            </tr>
                            <tr>
                                <td colspan="6"> </td>
                            </tr>
                            <tr class="light_gray">
                                <td><b>Total On Road Price</b></td>
                                <td class="right-align on_road_price" colspan="4"></td>
                                <td class="right-align on_road_price_deal"></td>
                            </tr>
                            <tr class="final-deal">
                                <td><b>Accepted Deal</b></td>
                                <td class="right-align final_deal_amt" colspan="4">{{ $make_deal_data->final_deal_amt ?? $make_deal_data->final_on_road_price_after_way_off }}</td>
                                <td class="right-align final_deal_deal">{!! $make_deal_data->final_deal_amt  ?? '' !!}</td>
                            </tr>
                            <tr>
                                <td><b>Difference</b></td>
                                <td class="right-align diff_amount" colspan="4"></td>
                                <td class="right-align diff_amount_deal"></td>
                            </tr>
                        </table>
                        
                        <table class="table table-bordered table-striped" style="color:black!important;margin-top:7px;">
                            <tr>
                                <td class="left-align" colspan="6"><b>Remark : </b>{{ $make_deal_data->remark ?? '' }}</td>
                            </tr>
                        </table>
                    </div> 
                </div>   
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div> 
@endsection

@section('scripts')
<script src="{{ asset('assets/js/dropify.min.js') }}"></script>
<script src="{{ asset('assets/js/promise.min.js') }}"></script>
<script src="{{ asset('assets/js/sweetalert2.bundle.js') }}"></script>
<script src="{{ asset('assets/js/select2.js') }}"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>

<?php
    if(!empty($data->priclist_detail)){
        $data->priclist_detail = json_decode($data->priclist_detail);
    }
 ?>


<script>
    jQuery(document).ready(function(){
        //For GST Calculation For Purchase Price
        var purchase_price = parseFloat(jQuery('.purchase_price').text().replace(/,/g, '')) || 0;
        var hidden_gst_tax = parseFloat(jQuery('#hidden_gst_tax').val()) || 0;
        var purchase_gst_calculation = purchase_price * hidden_gst_tax / 100;
        purchase_gst_calculation = Math.round(purchase_gst_calculation);
        jQuery('#purchase_gst_tax_deal').val(purchase_gst_calculation);

        //For Get Total On Road Price With Extended Warranty
        var ex_showroom_price = parseFloat(jQuery('.ex_showroom_price').text().replace(/,/g, '')) || 0;
        var gst_price = parseFloat(jQuery('.gst_price').text().replace(/,/g, '')) || 0;
        var cess_price = parseFloat(jQuery('.cess_price').text().replace(/,/g, '')) || 0;
        var tcs_price = parseFloat(jQuery('.tcs_price').text().replace(/,/g, '')) || 0;
        var municipal_price = parseFloat(jQuery('.municipal_price').text().replace(/,/g, '')) || 0;
        var municipal_custom_handling_charges = parseFloat(jQuery('.municipal_custom_handling_charges').text().replace(/,/g, '')) || 0;
        var rto_price = parseFloat(jQuery('.rto_price').text().replace(/,/g, '')) || 0;
        var rto_custom_handling_charges_price = parseFloat(jQuery('.rto_custom_handling_charges_price').text().replace(/,/g, '')) || 0;
        var insurance_price = parseFloat(jQuery('.insurance_price').text().replace(/,/g, '')) || 0;
        var fastage_price = parseFloat(jQuery('.fastage_price').text().replace(/,/g, '')) || 0;
        var extended_warranty = parseFloat(jQuery('.extended_warranty').text().replace(/,/g, '')) || 0;
        var accessories_price = parseFloat(jQuery('.accessories_price').text().replace(/,/g, '')) || 0;
        var rsa_price = parseFloat(jQuery('.rsa_price').text().replace(/,/g, '')) || 0;
        var mcp_price = parseFloat(jQuery('.mcp_price').text().replace(/,/g, '')) || 0;
        var other_price = parseFloat(jQuery('.other_price').text().replace(/,/g, '')) || 0;

        var final_on_road_price = ex_showroom_price + gst_price + cess_price + tcs_price + municipal_price + municipal_custom_handling_charges + rto_price + rto_custom_handling_charges_price + insurance_price + fastage_price + extended_warranty + accessories_price + rsa_price + mcp_price + other_price;
        jQuery('.on_road_price').text(final_on_road_price.toLocaleString());

        var final_deal_amt = parseFloat(jQuery('.final_deal_amt').text().replace(/,/g, '')) || 0;
        var difference = final_on_road_price - final_deal_amt;
        jQuery('.diff_amount').text(difference.toLocaleString());

        jQuery('.final_deal_deal').text(final_deal_amt);
        
        
        var ex_showroom_price_deal = parseFloat(jQuery('.ex_showroom_price_deal').text().replace(/,/g, '')) || 0;
        var gst_tax_deal = parseFloat(jQuery('.gst_tax_deal').text().replace(/,/g, '')) || 0;
        var cess_tax_deal = parseFloat(jQuery('.cess_tax_deal').text().replace(/,/g, '')) || 0;
        var tcs_tax_deal = parseFloat(jQuery('.tcs_tax_deal').text().replace(/,/g, '')) || 0;
        var municipal_tax_deal = parseFloat(jQuery('.municipal_tax_deal').text().replace(/,/g, '')) || 0;
        var municipal_custom_handling_charges_deal = parseFloat(jQuery('.municipal_custom_handling_charges_deal').text().replace(/,/g, '')) || 0;
        var rto_deal = parseFloat(jQuery('.rto_deal').text().replace(/,/g, '')) || 0;
        var rto_custom_handling_charges_deal = parseFloat(jQuery('.rto_custom_handling_charges_deal').text().replace(/,/g, '')) || 0;
        var insurance_deal = parseFloat(jQuery('.insurance_deal').text().replace(/,/g, '')) || 0;
        var fastage_amt_deal = parseFloat(jQuery('.fastage_amt_deal').text().replace(/,/g, '')) || 0;
        var ew_deal = parseFloat(jQuery('.ew_deal').text().replace(/,/g, '')) || 0;
        var accessories_deal = parseFloat(jQuery('.accessories_deal').text().replace(/,/g, '')) || 0;
        var rsa_deal = parseFloat(jQuery('.rsa_deal').text().replace(/,/g, '')) || 0;
        var mcp_deal = parseFloat(jQuery('.mcp_deal').text().replace(/,/g, '')) || 0;
        var other_deal = parseFloat(jQuery('.other_deal').text().replace(/,/g, '')) || 0;

        var on_road_price = ex_showroom_price_deal + gst_tax_deal + cess_tax_deal + tcs_tax_deal + municipal_tax_deal + municipal_custom_handling_charges_deal + rto_deal + rto_custom_handling_charges_deal + insurance_deal + fastage_amt_deal + ew_deal + accessories_deal + rsa_deal + mcp_deal + other_deal;
        jQuery('.on_road_price_deal').text(on_road_price.toLocaleString());

        //For Deal Side Showing Difference
        var on_road_price_deal = parseFloat(jQuery('.on_road_price_deal').text().replace(/,/g, '')) || 0;
        var final_deal_deal = parseFloat(jQuery('.final_deal_deal').text().replace(/,/g, '')) || 0;
        var deal_difference = on_road_price_deal - final_deal_deal;
        jQuery('.diff_amount_deal').text(deal_difference.toLocaleString());

    });

    function insurance_exist(){
       var insurance_exist =  $('input[name="insurance_exist"]:checked').val();

        if(insurance_exist == 1){
            $('.insurance_exist_c').show();
            $('.insurance_not_exist_c').show();
        }else{
            $('.insurance_exist_c').hide();
            $('.insurance_not_exist_c').show();
        }
    }

    $(document).on('change','.insurance_exist',function(){
        insurance_exist();
    });

    insurance_exist();

    $(document).ready(function(){
        if($('#address_1').val() == $('#address_2').val()){
            $("#chek_address").attr("checked" ,true);
        }

        var copyData = '';
        $('#chek_address').on('click', function(){
            if($('#chek_address').is(":checked")){
                copyData = $('#address_1').val();
                $('#address_2').val(copyData);
            }else{
                $('#address_2').val('');
            }
        })
        $('.dropify').dropify({
            messages: {
                'default': 'Drag and drop profile image here or click',
                'remove':  'Remove',
                'error':   'Ooops, something wrong happended.'
            }
        });

        var drEvent = $('.dropify').dropify();

        var dropifyElements = {};
        $('.dropify').each(function () {
            dropifyElements[this.id] = false;
        });

        drEvent.on('dropify.beforeClear', function(event, element){
            id = event.target.id;
            if(!dropifyElements[id]){
                var url = "{!! route('obf.profile.remove') !!}";
                <?php if(isset($data) && isset($data->id)){ ?>
                    var id_encoded = "{{ base64_encode($data->id) }}";

                    Swal.fire({
                        title: 'Are you sure want delete this image?',
                        text: "",
                        type: 'warning',
                        showCancelButton: true,
                        confirmButtonColor: '#3085d6',
                        cancelButtonColor: '#d33',
                        confirmButtonText: 'Yes'
                    }).then(function (result){
                        if (result.value){
                            $.ajax({
                                url: url,
                                type: "POST",
                                data:{
                                    id: id_encoded,
                                    _token: "{{ csrf_token() }}"
                                },
                                dataType: "JSON",
                                success: function (data){
                                    if(data.code == 200){
                                        Swal.fire('Deleted!', 'Deleted Successfully.', 'success');
                                        dropifyElements[id] = true;
                                        element.clearElement();
                                    }else{
                                        Swal.fire('', 'Failed to delete', 'error');
                                    }
                                },
                                error: function (jqXHR, textStatus, errorThrown){
                                    Swal.fire('', 'Failed to delete', 'error');
                                }
                            });
                        }
                    });

                    return false;
                <?php } else { ?>
                    Swal.fire({
                        title: 'Are you sure want delete this image?',
                        text: "",
                        type: 'warning',
                        showCancelButton: true,
                        confirmButtonColor: '#3085d6',
                        cancelButtonColor: '#d33',
                        confirmButtonText: 'Yes'
                    }).then(function (result){
                        if (result.value){
                            Swal.fire('Deleted!', 'Deleted Successfully.', 'success');
                            dropifyElements[id] = true;
                            element.clearElement();
                        }else{
                            Swal.fire('Cancelled', 'Discard Last Operation.', 'error');
                        }
                    });
                    return false;
                <?php } ?>
            } else {
                dropifyElements[id] = false;
                return true;
            }
        });
    });
</script>
<script>
    $(document).ready(function(){
        $('.select2').select2({
            placeholder:"Select Accessory",
        })

         $('.select_priclist').select2({
            placeholder:"Select Pricelist Detail",
        })
    }); 
     


    $('#accessories').on('change' , function(){
        var sum = 0;
        $('#accessories :selected').each(function() {
            sum  += parseInt($(this).data("price"));
        })
        //console.log(sum);
        $('#total').html(sum);
    });

    function openMakeDealModal() { 
        $('#makeDealModal').modal('show');
        setTimeout(function () {
            $('.modal-backdrop').remove();
        }, 300);
    }
     $('#pricelist_manager_id').attr('disabled',true);

       function car_mveriant(e){
          var id = e.value;
            $.ajax({
                url : "{{ url('obf/carvarient/') }}",
                data : {'id' : id},
                type : 'get',
                dataType : 'json',

                success : function(resp){
                    
                   
                    var html = ihtml = ehtml = vhtml = '';
                        
                    jQuery.each(resp.cardeails, function(key, val){ 
                        html = val.car_name;
                        vhtml = val.varient_name;
                        ehtml = val.exterior_color;
                        ihtml = val.interior_color;
                    });
                    jQuery("#exterior_color").val(ehtml);
                    jQuery("#interior_color").val(ihtml);
                    jQuery("#veriant").val(vhtml);
                    jQuery("#car_name").val(html);

                    var e_row = resp.data.pricelist_arr;

                   console.log(e_row);

                    html = '';
                    jQuery.each(e_row, function(key, val){ 
                        $('#pricelist_manager_id').removeAttr('disabled');
                        html += '<option value="'+val.price_id+'">'+val.price_list_name+' | '+val.transmission+'</option>';
                    });
                    console.log(html);
                    jQuery("#pricelist_manager_id").empty();
                    jQuery("#pricelist_manager_id").html(html);

                }
            });
            
        }



        function car_mveriant_edit(value){

          var id = value;
                $.ajax({
                   url : "{{ url('obf/carvarient/') }}",
                   data : {'id' : id},
                   type : 'get',
                   dataType : 'json',

                   success : function(resp){
                       
                       var html = ihtml = ehtml = vhtml = '';
                          
                       jQuery.each(resp.cardeails, function(key, val){ 
                           html = val.car_name;
                           vhtml = val.varient_name;
                           ehtml = val.exterior_color;
                           ihtml = val.interior_color;
                       });
                       jQuery("#exterior_color").val(ehtml);
                       jQuery("#interior_color").val(ihtml);
                       jQuery("#veriant").val(vhtml);
                       jQuery("#car_name").val(html);

                       var e_row = resp.data.pricelist_arr;

                       console.log(e_row);

                       var data_veriant = "<?php echo $data->product_id ?>"; 

                       html = '';

                       

                       var pricelist_id = "<?php echo $data->pricelist_id ?>"; 

                       jQuery.each(e_row, function(key, val){ 
                            var selected = '';
                            if(pricelist_id != '' && pricelist_id == val.id){
                                selected = "selected";
                            }

                           $('#pricelist_manager_id').removeAttr('disabled');
                           html += '<option value="'+val.id+'" '+selected+'>'+val.price_list_name+' | '+val.transmission+'</option>';
                       });
                       console.log(html);
                       jQuery("#pricelist_manager_id").empty();
                       jQuery("#pricelist_manager_id").html(html);
                   }
               });
               
           }
                                
            var data_veriant = "<?php echo $data->product_id ?>"; 
                console.log(data_veriant);
        if(data_veriant != ''){
            car_mveriant_edit(data_veriant);
        }

        var priclist_detail_arr_f = <?php echo json_encode($data->priclist_detail); ?>;
        const arrayColumn = (array, column) => {
            return array.map(item => item[column]);
        };
        const priclist_detail_arr = arrayColumn(priclist_detail_arr_f, 'detail_field');

        function Getpricelist_edit_get(id){

            if(id != ''){
                var URL='{{route('obf.getpricelist')}}';
                $.ajax({
                        url: URL,
                        type: 'post',
                        data: {id:id,_token: "{{ csrf_token() }}"},
                        cache: false,
                        success: function(data) {
                            if(data.detail_value != ''){
                                var e_row = jQuery.parseJSON(data.detail_value);

                               console.log("===--5555");
                                    console.log(priclist_detail_arr);
                                    console.log("===");

                                var html = '';                     

                                if(e_row.length > 0){
                                    // html +='<option value="">Select Veriant</option>';
                                    jQuery.each(e_row, function(key, val){
                                        console.log("---");
                                        console.log(val.value_field);
                                        console.log("---");
                                        var selected = '';

                                        // if(jQuery.inArray(val.value_field, priclist_detail_arr)) {
                                        if(jQuery.inArray(val.detail_field, priclist_detail_arr) != -1) {
                                            console.log('selected');
                                             selected = 'selected';
                                        }
                                       html +='<option value="'+val.detail_field+'__'+val.value_field+'" '+selected+' data-value_field="'+val.value_field+'">'+val.detail_field+' - '+val.value_field+'</option>';
                                    });


                                    jQuery("#priclist_detail").empty();
                                    jQuery("#priclist_detail").html(html);
                                }
                            }              
                        },
                        error: function(data) {
                            
                        }
                });
            }
        }

        Getpricelist_edit_get("<?php echo $data->pricelist_id; ?>");

         jQuery(document).on('change', '#lead', function(e){
            var id = $('#lead').val();
            sub_lead_html(id);
        });

        function sub_lead_html(id){
          $.ajax({
              url : "{{ url('obf/sub_lead_html/') }}",
              data : {'id' : id},
              type : 'get',
              dataType : 'json',
              success : function(resp){  
                  var c_row = resp.data.sub_lead_html; 
                  var html = '';
                  html +='<option value="">Select Sub Lead</option>';
                  jQuery.each(c_row, function(key, val){
                      var selected = '';
                      if("{{$data->sub_lead_id}}" == val.id){
                          selected = 'selected';
                      }

                      html +='<option value="'+val.id+'" '+selected+'>'+val.name+'</option>';
                  });                 
                  jQuery("#sub_lead_id").empty();
                  jQuery("#sub_lead_id").html(html);
              }
          });
        }

        if('{{$data->lead_id}}' != ''){
            sub_lead_html('{{$data->lead_id}}');
        }


    
</script>

<script>
// Open the Modal


$( ".hover-shadow" ).click(function() {
    document.getElementById("myModal").style.display = "block";
    console.log($(this).attr('src'));
    $('.image_set').attr('src',$(this).attr('src'));
}); 

$( ".hover-shadow2" ).click(function() {
    document.getElementById("myModal2").style.display = "block";
    console.log($(this).attr('src'));
    $('.image_set').attr('src',$(this).attr('src'));
});


// Close the Modal
function closeModal() {
    document.getElementById("myModal").style.display = "none";
}

function closeModal2() {
    document.getElementById("myModal2").style.display = "none";
}

</script>

@endsection