<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--style sheets--> 
<link href="../css/main.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../css/scroll_table.css" />
<!--jscript-->

<?php
include('../include/session.php');

$m = date("m");	
$check_date = date("Y-m-31");

if ($m=='02') {
$end = date("Y-m-28");
}

if ( ($m=='04') OR ($m=='06')  OR ($m=='09')  OR ($m=='11') ) {
$check_date = date("Y-m-30");
}
$check_date_display = date("M-Y", strtotime($check_date));

$table_name2 = $_SESSION['db_prefix']."_vehicle";
$road_license_query = "SELECT registration_no, make, model, department, road_license_date, clock_reading FROM $table_name2 WHERE road_license_date < '".$check_date."' AND road_license_date <> '0000-00-00' AND disposal_date = '2030-01-01'" ;
$road_license_result = mySQL_query($road_license_query);
$road_license_num = mysql_num_rows($road_license_result);

$table_name2 = $_SESSION['db_prefix']."_vehicle";
$ba_license_query = "SELECT registration_no, make, model, department, ba_license_date, clock_reading FROM $table_name2 WHERE ba_license_date < '".$check_date."' AND ba_license_date <> '0000-00-00' AND disposal_date = '2030-01-01'" ;
$ba_license_result = mySQL_query($ba_license_query);
$ba_license_num = mysql_num_rows($ba_license_result);

$table_name2 = $_SESSION['db_prefix']."_vehicle";
$insurance_query = "SELECT registration_no, make, model, department, renewal_date, insurance, clock_reading FROM $table_name2 WHERE renewal_date < '".$check_date."' AND renewal_date <> '0000-00-00' AND disposal_date = '2030-01-01'" ; 
$insurance_result = mySQL_query($insurance_query);
$insurance_num = mysql_num_rows($insurance_result);


?>
<script language="javascript" src="../jscript/calendar.js"></script>
</head>
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />
<body>
<?php
include ("../navigation/header.php");
$page_name = "Transport-main";
include ("../navigation/access.php");

if ($permission_num==1) {
	include ("../navigation/transport_sidebar.php");
    include ('../include/tooltip.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">License & insurance renewal</label></td>
            <td width="253">&nbsp;</td>
            <td width="171" align="right">&nbsp;</td>
          </tr>
        </table>
      </div>
<div class="page_middle_frame">
Renewals before the end of: <?php echo $check_date_display ?>
  <div class="page_inside_frame">
Road license renewal:
<table width="640"  id="table_details_display"  >
  <thead>
  <tr>
    <th>Registration no</th>
    <th>Vehicle</th>
    <th>Department</th>
    <th>renew before end of:</th>
    </tr>
    </thead>
<?php 

$i=0;
$a5_total=0;
$a6_total=0;
while ($i<$road_license_num) {

	$a0 = mysql_result($road_license_result, $i, "registration_no");
	$a1 = mysql_result($road_license_result, $i, "make")." ".mysql_result($road_license_result, $i, "model");
	$a2 = mysql_result($road_license_result, $i, "department");
	$a3 = mysql_result($road_license_result, $i, "road_license_date");
	$a4 = mysql_result($road_license_result, $i, "clock_reading");
	
	
	
	$vehicleTT ="<table id=table_tool_tip width=250 ><tr><td  width=75>Make/model:</td><td width=175>".$a1."</td></tr><tr><td>Department:</td><td>".$a2."</td></tr><tr><td>Km reading:</td><td>".$a4."km</td></tr></table><br><b>Click for details</b>"; 
	
	?>

  <tr>
    <td width="126" align="left"><a href="" onMouseover="ddrivetip('<?php echo $vehicleTT ?>', 150)"; onMouseout="hideddrivetip()"><?php echo $a0 ?></a></td>
    <td width="146" align="left"><?php echo $a1 ?></td>
    <td width="136" align="left"><?php echo $a2 ?></td>
    <td width="212" align="center"><?php  if ($a3!='') echo date("M-Y", strtotime($a3)); ?></td>
 </tr>
  
  <?php
  $i++;
}
?>
<tfoot>
</tfoot>
</table>
</div>
  <div class="page_inside_frame"> BA license renewal:
    <table width="640"  id="table_details_display"  >
      <thead>
        <tr>
          <th>Registration no</th>
          <th>Vehicle</th>
          <th>Department</th>
          <th>renew before end of:</th>
        </tr>
      </thead>
      <?php 

$i=0;
$a5_total=0;
$a6_total=0;
while ($i<$ba_license_num) {

	$b0 = mysql_result($ba_license_result, $i, "registration_no");
	$b1 = mysql_result($ba_license_result, $i, "make")." ".mysql_result($ba_license_result, $i, "model");
	$b2 = mysql_result($ba_license_result, $i, "department");
	$b3 = mysql_result($ba_license_result, $i, "ba_license_date");
	$b4 = mysql_result($ba_license_result, $i, "clock_reading");
	
	
	
	$vehicleTT ="<table id=table_tool_tip width=250 ><tr><td  width=75>Make/model:</td><td width=175>".$a1."</td></tr><tr><td>Department:</td><td>".$a2."</td></tr><tr><td>Km reading:</td><td>".$a4."km</td></tr></table><br><b>Click for details</b>"; 
	
	?>
      <tr>
        <td width="126" align="left"><?php echo $b0 ?></td>
        <td width="146" align="left"><?php echo $b1 ?></td>
        <td width="136" align="left"><?php echo $b2 ?></td>
        <td width="212" align="center"><?php  if ($b3!='') echo date("M-Y", strtotime($b3)); ?></td>
      </tr>
      <?php
  $i++;
}
?>
      <tfoot>
      </tfoot>
    </table>
  </div>
  <div class="page_inside_frame"> Insurance renewal:
    <table width="640"  id="table_details_display"  >
      <thead>
        <tr>
          <th>Registration no</th>
          <th>Vehicle</th>
          <th>Department</th>
          <th>renew before </th>
          <th>Insured with</th>
        </tr>
      </thead>
      <?php 

$i=0;
$a5_total=0;
$a6_total=0;
while ($i<$insurance_num) {

	$a0 = mysql_result($insurance_result, $i, "registration_no");
	$a1 = mysql_result($insurance_result, $i, "make")." ".mysql_result($insurance_result, $i, "model");
	$a2 = mysql_result($insurance_result, $i, "department");
	$a3 = mysql_result($insurance_result, $i, "renewal_date");
	$a4 = mysql_result($insurance_result, $i, "clock_reading");
	$a5 = mysql_result($insurance_result, $i, "insurance");
	
	
	
	$vehicleTT ="<table id=table_tool_tip width=250 ><tr><td  width=75>Make/model:</td><td width=175>".$a1."</td></tr><tr><td>Department:</td><td>".$a2."</td></tr><tr><td>Km reading:</td><td>".$a4."km</td></tr></table><br><b>Click for details</b>"; 
	
	?>
      <tr>
        <td width="108" align="left"><?php echo $a0 ?></td>
        <td width="109" align="left"><?php echo $a1 ?></td>
        <td width="131" align="left"><?php echo $a2 ?></td>
        <td width="126" align="center"><?php  if ($a3!='') echo date("d-m-Y", strtotime($a3)); ?></td>
        <td width="142" align="left"><?php echo $a5 ?></td>
      </tr>
      <?php
  $i++;
}
?>
      <tfoot>
      </tfoot>
    </table>
  </div>
<div class="page_inside_frame">
<a href="save_report_license_renewal.php"><input name="save_button" type="button" class="imagebutton" value="Save report"></a>
</div>  
</div>
</div>

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


</body>
</html>