<!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 ("../navigation/header.php");
include('../include/period_select_date.php');

$date = $_GET['date'];
$vehicle_id = $_GET['vehicle_id'];

$table_name2 = $_SESSION['db_prefix']."_fuel_supply";
$fuel_query = "SELECT * FROM $table_name2 WHERE vehicle_id = '".$vehicle_id."' AND supply_date >= '".$start."' AND supply_date <= '".$end."' ORDER BY fuel_id ASC";
$fuel_result = mySQL_query($fuel_query);
$fuel_num = mysql_num_rows($fuel_result);

$table_name = $_SESSION['db_prefix']."_vehicle";
$vehicle_query = "SELECT registration_no, make, model, department, clock_reading, driver FROM $table_name WHERE vehicle_id = '".$vehicle_id."' ";
$vehicle_result = mySQL_query($vehicle_query);
$vehicle_num = mysql_num_rows($vehicle_result);
$registration_no = mysql_result($vehicle_result, 0, "registration_no");
$make = mysql_result($vehicle_result, 0, "make");
$model = mysql_result($vehicle_result, 0, "model");
$department = mysql_result($vehicle_result, 0, "department");
$driver = mysql_result($vehicle_result, 0, "driver");
$clock_reading = number_format(mysql_result($vehicle_result, 0, "clock_reading"), 0, '.', ',');

$vehicleTT ="<table id=table_tool_tip width=250 ><tr><td  width=75>Make/model:</td><td width=175>".$make.' '.$model."</td></tr><tr><td>Department:</td><td>".$department."</td></tr><tr><td>Km reading:</td><td>".$clock_reading."km</td></tr></table><br><b>Click for details</b>"; 
?>
<script type="text/javascript" src="../jscript/tablesort.js"></script>
<script language="javascript" src="../jscript/calendar.js"></script>
</head>
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />
<body>
<?php

$page_name = "Stores-main";
include ("../navigation/access.php");

if ($permission_num==1) {
	include ("../navigation/store_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">Fuel</label></td>
            <td width="253">&nbsp;</td>
            <td width="171" align="right">&nbsp;</td>
          </tr>
        </table>
      </div>
<div class="page_middle_frame">
<?php
$page='vehicle_fuel_list.php';
$reference_name='vehicle_id';
$reference=$vehicle_id;
$reference_name_2='';
$reference_2='';
include('../include/period_select_block.php');
?>
<div class="page_inside_frame">
<!--jscript-->
<script type="text/javascript" language="javascript" src="../jscript/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">
			$(document).ready(function() {
				$('#scroll_table').dataTable( {
					"sScrollY": "500px",
					"bPaginate": false,
					"bScrollCollapse": true,
					"aaSorting": [[ 0, "desc" ]],
					"aoColumns": [
					     		{"bSortable": true},
								{"bSortable": false},
								{"bSortable": false},
                             	{"bSortable": false},
								{"bSortable": false},
								{"bSortable": false},
								{"bSortable": false},
								{"bSortable": false},
								{"bSortable": false},
								{"bVisible": false}
								 ]
				} );
			} );
		</script>
Fuel usage for: <font size="+1"> <a href="vehicle_details.php?vehicle_id=<?php echo $vehicle_id?>" onMouseover="ddrivetip('<?php echo $vehicleTT ?>  ', 200)"; onMouseout="hideddrivetip()"><?php echo $registration_no.' '.$make.' '.$model.'&nbsp;&nbsp;&nbsp;&nbsp;('.$driver.')' ?></a></font>
<table width="659" id="scroll_table" class="data_display"  >
  <thead>
  <tr>
    <th align="center">No</th>
    <th align="center">Date</th>
    <th align="center">Km(hrs)</th>
    <th align="center">Fuel</th>
    <th align="center">Qty<br>
    (ltrs)</th>
    <th align="center">Coverage</th>
    <th align="center">Consumption<br>Km(hrs) per ltr</th>
    <th align="center">Ref</th>
    <th align="center">Driver</th>
    <th align="center">&nbsp;</th>
    </tr>
    </thead>
<?php 

$i=0;
$pre_mileage=0;
$a5_total=0;
$a10_total=0;
while ($i<$fuel_num) {

	$a0 = mysql_result($fuel_result, $i, "fuel_id");
	$a1 = mysql_result($fuel_result, $i, "supply_date");
			
	$a3 = mysql_result($fuel_result, $i, "mileage");
	$a3a = $pre_mileage; 
	$a10 = $a3-$a3a;
	
	
	$a4 = mysql_result($fuel_result, $i, "fuel");
	$a5 = mysql_result($fuel_result, $i, "qty_supplied");
	
	if ($pre_mileage!=0) {
	$average = number_format($a10/$a5, 2, '.', ',');
	}
	else {
		$a10='';
		$average='';
	}
	$a5_total=$a5_total+$a5;
	
	
	
	
	
	$a7 = mysql_result($fuel_result, $i, "rec_no");
	
	$a9 = mysql_result($fuel_result, $i, "driver");
			
		
	$pre_mileage = mysql_result($fuel_result, $i, "mileage");
	
	
	?>
<tr>
    <td width="42" align="left"><a href="fuel_rec_display.php?fuel_id=<?php echo $a0 ?>" onMouseover="ddrivetip('Click for fuel receipt.', 150)"; onMouseout="hideddrivetip()"><?php echo $a0 ?></a>&nbsp;</td>
    <td width="54" align="left"><?php echo date("d-m-Y", strtotime($a1 )) ?></td>
    <td width="60" align="left"><?php echo $a3 ?></a> </td>
    <td width="64" align="left"><?php echo $a4 ?></td>
    <td width="52" align="center"><?php echo $a5 ?>  </a></td>
    <td width="69" align="center"><?php echo $a10 ?></td>
    <td width="106" align="center">1 : <?php echo $average ?></td>
    <td width="46" align="left"><?php echo $a7 ?></td>
    <td width="90" align="center"><?php echo $a9 ?></td>
    <td width="32" align="left"><?php echo $a1 ?></td>
    </tr>
  
  <?php
  $i++;
}
?>
<tfoot>
<tr>
  <td colspan="4" align="right">Totals:</td>
    <td align="center"><?php echo number_format($a5_total, 2, '.', ',') ?></td>
    <td align="center"><?php echo $a10_total ?></td>
    <td colspan="4" align="center">&nbsp;</td>
    </tr>
  </tfoot>
</table>
</div>
</div>
</div>
</body>
<?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'); ?>



</html>