<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

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

$edit_date = date("Y-m-d");
$edit_date = strtotime($edit_date);
$d = date("d", $edit_date ) ;
$m = date("m", $edit_date ) ;
$y = date("Y", $edit_date ) ;

$page = $_GET['page'];
	
if ($page=='vehicle') {
$reference='vehicle_details_edit.php?edit=0&vehicle_id=';	
$page_name_this='Edit vehicle';
$table_name = $_SESSION['db_prefix']."_vehicle";
$vehicleQuery = "SELECT vehicle_id, registration_no, make, model FROM $table_name  ORDER BY registration_no ASC";
$vehicleResult = execsql($vehicleQuery);
$vehicleNum = mysql_num_rows($vehicleResult);
	$w = 0;
	$arrId4 = array ();
	$arrName4 = array ();
	while ($w < $vehicleNum) {
		$arrId4[$w] = mysql_result($vehicleResult, $w, 'vehicle_id');
		$arrName4[$w] = mysql_result($vehicleResult, $w, 'registration_no').' '.mysql_result($vehicleResult, $w, 'make').' '.mysql_result($vehicleResult, $w, 'model');
		$w++;
	}
}

if ($page=='fuel') {
$reference='edit_fuel_rec.php?fuel_id=';
$page_name_this='Edit fuel receipt';
$table_name = $_SESSION['db_prefix']."_fuel_supply";
$receipt_query = "SELECT fuel_id, vehicle_id, reference FROM $table_name ORDER BY fuel_id DESC";
$receipt_result = mySQL_query($receipt_query);
$receipt_num = mysql_num_rows($receipt_result);

	$w = 0;
	$arrId2 = array ();
	$arrName2 = array ();
	while ($w < $receipt_num) {
		$arrId2[$w] = mysql_result($receipt_result, $w, 'fuel_id');
				$fuel_id = mysql_result($receipt_result, $w, "fuel_id");
				$vehicle_id = mysql_result($receipt_result, $w, "vehicle_id");
				$fuel_reference = mysql_result($receipt_result, $w, "reference");
				$table_name = $_SESSION['db_prefix']."_vehicle";
				$name_query = "SELECT registration_no, make, model FROM $table_name WHERE vehicle_id = '".$vehicle_id."'  ";
				$name_result = mySQL_query($name_query);
				$reg_no = mysql_result($name_result, 0, "registration_no");
				$make = mysql_result($name_result, 0, "make");
				$model = mysql_result($name_result, 0, "model");
		$arrName2[$w] = $fuel_id.' -  '.$fuel_reference.'&nbsp;&nbsp;&nbsp;'.$reg_no.' '.$make.' '.$model;
		$w++;
	}
}

?>
</head>

<body>
<?php
include ("../navigation/header.php");
$page_name = "Transport-edit vehicle";
include ("../navigation/access.php");
if ($permission_num==1) {
	include ("../navigation/transport_sidebar.php");
?>
<div class="main_frame">
<div class="page_head_frame">
        <table width="630" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="385"><label class="label_page_head">Select to edit</label></td>
            <td align="right">&nbsp;</td>
          </tr>
        </table>
      </div>

<div class="page_middle_frame"><br />

<?php 
if ($page=='vehicle') { ?>
<div class="page_inside_frame">
  <label class="label_std" style="font-size:16px;"><?php echo $page_name_this?></label>
  <br />
  <br />
  <form action="" method="get">
  
    <label class="label_std"> Select <?php echo $page_name_this?> to edit : &nbsp;&nbsp;</label>
    <select name="vehicle_select" autofocus class="selectbox300" id="vehicle_select" onchange="window.location.href= this.form.vehicle_select.options[this.form.vehicle_select.selectedIndex].value"> 
      <option value=" " selected="selected" >&nbsp;</option>
      <?php
    	for ($j = 0; $j < count($arrId4); $j++) {
			echo "<option value=".$reference.$arrId4[$j].">".$arrName4[$j]."</option>";	
		}
     ?>
    </select>
  
  </form>
  <br />
  <br />
<br />
<br />
<br />
</div>
<?php } ?>


<?php 
if ($page=='fuel') { 
?>
<div class="page_inside_frame">
  <label class="label_std" style="font-size:16px;"><?php echo $page_name_this ?></label>
  <br />
  <br />
  <form action="" method="get">
  
    <label class="label_std"> Select <?php echo $page_name_this ?> to edit : &nbsp;&nbsp;</label>
    <select name="fuel_id_select" autofocus class="selectbox300" id="fuel_id_select" onchange="window.location.href= this.form.fuel_id_select.options[this.form.fuel_id_select.selectedIndex].value"> 
      <option value=" " selected="selected" >&nbsp;</option>
      <?php
    	for ($j = 0; $j < count($arrId2); $j++) {
			echo "<option value=".$reference.$arrId2[$j].">".$arrName2[$j]."</option>";	
		}
     ?>
    </select>
  
  </form>
  <br />
  <br />
<br />
<br />
<br />
</div>
<?php } ?>

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


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

</body>
</html>