<?php
include("../include/session.php");
if(!$session->isAdmin()){
	header("Location: ../Store/denied2.php");
}else{
	include("../storeHeader.php");
	
	$vehicleId = mysql_real_escape_string($_GET['vehicleId']);
	$edit = $_GET['edit'];
	
	if ($edit=="1") {
		
		$field = $_GET['field'];
		$editText = $_GET['editText'];
		
		$editQuery = "UPDATE vehicle SET $field = '".  $editText ."' WHERE vehicleId = '$vehicleId' ";
		
        $editResult = mySQL_query($editQuery);
	}
   
	
	
	$vehicleQuery = "SELECT * FROM vehicle WHERE vehicleId ='". $vehicleId. "' ";
	$vehicleResult = execsql($vehicleQuery);
	$a1 = mysql_result($vehicleResult, 0, "reg_no");
	$a2 = mysql_result($vehicleResult, 0, "make");
	$a3 = mysql_result($vehicleResult, 0, "model");
	$a4 = mysql_result($vehicleResult, 0, "company");
	$a5 = mysql_result($vehicleResult, 0, "driver");
	$a6 = mysql_result($vehicleResult, 0, "fuel");
	$a7 = mysql_result($vehicleResult, 0, "manufactured");
	$a8 = mysql_result($vehicleResult, 0, "purchase");
	$a9 = mysql_result($vehicleResult, 0, "chassis_no");
	$a10 = mysql_result($vehicleResult, 0, "license");
	$a11 = mysql_result($vehicleResult, 0, "mileage");
	$a12 = mysql_result($vehicleResult, 0, "notes");
	
	$w=1;
	while ($w < 13) {
	$a = 'a';	
	   if (${$a.$w} == '') { ${$a.$w}="?"; }
	   $w++;
	}
	
	?>

<link rel="stylesheet" href="../css/dhtmlwindow.css" type="text/css" />
<script type="text/javascript" src="../css/dhtmlwindow.js"></script>
<link rel="stylesheet" href="../css/modal.css" type="text/css" />
<script type="text/javascript" src="../css/modal.js"></script>

<script type="text/javascript">
function checkifempty(){
if (document.form2.account_no_text.value==''){
document.getElementById("add_button").disabled=true
}
else {
document.getElementById("add_button").disabled=false	
}
}
if (document.all || document.getElementById)
setInterval("checkifempty()",100)
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
</script>
<script type="text/javascript" src="../css/tablesort.js"></script>

<link href="../css/main.css" rel="stylesheet" type="text/css" />
<table id="tableMain" width="595">
  <!--begin of tableMain-->
  <tr>
    <td ><div class="headerbox2"> Tocotex Vehicle</div>
      <p class="edit">
      <label class="std"><font size="3"><b><?php echo $a1 ?></b></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Click on the line you want to edit.</label></p></td>
    <!--center of tableMain-->
  </tr>
  <tr>
    <td><!--center of tableMain-->
      <table width="600" id="tablePlain">
        <tr>
          <td width="113">registration:</td>
          <td width="159"><b><?php echo $a1 ?></b></td>
          <td colspan="2"></b></td>
        </tr>
        <tr>
          <td>make:</td>
          <td><b><a href="" onclick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editVehicleLine.php?vehicleId=<?php echo $vehicleId?>&field=<?php echo 'make' ?>&Type=T ', 'Edit Vehicle', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $a2 ?></a></b></td>
          <td>model</td>
          <td>
		  <a href="" onclick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editVehicleLine.php?vehicleId=<?php echo $vehicleId?>&field=<?php echo 'model' ?>&Type=T ', 'Edit Vehicle', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $a3 ?></a></td>
        </tr>
        <tr>
          <td>company:</td>
          <td>
		  <a href="" onclick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editVehicleLine.php?vehicleId=<?php echo $vehicleId?>&field=<?php echo 'company' ?>&Type=T ', 'Edit Vehicle', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $a4 ?></a></td>
          <td width="129">driver:</td>
          <td width="179">
		  <a href="" onclick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editVehicleLine.php?vehicleId=<?php echo $vehicleId?>&field=<?php echo 'driver' ?>&Type=T ', 'Edit Vehicle', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $a5 ?></a></td>
        </tr>
        <tr>
          <td>fuel:</td>
          <td><b>
		  <a href="" onclick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editVehicleLine.php?vehicleId=<?php echo $vehicleId?>&field=<?php echo 'fuel' ?>&Type=T ', 'Edit Vehicle', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $a6 ?></a></b></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>manufactured:</td>
          <td><b>
		  <a href="" onclick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editVehicleLine.php?vehicleId=<?php echo $vehicleId?>&field=<?php echo 'manufactured' ?>&Type=T ', 'Edit Vehicle', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $a7 ?></a></b></td>
          <td>purchase:</td>
          <td>
		  <a href="" onclick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editVehicleLine.php?vehicleId=<?php echo $vehicleId?>&field=<?php echo 'purchase' ?>&Type=D ', 'Edit Vehicle', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo date("d-m-Y", strtotime( $a8))?></a></td>
        </tr>
        <tr>
          <td>chassis number:</td>
          <td colspan="3"><b>
		  <a href="" onclick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editVehicleLine.php?vehicleId=<?php echo $vehicleId?>&field=<?php echo 'chassis_no' ?>&Type=T ', 'Edit Vehicle', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $a9 ?></a></b></td>
        </tr>
        <tr>
          <td>expiry license:</td>
          <td colspan="3">
		  <a href="" onclick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editVehicleLine.php?vehicleId=<?php echo $vehicleId?>&field=<?php echo 'license' ?>&Type=T ', 'Edit Vehicle', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $a10 ?></a></td>
        </tr>
        <tr>
          <td>mileage:</td>
          <td colspan="3">
		  <?php echo $a11 ?></td>
        </tr>
        <tr>
          <td>notes:</td>
          <td colspan="3"><b>
		  <a href="" onclick="editwindow=dhtmlmodal.open('editBox', 'iframe', 'editVehicleLine.php?vehicleId=<?php echo $vehicleId?>&field=<?php echo 'notes' ?>&Type=T ', 'Edit Vehicle', 'width=330px,height=170px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false"><?php echo $a12 ?></a></b></td>
        </tr>
      </table></td>
  </tr>
  <tr>
  <td><p class="main">
    <label class="std">&nbsp;&nbsp;&nbsp;&nbsp;</label>
    <input name="button" type="button" class="imagebutton" id="button" onclick="MM_goToURL('parent','showAllProducts.php?cat=Tiles and Accessories&amp;productSelect=All&amp;colorSelect=All');return document.MM_returnValue" value="Done" />
  </p>
  </p></td>
  </tr>
</table>
<!--end of tableMain-->
<?php

	include("../footer.php");
}
?>
