<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<!--jscript-->
<script language="JavaScript" src="../jscript/tooltip.js"  type="text/javascript"></script> 

<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" /> 

<?php
include('../include/session.php');
$vehicle_id = $_GET['vehicle_id'];
?>
</head>
<?php

	
$table_name2 = $_SESSION['db_prefix']."_vehicle";
$vehicle_query = "SELECT * FROM $table_name2 WHERE vehicle_id ='".$vehicle_id."'  ";
$vehicle_result = mySQL_query($vehicle_query);
$vehicle_num = mysql_num_rows($vehicle_result);	

$a0 = mysql_result($vehicle_result, 0, "registration_no");
$a1 = mysql_result($vehicle_result, 0, "make");
$a2 = mysql_result($vehicle_result, 0, "model");
$a3 = mysql_result($vehicle_result, 0, "fuel");
$a4 = mysql_result($vehicle_result, 0, "department");
$a5 = mysql_result($vehicle_result, 0, "purchase_date");
$a6 = mysql_result($vehicle_result, 0, "purchase_cost");
$a7 = mysql_result($vehicle_result, 0, "chassis_no");
$a8 = mysql_result($vehicle_result, 0, "engine_no");
$a9 = mysql_result($vehicle_result, 0, "service_interval");
$a10 = mysql_result($vehicle_result, 0, "clock_reading");
$a11 = mysql_result($vehicle_result, 0, "road_license_date");
$a12 = mysql_result($vehicle_result, 0, "insurance");
$a13 = mysql_result($vehicle_result, 0, "renewal_date");
$a14 = mysql_result($vehicle_result, 0, "notes");
$a15 = mysql_result($vehicle_result, 0, "ba_license_date");
$a17 = mysql_result($vehicle_result, 0, "last_service_date");
$a18 = mysql_result($vehicle_result, 0, "last_service_mileage");
$a19 = mysql_result($vehicle_result, 0, "insurance_value");
$a20 = mysql_result($vehicle_result, 0, "disposal_date");

$table_name2 = $_SESSION['db_prefix']."_vehicle_service";
$service_query = "SELECT service_date, mileage, service, work_done FROM $table_name2 WHERE vehicle_id = '".$vehicle_id."' ORDER BY service_date ASC LIMIT 5";
$service_result = mySQL_query($service_query);
$service_num = mysql_num_rows($service_result);
$ttLine='';
$i=0;
while ($i<$service_num) {
$service_date = mysql_result($service_result, $i, "service_date");
$mileage = mysql_result($service_result, $i, "mileage"); 
$service = mysql_result($service_result, $i, "service");
$work_done = mysql_result($service_result, $i, "work_done");
$ttLine_add = "<tr><td  width=50>".date("d-m-Y", strtotime($service_date))."</td><td  width=50>".$mileage."</td><td  width=100>".$service."</td><td width=175>".$work_done."</td></tr>";
$ttLine = $ttLine_add.$ttLine;
$i++;
}
$ttHead = "<table width=400 border=1 style=border-collapse:collapse><tr><td>Date</td><td>Mileage</td><td>Service</td><td>Work done</td></tr>";
$ttFoot = "</table><br><b>Click for details</b>";

$serviceTT = "'".$ttHead.$ttLine.$ttFoot."'";

?>

<body>
<?php
include ("../navigation/header.php");
$page_name = "Transport-main";
include ("../navigation/access.php");

if ($permission_num==1) {
	include ("../navigation/transport_sidebar.php");
?>
<div class="main_frame">
 <div class="page_head_frame">
    <table width="809" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="385"><label class="label_page_head">Vehicle</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label class="label_page_head_2"><?php echo $a0 ?></label></td>
            <td width="253">&nbsp;</td>
            <td width="171" align="right">&nbsp;</td>
          </tr>
        </table>
      </div>
        
<div class="page_middle_frame">
<div class="page_inside_frame">
<div align="left">Vehicle  details</div>
  <table width="640" id="table_details_display">
    <tr>
      <td width="108" height="25">Registration:</td>
      <td width="111"><b><?php echo $a0?></b></td>
      <td width="89">&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td width="110">&nbsp;</td>
    </tr>
    <tr>
      <td height="25">Make:</td>
      <td><b><?php echo $a1?></b></td>
      <td>&nbsp;</td>
      <td width="119">Model:</td>
      <td width="75"><b><?php echo $a2?></b></td>
      <td>&nbsp;</td>
    </tr>
  </table>
</div>

<div class="page_inside_frame">
<div align="left">Vehicle specifications</div>
  <table width="640" id="table_details_display">
    <tr>
      <td width="108" height="25">Fuel:</td>
      <td width="107"><b><?php echo $a3?></b></td>
      <td width="140">Department:</td>
      <td width="101"><b><?php echo $a4?></b></td>
      <td width="47">&nbsp;</td>
      <td width="109">&nbsp;</td>
    </tr>
    <tr>
      <td height="25">Service interval:</td>
      <td><b><?php echo $a9?></b></td>
      <td>Current km reading:</td>
      <td><b><?php echo $a10?></b></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td height="25">Last service:</td>
      <td><b><?php if ($a17!='0000-00-00') { echo date("d-m-Y", strtotime($a17)); }?></b></td>
      <td>at:<b>&nbsp;&nbsp;<?php echo $a18?>&nbsp;&nbsp;km</b></td>
      <td colspan="3">Click <a href="vehicle_service_list.php?date=&vehicle_id=<?php echo $vehicle_id?>" onMouseover="ddrivetip(<?php echo $serviceTT ?>, 400)"; onMouseout="hideddrivetip()">here</a> for service record</td>
      </tr>
  </table>
</div>

<div class="page_inside_frame">
  <table width="640" id="table_details_display">
    <tr>
      <td width="108" height="25">Chassis no:</td>
      <td width="107"><b><?php echo $a7?></b></td>
      <td width="140">Engine no:</td>
      <td colspan="2"><b><?php echo $a8?></b></td>
      </tr>
    <tr>
      <td height="25">Purchase date:</td>
      <td><b><?php echo date("d-m-Y", strtotime($a5 )) ?></b></td>
      <td>&nbsp;</td>
      <td>Disposal date:</td>
      <td width="108"><b><?php if ($a20<'2030-01-01') { echo date("d-m-Y", strtotime($a20));} else { echo 'n/a';} ?></b></td>
    </tr>
    <tr>
      <td height="25">Purchase costs:</td>
      <td><b><?php echo number_format($a6, 2, '.', ',')?></b></td>
      <td>Insurance value:</td>
      <td colspan="2"><b><?php echo number_format($a19, 2, '.', ',')?></b></td>
      </tr>
  </table>
</div>

<div class="page_inside_frame">
<div align="left">Admin</div>
  <table width="640" id="table_details_display">
    <tr>
      <td height="25" colspan="2">Road license expires end of:&nbsp;&nbsp;&nbsp;<b><?php if ($a11!='0000-00-00') {echo date("M Y", strtotime($a11));} else { echo 'n/a'; }?></b></td>
      <td colspan="2">BA license expires end of:&nbsp;&nbsp;&nbsp;<b><?php if ($a15!='0000-00-00') {echo date("M Y", strtotime($a15));} else { echo 'n/a'; }?></b></td>
      </tr>
    <tr>
      <td width="108" height="25">Insurance:</td>
      <td width="176"><b><?php echo $a12 ?></b></td>
      <td width="161">Insurance renewal date:</td>
      <td width="175"><b><?php echo date("d-m-Y", strtotime($a13 ))?></b></td>
    </tr>
  </table>
</div>

<div class="page_inside_frame">
<div align="left">
  <p>Miscelaneous</p>
  <p>Click <a href="project_vehicle_list.php?vehicle_id=<?php echo $vehicle_id ?>&date=">here</a> for the projects this vehicle was used for.</p>
</div>
  <table width="640" id="table_details_display">
    <tr>
      <td width="108" height="25">Notes:</td>
      <td width="520"><b><?php echo $a14?></b></td>
    </tr>
  </table>
</div>

  
</div>
</div>
</body>
<?php } else {
$_SESSION['denied_return'] = "transport/transport-main.php";	
include ("../navigation/transport_sidebar.php");?>
	<body onload="accessdenied(); return false">
	</body>
<?php }
?>

<?php include ('../navigation/side_bar.php'); ?>
</html>