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

<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/scroll_table.css" />
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />

<link href="../css/main.css" rel="stylesheet" type="text/css" />
<?php
include('../include/session.php');
include('../include/period_select_date.php');	
	
$table_name2 = $_SESSION['db_prefix']."_tracking_transport";
$tracking_query = "SELECT * FROM $table_name2 WHERE entry_date >= '".$start."' AND entry_date <= '".$end."' ";
$tracking_result = mySQL_query($tracking_query);
$tracking_num = mysql_num_rows($tracking_result);
?>

</head>

<body>
<?php 
include ("../navigation/header.php");
$page_name = "AD-tracking";
include ("../navigation/access.php");
if ($permission_num==1) {
	include ("../navigation/admin_sidebar.php");
include('../include/tooltip.php');?>
<div class="main_frame">
  <div class="page_head_frame">
     <label class="label_page_head">Transport  tracking</label></td>
  </div>
        <br />
<br />
<br />
<br />
<div class="page_middle_frame">
<?php
$page='tracking_transport.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": [
								{"iDataSort": 5},
                              	{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bVisible": false}
								 ]
				} );
			} );
		</script>
<table width="659" id="scroll_table" class="data_display"  >
  <thead>
  <tr>
    <th>date</th>
    <th>time</th>
    <th>user</th>
    <th>action</th>
    <th>details</th>
    <th>&nbsp;</th>
  </tr>
  </thead>
<?php 

$i=0;

while ($i<$tracking_num) {
    $b0  =  mysql_result($tracking_result, $i, "action_id");
	$b1 =  mysql_result($tracking_result, $i, "entry_date");
	$b2 =  mysql_result($tracking_result, $i, "user_name");
	$b3 =  mysql_result($tracking_result, $i, "action");
	$d1 =  mysql_result($tracking_result, $i, "details_1");
	$d2 =  mysql_result($tracking_result, $i, "details_2");
	$d3 =  mysql_result($tracking_result, $i, "details_3");
	$d4 =  mysql_result($tracking_result, $i, "details_4");
	
	$action='';
	$details='';
	switch ($b3) {
    case 40:
	    $action = 'New vehicle';
        $table_name = $_SESSION['db_prefix']."_employee";
		$table_name = $_SESSION['db_prefix']."_vehicle";
		$vehicle_query = "SELECT vehicle_id, registration_no, make, model FROM $table_name WHERE registration_no = '".$d2."' ";
		$vehicle_result = mySQL_query($vehicle_query);
		$vehicle_id = mysql_result($vehicle_result, 0, "vehicle_id");
		$vehicle = mysql_result($vehicle_result, 0, "registration_no").' '.mysql_result($vehicle_result, 0, "make").' '.mysql_result($vehicle_result, 0, "model");
		$TT = "'Click here for details on ".$vehicle."'";
        $details='New vehicle: <b><a href="../transport/vehicle_details.php?vehicle_id='.$vehicle_id.'" onMouseover="ddrivetip('.$TT.', 250)"; onMouseout="hideddrivetip()">'.$vehicle.'</a></b> ';
        break;
		
	case 41:
	    $action = 'Edit';
        $table_name = $_SESSION['db_prefix']."_vehicle";
		$vehicle_query = "SELECT registration_no, make, model FROM $table_name WHERE vehicle_id = '".$d1."' ";
		$vehicle_result = mySQL_query($vehicle_query);
		$vehicle = mysql_result($vehicle_result, 0, "registration_no").' '.mysql_result($vehicle_result, 0, "make").' '.mysql_result($vehicle_result, 0, "model");
		$TT = "'Click here for details on ".$vehicle."'";
        $details= $d4.' for: <b><a href="../transport/vehicle_details.php?vehicle_id='.$d1.'" onMouseover="ddrivetip('.$TT.', 250)"; onMouseout="hideddrivetip()">'.$vehicle.'</a></b> edited from: '.$d2.' to: '.$d3;
        break;
		
		case 42:
	    $action = 'Fuel';
        $table_name = $_SESSION['db_prefix']."_vehicle";
		$vehicle_query = "SELECT registration_no, make, model FROM $table_name WHERE vehicle_id = '".$d1."' ";
		$vehicle_result = mySQL_query($vehicle_query);
		$vehicle = mysql_result($vehicle_result, 0, "registration_no").' '.mysql_result($vehicle_result, 0, "make").' '.mysql_result($vehicle_result, 0, "model");
		$TT = "'Click here for details on ".$vehicle."'";
        $details= $d3.'ltr for: <b><a href="../transport/vehicle_details.php?vehicle_id='.$d1.'" onMouseover="ddrivetip('.$TT.', 250)"; onMouseout="hideddrivetip()">'.$vehicle.'</a></b> on: '.date("d-m-Y", strtotime($d2)).' on: '.$d4.'km';
        break;
		
		case 43:
	    $action = 'Service';
        $table_name = $_SESSION['db_prefix']."_vehicle";
		$vehicle_query = "SELECT registration_no, make, model FROM $table_name WHERE vehicle_id = '".$d1."' ";
		$vehicle_result = mySQL_query($vehicle_query);
		$vehicle = mysql_result($vehicle_result, 0, "registration_no").' '.mysql_result($vehicle_result, 0, "make").' '.mysql_result($vehicle_result, 0, "model");
		$TT = "'Click here for details on ".$vehicle."'";
        $details= $d3.' for: <b><a href="../transport/vehicle_details.php?vehicle_id='.$d1.'" onMouseover="ddrivetip('.$TT.', 250)"; onMouseout="hideddrivetip()">'.$vehicle.'</a></b> on: '.date("d-m-Y", strtotime($d2)).' on: '.$d4.'km';
        break;
		
		case 44:
	    $action = 'Admin';
        $table_name = $_SESSION['db_prefix']."_vehicle";
		$vehicle_query = "SELECT registration_no, make, model FROM $table_name WHERE vehicle_id = '".$d1."' ";
		$vehicle_result = mySQL_query($vehicle_query);
		$vehicle = mysql_result($vehicle_result, 0, "registration_no").' '.mysql_result($vehicle_result, 0, "make").' '.mysql_result($vehicle_result, 0, "model");
		$TT = "'Click here for details on ".$vehicle."'";
        $details= $d2.' for: <b><a href="../transport/vehicle_details.php?vehicle_id='.$d1.'" onMouseover="ddrivetip('.$TT.', 250)"; onMouseout="hideddrivetip()">'.$vehicle.'</a></b> on: '.$d4.'km';
        break;
		
		case 45:
	    $action = 'Edit fuel receipt';
        $table_name = $_SESSION['db_prefix']."_vehicle";
		$TT = "'Click here for receipt details'";
        $details= '<b>'.$d4.'</b> on fuel receipt: <b><a href="../transport/fuel_rec_display.php?fuel_id='.$d1.'" onMouseover="ddrivetip('.$TT.', 250)"; onMouseout="hideddrivetip()">'.$d1.'</a></b> changed from: <b>'.$d2.'</b> to <b>'.$d3.'</b>';
        break;
		

}
?>

  <tr>
    <td width="66" align="left"><?php echo date("d-m-Y", strtotime($b1 )) ?></td>
    <td width="46" align="left"><?php echo date("H:i", strtotime($b1 ))  ?></td>
    <td width="49" align="left"><?php echo $b2 ?></td>
    <td width="71" align="left"><?php echo $action ?></td>
    <td width="376" align="left"><?php echo $details ?></td>
    <td width="23" align="left"><?php echo $b1 ?></td>
    </tr>
  <?php
  $i++;
}
?>

</table>
</div>
</div>
</div>

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