<!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'];
$department = $_GET['company'];


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



?>

<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='company_fuel_list.php';
$reference_name='company';
$reference=$department;
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": [[ 1, "desc" ]],
					"aoColumns": [
					     		{"bSortable": true},
								{"iDataSort": 7},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bVisible": false}
								 ]
				} );
			} );
		</script>
Fuel usage for: <font size="+1"> &nbsp;&nbsp;<?php echo $department ?></font>
<table width="679" id="scroll_table" class="data_display"  >
  <thead>
  <tr>
    <th align="center">No</th>
    <th align="center">Date</th>
    <th align="center">Vehicle</th>
    <th align="center">Registration</th>
    <th align="center">Mileage</th>
    <th align="center">Ltrs</th>
    <th align="center">Supplied to</th>
    <th align="center">&nbsp;</th>
    </tr>
    </thead>
<?php 

$i=0;
$a5_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, "vehicle_id");
	$a4 = mysql_result($fuel_result, $i, "fuel");
	$a5 = mysql_result($fuel_result, $i, "qty_supplied");
	$clock_reading = number_format(mysql_result($fuel_result, $i, "mileage"), 0, '.', ',');
		
	$table_name = $_SESSION['db_prefix']."_vehicle";
	$vehicle_query = "SELECT registration_no, make, model, department FROM $table_name WHERE vehicle_id = '".$a3."' ";
	$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");
	

$vehicleTT ="<table id=table_tool_tip width=250 ><tr><td  width=75>Make/model:</td><td width=175>".$make.' '.$model."</td></tr><tr><td>Company:</td><td>".$department."</td></tr><tr><td>Km reading:</td><td>".$clock_reading."km</td></tr></table><br><b>Click for details</b>"; 
	
	
	
	$a7 = mysql_result($fuel_result, $i, "rec_no");
	
	$a9 = mysql_result($fuel_result, $i, "driver");
		
		
	
	
	
	?>
<tr>
    <td width="23" 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="36" align="left"><?php echo date("d-m-Y", strtotime($a1 )) ?></td>
    <td width="173" align="left"><a href="vehicle_details.php?vehicle_id=<?php echo $a3 ?>" onMouseover="ddrivetip('<?php echo $vehicleTT ?>', 175)"; onMouseout="hideddrivetip()"><?php echo $make.' '.$model ?></a></td>
    <td width="116" align="center"><?php echo $registration_no ?>  </a></td>
    <td width="96" align="center"><?php echo $clock_reading ?></td>
    <td width="76" align="right"><?php echo $a5; $a5_total = $a5_total + $a5; ?></td>
    <td width="100" align="center"><?php echo $a9 ?></td>
    <td width="23" align="left"><?php echo $a1 ?></td>
    </tr>
  
  <?php
  $i++;
}
?>
<tfoot>
<tr>
  <td colspan="5" align="right">Totals:</td>
  <td align="right"><?php echo number_format($a5_total, 2, '.', ',') ?></td>
    <td align="left">&nbsp;</td>
    <td align="left">&nbsp;</td>
    </tr>
  </tfoot>
</table>
</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>