<?php
include("../include/session.php");
include("../include/db.php");
	
	
	
	
	
		
	$reg_no = $_SESSION['reg_no'];
	$make = $_SESSION['VehicleMake'];
	$model = $_SESSION['VehicleModel'];
	$fuel = $_SESSION['fuel'];
	$manufactured = $_SESSION['year'];
	$purchase = $_SESSION['PurchaseDate'];
	$chassis_no = $_SESSION['chassis_no'];
	$company = $_SESSION['CompanyName'];
	$license = $_SESSION['License'];
	$driver = $_SESSION['DriverName'];
	$notes = $_SESSION['Notes'];
	
	$created_by = $_SESSION['username'];
	date_default_timezone_set('Africa/Khartoum');
	$entryDate = date("Y-m-d H:i:s",time()-3600); 
	
	
	$vehicleQuery = "INSERT INTO vehicle (reg_no, make,  model, fuel, manufactured, purchase, chassis_no, company, license, driver, notes) VALUES ('".$reg_no."' ,'".$make."' , '".$model."','".$fuel."', '".$manufactured."','".$purchase."', '".$chassis_no."','".$company."' ,'".$license."' , '".$driver."','".$notes."')";
	execsql($vehicleQuery);
	
	$actionQuery = "INSERT INTO action_tracking (entry_date, user, action, details) VALUES ('".$entryDate."' ,'".$created_by."','New vehicle' ,'".$reg_no."' )";
	execsql($actionQuery);
	
	$query = "SELECT vehicleId FROM vehicle ORDER BY vehicleId DESC LIMIT 1 ";
	$result = mySQL_query($query) or die ("Error in query:   $Query . * ". mySQL_error());
	$vehicleId = mysql_result($result, 0, "vehicleId");
	
	
	if (isset($_GET['new_button']) )
	   {
		 $action='vehicleWiz0.php';
	   }
		 
	if (isset($_GET['finish_button']) )
	  {
		$action='displayVehicle.php?vehicleId='.$vehicleId;
	  }
	
?>
<?php
    $_SESSION['reg_no'] = ""; 
	$_SESSION['VehicleMake'] = "";
	$_SESSION['VehicleModel'] = "";
    $_SESSION['year'] ="";
	$_SESSION['fuel'] = "";
    $_SESSION['chassis_no'] = "";
    $_SESSION['CompanyNo'] = "";
	$_SESSION['CompanyName'] = "";
    $_SESSION['DriverNo'] = "";
	$_SESSION['DriverName'] = "";
    $_SESSION['License'] = "";
    $_SESSION['PurchaseDate'] = date('Y-m-d');
    $_SESSION['Notes'] = "";
	 $_SESSION['p'] = 1;
	 $_SESSION['error']=0;
?>
<script language="javascript" type="text/javascript">
        <!--
		  window.location="<?php echo $action ?> ";
        -->
       </script>

