<!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');

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

$table_name2 = $_SESSION['db_prefix']."_vehicle_admin";
$admin_query = "SELECT * FROM $table_name2 WHERE vehicle_id = '".$vehicle_id."' AND admin_date >= '".$start."' AND admin_date <= '".$end."' ORDER BY admin_date ASC";
$admin_result = mySQL_query($admin_query);
$admin_num = mysql_num_rows($admin_result);

$table_name = $_SESSION['db_prefix']."_vehicle";
$vehicle_query = "SELECT registration_no, make, model, department, clock_reading 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");
$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
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">Admin</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_admin_list.php';
$reference_name='vehicle_id';
$reference=$vehicle_id;
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": [[ 7, "desc" ]],
					"aoColumns": [
					     		
								{"iDataSort": 7},
								{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bVisible": false}
								 ]
				} );
			} );
		</script>
Admin record 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 ?></a></font>
<table width="670" id="scroll_table" class="data_display"  >
  <thead>
  <tr>
    <th align="center">Date</th>
    <th align="center">Km</th>
    <th align="center">Admin</th>
    <th align="center">Cost</th>
    <th align="center">Document<br>
      no</th>
    <th align="center">Provider</th>
    <th align="center">Notes</th>
    <th align="center">&nbsp;</th>
    </tr>
    </thead>
<?php 

$i=0;

$a5_total=0;

$a10_total=0;
while ($i<$admin_num) {

	
	$a1 = mysql_result($admin_result, $i, "admin_date");
	
	$a3 = mysql_result($admin_result, $i, "mileage");
		
	$a4 = mysql_result($admin_result, $i, "admin_type");
	$a5 = mysql_result($admin_result, $i, "admin_cost");
	$a5_total=$a5_total+$a5;
	$a6 = mysql_result($admin_result, $i, "document_no");
	
	$a8 = mysql_result($admin_result, $i, "provider");
	$a9 = mysql_result($admin_result, $i, "notes");

	?>

  <tr>
    <td width="51" align="left"><?php echo date("d-m-Y", strtotime($a1 )) ?></td>
    <td width="41" align="right"><?php echo $a3 ?></a> </td>
    <td width="101" align="left"><?php echo $a4 ?></td>
    <td width="56" align="right"><?php echo number_format($a5, 2, '.', ',') ?></td>
    <td width="71" align="left"><?php echo $a6 ?></td>
    <td width="131" align="left"><?php echo $a8 ?></td>
    <td width="160" align="left">&nbsp;<?php echo $a9 ?></td>
    <td width="23" align="left"><?php echo $a1 ?></td>
    </tr>
  
  <?php
  $i++;
}
?>
<tfoot>
<tr>
    <td align="right">&nbsp;</td>
    <td align="right">&nbsp;</td>
    <td align="right">Totals:</td>
    <td align="right"><?php echo number_format($a5_total, 2, '.', ',') ?></td>
    <td align="right">&nbsp;</td>
    <td align="right">&nbsp;</td>
    <td align="right">&nbsp;</td>
    <td align="right">&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>