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


$table_name2 = $_SESSION['db_prefix']."_fuel_supply";
$fuel_query = "SELECT * FROM $table_name2 WHERE supply_date >= '".$start."' AND supply_date <= '".$end."' ";
$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
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">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='fuel_list.php';
$reference_name='';
$reference='';
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},
								{"iDataSort": 9},
								{"bSortable": true},
                              	{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bVisible": false}
								 ]
				} );
			} );
		</script>
<table width="650" id="scroll_table" class="data_display"  >
  <thead>
  <tr>
    <th>No</th>
    <th>Date</th>
    <th>Vehicle</th>
    <th>Km</th>
    <th>Fuel</th>
    <th>Qty</th>
    <th>Cost</th>
    <th>Ref</th>
    <th>Supplier</th>
    <th>Received</th>
    <th>&nbsp;</th>
    </tr>
    </thead>
<?php 

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

	$a0 = mysql_result($fuel_result, $i, "fuel_id");
	$a1 = mysql_result($fuel_result, $i, "supply_date");
		
	$a2 = mysql_result($fuel_result, $i, "vehicle_id");
	   	$table_name = $_SESSION['db_prefix']."_vehicle";
    	$vehicle_query = "SELECT registration_no, make, model, department, clock_reading  FROM $table_name WHERE vehicle_id = $a2 ";
		$vehicle_result = mySQL_query($vehicle_query);
		$a2a = mysql_result($vehicle_result, 0, "registration_no");
        $a2b = mysql_result($vehicle_result, 0, "make")." ".mysql_result($vehicle_result, 0, "model");
		$a10 = mysql_result($vehicle_result, 0, "department");
		$a11 =number_format(mysql_result($vehicle_result, 0, "clock_reading"), 0, '.', ',') ;
		
	$a3 = number_format(mysql_result($fuel_result, $i, "mileage"), 0, '.', ',');
	$a4 = mysql_result($fuel_result, $i, "fuel");
	$a5 = mysql_result($fuel_result, $i, "qty_supplied");
	$a6 = mysql_result($fuel_result, $i, "price");
	$a6a = $a5*$a6;
	$a5_total=$a5_total+$a5;
	$a6_total=$a6_total+$a6a;
	$a7 = mysql_result($fuel_result, $i, "reference");
	$a8 = mysql_result($fuel_result, $i, "supplier");
	$a9 = mysql_result($fuel_result, $i, "driver");
	
	
	$table_name2 = $_SESSION['db_prefix']."_employee";
	$employee_query = "SELECT emp_first_name, emp_last_name FROM $table_name2 WHERE emp_id ='".$a9."' ";
	$employee_result = mySQL_query($employee_query);
	$employee_num = mysql_num_rows($employee_result);	
	$a9a = mysql_result($employee_result, 0, "emp_first_name").' '.mysql_result($employee_result, 0, "emp_last_name"); 
	
	
	$vehicleTT ="<table id=table_tool_tip width=250 ><tr><td  width=75>Make/model:</td><td width=175>".$a2b."</td></tr><tr><td>Department:</td><td>".$a10."</td></tr><tr><td>Km reading:</td><td>".$a11."km</td></tr></table><br><b>Click for details</b>"; 
	
	?>

  <tr>
    <td width="27" 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></td>
    <td width="46" align="left"><?php echo date("d-m-Y", strtotime($a1 )) ?></td>
    <td width="126" align="left"><a href="vehicle_details.php?vehicle_id=<?php echo $a2?>" onMouseover="ddrivetip('<?php echo $vehicleTT ?>  ', 200)"; onMouseout="hideddrivetip()"><?php echo $a2a ?></a><br><?php echo $a2b ?></td>
    <td width="46" align="right"><?php echo $a3 ?></a></td>
    <td width="46" align="right"><?php echo $a4 ?></td>
    <td width="56" align="right"><?php echo $a5 ?>  </a></td>
    <td width="46" align="right"><?php echo number_format($a6a, 2, '.', ',') ?></td>
    <td width="46" align="left"><?php echo $a7 ?></td>
    <td width="75" align="left"><?php echo $a8 ?></td>
    <td width="65" align="left"><?php echo $a9a ?></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, '.', ',') ?>&nbsp;</td>
    <td align="right"><?php echo number_format($a6_total, 2, '.', ',') ?></td>
    <td colspan="4" 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>