@extends('template.app') 

@section('meta')
@endsection

@section('title')
Obf View
@endsection

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

    img.demo {
      opacity: 0.6;
    }

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

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

    .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);
    }


</style>
@endsection

@section('content')
<div class="page-breadcrumb">
    <div class="row">
        <div class="col-7 align-self-center">
            <h4 class="page-title text-truncate text-dark font-weight-medium mb-1">OBF View</h4>
            <div class="d-flex align-items-center">
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb m-0 p-0">
                        <li class="breadcrumb-item"><a href="{{ route('dashboard') }}" class="text-muted">Dashboard</a></li>
                        <li class="breadcrumb-item"><a href="{{ route('obf') }}" class="text-muted">OBF</a></li>
                        <li class="breadcrumb-item text-muted active" aria-current="page">View</li>
                    </ol>
                </nav>
            </div>
        </div>
        <div class="col-5 align-self-center">
            <div class="customize-input float-right">
            </div>
        </div>
    </div>
</div>
<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-body">
                    <div class="stepwizard col-md-offset-3">
                        <div class="stepwizard-row setup-panel">
                            <div class="stepwizard-step">
                                <a href="#step-1" type="button" class="btn btn-primary btn-circle text-white">1</a>
                                <p>Personal Details</p>
                            </div>
                            <div class="stepwizard-step">
                                <a href="#step-2" type="button" class="btn btn-default btn-circle text-white" disabled="disabled">2</a>
                                <p>Car Details</p>
                            </div>
                             @canany(['Process MCP'])
                             <div class="stepwizard-step">
                                <a href="#step-3" id="thrid_new" type="button" class="btn btn-default btn-circle text-white" disabled="disabled">3</a>
                                <p>MCP Details</p>
                            </div>
                            @endcanany  
                        </div>
                    </div>
                    <form method="POST" action="{{ route('obf.processmcpdms') }}" enctype="multipart/form-data">
                      @csrf
                        <input type="hidden" name="id" value="{{ $data->id }}" >
                        <div class="row setup-content" id="step-1">
                            <div class="col-lg-12 ">
                                <div class="col-md-12">
                                    <h3> Personal Details</h3>
                                    <div class="row">
                                        
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Booking Date</label>
                                            <input type="date" id="booking_date" class="form-control" value="{{ $data->booking_date ?? '' }}" disabled>
                                            <span class="kt-form__help error booking_date"></span>
                                        </div>
                                        
                                        <div class="form-group col-md-3">
                                            <label class="control-label">Customer Name</label>
                                            <input type="text"  id="customer_name" class="form-control" placeholder="Enter Customer Name" value="{{ $data->customer_name ?? '' }}" disabled>
                                            <span class="kt-form__help error customer_name"></span>
                                        </div>

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

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

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

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

                                        

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

                                        <div class="form-group col-md-3">
                                            <label class="control-label">RSA MASTER</label>
                                            <select  id="rsa_master_obf" class="form-control" disabled>
                                                <option value="">Select RSA</option>
                                                @if(isset($rsa) && $rsa->isNotEmpty())
                                                    @foreach($rsa AS $row)
                                                        <option value="{{ $row->id }}" @if($data->rsa_master_obf == $row->id) selected @endif>{{ $row->amount ??'' }} - {{ $row->name }}</option>
                                                    @endforeach
                                                @endif
                                            </select>
                                            <span class="kt-form__help error rsa_master_obf"></span>
                                        </div>
                                        <div class="form-group col-md-3"> 
                                            <label class="control-label">My Convinience Program</label>
                                            
                                            <select  id="convinience_program" class="form-control" disabled>
                                                @if(isset($mcp) && $mcp->isNotEmpty())
                                                    @foreach($mcp AS $row)
                                                        <option value="{{ $row->id }}" @if($data->convinience_program == $row->id) selected @endif>{{ $row->name ??'' }}</option>
                                                    @endforeach
                                                @endif
                                            </select>
                                            <input type="checkbox"> 
                                            <span class="kt-form__help error convinience_program"></span>
                                        </div>
                                    </div>
                                    <button class="btn  btn-outline-secondary prevBtn btn-lg pull-left" type="button">Previous</button>
                                     @if(auth()->user()->can('obf-finance') == false && auth()->user()->can('obf-insuranceview') == false && auth()->user()->can('obf-rtoview') == false && auth()->user()->can('obf-fasttagview') == false)                                   
                                        <!-- <button class="btn btn-outline-primary nextBtn btn-lg pull-right" type="submit">Submit</button> -->
                                    @else                                        
                                        <button class="btn waves-effect waves-light btn-rounded btn-outline-primary nextBtn btn-lg pull-right" type="button">Next</button>
                                    @endif
                                </div>
                            </div>
                        </div>
                        <div class="row setup-content" id="step-3">
                            <div class="col-lg-12 ">
                                <div class="col-md-12">
                                    <h3> MCP Details</h3>
                                    <div class="row">

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


                            <div class="form-group col-sm-3">
                                <label for="exterior_color">MCP Plan</label>
                                <input type="text" class="form-control" id="exterior_color" value="{{ $data->carName }}" readonly>
                                <span class="kt-form__help error exterior_color"></span>
                            </div> 
                            <div class="form-group col-sm-3">
                                <label for="interior_color">Amount</label>
                                <input type="text" class="form-control" id="interior_color" value="{{ $data->mcpAmount }}" readonly>
                                <span class="kt-form__help error interior_color"></span>
                            </div>
                            <div class="form-group col-md-3">
                                <label class="control-label">Status</label>
                                    <select name="mcp_status" id="mcp_status" class="form-control">
                                        <option value="mcp_completed" @if($data->mcp_status == 'mcp_completed') selected @endif>MCP Completed</option>
                                        <option value="mcp_in_progress" @if($data->mcp_status == 'mcp_in_progress') selected @endif>MCP In-progress</option>
                                    </select>
                                <span class="kt-form__help error rto_type"></span>
                            </div>
                                    </div>
                                    <div class="col-lg-12 ">
                                <div class="col-md-12">
                                    <h3> DMS Details</h3>
                                    <div class="row">
                            <div class="form-group col-sm-3">
                                <label for="dms_invoice_no">DMS Invoice No</label>
                                <input type="text" class="form-control" name="dms_invoice_no"  value="{{ (!empty($data->dms_invoice_no)) ? $data->dms_invoice_no : ((!empty($dms_data->dms_invoice_no)) ? $dms_data->dms_invoice_no : '') }}"> 
                                <span class="kt-form__help error dms_invoice_no"></span>
                            </div>
                            
                            <div class="form-group col-sm-3">
                                <label for="dms_invoice_date">DMS Invoice Date</label>
                                <input type="date" class="form-control" name="dms_invoice_date" value="{{ (!empty($data->dms_invoice_date)) ? $data->dms_invoice_date : ((!empty($dms_data->date)) ? $dms_data->date : '') }}"> 
                                <span class="kt-form__help error dms_invoice_date"></span>
                            </div>
                            
                            <div class="form-group col-sm-3" id="fule_type">
                                <label for="fule_type">GatePass Closing Date</label> 
                                <input type="date" class="form-control" name="dms_gatepass_date" value="{{ (!empty($data->dms_gatepass_date)) ? $data->dms_gatepass_date : ((!empty($dms_data->getpass_closing_date)) ? $dms_data->getpass_closing_date : '') }}"> 
                                <span class="kt-form__help error fule_type"></span>
                            </div>


                            <div class="form-group col-sm-3">
                                <label for="exterior_color">Location</label>
                                <input type="text" class="form-control" name="dms_location" id="" value="" placeholder="Enter Location">
                                <span class="kt-form__help error exterior_color"></span>
                            </div>
                            <div class="form-group col-sm-3">
                                <label for="interior_color">OBF MCP CREATE DATE</label>
                                <input type="date" class="form-control" name="dms_mcp_create_date" id="" value="" placeholder="OBF MCP CREATE DATE">
                                <span class="kt-form__help error interior_color"></span>
                            </div>
                            <div class="form-group col-sm-3">
                                <label for="interior_color">MCP Certificate</label>
                                <input type="file" class="form-control" name="dms_mcp_certificate" value="" placeholder="MCP Certificate">
                                <span class="kt-form__help error interior_color"></span>
                            </div>   
                                    </div>                                        
                                        <button class="btn waves-effect waves-light btn-rounded btn-outline-primary nextBtn 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(){
        if($('#address_1').val() == $('#address_2').val()){
            $("#chek_address").attr("checked" ,true);
        }

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

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

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

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

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

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

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


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

     $('#pricelist_manager_id').attr('disabled',true);

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

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

                    var e_row = resp.data.pricelist_arr;

                   console.log(e_row);

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

                }
            });
            
        }



        function car_mveriant_edit(value){

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

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

                       var e_row = resp.data.pricelist_arr;

                       console.log(e_row);

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

                       html = '';

                       

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

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

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

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

        function Getpricelist_edit_get(id){

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

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

                                var html = '';                     

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

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


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

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

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

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

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

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


    
</script>

<script>
// Open the Modal


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

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


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

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

</script>

@endsection