<?php
session_start();
if(!isset ($_SESSION['user_id'])){
	header("Location:../login.php?msg=Log in first");
    exit();
}else{
	
	include('../Server/connection.php');
	include('includes/session.php');
	echo "<div class='div-request div-hide'>editOrd</div>";
    	
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

	
	 <?php
  include 'title.php';
         ?>
	
	
	<link type = "image/png" rel="icon" href="images/brvision.png" />

    <!-- Bootstrap must-->
    <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
	
    <!-- Font Awesome must-->
    <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
	
	<!-- custom css -->
    <link rel="stylesheet" href="custom/css/custom.css">
	
    <!-- NProgress must-->
    <link href="../vendors/nprogress/nprogress.css" rel="stylesheet">
	
    <!-- Custom Theme Style must-->
    <link href="../build/css/custom.min.css" rel="stylesheet">
	
	
	
	<!-- must-->
	<script src="assests/jquery/jquery.min.js"></script>
	
	<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/jquery.validate.min.js"></script>
    <script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/additional-methods.min.js"></script>
	
  <!-- jquery ui -->  
  <link rel="stylesheet" href="assests/jquery-ui/jquery-ui.min.css">
  <script src="assests/jquery-ui/jquery-ui.min.js"></script>
	
  <!-- Must Bootstrap -->
    <script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></script>
	
	<style>
  .error {
    color: #F00;
}  

</style>
	
	<script type="text/javascript">
$(document).ready(function(){
    $('#vbrandId').on('change',function(){
        var veID = $(this).val();
        if(veID){
            $.ajax({
                type:'POST',
                url:'verajaxData.php',
                data:'veId='+veID,
                success:function(html){
                    $('#vmodelId').html(html);
                }
            }); 
        }else{
            $('#vmodelId').html('<option value="">Select Vehicle Brand First</option>');
        }
    });

});
</script>
	
  </head>

  <body class="nav-md">
  
    <div class="container body">
	
      <div class="main_container">
        <div class="col-md-3 left_col">
          <div class="left_col scroll-view">
		  
             <?php  
		include 'includes/role.php';
               ?>

            <div class="clearfix"></div>
            
			
			<?php
            include 'includes/profile.php';
			print '</br></br>';
			include 'includes/menu.php';
			?>


           

        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
		  
			
			
            <div class="clearfix"></div>

            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
				  
                    <a href="manage_vehicles.php">  <h2><span class="glyphicon glyphicon-step-backward"></span> Back</h2></a>
					
					<?php
				$vehicle_id = $_GET['i'];
				$sql81 = "SELECT * FROM vehicles WHERE vehicle_id = {$vehicle_id}";
				$result81 = $conn->query($sql81);
				while($data81 = mysqli_fetch_array($result81))
							{
							$vPlateNo = $data81['vehicle_plate_no'];
							$vChassisNo = $data81['vehicle_chassis_no'];
							$vehicle_brand_id = $data81['vehicle_brand_id'];
							$vehicle_model_id = $data81['vehicle_model_id'];
							$vehicle_color_id = $data81['vehicle_color_id'];
							$vehicle_type_id = $data81['vehicle_type_id'];
							$vFuelId = $data81['fuel_id'];
							$veh_owner_id = $data81['veh_owner_id'];
							$vehicle_desc = $data81['vehicle_desc'];
							$veh_value = $data81['value'];
				            }	


                          $sql81z = "SELECT * FROM insurance_management WHERE vehicle_id = {$vehicle_id} order by insurance_id desc limit 1";
				$result81z = $conn->query($sql81z);
				while($data81z = mysqli_fetch_array($result81z))
							{
							$insurer_id = $data81z['insurer_id'];
							$issued_date = $data81z['issued_date'];
							$expire_date = $data81z['expire_date'];
							$insurance_cost = $data81z['insurance_cost'];
							$vInsuranceNo = $data81z['insurance_number'];
							}
                       if($veh_owner_id==2){
                     $sql81z1 = "SELECT * FROM veh_owners WHERE veh_owner_id = {$veh_owner_id}";
				$result81z1 = $conn->query($sql81z1);
				while($data81z1 = mysqli_fetch_array($result81z1))
							{
							$firstname = $data81z1['firstname'];
							$middlename = $data81z1['middlename'];
							$lastname = $data81z1['lastname'];
							$phoneNumber = $data81z1['phoneNumber'];
							$emailAddress = $data81z1['emailAddress'];
							$address = $data81z1['address'];
							$n = substr($phoneNumber,3);
                            $n1 = '0';
                            $phone_number = $n1.$n;
							}
							
			 $sql81z1a = "SELECT * FROM veh_owners_contracts WHERE veh_owner_id = {$veh_owner_id}";
				$result81z1a = $conn->query($sql81z1a);
				while($data81z1a = mysqli_fetch_array($result81z1a))
							{
							$veh_contract_start = $data81z1a['contract_start'];
							$veh_contract_end = $data81z1a['contract_end'];
							}

                            }							
				      ?>
					
					
					
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                      
                     
                    </ul>
                    <div class="clearfix"></div>
                  </div>
				  
				
				<div class="x_content" style="overflow: auto;">
				
				<?php if (isset($_SESSION['success_message']) && !empty($_SESSION['success_message'])) { ?>
                        <div class="success-message" style="margin-bottom: 20px;font-size: 20px;color: green;"><?php echo $_SESSION['success_message']; ?></div>
                        <?php
                        unset($_SESSION['success_message']);
                    }
                    ?>	
				 
				  <div class="success-messages"></div> <!--/success-messages-->

               <form class="form-horizontal" method="POST" action="php_action/editVehicle.php" enctype="multipart/form-data">
			   
			    <input type="hidden" name="vehicle_id" value="<?php echo $vehicle_id; ?>">
				
				  <div class="controls">
			  <div class="row">
			  

			  <div class="col-sm-4">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Plate No </label>
                 <input  type="text" class="form-control" id="vplate_no" name="vplate_no"  value="<?php echo $vPlateNo; ?>" placeholder="Vehicle Plate No" autocomplete="off" />
                    <br/>
                         <label for="vplate_no" class="error" generated="true"></label>  
                    </div>
			  </div>
			  
			  <div class="col-sm-4">
			  <div class="form-group">
			  
			  <label for="form_name"> Vehicle Chassis No </label>
                 <input  type="text" class="form-control" id="vchassis_no" name="vchassis_no"  value="<?php echo $vChassisNo; ?>" placeholder="Vehicle Chassis No" autocomplete="off" />
                 <br/>
                         <label for="vchassis_no" class="error" generated="true"></label>  
                      
                    </div>
			  </div>
			  
			  <div class="col-sm-4">
			  <div class="form-group">
			  
			  <label for="form_name"> Vehicle Insurance No </label>
                 <input  type="text" class="form-control" id="vinsurance_no" name="vinsurance_no"  value="<?php echo $vInsuranceNo; ?>" placeholder="Vehicle Insurance No" autocomplete="off"/>
                 <br/>
                         <label for="vinsurance_no" class="error" generated="true"></label>
                      
                    </div>
			  </div>
			 
			  
			  	</div>	  
                </div>
				
				
				<div class="controls">
			  <div class="row">
			  
			   <div class="col-sm-3">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Brand </label>
				 <select class="form-control" name="vbrandId" id="vbrandId">
			  						<?php
			  							$productSql2 = "SELECT * FROM vehicle_brands where vehicle_brand_id='$vehicle_brand_id'";
			  							$productData2 = $conn->query($productSql2);
			  							while($row2 = $productData2->fetch_array()){									 		
			  								echo "<option value='".$row2['vehicle_brand_id']."'>".$row2['vehicle_brand_name']."</option>";
										 	} // /while 
                                         
									    $productSql3 = "SELECT * FROM vehicle_brands where vehicle_brand_id!='$vehicle_brand_id'";
			  							$productData3 = $conn->query($productSql3);
			  							while($row3 = $productData3->fetch_array()){									 		
			  								echo "<option value='".$row3['vehicle_brand_id']."'>".$row3['vehicle_brand_name']."</option>";
										 	} // /while 
			  						?>
		  						</select>
				 
                    <br/>
                         <label for="vbrandId" class="error" generated="true"></label>  
                    </div>
			  </div>
			  
			   <div class="col-sm-3">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Model </label>
                 <select class="form-control" name="vmodelId" id="vmodelId">
				 <?php
				 $productSql32 = "SELECT * FROM vehicle_models where vehicle_model_id='$vehicle_model_id' and vehicle_brand_id='$vehicle_brand_id'";
			  							$productData32 = $conn->query($productSql32);
			  							while($row32 = $productData32->fetch_array()){									 		
			  								echo "<option value='".$row32['vehicle_model_id']."'>".$row32['vehicle_model_name']."</option>";
										 	} // /while 
											
				$productSql33 = "SELECT * FROM vehicle_models where vehicle_model_id!='$vehicle_model_id' and vehicle_brand_id='$vehicle_brand_id'";
			  							$productData33 = $conn->query($productSql33);
			  							while($row33 = $productData33->fetch_array()){									 		
			  								echo "<option value='".$row33['vehicle_model_id']."'>".$row33['vehicle_model_name']."</option>";
										 	} // /while 
											?>
			  					
		  						</select>  
                    <br/>
                         <label for="vmodelId" class="error" generated="true"></label>  
                    </div>
			  </div>

			  <div class="col-sm-3">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Color</label>
				  <select class="form-control" name="vcolor_id" id="vcolor_id" autocomplete="off" />
				
			  						<?php
			  							$productSql = "SELECT * from vehicle_colors where vehicle_color_id='$vehicle_color_id'";
			  							$productData = $conn->query($productSql);

			  							while($row = $productData->fetch_array()){									 		
			  								echo "<option value='".$row['vehicle_color_id']."'>".$row['vehicle_color_name']."</option>";
										 	} // /while 
											
									   $productSql1 = "SELECT * from vehicle_colors where vehicle_color_id!='$vehicle_color_id'";
			  							$productData1 = $conn->query($productSql1);

			  							while($row1 = $productData1->fetch_array()){									 		
			  								echo "<option value='".$row1['vehicle_color_id']."'>".$row1['vehicle_color_name']."</option>";
										 	} // /while

			  						?>
		  						</select>
                      <br/>
                         <label for="vcolor_id" class="error" generated="true"></label>  
                    </div>
			  </div>
			  
			  
			   <div class="col-sm-3">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Fuel </label>
                   <select class="form-control" name="fuel_id" id="fuel_id" autocomplete="off" />
				
			  						<?php
			  							$productSql3 = "SELECT * from fuel where fuel_id='$vFuelId'";
			  							$productData3 = $conn->query($productSql3);

			  							while($row3 = $productData3->fetch_array()){									 		
			  								echo "<option value='".$row3['fuel_id']."'>".$row3['name']."</option>";
										 	} // /while 
											
									   $productSql13 = "SELECT * from fuel where fuel_id!='$vFuelId'";
			  							$productData13 = $conn->query($productSql13);

			  							while($row13 = $productData13->fetch_array()){									 		
			  								echo "<option value='".$row13['fuel_id']."'>".$row13['name']."</option>";
										 	} // /while

			  						?>
		  						</select>
                    </div>
			  </div>
			  
			  
			
			  	</div>	  
                </div>
				
						<div class="controls">
			  <div class="row">
			  
			   <div class="col-sm-3">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Type </label>
                   <select class="form-control" name="veh_type_id" id="veh_type_id" autocomplete="off" />
				
			  						<?php
			  							$productSql3x = "SELECT * from veh_type where vehicle_type_id='$vehicle_type_id'";
			  							$productData3x = $conn->query($productSql3x);

			  							while($row3x = $productData3x->fetch_array()){									 		
			  								echo "<option value='".$row3x['vehicle_type_id']."'>".$row3x['vehicle_type']."</option>";
										 	} // /while 
											
									   $productSql13xx = "SELECT * from veh_type where vehicle_type_id!='$vehicle_type_id'";
			  							$productData13xx = $conn->query($productSql13xx);

			  							while($row13xx = $productData13xx->fetch_array()){									 		
			  								echo "<option value='".$row13xx['vehicle_type_id']."'>".$row13xx['vehicle_type']."</option>";
										 	} // /while

			  						?>
		  						</select> 
                    </div>
			  </div>
			 
			  
			  <div class="col-sm-3">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Insurance Issue Date </label>
                 <input  type="text" class="form-control" id="vinsurance_issueDate" name="vinsurance_issueDate"  value="<?php echo $issued_date; ?>" placeholder="Vehicle Insurance Issue Date" autocomplete="off" />
                    <br/>
                         <label for="vinsurance_issueDate" class="error" generated="true"></label>  
                    </div>
			  </div>
			  
			  <div class="col-sm-3">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Insurance Expire Date </label>
                 <input  type="text" class="form-control" id="vinsurance_expireDate" name="vinsurance_expireDate"  value="<?php echo $expire_date; ?>" placeholder="Vehicle Insurance Expire Date" autocomplete="off" />
                    <br/>
                         <label for="vinsurance_expireDate" class="error" generated="true"></label>  
                    </div>
			  </div>
			  
              <div class="col-sm-3">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Insurance Cost </label>
                 <input  type="number" class="form-control" id="vinsurance_cost" name="vinsurance_cost"  value="<?php echo $insurance_cost; ?>" placeholder="Vehicle Insurance Expire Date" autocomplete="off" />
                    <br/>
                         <label for="vinsurance_cost" class="error" generated="true"></label>  
                    </div>
			  </div>
			
			  	</div>	  
                </div>
				
			<div class="controls">
			  <div class="row">
			  
			   <div class="col-sm-3">
			  <div class="form-group">
                 <label for="form_name"> Insurer </label>
				  <select class="form-control" name="insurer_id" id="insurer_id" autocomplete="off" />
				     
			  						<?php
			  							$productSql1 = "SELECT * from insurer where insurer_id='$insurer_id'";
			  							$productData1 = $conn->query($productSql1);

			  							while($row1 = $productData1->fetch_array()){									 		
			  								echo "<option value='".$row1['insurer_id']."'>".$row1['insurer_name']."</option>";
										 	} // /while 
											
										$productSql1x = "SELECT * from insurer where insurer_id!='$insurer_id'";
			  							$productData1x = $conn->query($productSql1x);

			  							while($row1x = $productData1x->fetch_array()){									 		
			  								echo "<option value='".$row1x['insurer_id']."'>".$row1x['insurer_name']."</option>";
										 	} // /while 

			  						?>
		  						</select>
                      <br/>
                         <label for="insurer_id" class="error" generated="true"></label>  
                    </div>
			  </div>
			  
			   <div class="col-sm-3">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Value </label>
                 <input  type="number" class="form-control" id="veh_value" name="veh_value"  value="<?php echo $veh_value; ?>" placeholder="Vehicle Value" autocomplete="off" />
                    <br/>
                         <label for="veh_value" class="error" generated="true"></label>  
                    </div>
			  </div>
			  
			   <div class="col-sm-3">
			  <div class="form-group">
                 <label for="form_name"> Remarks </label>
                 <textarea id="veh_remarks" rows="10" cols="50" name="veh_remarks" class="form-control" style="margin-left:0%;" autocomplete="off"> <?php echo htmlspecialchars($vehicle_desc);  ?> </textarea>
			            <br/>
                         <label for="veh_remarks" class="error" generated="true"></label>
                    </div>
			  </div>
			  
			  <div class="col-sm-3">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Owner </label>
				 </br>
				 
				 
			<?php	
                 $sql421 = "SELECT * FROM vehicles where vehicle_id='$vehicle_id'";	
        $result421 = $conn->query($sql421); 
		while ($row421 = mysqli_fetch_array($result421))
		{
			
			$vehOwnerId = $row421['veh_owner_id'];
	
		?>			
				 
				 <label class="radio-inline">
          <input type="radio" name="owner_status" value="1" id="owner_status" <?php if($vehOwnerId==1){ echo "checked";}?> /> Company
         </label>&nbsp&nbsp&nbsp&nbsp
         <label class="radio-inline">
          <input type="radio" name="owner_status" value="2" id="owner_status" <?php if($vehOwnerId==2){ echo "checked";}?> /> Other Owner
         </label>&nbsp&nbsp&nbsp&nbsp
				 
		<?php
		                }
						?>		 
				 
				
				    
              </div>
			  </div>
			  
			  
			 
			
			  	</div>	  
                </div>
				
				
				
				
				
				  <?php
			if($veh_owner_id==2){  
			  ?>
				
				
			   <div id="textboxes1">
				<div class="controls">
			  <div class="row">
			   
			   <div class="col-sm-4">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Owner First Name </label>
                 
				 <input type="text" class="form-control" id="vowner_fname" name="vowner_fname" value="<?php echo $firstname; ?>" autocomplete="off"  />
                      
                </div>
			   </div>
			   
			   <div class="col-sm-4">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Owner Middle Name </label>
                 
				 <input type="text" class="form-control" id="vowner_mname" name="vowner_mname" value="<?php echo $middlename; ?>" autocomplete="off" />
                      
                </div>
			   </div>
			   
			   
			   <div class="col-sm-4">
			  <div class="form-group">
			  
			  <label for="form_name">  Vehicle Owner Last Name </label>
                 <input  type="text" class="form-control" id="vowner_lname" name="vowner_lname"  value="<?php echo $lastname; ?>" autocomplete="off"/>
                 
                      
                    </div>
			  </div>
			   
			 
			  
			  	</div>	  
                </div>
				
				
					<div class="controls">
			  <div class="row">
			   
			   <div class="col-sm-4">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Owner Phone Number </label>
                 
				 <input type="text" class="form-control" id="vowner_pnumber" name="vowner_pnumber" value="<?php echo $phone_number; ?>" autocomplete="off"  />
                      
                </div>
			   </div>
			   
			   <div class="col-sm-4">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Owner Email Address </label>
                 
				 <input type="text" class="form-control" id="vowner_email" name="vowner_email" value="<?php echo $emailAddress; ?>" autocomplete="off" />
                      
                </div>
			   </div>
			   
			   
			   <div class="col-sm-4">
			  <div class="form-group">
			  
			  <label for="form_name">  Vehicle Owner Physical Address </label>
                 <input  type="text" class="form-control" id="vowner_address" name="vowner_address"  value="<?php echo $address; ?>" autocomplete="off"/>
                 
                      
                    </div>
			  </div>
			   
			 
			  
			  	</div>	  
                </div>
				
				  <div class="controls">
			  <div class="row">
			 
			  
			  <div class="col-sm-4">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Contract Start </label>
                 <input  type="text" class="form-control" id="veh_contStart" name="veh_contStart"  value="<?php echo $veh_contract_start; ?>" placeholder="Vehicle Contract Start" autocomplete="off" />
                    <br/>
                         <label for="veh_contStart" class="error" generated="true"></label>  
                    </div>
			  </div>
			  
			  <div class="col-sm-4">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Contract End </label>
                 <input  type="text" class="form-control" id="veh_contEnd" name="veh_contEnd"  value="<?php echo $veh_contract_end; ?>" placeholder="Vehicle Contract End" autocomplete="off" />
                    <br/>
                         <label for="veh_contEnd" class="error" generated="true"></label>  
                    </div>
			  </div>
			  
              <div class="col-sm-4">
			  <div class="form-group">
                 <label for="form_name"> Upload Contract </label>
                 <input  type="file" name="file[]"  id="file" class="form-control" style="width:100%;margin-left:0%;" multiple>
			  </div>
			
			  	</div>	  
                </div>
				
				</div>
			

			  </div>
			  
			  <?php
			   }else{
			  ?>
			  
			  <div id="textboxes1" style="display: none">	
				<div class="controls">
			  <div class="row">
			   
			   <div class="col-sm-4">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Owner First Name </label>
                 
				 <input type="text" class="form-control" id="vowner_fname" name="vowner_fname" autocomplete="off"  />
                      
                </div>
			   </div>
			   
			   <div class="col-sm-4">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Owner Middle Name </label>
                 
				 <input type="text" class="form-control" id="vowner_mname" name="vowner_mname"  autocomplete="off" />
                      
                </div>
			   </div>
			   
			   
			   <div class="col-sm-4">
			  <div class="form-group">
			  
			  <label for="form_name">  Vehicle Owner Last Name </label>
                 <input  type="text" class="form-control" id="vowner_lname" name="vowner_lname"  autocomplete="off"/>
                 
                      
                    </div>
			  </div>
			   
			 
			  
			  	</div>	  
                </div>
				
				
					<div class="controls">
			  <div class="row">
			   
			   <div class="col-sm-4">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Owner Phone Number </label>
                 
				 <input type="text" class="form-control" id="vowner_pnumber" name="vowner_pnumber"  autocomplete="off"  />
                      
                </div>
			   </div>
			   
			   <div class="col-sm-4">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Owner Email Address </label>
                 
				 <input type="text" class="form-control" id="vowner_email" name="vowner_email"  autocomplete="off" />
                      
                </div>
			   </div>
			   
			   
			   <div class="col-sm-4">
			  <div class="form-group">
			  
			  <label for="form_name">  Vehicle Owner Physical Address </label>
                 <input  type="text" class="form-control" id="vowner_address" name="vowner_address"  autocomplete="off"/>
                 
                      
                    </div>
			  </div>
			   
			 
			  
			  	</div>	  
                </div>
				
				  <div class="controls">
			  <div class="row">
			 
			  
			  <div class="col-sm-4">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Contract Start </label>
                 <input  type="text" class="form-control" id="veh_contStart" name="veh_contStart"   placeholder="Vehicle Contract End" autocomplete="off" />
                    <br/>
                         <label for="veh_contStart" class="error" generated="true"></label>  
                    </div>
			  </div>
			  
			  <div class="col-sm-4">
			  <div class="form-group">
                 <label for="form_name"> Vehicle Contract Start </label>
                 <input  type="text" class="form-control" id="veh_contEnd" name="veh_contEnd"   placeholder="Vehicle Contract Start" autocomplete="off" />
                    <br/>
                         <label for="veh_contEnd" class="error" generated="true"></label>  
                    </div>
			  </div>
			  
              <div class="col-sm-4">
			  <div class="form-group">
                 <label for="form_name"> Upload Contract </label>
                 <input  type="file" name="file[]"  id="file" class="form-control" style="width:100%;margin-left:0%;" multiple>
			  </div>
			
			  	</div>	  
                </div>
				
				</div>
			

			  </div>
			  
			  
			  <?php
                 }
			  ?>
			 
			
			  
			  </br></br></br></br></br>
			  
			 
			
			  <div class="form-group submitButtonFooter">
			    <div class="col-sm-12">
			      <button type="submit" id="createOrderBtn" data-loading-text="Loading..." class="btn btn-success"><i class="glyphicon glyphicon-ok-sign"></i> Save Changes</button>
                  </br></br>
			      <!--<button type="reset" class="btn btn-default" onclick="resetOrderForm()"><i class="glyphicon glyphicon-erase"></i> Reset</button>-->
			    </div>
			  </div>
			  
			  
			</form>                  
				
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->
		
		
		<?php
		include 'includes/footer.php';
		?>
		
        
      </div>
    </div>
	
	<script>
	// order date picker
		$("#vinsurance_issueDate").datepicker();
		
		// delivery date picker
		$("#vinsurance_expireDate").datepicker();
		
		$("#veh_contStart").datepicker();
		
		$("#veh_contEnd").datepicker();
	
	</script>
	
	<script>
//$(function(){
	
$(document).ready(function(){
    $('input[name="owner_status"]').on('click', function(){
        if ($(this).val() == 2){
			 $('#textboxes1').show();
        }else {
			$('#textboxes1').hide();
		}
	
		
    });
});

$(document).ready(function(){
    $('input[name="upl_status"]').on('click', function(){
        if ($(this).val() == 'Yes'){
			 $('#textboxes7').show();
        }else {
			$('#textboxes7').hide();
		}
	
		
    });
});

$(document).ready(function(){
    $('input[name="emptype_id"]').on('click', function(){
        if ($(this).val() == 1){
			 $('#textboxes6').hide();
        }else if($(this).val() == 2){
			$('#textboxes6').show();
		}
	
		
    });
});

$(document).ready(function(){
    $('input[name="staffcate_id"]').on('click', function(){
        if ($(this).val() == 1){
			 $('#textboxes2').show();
			 $('#textboxes3').hide();
			 $('#textboxes4').hide();
			 $('#textboxes5').hide();
        }else if($(this).val() == 2){
			$('#textboxes5').show();
			$('#textboxes2').hide();
			$('#textboxes3').hide();
			$('#textboxes4').hide();
		}else if($(this).val() == 3){
			$('#textboxes3').show();
			$('#textboxes2').hide();
			$('#textboxes4').hide();
			$('#textboxes5').hide();
		}else{
			$('#textboxes4').show();
			$('#textboxes2').hide();
			$('#textboxes3').hide();
			$('#textboxes5').hide();
		}
	
		
    });
});

$(document).ready(function(){
    $('#dept_id').on('change', function(){
        var deptID = $(this).val();
        if(deptID){
            $.ajax({
                type:'POST',
                url:'ajax_Data.php',
                data:'dept_id='+deptID,
                success:function(html){
                    $('#sect_id').html(html);
                    $('#des_id').html('<option value="">Select Section first</option>'); 
                }
            }); 
        }else{
            $('#sect_id').html('<option value="">Select Department first</option>');
            $('#des_id').html('<option value="">Select Section first</option>'); 
        }
    });
    
    $('#sect_id').on('change', function(){
        var sectID = $(this).val();
        if(sectID){
            $.ajax({
                type:'POST',
                url:'ajax_Data.php',
                data:'sect_id='+sectID,
                success:function(html){
                    $('#des_id').html(html);
                }
            }); 
        }else{
            $('#des_id').html('<option value="">Select Section first</option>'); 
        }
    });
});


$(document).ready(function(){
    $('#region_id').on('change', function(){
        var regionID = $(this).val();
        if(regionID){
            $.ajax({
                type:'POST',
                url:'ajax_Data16.php',
                data:'region_id='+regionID,
                success:function(html){
                    $('#district_id').html(html);
                    $('#ward_id').html('<option value="">Select District first</option>'); 
                }
            }); 
        }else{
            $('#district_id').html('<option value="">Select Region first</option>');
            $('#ward_id').html('<option value="">Select District first</option>'); 
        }
    });
    
    $('#distict_id').on('change', function(){
        var districtID = $(this).val();
        if(districtID){
            $.ajax({
                type:'POST',
                url:'ajax_Data16.php',
                data:'district_id='+districtID,
                success:function(html){
                    $('#ward_id').html(html);
                }
            }); 
        }else{
            $('#ward_id').html('<option value="">Select District first</option>'); 
        }
    });
});


$(document).ready(function(){
    $('#depart_id').on('change', function(){
        var departID = $(this).val();
        if(departID){
            $.ajax({
                type:'POST',
                url:'ajax_Data1.php',
                data:'depart_id='+departID,
                success:function(html){
                    $('#section_id').html(html);
                    $('#desi_id').html('<option value="">Select Section first</option>'); 
                }
            }); 
        }else{
            $('#section_id').html('<option value="">Select Department first</option>');
            $('#desi_id').html('<option value="">Select Section first</option>'); 
        }
    });
    
    $('#section_id').on('change', function(){
        var sectiID = $(this).val();
        if(sectiID){
            $.ajax({
                type:'POST',
                url:'ajax_Data1.php',
                data:'section_id='+sectiID,
                success:function(html){
                    $('#desi_id').html(html);
                }
            }); 
        }else{
            $('#desi_id').html('<option value="">Select Section first</option>'); 
        }
    });
});

 $("#id_frm").validate({
        rules: {
			
			"vplate_no": {
                required: true
            },
			
			"vchassis_no": {
                required: true
            },
			
			"lname": {
                required: true
            },
			
			"gender_id": {
                required: true
            },
			
			"email": {
                required: true
            },
			
			"phone": {
                required: true
            },
			
			
			"bdate": {
                required: true
            },
			
			
			"empdate": {
                required: true
            },
			
			"marital_id": {
                required: true
            },
			
			"relId": {
                required: true
            },
			
			"denId": {
                required: true
            },
			
			"cont_dur_id": {
                required: true
            },
			
			
            "contStart": {
                required: true,
                //minlength: 10,
                // minlength: 10 // same rule twice
            },
			
			"edu_level_id": {
                required: true
            },
			
			"region_id": {
                required: true
            },
			
			"district_id": {
                required: true
            },
			
			"ward_id": {
                required: true
            },
			
			"heslb_status": {
                required: true
            },
			
			"basicSalary": {
                required: true
            },
			
			"bankName": {
                required: true
            },
			
			"bankAccountNo": {
                required: true
            },
			
			"company_address": {
                required: true
            }
			
            
        },
        messages: {
			
			"vplate_no": {
                required: "Please Enter Vehicle Plate Number"
            },
			
			"vchassis_no": {
                required: "Please Enter Vehicle Chassis Number"
            },
			
			"lname": {
                required: "Please Enter Staff Last Name"
            },
			
			"gender_id": {
                required: "Please Select Gender"
            },
			
            "email": {
                required: "Please Enter Staff Email Address"
            },
			
			"phone": {
                required: "Please Enter Staff Phone Number"
            },
			
			"bdate": {
                required: "Please Enter Staff Birth Date"
            },
			
			"empdate": {
                required: "Please Enter Staff Employment Date"
            },
			
			"marital_id": {
                required: "Please Select Marital Status."
            },
			
			
			"relId": {
                required: "Please Select Religion"
            },
			
			"denId": {
                required: "Please Select Denomination."
            },
			
			
			"cont_dur_id": {
                required: "Please Select Contract Duration"
            },
			
			"contStart": {
                required: "Please Enter Contract Start Date"
            },
			
			"edu_level_id": {
                required: "Please Select Education Level"
            },
			
			"region_id": {
                required: "Please Select Region"
            },
			
			"district_id": {
                required: "Please Select District"
            },
			
			"ward_id": {
                required: "Please Select Ward"
            },
			
			"heslb_status": {
                required: "Please Select Heslb Status"
            },
			
			"basicSalary": {
                required: "Please Select Staff Basic Salary"
            },
			
			"bankName": {
                required: "Please Select Staff Bank Name"
            },
			
			"bankAccountNo": {
                required: "Please Select Staff Bank Account No"
            },
			
			"company_address": {
                required: "Please Enter Company Address"
            }
			
			
        },
        // for demo
        //submitHandler: function(form) {
            //alert('valid form');
            //return false;
        //}
 });


</script>
	
	

   <!-- Must -->
    <script src="custom/js/editInvoice.js"></script>
	
    <!-- Must Custom Theme Scripts -->
    <script src="../build/js/custom.min.js"></script>
	
	<!-- file input -->
	<script src="assests/plugins/fileinput/js/plugins/canvas-to-blob.min.js'); ?>" type="text/javascript"></script>	
	<script src="assests/plugins/fileinput/js/plugins/sortable.min.js" type="text/javascript"></script>	
	<script src="assests/plugins/fileinput/js/plugins/purify.min.js" type="text/javascript"></script>
	<script src="assests/plugins/fileinput/js/fileinput.min.js"></script>	


	<!-- DataTables -->
	<script src="assests/plugins/datatables/jquery.dataTables.min.js"></script>

  </body>
</html>



<?php
}
?>