<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php 
include('../include/session.php');

$vehicle_id = $_GET['vehicle_id'];
include('../include/period_select_date.php');	 
 
$table_name = $_SESSION['db_prefix']."_vehicle_project";	 	
$display_query = "SELECT * FROM $table_name WHERE vehicle_id = '".$vehicle_id."' AND (use_date BETWEEN '".$start."' AND '".date('Y-m-d', strtotime(date("Y-m-d", strtotime($end))." +1 day"))."') ";
$display_result = execsql($display_query);
$display_num = mysql_num_rows($display_result); 

$table_name2 = $_SESSION['db_prefix']."_vehicle";
$vehicle_query = "SELECT registration_no, make, model FROM $table_name2 WHERE vehicle_id ='".$vehicle_id."' ";
$vehicle_result = mySQL_query($vehicle_query);
$vehicle_num = mysql_num_rows($vehicle_result);	
$vehicle = mysql_result($vehicle_result, 0, "registration_no").' '.mysql_result($vehicle_result, 0, "make").' '.mysql_result($vehicle_result, 0, "model"); 
?> 

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

<!--jscript-->
<script language="JavaScript" src="../jscript/tooltip.js"  type="text/javascript"></script> 


</head>


<body>
<?php
include ("../navigation/header.php");
include ("../navigation/transport_sidebar.php");
$page_name = "Transport-main";
include ("../navigation/access.php");
if ($permission_num==1) {
?>
<div class="main_frame">
<div class="page_head_frame">
  <label class="label_page_head">Projects for vehicle</label>&nbsp;&nbsp;&nbsp; 
  <label class="label_page_head_2"><?php echo $vehicle ?></label>
  </div>

<div class="page_middle_frame">

<?php
$page='project_vehicle_list.php';
$reference_name='vehicle_id';
$reference=$vehicle_id;
include('../include/period_select_block.php');
?>
<div class="page_inside_frame">
<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": [[ 5, "desc" ]],
					"aoColumns": [
								{"iDataSort": 5},
								{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bVisible": false}				
								 ]
				} );
			} );
		</script> 
Projects for <?php echo $vehicle ?>
<table width="661" id="scroll_table" class="data_display" >
  <thead>
		<tr>
		  <th width="78">Date</th>
		  <th width="86">Job card no</th>
		  <th width="176">Project</th>
          <th width="196" >Customer</th>
		  <th width="66" >Mileage</th>
		  <th width="31" >&nbsp;</th>
		  </tr>
	</thead>
	<tbody>
  <?php
    $b3_tot=0;
    $i=0;
	while($i < $display_num){
		 $b1 = mysql_result($display_result, $i, "use_date");
		 $b2 = mysql_result($display_result, $i, "job_card_no"); 
		 
		 $table_name = $_SESSION['db_prefix']."_compiled_jobs";
		 $job_query = "SELECT project, project_no, project_place, project_description, value, del_date, cust_id FROM $table_name WHERE job_card_no = '".$b2."' ";
		 $job_result = mySQL_query($job_query);
	     $job_num = mysql_num_rows($job_result);
	     $project = mysql_result($job_result, 0, "project");
		 $cust_id = mysql_result($job_result, 0, "cust_id");
		 
		 $b9 = mysql_result($job_result, 0, "project_no");
		 $b10 = mysql_result($job_result, 0, "project_place");
		 $b11 = mysql_result($job_result, 0, "project_description");
		 $b12 = mysql_result($job_result, 0, "del_date");
		 $b13 = mysql_result($job_result, 0, "value");
		 
		 $table_name2 = $_SESSION['db_prefix']."_customer";
		 $customer_query = "SELECT * FROM $table_name2 WHERE cust_id ='".$cust_id."' ";
		 $customer_result = mySQL_query($customer_query);
		 $customer_num = mysql_num_rows($customer_result);	
		 $a1 = mysql_result($customer_result, 0, "account_type");
			if ($a1=="corporate") { 
				$cust_name = mysql_result($customer_result, 0, "comp_name"); 
			} 
			else {
				$cust_name = mysql_result($customer_result, 0, "title")." ".mysql_result($customer_result, 0, "name_2")." ".mysql_result($customer_result, 0, "comp_name");
 			}
		 if ($customer_num!=0) {
         $a2a = mysql_result($customer_result, 0, "comp_name");
		 $a2b = mysql_result($customer_result, 0, "bag_box");
		 $a2c = mysql_result($customer_result, 0, "box_no");
		 $a2d = mysql_result($customer_result, 0, "postal_place");
		 $a2e = mysql_result($customer_result, 0, "phone");
		 $a2f = mysql_result($customer_result, 0, "contact_1");
		 $a3 = mysql_result($customer_result, 0, "status");
		 }  	
			
		 
		 $b3 = mysql_result($display_result, $i, "mileage"); 
		 
		$b3_tot=$b3_tot+$b3;
		
		$jobTT ="<table id=table_tool_tip width=300 ><tr><td  width=100>Job no:</td><td width=175>".$b2."</td></tr><tr><td valign=top>Project no /place:</td><td>".$b9."&nbsp;".$b10."</td></tr><tr><td>Project description:</td><td>".$b11."</td></tr><tr><td>Job value:</td><td>P ".number_format($b13, 2, '.', ',')."</td></tr><tr><td>Delivery date:</td><td>".$b12."</td></tr></table><br><b>Click for details</b>";
		
		$customerTT ="<table id=table_tool_tip width=250 ><tr><td  width=75>Company:</td><td width=175>".$cust_name."</td></tr><tr><td>Address:</td><td>".$a2b."&nbsp;".$a2c."<br>".$a2d."</td></tr><tr><td>Phone:</td><td>".$a2e."</td></tr><tr><td>Contact:</td><td>".$a2f."</td></tr></table><br><b>Click for details</b>";
		
		 
		?>
		<tr >
		  <td ><?php echo date("d-m-Y", strtotime($b1 ))?></td>
		  <td ><a href="../orders/job_card.php?job_card_no=<?php echo $b2?>" onmouseover="ddrivetip('<?php echo $jobTT?>', 300)"; onmouseout="hideddrivetip()" target="_parent"><?php echo $b2?></a></td>
		  <td align="left"><?php echo $project ?></td>
			<td align="left"><a href="../sales/customer_details.php?cust_id=<?php echo $cust_id?>" onmouseover="ddrivetip('<?php echo $customerTT?>', 250)"; onmouseout="hideddrivetip()"><?php echo $cust_name?></a></td>
			<td align="right"><?php echo $b3 ?></td>
			<td align="right"><?php echo $b2 ?></td>
	      </tr>
		     
		<?php
		$i++; 
	}
	?>
    </tbody>
    <tfoot>
    <tr >
		  <td colspan="6" align="right" ><img src="../images/info_green.png" width="16" height="16"><font pointsize="10px;">Mileage is mileage at time of recording the project installation.</font></td>
		  </tr>
        </tfoot>
	
</table>
		
</div>	
</div>    
</div>
</body>
<?php } else { 
    $_SESSION['denied_return'] = "store/store_main.php";	?>
<body onLoad="accessdenied(); return false">
</body>
<?php }
?>
<?php include ('../navigation/side_bar.php'); ?>