  <?php
  $Currency = getCurrency();
  
?>
<!-- PAGE-INDEX-STARTS -->

<div class="breadcrumbs">
    <div class="breadcrumbs-inner">
        <div class="row m-0">
            <div class="col-sm-4">
                <div class="page-header float-left">
                    <div class="page-title">
                        <h1><?= $pTitle ?></h1>
                    </div>
                </div>
            </div>
            <div class="col-sm-8">
                <div class="page-header float-right">
                    <div class="page-title">
                        <ol class="breadcrumb text-right">
                            <li><a href="<?= base_url() ?>">Dashboard</a></li>
                            <li><a ><?= $menu ?></a></li>
                            <li class="active"><?= $smenu ?></li>
                        </ol>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- PAGE-INDEX-ENDS -->
<?php
  $Currency = getCurrency();
  
?>
<!-- PAGE-CONTENT-STARTS -->

<div class="content">
  <div class="animated fadeIn">
      <div class="row">
        <div class="col-lg-12">
        <?php 
        $cid=$this->session->flashdata('customer_id');
        $url = (!isset($vehicle_id)||empty($vehicle_id))
        ?'Vehicle_details/create_vehicle':'Vehicle_details/edit_vehicle/'.$vehicle_id;
        if($this->session->flashdata('message')) { 
        $flashdata = $this->session->flashdata('message'); ?>
          <div class="alert alert-<?= $flashdata['class'] ?>">
            <button class="close" data-dismiss="alert" type="button">×</button>
            <?= $flashdata['message'] ?>
          </div>
          <?php } ?>
          <form role="form" action="<?= base_url($url) ?>" method="post" class="validate" data-parsley-validate="" enctype="multipart/form-data">
            <div class="card">
              <div class="card-header">
                <strong><?= $pDescription ?></strong>
              </div>
              <div class="card-body card-block">
                <div class="form-group">
                  <div class="row">
                     <input type="hidden" data-parsley-trigger="change" data-parsley-minlength="2" data-parsley-pattern="^[a-zA-Z0-9\ . _ - ' \/]+$"  name="user_id" class="form-control required" value="<?= (isset($user_id))?$user_id:'' ?>" >
                    <div class="col-md-6">
                      <label for="nf-email" class=" form-control-label">Vehicle Name</label>
                      <input type="text" data-parsley-trigger="change" data-parsley-minlength="2" data-parsley-pattern="^[a-zA-Z0-9\ . _ - ' \/]+$" id="nf-brand" name="vehicle_name" placeholder="Enter Vehicle Name" class="form-control required" value="<?= (isset($vehicleData->vehicle_name))?$vehicleData->vehicle_name:'' ?>" >
                    </div>
                    <div class="col-md-6">
                    <label for="nf-email" class=" form-control-label">Model</label>
                      <input type="text" data-parsley-trigger="change" data-parsley-minlength="2" data-parsley-pattern="^[a-zA-Z0-9\ . _ - ' \/]+$" id="nf-brand" name="model" placeholder="Enter Model" class="form-control required" value="<?= (isset($vehicleData->model))?$vehicleData->model:'' ?>" >
                                
                    </div>
                  </div>
                </div>
                
                <div class="form-group">
                  <div class="row">
                    <div class="col-md-6">
                     <label for="nf-email" class=" form-control-label">Year</label>
                      <input type="text" data-parsley-trigger="change" data-parsley-minlength="2" data-parsley-pattern="^[a-zA-Z0-9\ . _ - ' \/]+$" id="nf-brand" name="year" placeholder="Enter Year" class="form-control required" value="<?= (isset($vehicleData->year))?$vehicleData->year:'' ?>" >
                  
                    </div>
                    <div class="col-md-6">
                      <label for="nf-email" class=" form-control-label">Make</label>
                      <input type="text" data-parsley-trigger="change" data-parsley-trigger="change"  data-parsley-minlength="2" id="nf-brand" name="make" placeholder="Enter Make" class="form-control required" value="<?= (isset($vehicleData->make))?$vehicleData->make:'' ?>" >
                    </div>
                  </div>
                </div>
                 <div class="form-group">
                  <div class="row">
                   <div class="col-md-6">
                      <label for="nf-email" class=" form-control-label">Mileage</label>
                      <input type="text" id="pd_email" name="mileage" placeholder="Enter Mileage" class="form-control required" onfocusout="myFunction()" value="<?= (isset($vehicleData->mileage))?$vehicleData->mileage:'' ?>" >
                      
                    </div>
                    <div class="col-md-6">
                      <label for="nf-email" class=" form-control-label">VIN</label>
                      <input type="text" data-parsley-trigger="change" data-parsley-trigger="change"  data-parsley-minlength="2" id="nf-brand" name="vin" placeholder="Enter VIN NO" class="form-control required" value="<?= (isset($vehicleData->vin))?$vehicleData->vin:'' ?>" >
                    </div>
                  </div>
                </div>

                <div class="form-group">
                  <div class="row">
                    
                     <?php $req = (!isset($vehicle_id)||empty($vehicle_id))
                  ?'form-control required':'form-control';?>
                    <div class="col-md-6">
                      <label>Vehicle Photo</label><br>
                        <img  src="<?= (isset($vehicleData->vehicle_image))?base_url($vehicleData->vehicle_image):'' ?>" onerror="this.src='<?=base_url("assets/images/user_avatar.jpg")?>';" height="75" width="75" />
                       
                        <input name="vehicle_pic" type="file" accept="image/*" onchange="setImg(this,'image_id_1');" class="<?= base_url($req) ?>"/>
                    </div>
                  </div>
                </div>
             
               
             
                  <div class="form-group">
                    <div class="row">
                      <div class="col-md-12">
                          <button type="submit" class="btn btn-primary">
                                <i class="fa fa-dot-circle-o"></i> Submit
                          </button>

                         
                      </div>
                    </div>
                  </div>   
                </div>
              </div>
            </form>
          </div>
         </div>
      </div>
   </div>
   <div class="clear-fix"></div>

   
<script type="text/javascript">

function myFunction(){
alert("ddfgd");
var email = document.getElementById('pd_email').value;

var site_url = '<?php echo SITE_URL; ?>';

$.ajax({
type: "POST",
url: "Customer/check_email_availability",
data: {email:email},

success: function(result){
var val = JSON.parse(result);
console.log(val.data.is_email_avaliable);



if(val.data.is_email_avaliable==true){
var email = val.email;



}
else { 

var message = "This email is already being used!!";
document.getElementById("email_req").innerHTML = '<div style="margin:-20px;" class="normal"><font color="red" font size="2px" vertical-align="top" text-align="center"> <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+message+'</b></font></div>';


}




}
});

}
</script> 
        