<?php $this->view("includes/Inc_pagehead");?>
<!-- Page Styles Goes Here-->

<?php $this->view("includes/Inc_navigation");?>
<div class="m-grid__item m-grid__item--fluid m-wrapper">
  <!-- BEGIN: Subheader -->
  <div class="m-subheader ">
    <div class="d-flex align-items-center">
      <div class="mr-auto">
        <h3 class="m-subheader__title m-subheader__title--separator">
          Edit Vehicle Details
        </h3>
        <ul class="m-subheader__breadcrumbs m-nav m-nav--inline">
          <li class="m-nav__item m-nav__item--home">
            <a href="#" class="m-nav__link m-nav__link--icon">
              <i class="m-nav__link-icon la la-home"></i>
            </a>
          </li>
          <li class="m-nav__separator">
            -
          </li>
          <li class="m-nav__item">
            <a href="<?php echo base_url().'dashboard'?>" class="m-nav__link">
              <span class="m-nav__link-text">
                Home
              </span>
            </a>
          </li>
          <li class="m-nav__separator">
            -
          </li>
          <li class="m-nav__item">
            <a href="<?php echo base_url().'vehicles' ?>" class="m-nav__link">
              <span class="m-nav__link-text">
                Edit Vehicle
              </span>
            </a>
          </li>


        </ul>
      </div>
      <div>

      </div>
    </div>
  </div>
  <!-- END: Subheader -->
  <div class="m-content">
    <div class="m-portlet m-portlet--full-height">

      <!--begin: Portlet Head-->
      <div class="m-portlet__head">
        <div class="m-portlet__head-caption">
          <div class="m-portlet__head-title">
            <h3 class="m-portlet__head-text">
              Edit Vehicle (Owned)
            </h3>
          </div>
        </div>
        <div class="m-portlet__head-tools">

        </div>
      </div>
      <!--end: Portlet Head-->

      <!--begin: Form Wizard-->
      <div class="m-wizard m-wizard--2 m-wizard--success" id="m_wizard">

        <!--begin: Message container -->
        <div class="m-portlet__padding-x">

          <!-- Here you can put a message or alert -->
        </div>

        <!--end: Message container -->

        <!--begin: Form Wizard Head -->
        <div class="m-wizard__head m-portlet__padding-x">

          <!--begin: Form Wizard Progress -->
          <div class="m-wizard__progress">
            <div class="progress">
              <div class="progress-bar" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
            </div>
          </div>

          <!--end: Form Wizard Progress -->

          <!--begin: Form Wizard Nav -->
          <div class="m-wizard__nav">
            <div class="m-wizard__steps">
              <div class="m-wizard__step m-wizard__step--current" m-wizard-target="m_wizard_form_step_1">
                <a href="#" class="m-wizard__step-number">
                  <span><i class="fa fa-truck"></i></span>
                </a>
                <div class="m-wizard__step-info">
                  <div class="m-wizard__step-title">
                    1. Vehicle Information
                  </div>
                  <div class="m-wizard__step-desc">

                  </div>
                </div>
              </div>
              <div class="m-wizard__step" m-wizard-target="m_wizard_form_step_2">
                <a href="#" class="m-wizard__step-number">
                  <span><i class="fa  flaticon-layers"></i></span>
                </a>
                <div class="m-wizard__step-info">
                  <div class="m-wizard__step-title">
                    2. Finance & Renewals
                  </div>
                  <div class="m-wizard__step-desc">

                  </div>
                </div>
              </div>
            </div>
          </div>
          <!--end: Form Wizard Nav -->
        </div>
        <!--end: Form Wizard Head -->

        <!--begin: Form Wizard Form-->
        <div class="m-wizard__form">

          <form action="<?php echo base_url().'vehicles/update/own'?>" class="m-form m-form--label-align-left- m-form--state-" method="POST" enctype="multipart/form-data" id="form_vehicle_add">
            <!--begin: Form Body -->
            <div class="m-portlet__body">
              <!--begin: Form Wizard Step 1-->
              <div class="m-wizard__form-step m-wizard__form-step--current" id="m_wizard_form_step_1">
                <div class="row offset-xl-1">
                  <div class="col-xl-12">
                    <div class="m-form__section m-form__section--first">
                      <div class="m-form__heading">
                        <h3 class="m-form__heading-title">Vehicle Details</h3>
                      </div>
                    </div>
                  </div>
                </div>
                <input type="hidden" name="vehicle_id" value="<?php echo $vehicle_data->id?>" />
                <input type="hidden" name="vehicle_type" value="own" />
                <div class="row offset-xl-1" style="margin-right: 8%">
                  <div class="col-xl-12">
                    <div class="form-group m-form__group">
                      <label>Vehicle Name:</label>
                      <input value="<?php echo $vehicle_data->vehicle_name?>" style="text-transform: uppercase;" type="text" disabled class="form-control m-input m-input--air m-input--pill">
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                </div>
                <div class="row offset-xl-1" style="margin-right: 8%">
                  <div class="col-xl-4">
                    <div class="form-group m-form__group">
                      <label>Vehicle No:</label>
                      <input value="<?php echo $vehicle_data->vehicle_no?>" style="text-transform: uppercase;" type="text" required name="vehicle_number" class="form-control m-input m-input--air m-input--pill" placeholder="Eg: KL-11-AA-1001" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-4">
                    <div class="form-group m-form__group">
                      <label>Vehicle Type:</label>
                      <select class="form-control m-bootstrap-select m_selectpicker m-bootstrap-select--air m-bootstrap-select--pill" id="vehicle_type_cat" name="vehicle_type_cat">
                        <option selected disabled>Select Vehicle Type</option>
                        <option value="Light Vehicle">Light Vehicle</option>
                        <option value="Medium Vehicle">Medium Vehicle</option>
                        <option value="Heavy Vehicle">Heavy Vehicle</option>
                        <option value="Machineries">Machineries</option>
                      </select>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-4">
                    <div class="form-group m-form__group">
                      <label>Manufacturer:</label>
                      <input type="text" value="<?php echo $vehicle_data->manufacturer?>" style="text-transform: uppercase;" required name="manufacturer" class="form-control m-input m-input--air m-input--pill" placeholder="Eg: TATA" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                </div>
                <div class="row offset-xl-1" style="margin-right: 8%">
                  <div class="col-xl-4">
                    <div class="form-group m-form__group">
                      <label>Vehicle Category:</label>
                      <input type="text" value="<?php echo $vehicle_data->vehicle_category?>" style="text-transform: uppercase;" required name="category" class="form-control m-input m-input--air m-input--pill" placeholder="Eg: TIPPER" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-4">
                    <div class="form-group m-form__group">
                      <label>Vehicle Model:</label>
                      <input type="text" value="<?php echo $vehicle_data->model?>" style="text-transform: uppercase;" required name="model" class="form-control m-input m-input--air m-input--pill" placeholder="Eg: 1613" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-4">
                    <div class="form-group m-form__group">
                      <label>Dealer:</label>
                      <input type="text" value="<?php echo $vehicle_data->dealer?>" name="dealer" class="form-control m-input m-input--air m-input--pill" placeholder="Dealer Name" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                </div>
                <div class="row offset-xl-1" style="margin-right: 8%">
                  <div class="col-xl-4">
                    <div class="form-group m-form__group">
                      <label>Engine No:</label>
                      <input type="text" value="<?php echo $vehicle_data->engine_no?>"  name="engine_no" class="form-control m-input m-input--air m-input--pill" placeholder="Engine No" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-4">
                    <div class="form-group m-form__group">
                      <label>Chasis No:</label>
                      <input type="text" value="<?php echo $vehicle_data->chasis_no?>" name="chasis_no" class="form-control m-input m-input--air m-input--pill" placeholder="Chasis No" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-4">
                    <div class="form-group m-form__group">
                      <label>Delivery Date:</label>
                      <input type="text" value="<?php if($vehicle_data->date_of_delivery!='0000-00-00'){ echo date('d-m-Y',strtotime($vehicle_data->date_of_delivery));} ?>"  name="delivery_date" class="form-control m-input m-input--air m-input--pill date_picker" data-date-format="dd-mm-yyyy">
                      <span class="m-form__help"></span>
                    </div>
                  </div>

                </div>
                <div class="row offset-xl-1" style="margin-right: 8%">
                  <div class="col-xl-4">
                    <div class="form-group m-form__group">
                      <label for="user_name">
                        Basic Charge
                      </label>
                      <input required  value="<?php echo $vehicle_data->basic_charge?>" type="text"  name="basic_charge"  class="form-control m-input m-input--air m-input--pill" placeholder="Basic Charge" aria-describedby="basic-addon1">
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-4">
                    <div class="form-group m-form__group">
                      <label for="user_name">
                        Work Duration Type
                      </label>
                      <select required class="form-control m-bootstrap-select m_selectpicker m-bootstrap-select--air m-bootstrap-select--pill" id="work_duration_type" name="work_duration_type_edit">
                        <option disabled="" selected="">Select the Duration type</option>
                        <option value="Hour">Hour</option>
                        <option value="Trip">Trip</option>
                        <option value="Kilometer">Kilometer</option>
                        <option value="Day">Day</option>
                        <option value="Month">Month</option>
                      </select>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-4">
                    <div class="form-group m-form__group">
                      <label for="user_name">
                        Consignee Name
                      </label>
                      <div class="input-group m-input-group m-input-group--pill">
                        <div class="input-group-prepend">
                          <a href="#consignee_add_modal"   data-toggle="modal" data-target="#consignee_add_modal" class="btn btn-focus">
                            <i class="fa fa-plus-circle"></i>
                          </a>
                        </div>
                        <select style="width: 80%"  class="form-control m-select2 m-select2-general" required id="consignee_edit" name="consignee">

                        </select>
                      </div>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-4">
                    <div class="form-group m-form__group">
                      <label>Vehicle Status:</label>
                      <select required class="form-control m-bootstrap-select m_selectpicker m-bootstrap-select--air m-bootstrap-select--pill" id="vehicle_status" name="vehicle_status">
                        <option disabled="" selected>Select Status</option>
                        <option value="1">Active</option>
                        <option value="2">On Repair</option>
                      </select>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-4">
                    <div class="form-group m-form__group">
                      <label>Loading Capacity (CFT):</label>
                      <input type="text" value="<?php echo $vehicle_data->loading_capacity_cft?>" name="loading_capacity_cft" class="form-control m-input m-input--air m-input--pill" placeholder="Loading Capacity (CFT)" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-4">
                    <div class="form-group m-form__group">
                      <label>Loading Capacity (TON):</label>
                      <input type="text" value="<?php echo $vehicle_data->loading_capacity_ton?>" name="loading_capacity_ton" class="form-control m-input m-input--air m-input--pill" placeholder="Loading Capacity (TON)" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-4">
                    <div class="form-group m-form__group">
                      <label>Opening Balance Payable:</label>
                      <input type="text" required value="<?php echo $vehicle_data->vehicle_op_balance?>" name="op_balance" class="form-control m-input m-input--air m-input--pill" placeholder="OP Balance" >
                      <span class="m-form__help">Outstanding Balance At the time of Creation</span>
                    </div>
                  </div>
                </div>
              </div>
              <!--end: Form Wizard Step 1-->

              <!--begin: Form Wizard Step 2-->
              <div class="m-wizard__form-step" id="m_wizard_form_step_2">
                <div class="row offset-xl-1">
                  <div class="col-xl-12">
                    <div class="m-form__section m-form__section--first">
                      <div class="m-form__heading">
                        <h3 class="m-form__heading-title">Finance Details</h3>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="row offset-xl-1">
                  <div class="col-xl-3">
                    <div class="form-group m-form__group" style="margin-bottom:20px">
                      <label>Have EMI/Loans:</label>
                      <br/>
                      <span class="m-bootstrap-switch m-bootstrap-switch--pill m-bootstrap-switch--air">
                        <input data-type="emi" class="renewal_switches" id="have_emi" name="have_emi" data-switch="true" type="checkbox" data-on-color="success" data-off-color="danger" data-on-text="Yes" data-off-text="No">
                      </span>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-3">
                    <div class="form-group m-form__group emi_div">
                      <label>Financier:</label>
                      <div class="input-group m-input-group m-input-group--pill">
                        <div class="input-group-prepend" id='suppler_add_btn'>
                          <a href=""   data-toggle="modal" data-target="#provider_add_modal" class="btn btn-focus">
                            <i class="fa fa-plus-circle"></i>
                          </a>
                        </div>
                        <select style="width: 75%" class="form-control m-select2 m-select2-general emi_required_fields" required id="provider_add" name="financier" data-placeholder="Select Financier">

                        </select>
                      </div>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-3">
                    <div class="form-group m-form__group emi_div">
                      <label>Total Amount:</label>
                      <input type="text"  name="total_loan_amount" value="<?php echo $vehicle_data->total_amount?>" class="form-control m-input m-input--air m-input--pill emi_required_fields" placeholder="Total Amount" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-3">
                    <div class="form-group m-form__group emi_div">
                      <label>EMI Amount:</label>
                      <input type="text"  name="emi_amount" value="<?php echo $vehicle_data->emi_amount?>" class="form-control m-input m-input--air m-input--pill emi_required_fields" placeholder="EMI Amount" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                </div>
                <div class="row offset-xl-1">
                  <div class="col-xl-3">
                    <div class="form-group m-form__group emi_div">
                      <label>Loan No:</label>
                      <input type="text"  name="loan_no" value="<?php echo $vehicle_data->loan_no?>" class="form-control m-input m-input--air m-input--pill" placeholder="Loan No" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-3">
                    <div class="form-group m-form__group emi_div">
                      <label>Installments:</label>
                      <input type="text"  name="installments" value="<?php echo $vehicle_data->installments?>" class="form-control m-input m-input--air m-input--pill" placeholder="No of Installments" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-3">
                    <div class="form-group m-form__group emi_div">
                      <label>Purchase Month:</label>
                      <input type="text" value="<?php if($vehicle_data->purchase_month!='0000-00-00'){ echo date('M Y',strtotime($vehicle_data->purchase_month));} ?>" name="purchase_month" class="form-control m-input m-input--air m-input--pill month_picker" data-date-format="mm-yyyy">
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-3">
                    <div class="form-group m-form__group emi_div">
                      <label>Closing Month:</label>
                      <input type="text" value="<?php if($vehicle_data->closing_month!='0000-00-00'){ echo date('M Y',strtotime($vehicle_data->closing_month));} ?>" name="close_month" class="form-control m-input m-input--air m-input--pill month_picker" data-date-format="mm-yyyy">
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                </div>
                <div class="row offset-xl-1">
                  <div class="col-xl-3">
                    <div class="form-group m-form__group emi_div">
                      <label>EMI Date:</label>
                      <select required class="form-control m-bootstrap-select m_selectpicker m-bootstrap-select--air m-bootstrap-select--pill emi_required_fields" id="emi_date" name="emi_date">
                        <option disabled="" selected>Select EMI Date</option>
                        <?php for($i=1;$i<=31;$i++){ ?>
                          <option value="<?php echo $i?>"><?php echo $i?></option>
                        <?php } ?>
                      </select>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-3">
                    <div class="form-group m-form__group emi_div">
                      <label>EMI Status:</label>
                      <select required class="form-control m-bootstrap-select m_selectpicker m-bootstrap-select--air m-bootstrap-select--pill" id="emi_status" name="emi_status">
                        <option disabled="" selected>Select Status</option>
                        <option value="1">Ongoing</option>
                        <option value="2">Finished</option>
                      </select>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-3">
                    <div class="form-group m-form__group emi_div emi_next_renewal_date_div">
                      <label>Next Renewal Date:</label>
                      <div class="input-group m-input-group m-input-group--pill">
                        <div class="input-group-prepend"><span class="input-group-text" id="emi_date_info"></span></div>
                        <input type="text" id="emi_next_month" value="<?php if($vehicle_data->next_emi_renewal_date!='0000-00-00'){ echo date('M Y',strtotime($vehicle_data->next_emi_renewal_date));} ?>" name="emi_next_month" class="form-control m-input m-input--air m-input--pill month_picker" data-date-format="mm-yyyy">
                      </div>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-3">
                    <div class="form-group m-form__group emi_div">
                      <label>EMI Bank A/C:</label>
                      <div class="m-select2 m-select2--air m-select2--pill">
                        <select id="emi_bank_account" name="emi_bank_account" style="width: 100%" class="form-control m-input emi_required_fields"  aria-describedby="basic-addon1">
                          <?php
                          foreach($this->config->item('account_heads') as $row):
                            if($row->account_type==36){?>
                              <option value="<?php echo $row->acc_head_id?>"><?php echo $row->acc_head_name?></option>
                            <?php }
                          endforeach;
                          ?>
                        </select>
                      </div>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-3">
                    <div class="form-group m-form__group emi_div">
                      <label>No of Installments Left:</label>
                      <input type="text" value="<?php echo $vehicle_data->installments_left?>" name="installments_left" class="form-control m-input m-input--air m-input--pill emi_required_fields" placeholder="No of Installments Left" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-3">
                    <div class="form-group m-form__group emi_div">
                      <label>Current Payable Loan Amount:</label>
                      <input type="text" value="<?php echo $vehicle_data->current_payable_amount?>" name="emi_current_payable_amount" class="form-control m-input m-input--air m-input--pill emi_required_fields" placeholder="Current Payable Amount" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                </div>
                <div class="row offset-xl-1">
                  <div class="col-xl-12">
                    <div class="m-form__section m-form__section--first">
                      <div class="m-form__heading">
                        <h3 class="m-form__heading-title">Other Renewal Details</h3>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="row offset-xl-1">
                  <div class="col-xl-3">
                    <div class="form-group m-form__group" style="margin-bottom:20px">
                      <label>Have Insurance:</label>
                      <br/>
                      <span class="m-bootstrap-switch m-bootstrap-switch--pill m-bootstrap-switch--air">
                        <input data-type="insurance" class="renewal_switches" id="have_insurance" name="have_insurance" data-switch="true" type="checkbox" data-on-color="success" data-off-color="danger" data-on-text="Yes" data-off-text="No">
                      </span>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-3">
                    <div class="form-group m-form__group insurance_div">
                      <label>Insurer:</label>
                      <input type="text"  name="insurer" value="<?php echo $vehicle_data->insurer?>" class="form-control m-input m-input--air m-input--pill insurance_required_fields" placeholder="Insurance Provider" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-3">
                    <div class="form-group m-form__group insurance_div">
                      <label>Next Renewal Date:</label>
                      <input type="text" data-date-format="dd-mm-yyyy" value="<?php if($vehicle_data->insurance_renewal_date!='0000-00-00'){ echo date('d-m-Y',strtotime($vehicle_data->insurance_renewal_date));} ?>"  name="insurance_date" class="date_picker form-control m-input m-input--air m-input--pill insurance_required_fields" placeholder="" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                </div>
                <div class="row offset-xl-1">
                  <div class="col-xl-3">
                    <div class="form-group m-form__group" style="margin-bottom:20px">
                      <label>Have Tax:</label>
                      <br/>
                      <span class="m-bootstrap-switch m-bootstrap-switch--pill m-bootstrap-switch--air">
                        <input data-type="tax" class="renewal_switches" id="have_tax" name="have_tax" data-switch="true" type="checkbox" data-on-color="success" data-off-color="danger" data-on-text="Yes" data-off-text="No">
                      </span>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-3">
                    <div class="form-group m-form__group tax_div">
                      <label>Next Renewal Date:</label>
                      <input type="text" value="<?php if($vehicle_data->tax_renewal_date!='0000-00-00'){ echo date('d-m-Y',strtotime($vehicle_data->tax_renewal_date));} ?>" data-date-format="dd-mm-yyyy"  name="tax_date" class="date_picker form-control m-input m-input--air m-input--pill tax_required_fields" placeholder="" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                </div>
                <div class="row offset-xl-1">
                  <div class="col-xl-3">
                    <div class="form-group m-form__group" style="margin-bottom:20px">
                      <label>Have Break Renewal:</label>
                      <br/>
                      <span class="m-bootstrap-switch m-bootstrap-switch--pill m-bootstrap-switch--air">
                        <input data-type="break" class="renewal_switches" id="have_break" name="have_break" data-switch="true" type="checkbox" data-on-color="success" data-off-color="danger" data-on-text="Yes" data-off-text="No">
                      </span>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-3">
                    <div class="form-group m-form__group break_div">
                      <label>Next Renewal Date:</label>
                      <input type="text" value="<?php if($vehicle_data->break_renewal_date!='0000-00-00'){ echo date('d-m-Y',strtotime($vehicle_data->break_renewal_date));} ?>" data-date-format="dd-mm-yyyy"  name="break_date" class="date_picker form-control m-input m-input--air m-input--pill break_required_fields" placeholder="" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                </div>
                <div class="row offset-xl-1">
                  <div class="col-xl-3">
                    <div class="form-group m-form__group" style="margin-bottom:20px">
                      <label>Have Permit Renewal:</label>
                      <br/>
                      <span class="m-bootstrap-switch m-bootstrap-switch--pill m-bootstrap-switch--air">
                        <input data-type="permit" class="renewal_switches" id="have_permit" name="have_permit" data-switch="true" type="checkbox" data-on-color="success" data-off-color="danger" data-on-text="Yes" data-off-text="No">
                      </span>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-3">
                    <div class="form-group m-form__group permit_div">
                      <label>Next Renewal Date:</label>
                      <input type="text" value="<?php if($vehicle_data->permit_renewal_date!='0000-00-00'){ echo date('d-m-Y',strtotime($vehicle_data->permit_renewal_date));} ?>" data-date-format="dd-mm-yyyy"  name="permit_date" class="date_picker form-control m-input m-input--air m-input--pill permit_required_fields" placeholder="" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                </div>
                <div class="row offset-xl-1">
                  <div class="col-xl-3">
                    <div class="form-group m-form__group" style="margin-bottom:20px">
                      <label>Have Fitness Renewal:</label>
                      <br/>
                      <span class="m-bootstrap-switch m-bootstrap-switch--pill m-bootstrap-switch--air">
                        <input data-type="fitness" class="renewal_switches" id="have_fitness" name="have_fitness" data-switch="true" type="checkbox" data-on-color="success" data-off-color="danger" data-on-text="Yes" data-off-text="No">
                      </span>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-3">
                    <div class="form-group m-form__group fitness_div">
                      <label>Next Renewal Date:</label>
                      <input type="text" value="<?php if($vehicle_data->fitness_renewal_date!='0000-00-00'){ echo date('d-m-Y',strtotime($vehicle_data->fitness_renewal_date));} ?>" data-date-format="dd-mm-yyyy"  name="fitness_date" class="date_picker form-control m-input m-input--air m-input--pill fitness_required_fields" placeholder="" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                </div>
                <div class="row offset-xl-1">
                  <div class="col-xl-3">
                    <div class="form-group m-form__group" style="margin-bottom:20px">
                      <label>Have Pollution Renewal:</label>
                      <br/>
                      <span class="m-bootstrap-switch m-bootstrap-switch--pill m-bootstrap-switch--air">
                        <input data-type="pollution" class="renewal_switches" id="have_pollution" name="have_pollution" data-switch="true" type="checkbox" data-on-color="success" data-off-color="danger" data-on-text="Yes" data-off-text="No">
                      </span>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-3">
                    <div class="form-group m-form__group pollution_div">
                      <label>Next Renewal Date:</label>
                      <input type="text" data-date-format="dd-mm-yyyy" value="<?php if($vehicle_data->pollution_renewal_date!='0000-00-00'){ echo date('d-m-Y',strtotime($vehicle_data->pollution_renewal_date));} ?>"  name="pollution_date" class="date_picker form-control m-input m-input--air m-input--pill pollution_required_fields" placeholder="" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                </div>
                <div class="row offset-xl-1">
                  <div class="col-xl-3">
                    <div class="form-group m-form__group" style="margin-bottom:20px">
                      <label>Have GPS Renewal:</label>
                      <br/>
                      <span class="m-bootstrap-switch m-bootstrap-switch--pill m-bootstrap-switch--air">
                        <input data-type="gps" class="renewal_switches" id="have_gps" name="have_gps" data-switch="true" type="checkbox" data-on-color="success" data-off-color="danger" data-on-text="Yes" data-off-text="No">
                      </span>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-3">
                    <div class="form-group m-form__group gps_div">
                      <label>Next Renewal Date:</label>
                      <input type="text" data-date-format="dd-mm-yyyy" value="<?php if($vehicle_data->gps_renewal_date!='0000-00-00'){ echo date('d-m-Y',strtotime($vehicle_data->gps_renewal_date));} ?>"  name="gps_date" class="date_picker form-control m-input m-input--air m-input--pill gps_required_fields" placeholder="" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                </div>
                <div class="row offset-xl-1">
                  <div class="col-xl-3">
                    <div class="form-group m-form__group" style="margin-bottom:20px">
                      <label>Have Speed Governor Renewal:</label>
                      <br/>
                      <span class="m-bootstrap-switch m-bootstrap-switch--pill m-bootstrap-switch--air">
                        <input data-type="speed_governor" class="renewal_switches" id="have_speed_governor" name="have_speed_governor" data-switch="true" type="checkbox" data-on-color="success" data-off-color="danger" data-on-text="Yes" data-off-text="No">
                      </span>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-3">
                    <div class="form-group m-form__group speed_governor_div">
                      <label>Next Renewal Date:</label>
                      <input type="text" data-date-format="dd-mm-yyyy" value="<?php if($vehicle_data->speed_governor_renewal_date!='0000-00-00'){ echo date('d-m-Y',strtotime($vehicle_data->speed_governor_renewal_date));} ?>"  name="speed_governor_date" class="date_picker form-control m-input m-input--air m-input--pill speed_governor_required_fields" placeholder="" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                </div>
                <div class="row offset-xl-1">
                  <div class="col-xl-3">
                    <div class="form-group m-form__group" style="margin-bottom:20px">
                      <label>Have Welfare Renewal:</label>
                      <br/>
                      <span class="m-bootstrap-switch m-bootstrap-switch--pill m-bootstrap-switch--air">
                        <input data-type="welfare" class="renewal_switches" id="have_welfare" name="have_welfare" data-switch="true" type="checkbox" data-on-color="success" data-off-color="danger" data-on-text="Yes" data-off-text="No">
                      </span>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                  <div class="col-xl-3">
                    <div class="form-group m-form__group welfare_div">
                      <label>Next Renewal Date:</label>
                      <input type="text" data-date-format="dd-mm-yyyy" value="<?php if($vehicle_data->welfare_renewal_date!='0000-00-00'){ echo date('d-m-Y',strtotime($vehicle_data->welfare_renewal_date));} ?>" name="welfare_date" class="date_picker form-control m-input m-input--air m-input--pill welfare_required_fields" placeholder="" >
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                </div>
              </div>
              <!--end: Form Wizard Step 2-->
            </div>

            <!--end: Form Body -->
            <!--begin: Form Actions -->
            <div class="m-portlet__foot m-portlet__foot--fit m--margin-top-40">
              <div class="m-form__actions">
                <div class="row">
                  <div class="col-lg-2"></div>
                  <div class="col-lg-4 m--align-left">
                    <a href="#" class="btn btn-secondary m-btn m-btn--custom m-btn--icon" data-wizard-action="prev">
                      <span>
                        <i class="la la-arrow-left"></i>&nbsp;&nbsp;
                        <span>Back</span>
                      </span>
                    </a>
                  </div>
                  <div class="col-lg-4 m--align-right">
                    <a href="#" class="btn btn-primary m-btn m-btn--custom m-btn--icon" data-wizard-action="submit">
                      <span>
                        <i class="la la-check"></i>&nbsp;&nbsp;
                        <span>Submit</span>
                      </span>
                    </a>
                    <a href="#" class="btn btn-warning m-btn m-btn--custom m-btn--icon" data-wizard-action="next">
                      <span>
                        <span>Continue</span>&nbsp;&nbsp;
                        <i class="la la-arrow-right"></i>
                      </span>
                    </a>
                  </div>
                  <div class="col-lg-2"></div>
                </div>
              </div>
            </div>
            <!--end: Form Actions -->
          </form>
        </div>
        <!--end: Form Wizard Form-->
      </div>
      <!--end: Form Wizard-->
      <div class="modal fade" tabindex="-1" id="provider_add_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog " role="document" style="max-width: 800px">
          <div class="modal-content">
            <div class="modal-header" style="background-color: #36a3f7;border-radius: 4px">
              <h5 class="modal-title" id="exampleModalLabel" style="color: #ffffff" >
                Create New Loan Provider
              </h5>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">
                  &times;
                </span>
              </button>
            </div>
            <form autocomplete="off" id="form_provider_add" data-form-type="provider_create" data-modal-id="provider_add_modal" method="post" action="<?php echo base_url().'loans/create_provider'?>" enctype="multipart/form-data" class="m-form m-form--fit m-form--state m-form--label-align-right " >
              <div class="modal-body">
                <div class="m-form__content">
                  <div class="m-alert m-alert--icon alert alert-warning m--hide" role="alert" id="form_provider_add_msg">
                    <div class="m-alert__icon">
                      <i class="la la-warning"></i>
                    </div>
                    <div class="m-alert__text">
                      Oh snap! Change a few things up and try submitting again.
                    </div>
                    <div class="m-alert__close">
                      <button type="button" class="close" data-close="alert" aria-label="Close"></button>
                    </div>
                  </div>
                </div>
                <div class="row">
                  <div class="col-lg-12">
                    <div class="form-group m-form__group">
                      <label for="user_name">
                        Loan Provider Name
                      </label>
                      <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                        <div class="input-group-prepend">
                          <span class="input-group-text" id="basic-addon1">
                            <i class="la la-tag"></i>
                          </span>
                        </div>
                        <input required type="text" name="name"  class="form-control m-input form_provider_add_fields" placeholder="Provider Name" aria-describedby="basic-addon1">
                      </div>
                      <span class="m-form__help"></span>
                    </div>
                  </div>
                </div>
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">
                  Close
                </button>
                <button type="submit" class="btn btn-primary form_submit_btn">
                  Submit
                </button>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
</div>
<!-- end:: Body -->
<!-- begin::Footer -->

<?php $this->view("includes/Inc_footer");?>
<?php $this->view("modules/include_modals/modal_vehicle_add");?>
<?php $this->view("modules/include_modals/modal_vehicle_consignee_add");?>
<!-- end::Footer -->
</div>
<!-- end:: Page -->

<?php $this->view("includes/Inc_sidebar");?>
<?php $this->view("includes/Inc_scripts");?>
<?php $this->view("modules/include_scripts/vehicles_scripts");?>

<script type="text/javascript">
$("[data-switch=true]").bootstrapSwitch();
$(".m_selectpicker").selectpicker();
$("#provider_add").select2({
  dropdownParent: $("#form_vehicle_add"),
  placeholder: "Select Provider"
})
function select_provider(select_id,selected_value='',type=''){
  $('#'+select_id).html('');
  if(type=='filter'){
    $('#'+select_id).append("<option value='all' selected >All Providers</option>");
  }else{
    $('#'+select_id).append("<option disabled selected >Select Provider</option>");
  }
  $.post("<?php echo base_url() ?>loans/select_provider",{},function(data) {
    var obj = $.parseJSON(data);
    var i=0;
    if(obj.count>0) {
      while (i < obj.data.length) {
        $('#'+select_id).append("<option value=" + obj.data[i]['loan_provider_id'] + ">" +obj.data[i]['loan_provider_name'] + "</option>");
        i++;
      }
      if(selected_value!=''){
        $('#'+select_id).val(selected_value).trigger("change");
      }
    }
  })
}
select_provider('provider_add');
$("#emi_bank_account").select2({
  placeholder: "Select Bank A/C",
  dropdownParent: $("#form_vehicle_add")
})
$("#consignee_edit").select2({
  placeholder: "Select Consignee",
  dropdownParent: $("#form_vehicle_add")
})
$(".emi_div,.insurance_div,.tax_div,.break_div,.permit_div,.fitness_div,.pollution_div,.gps_div,.speed_governor_div,.welfare_div").hide();
$(".emi_required_fields,.insurance_required_fields,.tax_required_fields,.break_required_fields,.permit_required_fields,.fitness_required_fields,.pollution_required_fields,.gps_required_fields,.speed_governor_required_fields,.welfare_required_fields").removeAttr('required',true);
$('.renewal_switches').on('switchChange.bootstrapSwitch', function (event, state) {
  var type = $(this).data('type');
  if($(this).is(':checked')) {
    $("."+type+"_div").show();
    $("."+type+"_required_fields").attr('required',true);
  } else {
    $("."+type+"_div").hide();
    $("."+type+"_required_fields").removeAttr('required',true);
  }
});
$(".date_picker").datepicker( {
  todayHighlight:!0, orientation:"bottom left", templates: {
    leftArrow: '<i class="la la-angle-left"></i>', rightArrow: '<i class="la la-angle-right"></i>'
  }
})
$(".month_picker").datepicker( {
  todayHighlight:!0, orientation:"bottom left",format: "M yyyy",viewMode: "months", minViewMode: "months", templates: {
    leftArrow: '<i class="la la-angle-left"></i>', rightArrow: '<i class="la la-angle-right"></i>'
  }
})

$("#vehicle_type_cat").val("<?php echo $vehicle_data->vehicle_type_cat?>").trigger('change');
$("#work_duration_type").val("<?php echo $vehicle_data->work_duration_type?>").trigger('change');
$("#vehicle_status").val("<?php echo $vehicle_data->vehicle_status?>").trigger('change');
select_consignee('consignee_edit',"<?php echo $vehicle_data->consignee?>");
$('#emi_date').on("change", function(e) {
  var emi_date = parseFloat($('#emi_date').val());
  if(emi_date<10){
    emi_date="0"+emi_date;
  }
  $("#emi_date_info").text(emi_date+" -");
})
$('#emi_status').on("change", function(e) {
  var emi_status = $('#emi_status').val();
  if(emi_status==1){
    $('.emi_next_renewal_date_div').show();
    $('#emi_next_month').attr('required',true);
  }else{
    $('.emi_next_renewal_date_div').hide();
    $('#emi_next_month').removeAttr('required',true);
  }
})
<?php if($vehicle_data->emi_status!=0){?>
  $('#have_emi').bootstrapSwitch('state',true);
  $("#emi_date").val("<?php echo $vehicle_data->emi_date?>").trigger('change');
  $("#emi_date_info").text("<?php echo sprintf("%02d", $vehicle_data->emi_date)?>"+" -");
  $("#emi_bank_account").val("<?php echo $vehicle_data->emi_bank_account?>").trigger('change');
  $("#emi_status").val("<?php echo $vehicle_data->emi_status?>").trigger('change');
  select_provider('provider_add',"<?php echo $vehicle_data->financier?>");
  var emi_status = "<?php echo $vehicle_data->emi_status?>";
  if(emi_status==1){
    $('.emi_next_renewal_date_div').show();
    $('#emi_next_month').attr('required',true);
  }else{
    $('.emi_next_renewal_date_div').hide();
    $('#emi_next_month').removeAttr('required',true);
  }
<?php } ?>
<?php if($vehicle_data->insurance_renewal_date!='0000-00-00'){?>
  $('#have_insurance').bootstrapSwitch('state',true);
<?php } ?>
<?php if($vehicle_data->tax_renewal_date!='0000-00-00'){?>
  $('#have_tax').bootstrapSwitch('state',true);
<?php } ?>
<?php if($vehicle_data->break_renewal_date!='0000-00-00'){?>
  $('#have_break').bootstrapSwitch('state',true);
<?php } ?>
<?php if($vehicle_data->permit_renewal_date!='0000-00-00'){?>
  $('#have_permit').bootstrapSwitch('state',true);
<?php } ?>
<?php if($vehicle_data->fitness_renewal_date!='0000-00-00'){?>
  $('#have_fitness').bootstrapSwitch('state',true);
<?php } ?>
<?php if($vehicle_data->pollution_renewal_date!='0000-00-00'){?>
  $('#have_pollution').bootstrapSwitch('state',true);
<?php } ?>
<?php if($vehicle_data->gps_renewal_date!='0000-00-00'){?>
  $('#have_gps').bootstrapSwitch('state',true);
<?php } ?>
<?php if($vehicle_data->speed_governor_renewal_date!='0000-00-00'){?>
  $('#have_speed_governor').bootstrapSwitch('state',true);
<?php } ?>
<?php if($vehicle_data->welfare_renewal_date!='0000-00-00'){?>
  $('#have_welfare').bootstrapSwitch('state',true);
<?php } ?>
</script>

<!--begin::Page Snippets -->
<script>
$("#vehicle_menu").addClass('m-menu__item--active m-menu__item--open');
$("#vehicle_menu_1").addClass('m-menu__item--active');

</script>
<script>
var WizardDemo = (function () {
  $("#m_wizard");
  var e,
  r,
  i = $("#form_vehicle_add");
  return {
    init: function () {
      var n;
      $("#m_wizard"),
      (i = $("#form_vehicle_add")),
      (r = new mWizard("m_wizard", { startStep: 1 })).on("beforeNext", function (r) {
        !0 !== e.form() && r.stop();
      }),
      r.on("change", function (e) {
        mUtil.scrollTop();
      }),
      r.on("change", function (e) {
        1 === e.getStep();
      }),
      (e = i.validate({
        ignore: ":hidden",
        rules: {
          name: { required: !0 },
          basic_charge: { required: !0, number: !0 },
          total_loan_amount: { number: !0 },
          installments: { number: !0 },
          loading_capacity_cft: { number: !0 },
          loading_capacity_ton: { number: !0 },
        },
        invalidHandler: function (e, r) {
          mUtil.scrollTop(), swal({ title: "", text: "There are some errors in your submission. Please correct them.", type: "error", confirmButtonClass: "btn btn-secondary m-btn m-btn--wide" });
        },
        submitHandler: function (e) {},
      })),
      (n = i.find('[data-wizard-action="submit"]')).on("click", function (r) {
        r.preventDefault(),
        e.form() &&
        (mApp.progress(n),
        i.ajaxSubmit({
          success: function (e, t, r, s) {
            mApp.unprogress(n);
            var obj = $.parseJSON(e);
            if (obj.status == 1) {
              swal({
                width: 500,
                title: obj.flashdata_title,
                text: obj.flashdata_msg,
                type: obj.flashdata_type,
                showCancelButton: 0,
                confirmButtonText: "OK",
                cancelButtonText: "",
                confirmButtonColor: '#3085d6',
                cancelButtonColor: '#d33',
                reverseButtons: !0,
                closeOnClickOutside: false,
                allowOutsideClick: false,
              }).then(function(e) {
                window.location.replace("<?php echo base_url()?>vehicles");
              })
            } else {
              toastr[obj.flashdata_type](obj.flashdata_msg, obj.flashdata_title);
            }
            if (obj == null) {
              setTimeout(function () {
                toastr["warning"]("Your Attempt is Timed Out. Please Try Again.", "Timed Out");
              }, 2e4)
            }
          },error: function() {
            toastr["error"]("Sorry. There Has Been Some Error Occurred. Please Try Again.", "Error");
          }
        }));
      });
    },
  };
})();
jQuery(document).ready(function () {
  WizardDemo.init();
});
$(".form_submit_btn").click(function (e) {
  e.preventDefault();
  var a = $(this),
  l = $(this).closest("form"),
  action = l.attr('action');
  var form_id = l.attr('id');
  l.validate({
    rules: {
      op_balance: {
        number: !0
      },
      basic_wage: {
        number: !0
      },
      contact_no: {
        number: !0
      }
    }, invalidHandler: function (e, r) {
      var i = $("#" + form_id + "_msg");
      i.removeClass("m--hide").show(), mUtil.scrollTo(i, -200)
    }, submitHandler: function (e) {
    }
  }), l.valid() && (a.addClass("m-loader m-loader--right m-loader--light").attr("disabled", !0),
  l.ajaxSubmit({
    url: action,
    success: function (e, t, r, s) {
      var modal_id = l.attr('data-modal-id');
      var form_type = l.attr('data-form-type');
      $("#" + form_id + "_msg").addClass("m--hide");
      // Block UI
      mApp.blockPage({
        overlayColor: "#000000",
        type: "loader",
        state: "success",
        message: "Please wait..."
      }), setTimeout(function () {
        mApp.unblockPage()
      }, 2e3);
      var obj = $.parseJSON(e);
      if (obj.status == 1) {
        a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
        $("#"+modal_id).modal('toggle');
        $("."+form_id+"_fields").val('');
        $("."+form_id+"_select").val('').trigger("change");
        toastr[obj.flashdata_type](obj.flashdata_msg, obj.flashdata_title);
        select_consignee('consignee_add');
        select_consignee('consignee_edit');
        select_provider('provider_add');
      } else {
        a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
        toastr[obj.flashdata_type](obj.flashdata_msg, obj.flashdata_title);
      }
      if (obj == null) {
        setTimeout(function () {
          a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
          toastr["warning"]("Your Attempt is Timed Out. Please Try Again.", "Timed Out");
        }, 2e4)
      }
    },error: function() {
      a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
      toastr["error"]("Sorry. There Has Been Some Error Occurred. Please Try Again.", "Error");
    }
  })
)
});
</script>
