@extends('template.app') 

@section('meta')
@endsection

@section('title')
Obf Insurance
@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 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 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 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 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 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;
        }

        .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);
        }
        
        .uploaded_images{
            border:1px solid white;
            border-style: dashed;
            margin-bottom: 20px;
            border-radius: 5px;
        }
        
        .mt-5{
            margin-top: 6rem !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">Insurance</li>
                    </ol>
                </nav>
            </div>
        </div>
        <div class="col-5 align-self-center">
            <div class="customize-input float-right">
            </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">2</a>
                                <p>Car Details</p>
                            </div>
                            @canany(['Process Insurance'])
                                <div class="stepwizard-step">
                                    <a href="#step-3" id="thrid_new" type="button" class="btn btn-default btn-circle text-white">3</a>
                                    <p>Insurance Details</p>
                                </div>
                            @endcanany  
                        </div>
                    </div>
                    <form method="POST" action="{!! route('obf.processinsurancedms') !!}" enctype="multipart/form-data">
                      @csrf
                        <input type="hidden" name="id" value="{{ $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">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-primary 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="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="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>
                                            </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">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-primary 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">
                                    <h5> Insurance Details</h5>
                                    <div class="row">
                                        <div class="form-group col-md-3">
                                            <label class="control-label col-sm-12">Insurance</label>
                                            <label class="checkbox-inline"><input type="radio" value="1" name="insurance_exist" class="chk_ncb insurance_exist" {{ old('insurance_exist', $data->insurance_exist ?? '1') == '1' ? 'checked' : '' }}> Yes</label>
                                            <label class="checkbox-inline"><input type="radio" value="2" name="insurance_exist" class="chk_ncb insurance_exist" {{ old('insurance_exist', $data->insurance_exist ?? '2') == '2' ? 'checked' : '' }}> No</label>
                                            <span class="kt-form__help error insurance_exist"></span>
                                        </div>
                                        <div class="form-group col-md-3 insurance_exist_c">
                                            <label class="control-label col-sm-12">NCB - No Claim Bonus</label>
                                            <label class="checkbox-inline"><input type="radio" value="yes" name="ncb" class="chk_ncb" {{ old('ncb', $data->ncb ?? 'yes') == 'yes' ? 'checked' : '' }}> Yes</label>
                                            <label class="checkbox-inline"><input type="radio" value="no" name="ncb" class="chk_ncb" {{ old('ncb', $data->ncb ?? 'no') == 'no' ? 'checked' : '' }}> No</label>
                                            <span class="kt-form__help error occupation"></span>
                                        </div>
                                        <div class="form-group col-md-3 insurance_exist_c">
                                            <label class="control-label">Date of Insurance</label>
                                            <input type="date" name="date_of_insurance" id="date_of_insurance" class="form-control" value="{{ (!empty($data->date_of_insurance)) ? $data->date_of_insurance : date('Y-m-d')}}">
                                            <span class="kt-form__help error date_of_insurance"></span>
                                        </div>
                                        <div class="form-group col-md-3 insurance_exist_c">
                                            <label class="control-label">Select Insurance Plan</label>
                                            <select name="time_of_insurance" id="time_of_insurance" class="form-control">
                                                <option value="" selected disabled>Please Select Year</option>
                                                <option value="4" @if($data->time_of_insurance == '4') selected @endif>1+3 Year</option>
                                            </select>
                                            <span class="kt-form__help error time_of_insurance"></span> 
                                        </div>
                                        <div class="form-group col-md-3 insurance_exist_c">
                                            <label class="control-label">1 Year End Date</label>
                                            <input type="date" name="last_time_of_insurance1" id="last_time_of_insurance1" class="form-control" placeholder="1 Year End Date" readonly>
                                            <span class="kt-form__help error last_time_of_insurance1"></span>
                                        </div>
                                        <div class="form-group col-md-3 insurance_exist_c">
                                            <label class="control-label">3 Year End Date</label>
                                            <input type="hidden" name="last_time_of_insurance" id="last_time_of_insurance" value="">
                                            <input type="date" name="last_time_of_insurance3" id="last_time_of_insurance3" class="form-control" placeholder="3 Year End Date" value="{{ $data->last_time_of_insurance ?? '' }}" readonly>
                                            <span class="kt-form__help error last_time_of_insurance3"></span>
                                        </div>   
                                        <div class="form-group col-md-3 insurance_not_exist_c">
                                            <label class="control-label">Insurance Company Name</label>
                                            <select name="insurance_company_name" id="insurance_company_name" class="form-control">
                                                <option value="" selected>Select Insurance Company</option>
                                                @foreach($insurance as $key => $val)
                                                    <option value="{{$val->id}}" @if($data->insurance_company_name == $val->id) selected @endif>{{ $val->name }}</option>
                                                @endforeach    
                                            </select>
                                            <span class="kt-form__help error insurance_company_name"></span>
                                        </div>
                                        <div class="form-group col-md-3 insurance_not_exist_c">
                                            <label class="control-label">Amount</label>
                                            <input type="number"  name="ncb_amount" id="ncb_amount" class="form-control" placeholder="Enter NCB Amount" value="{{ $data->ncb_amount ?? '' }}">
                                            <span class="kt-form__help error ncb_amount"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Own Damage Premium</label>
                                            <input type="number"  name="own_damage_premium" id="own_damage_premium" class="form-control" placeholder="Enter Amount" value="{{ $data->own_damage_premium ?? '' }}" required>
                                            <span class="kt-form__help error own_damage_premium"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Gross Premium Paid</label>
                                            <input type="number"  name="gross_premium_paid" id="gross_premium_paid" class="form-control" placeholder="Enter Amount" value="{{ $data->gross_premium_paid ?? '' }}" required>
                                            <span class="kt-form__help error gross_premium_paid"></span>
                                        </div>
                                        <div class="form-group col-md-3 insurance_exist_c">
                                            <label class="control-label">Policy Number</label>
                                            <input type="text"  name="policy_number" id="policy_number" class="form-control" placeholder="Enter Policy Number" value="{{ $data->policy_number ?? '' }}">
                                            <span class="kt-form__help error policy_number"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Issue Date</label>
                                            <input type="date" name="issue_date" id="issue_date" class="form-control" value="{{ (!empty($data->issue_date)) ? $data->issue_date : date('Y-m-d')}}">
                                            <span class="kt-form__help error issue_date"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <input type="date" name="risk_start_date" id="risk_start_date" class="form-control" value="{{ (!empty($data->risk_start_date)) ? $data->risk_start_date : date('Y-m-d')}}">
                                            <span class="kt-form__help error risk_start_date"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Risk End Date</label>
                                            <input type="date" name="risk_end_date" id="risk_end_date" class="form-control" value="{{ (!empty($data->risk_end_date)) ? $data->risk_end_date : date('Y-m-d')}}">
                                            <span class="kt-form__help error risk_end_date"></span>
                                        </div>
                                    </div>
                                </div>
                            </div>   
                            <div class="col-lg-12 ">
                                <div class="col-md-12">
                                    <div class="row">
                                        <div class="form-group col-md-3 mt-5">
                                            <label class="control-label"> Tyre No 1</label>
                                            <input type="text"  name="tyre_no1" id="tyre_no1" class="form-control" placeholder="Enter Tyre 1" value="{{ $data->tyre_no1 ?? '' }}">
                                            <span class="kt-form__help error"></span>
                                        </div>
                                        <div class="form-group col-md-3 mt-5">
                                            <label class="control-label">Tyre Company 1</label>
                                            <input type="text" class="form-control" name="tyre_company_1" id="tyre_company_1" placeholder="Enter Tyre Company No 1" value="{{ $data->tyre_company_1 ?? '' }}">
                                            <span class="kt-form__help error tyre_company_1"></span>
                                        </div>
                                        <div class="form-group col-md-3 mt-5">
                                            <label class="control-label">Tyre Year 1</label>
                                            <input type="text" class="form-control" name="tyre_year_1" id="tyre_year_1" placeholder="Enter Tyre Year 1" value="{{ $data->tyre_year_1 ?? '' }}">
                                            <span class="kt-form__help error tyre_year_1"></span>
                                        </div>
                                        
                                        <div class="form-group col-md-3 mt-5"></div>
                                        
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Tyer No 2</label>
                                            <input type="text"  name="tyre_no2" id="tyre_no2" class="form-control" placeholder="Enter Tyre 2" value="{{ $data->tyre_no2 ?? '' }}">
                                            <span class="kt-form__help error"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Tyre Company 2</label>
                                            <input type="text" class="form-control" name="tyre_company_2" id="tyre_company_2" placeholder="Enter Tyre Company No 2" value="{{ $data->tyre_company_2 ?? '' }}">
                                            <span class="kt-form__help error tyre_company_2"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Tyre Year 2</label>
                                            <input type="text" class="form-control" name="tyre_year_2" id="tyre_year_2" placeholder="Enter Tyre Year 2" value="{{ $data->tyre_year_2 ?? '' }}">
                                            <span class="kt-form__help error tyre_year_2"></span>
                                        </div>
                                        
                                        <div class="form-group col-md-3"></div>
                                        
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Tyer No 3</label>
                                            <input type="text"  name="tyre_no3" id="tyre_no3" class="form-control" placeholder="Enter Tyre 3" value="{{ $data->tyre_no3 ?? '' }}">
                                            <span class="kt-form__help error "></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Tyre Company 3</label>
                                            <input type="text" class="form-control" name="tyre_company_3" id="tyre_company_3" placeholder="Enter Tyre Company No 3" value="{{ $data->tyre_company_3 ?? '' }}">
                                            <span class="kt-form__help error tyre_company_3"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Tyre Year 3</label>
                                            <input type="text" class="form-control" name="tyre_year_3" id="tyre_year_3" placeholder="Enter Tyre Year 3" value="{{ $data->tyre_year_3 ?? '' }}">
                                            <span class="kt-form__help error tyre_year_3"></span>
                                        </div>
                                        
                                        <div class="form-group col-md-3"></div>
                                        
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Tyer No 4</label>
                                            <input type="text"  name="tyre_no4" id="tyre_no4" class="form-control" placeholder="Enter Tyre 4" value="{{ $data->tyre_no4 ?? '' }}">
                                            <span class="kt-form__help error"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Tyre Company 4</label>
                                            <input type="text" class="form-control" name="tyre_company_4" id="tyre_company_4" placeholder="Enter Tyre Company No 4" value="{{ $data->tyre_company_4 ?? '' }}">
                                            <span class="kt-form__help error tyre_company_4"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Tyre Year 4</label>
                                            <input type="text" class="form-control" name="tyre_year_4" id="tyre_year_4" placeholder="Enter Tyre Year 4" value="{{ $data->tyre_year_4 ?? '' }}">
                                            <span class="kt-form__help error tyre_year_4"></span>
                                        </div>
                                        
                                        <div class="form-group col-md-3"></div>
                                        
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Tyer No 5</label>
                                            <input type="text"  name="tyre_no5" id="tyre_no5" class="form-control" placeholder="Enter Tyre 5" value="{{ $data->tyre_no5 ?? '' }}">
                                            <span class="kt-form__help error"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Tyre Company 5</label>
                                            <input type="text" class="form-control" name="tyre_company_5" id="tyre_company_5" placeholder="Enter Tyre Company No 5" value="{{ $data->tyre_company_5 ?? '' }}">
                                            <span class="kt-form__help error tyre_company"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Tyre Year 5</label>
                                            <input type="text" class="form-control" name="tyre_year_5" id="tyre_year_5" placeholder="Enter Tyre Year 5" value="{{ $data->tyre_year_5 ?? '' }}">
                                            <span class="kt-form__help error tyre_year_5"></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            
                            <div class="col-lg-12 mt-5">
                                <div class="col-md-12">
                                    <div class="row">
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Status</label>
                                            <select name="status" id="status" class="form-control">
                                                <option value="insurance_in_progress" @if($data->status == 'insurance_in_progress') selected @endif>Process In-progress</option>
                                                <option value="insurance_completed" @if($data->status == 'insurance_completed') selected @endif>Process Completed</option>
                                            </select>
                                            <span class="kt-form__help error rto_type"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Insurance Status</label>
                                            <select name="insurance_status" id="insurance_status" class="form-control">
                                                <option value="1" @if($data->insurance_status == '1') selected @endif>Running</option>
                                                <option value="0" @if($data->insurance_status == '0') selected @endif>Expired</option>
                                            </select>
                                            <span class="kt-form__help error rto_type"></span>
                                        </div>
                                        <div class="form-group col-md-6">
                                            <label class="control-label">Remarks</label>
                                            <textarea name="insurance_remarks" class="form-control insurance-remarks" placeholder="Enter Remarks">{{ $data->remarks ?? '' }}</textarea>
                                            <span class="kt-form__help error step3_remarks"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Handicap:</label>
                                            <select name="handicap" id="handicap" class="form-control">
                                                <option value="">Select Options</option>
                                                <option value="yes"  @if($data->handicap == 'yes') selected @endif>Yes</option>
                                                <option value="no"  @if($data->handicap == 'no') selected @endif>No</option>
                                            </select>
                                        </div>
                                        <div class="form-group col-md-3" id="handicap_doc_section">
                                            <label class="control-label">Upload Handicap Documents</label>
                                            <input type="file" name="handicap_image[]" id="handicap_image"  onchange="previewMultiple(event,'handicap_image_multi','handicap_image')" class="form-control dropify" data-default-file="" data-allowed-file-extensions="jpg png jpeg pdf" data-max-file-size-preview="3M" multiple>
                                            <span class="kt-form__help error handicap_image"></span>
                                        </div>
                                        <div class="form-group col-md-3 insurance_exist_c"> 
                                            <label class="control-label">Upload OLD RC Book</label>
                                            <input type="file" name="old_rc_book_image[]" id="old_rc_book_image"  onchange="previewMultiple(event,'old_rc_book_image_multi','old_rc_book_image')" class="form-control dropify" data-default-file="" data-allowed-file-extensions="jpg png jpeg pdf" data-max-file-size-preview="3M" multiple>
                                            <span class="kt-form__help error documents"></span>
                                        </div>
                                        <div class="form-group col-md-3 insurance_exist_c">
                                            <label class="control-label">Upload Original Policy </label>
                                            <input type="file" name="policy_image[]" id="policy_image"  onchange="previewMultiple(event,'policy_image_multi','policy_image')" class="form-control dropify" data-default-file="" data-allowed-file-extensions="jpg png jpeg pdf" data-max-file-size-preview="3M" multiple>
                                            <span class="kt-form__help error documents"></span>
                                        </div>
                                        <div class="form-group col-md-3 insurance_exist_c">
                                            <label class="control-label">Upload NCB Certificate Original </label>
                                            <input type="file" name="ncb_certificate_image[]" id="ncb_certificate_image"  onchange="previewMultiple(event,'ncb_certificate_image_multi','ncb_certificate_image')" class="form-control dropify" data-default-file="" data-allowed-file-extensions="jpg png jpeg pdf" data-max-file-size-preview="3M" multiple>
                                            <span class="kt-form__help error documents"></span>
                                        </div>
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Upload Documents</label>
                                            <input type="file" name="insurance_image[]" id="insurance_image" onchange="previewMultiple(event,'insurance_image_multi','insurance_image')" class="form-control dropify" data-default-file="" data-allowed-file-extensions="jpg png jpeg pdf"  data-max-file-size-preview="3M" multiple>
                                            <span class="kt-form__help error insurance_image"></span>
                                        </div>
                                    </div>
                                </div>
                            </div>   
                            <div class="col-lg-12 ">
                                <div class="col-md-12">
                                    <div class="uploaded_images">
                                        <div class="col-md-12 row">
                                            <div id="handicap_image_multi" class="form-group col-md-2 mt-2 ml-5">
                                                @php
                                                    if (!empty($data->handicap_image)) {
                                                        $other_documents_arr = explode(',', $data->handicap_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:100%; height:auto;" alt="Handicap Image">
                                                                    <p class="mt-1">Handicap Image</p>
                                                                </div>
                                                @php
                                                            }
                                                        }
                                                    }
                                                @endphp
                                            </div>
                                            
                                            <div id="old_rc_book_image_multi" class="form-group col-md-2 mt-2 ml-5">
                                                @php
                                                    if (!empty($data->old_rc_book_image)) {
                                                        $other_documents_arr = explode(',', $data->old_rc_book_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:100%; height:auto;" alt="Handicap Image">
                                                                    <p class="mt-1">OLD RC Book Image</p>
                                                                </div>
                                                @php
                                                            }
                                                        }
                                                    }
                                                @endphp
                                            </div>
                                            <!--<div id="policy_image_multi" class="form-group col-md-2 mt-2 ml-5">
                                                @php
                                                    if (!empty($data->policy_image)) {
                                                        $other_documents_arr = explode(',', $data->policy_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:100%; height:auto;" alt="Handicap Image">
                                                                    <p class="mt-1">Original Policy Image</p>
                                                                </div>
                                                @php
                                                            }
                                                        }
                                                    }
                                                @endphp
                                            </div>-->
                                            
                                            <div id="policy_image_multi" class="form-group col-md-2 mt-2 ml-5">
                                                @php
                                                    if (!empty($data->policy_image)) {
                                                        $other_documents_arr = explode(',', $data->policy_image);
                                            
                                                        foreach ($other_documents_arr as $value) {
                                                            $file_path = public_path('/uploads/kyc/' . $value);
                                                            if (!file_exists($file_path)) {
                                                                continue;
                                                            }
                                            
                                                            $extension = strtolower(pathinfo($value, PATHINFO_EXTENSION));
                                                @endphp
                                            
                                                            <div class="mb-2 text-center">
                                                                @if(in_array($extension, ['jpg','jpeg','png','gif','webp']))
                                                                    {{-- SHOW IMAGE --}}
                                                                    <img src="{{ asset('uploads/kyc/' . $value) }}"
                                                                         style="max-width:100%; height:auto;"
                                                                         alt="Document Image">
                                                                    <p class="mt-1">Original Policy Image</p>
                                            
                                                                @elseif($extension == 'pdf')
                                                                    {{-- SHOW PDF ICON + LINK --}}
                                                                    <a href="{{ asset('uploads/kyc/' . $value) }}" target="_blank">
                                                                        <img src="https://img.icons8.com/?id=25009&format=png&color=000000"
                                                                             width="60" height="60"
                                                                             alt="Original Policy PDF File">
                                                                    </a>
                                                                    <p class="mt-1">View PDF</p>
                                                                @else
                                                                    {{-- UNKNOWN FILE TYPE --}}
                                                                    <p>Unsupported file: {{ $value }}</p>
                                                                @endif
                                                            </div>
                                            
                                                @php
                                                        }
                                                    }
                                                @endphp
                                            </div>

                                            
                                            <div id="ncb_certificate_image_multi" class="form-group col-md-2 mt-2 ml-5">
                                                @php
                                                    if (!empty($data->ncb_certificate_image)) {
                                                        $other_documents_arr = explode(',', $data->ncb_certificate_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:100%; height:auto;" alt="Handicap Image">
                                                                    <p class="mt-1">NCB Certificate Original Image</p>
                                                                </div>
                                                @php
                                                            }
                                                        }
                                                    }
                                                @endphp
                                            </div>
                                            
                                            <div id="insurance_image_multi" class="form-group col-md-2 mt-2 ml-5">
                                                @php
                                                    if (!empty($data->insurance_image)) {
                                                        $other_documents_arr = explode(',', $data->insurance_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:100%; height:auto;" alt="Handicap Image">
                                                                    <p class="mt-1">Documant Image</p>
                                                                </div>
                                                @php
                                                            }
                                                        }
                                                    }
                                                @endphp
                                            </div>
                                            
                                        </div>
                                    </div>    
                                </div>
                            </div>    
                                    <div id="insurance_image_multi" class="form-group col-md-3 insurance_exist_c"></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-primary submit_once btn-lg pull-right" type="submit">Submit</button>
                                </div>
                            </div>
                        </div>    
                    </form>
                </div>
            </div>
        </div>
    </div>
</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>
    
    <?php
        if(!empty($data->priclist_detail)){
            $data->priclist_detail = json_decode($data->priclist_detail);
        }
    ?>


    <script>
        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(){
            var form = $('#form');
            $('.kt-form__help').html('');
            form.submit(function(e) {
                $('.help-block').html('');
                $('.m-form__help').html('');
                $.ajax({
                    url: form.attr('action'),
                    type: form.attr('method'),
                    data: new FormData($(this)[0]),
                    dataType: 'json',
                    async: false,
                    processData: false,
                    contentType: false,
                    success: function(json) {
                        return true;
                    },
    
                    error: function(json) {
                        if (json.status === 422) {
                            e.preventDefault();
                            var errors_ = json.responseJSON;
                            $('.kt-form__help').html('');
                            $.each(errors_.errors, function(key, value) {
                                $('.' + key).html(value);
                            });
                        }
                    }
                });
            });
        
            function getTodayDate() {
                const today = new Date();
                const yyyy = today.getFullYear();
                const mm = String(today.getMonth() + 1).padStart(2, '0');
                const dd = String(today.getDate()).padStart(2, '0');
                return `${yyyy}-${mm}-${dd}`;
            }

            // Set only min attribute (no default value)
            // window.onload = function () {
            //     const today = getTodayDate();
            //     document.getElementById('issue_date').min = today;
            //     document.getElementById('risk_start_date').min = today;
            //     document.getElementById('risk_end_date').min = today;
            // };
            
            $('#handicap_doc_section').hide();
            
            var handicap_value_check = $('#handicap').val();
            if (handicap_value_check === 'yes') {
                $('#handicap_doc_section').show();
            } else {
                $('#handicap_doc_section').hide();
            }

            // Change event listener
            $('#handicap').change(function () {
                if ($(this).val() === 'yes') {
                    $('#handicap_doc_section').show();
                } else {
                    $('#handicap_doc_section').hide();
                }
            });
            
            $('.select2').select2({
                placeholder:"Select Accessory",
            })
    
             $('.select_priclist').select2({
                placeholder:"Select Pricelist Detail",
            })
            
            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;
                }
            });
            
            $(document).on('click','.chk_ncb',function(){

                var value=$(this).val();
        
                html='';
        
                if(value == 'yes'){
        
                    html+='<div class="form-group col-md-3">';
        
                    html+='<label class="control-label">Date of Insurance</label>';
        
                    html+='<input type="date"  name="date_of_insurance" id="date_of_insurance" class="form-control" placeholder="Date Of Insurance">';
        
                    html+='<span class="kt-form__help error date_of_insurance"></span>';
        
                    html+='</div>';
        
                    html+='<div class="form-group col-md-3">';
        
                    html+='<label class="control-label">Time of Insurance</label>';
        
                    html+='<select name="time_of_insurance" id="time_of_insurance" class="form-control">';
        
                    html+='<option value="" selected disabled>Please Select Year</option>';
        
                    html+='<option value="1">1 Year</option>';
        
                    html+='<option value="3">3 Year</option>';
        
                    html+='</select>';
        
                    html+='<span class="kt-form__help error time_of_insurance"></span>';
        
                    html+='</div>';
        
                    html+='<div class="form-group col-md-3">';
        
                    html+='<input type="text" name="last_time_of_insurance" id="last_time_of_insurance" hidden>';
        
                    html+='<label class="control-label">Last Date of Insurance</label>';
        
                    html+='<input type="text"  name="last_time_of_insurance1" id="last_time_of_insurance1" class="form-control" placeholder="last time of insurance" disabled>';
        
                    html+='<span class="kt-form__help error last_time_of_insurance1"></span>';
        
                    html+='</div>';
        
                    html+='<div class="form-group col-md-3">';
        
                    html+='<label class="control-label">Company Name</label>';
        
                    html+='<input type="text"  name="insurance_company_name" id="insurance_company_name" class="form-control" placeholder="Enter Company Name">';
        
                    html+='<span class="kt-form__help error insurance_company_name"></span>';
        
                    html+='</div>';
        
                    html+='<div class="form-group col-md-3">';
        
                    html+='<label class="control-label">Amount</label>';
        
                    html+='<input type="number"  name="ncb_amount" id="ncb_amount" class="form-control" placeholder="Enter NCB Amount">';
        
                    html+='<span class="kt-form__help error ncb_amount"></span>';
        
                    html+='</div>';
        
                    html+='<div class="form-group col-md-3">';
        
                    html+='<label class="control-label">Policy Number</label>';
        
                    html+='<input type="text"  name="policy_number" id="policy_number" class="form-control" placeholder="Enter Policy Number">';
        
                    html+='<span class="kt-form__help error policy_number"></span>';
        
                    html+='</div>';
        
                    $('#ncb_data').html(html);
        
                    $('.documents_upload_class').show();
                }
        
                else{
        
                    $('#ncb_data').html(html);
        
                    $('.documents_upload_class').hide();
        
                }
        
            })
        });
        
        // $('#time_of_insurance').change(function() {
        //     var start_date = document.getElementById("date_of_insurance").value;
        //     var currentDate = moment().format('DD-MM-YYYY');
        //     var date1Year = moment(start_date, "YYYY-MM-DD").add(1, 'year').subtract(1, 'day').format('DD-MM-YYYY');
        //     var date3Year = moment(start_date, "YYYY-MM-DD").add(3, 'year').subtract(1, 'day').format('DD-MM-YYYY');
    
        //     $("#last_time_of_insurance1").val(date1Year);
        //     $("#last_time_of_insurance3").val(date3Year);
        // });
        
            var start_date = document.getElementById("last_time_of_insurance3").value;
            if (start_date) {
                var date3Year = moment(start_date, "YYYY-MM-DD").subtract(2, 'year').format('YYYY-MM-DD');
        
                $("#last_time_of_insurance1").val(date3Year);
            }
        
        $('#time_of_insurance').change(function () {
            var start_date = document.getElementById("date_of_insurance").value;
        
            if (start_date) {
                var date1Year = moment(start_date, "YYYY-MM-DD").add(1, 'year').subtract(1, 'day').format('YYYY-MM-DD');
                var date3Year = moment(start_date, "YYYY-MM-DD").add(3, 'year').subtract(1, 'day').format('YYYY-MM-DD');
        
                $("#last_time_of_insurance1").val(date1Year);
                $("#last_time_of_insurance3").val(date3Year);
                $("#last_time_of_insurance").val(date3Year); // Hidden field if needed for DB
            }
        });
    
        $('#accessories').on('change' , function(){
            var sum = 0;
            $('#accessories :selected').each(function() {
                sum  += parseInt($(this).data("price"));
            })
            $('#total').html(sum);
        });
    
        $('#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 ?>"; 
        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}}');
        }
    
        $( ".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