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

include('../include/period_select_date.php');	

	$store_item_id =  $_GET['store_item_id'];	 
	
		  
	$table_name1 = $_SESSION['db_prefix']."_item_history";
	$table_name2 = $_SESSION['db_prefix']."_store_items";
	  
		$displayQuery = "SELECT $table_name1.history_id, $table_name1.store_item_id, $table_name1.details, $table_name1.entry, $table_name1.reference, $table_name1.reference_2, $table_name1.reference_3, $table_name1.quantity, $table_name1.total, $table_name1.date, $table_name1.entryDate,  $table_name1.userId, $table_name2.store_item_id, $table_name2.item_name FROM $table_name1, $table_name2 WHERE $table_name2.store_item_id=$store_item_id AND  $table_name2.store_item_id = $table_name1.store_item_id AND $table_name1.entryDate >= '$start' AND $table_name1.entryDate <= '$end' ORDER BY $table_name1.history_id DESC";

		$displayResult = execsql($displayQuery);
		$i = 0;
		$num = mysql_num_rows($displayResult);
		if ($num==0) {
		  $message="No records to show"; 
		   }
		else  {
		  $message="End of list";
		  }
	
	$table_name3 = $_SESSION['db_prefix']."_store_items";
    $item_query = "SELECT item_name, subCategory, location, quantity, minimumStock, price FROM $table_name3 WHERE store_item_id = '".$store_item_id."'  ";
    $item_result = mySQL_query($item_query);
    $b2 = mysql_result($item_result, 0, "item_name");
	$b3 = mysql_result($item_result, 0, "subCategory");
	$b4 = mysql_result($item_result, 0, "location");
	$b5 = mysql_result($item_result, 0, "quantity");
	$b6 = mysql_result($item_result, 0, "minimumStock");
	$b7 = mysql_result($item_result, 0, "price");
	
	$itemTT =
		   "<img src=../images/view.png  width=20 height=16><table id=table_tool_tip width=250 ><tr><td  width=75>Item name:</td><td width=175>".$b2."</td></tr><tr><td>Category</td><td>".$b3."</td></tr><tr><td>Location</td><td>".$b4."</td></tr><tr><td>stock qty</td><td>".$b5."</td></tr><tr><td>Min. stock</td><td>".$b6."</td></tr><tr><td>Price</td><td>".$b7."</td></tr></table><br><b>Click for details</b>";
	
	?>
<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />

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

</head>

<body>
<?php
include ("../navigation/header.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">
    <label class="label_page_head">Store Item History</label>
    &nbsp;&nbsp;
    <label class="label_page_head_2"> &nbsp;&nbsp; 
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="store_item_display.php?store_item_id=<?php echo $store_item_id ?> " onMouseover="ddrivetip('<?php echo $itemTT ?>', 260)"; onMouseout="hideddrivetip()"> <?php echo $b2 ?></a></label>
  </div>
<?php
$page='';
$reference_name='store_item_id';
$reference=$store_item_id;
include('../include/period_select_block.php');
?>
  <br />
  <div class="scroll_frame_long">
    <table width="660" id="table_list" class="sortable-onload-0r rowstyle-alt no-arrow "  >
      <thead>
        <tr>
          <th colspan="2" class="sortable-numeric">Entry </th>
          <th width="468" >Details </th>
          <th width="42" > qty <br />
            in/out </th>
          <th width="41"> stock qty</th>
          <th width="38" >Date</th>
        </tr>
      </thead>
      <tbody>
        <?php
    $i=0;
	$receiveTT = "";
	$TT="";
	$link="";
	while($i < $num){
		$b1 = mysql_result($displayResult, $i, "history_id");
		$b2 = mysql_result($displayResult, $i, "details");
		$b3 = mysql_result($displayResult, $i, "quantity");
		$b4 = mysql_result($displayResult, $i, "date");
		$b5 = mysql_result($displayResult, $i, "store_item_id");
		$b7 = mysql_result($displayResult, $i, "total");
		$b8 = mysql_result($displayResult, $i, "reference");
		$b30 = mysql_result($displayResult, $i, "reference_3");
		
		
		$b10 = mysql_result($displayResult, $i, "entry");
		$b12="";
		
		if ($b10==5) {if ($b3>0) {$b3='+'.$b3;} }
		if (($b10==20) OR ($b10==36) OR ($b10==44) OR ($b10==45) OR ($b10==50)) {$b3='+'.$b3;}
		if (($b10==30) OR ($b10==31) OR ($b10==37) OR ($b10==40) OR($b10==41) OR ($b10==42) OR ($b10==43)) {$b3='-'.$b3;}
		
		
		//stock count
		if ($b10==5) { 
		$b10a = "Stock count";
		$stockCountTT = "stock count";
		}
		
		//new item added
		if ($b10==10) {
			$table_name = $_SESSION['db_prefix']."_store_items";
			$item_query = "SELECT item_name, category, subCategory, location, minimumStock FROM $table_name WHERE store_item_id = '".$b5."' ";
			$item_result = mySQL_query($item_query);
			$m1 = mysql_result($item_result, 0, "item_name");
			$m2 = mysql_result($item_result, 0, "category");
			$m3 = mysql_result($item_result, 0, "subCategory");
			$m4 = mysql_result($item_result, 0, "location");
			$m5 = mysql_result($item_result, 0, "minimumStock");
			
			$itemTT = "<table id=table_tool_tip width=250 ><tr><td  width=75>Item name:</td><td width=175>".$m1."</td></tr><tr><td>Category</td><td>".$m2."</td></tr><tr><td>Sub category</td><td>".$m3."</td></tr><tr><td>Location:</td><td>".$m4."</td></tr><tr><td>Min. stock</td><td>".$m5."</td></tr></table><br><b>Click for details</b>";
			
		}
			           
		//stock received		
		if ($b10==20) {
			$table_name5 = $_SESSION['db_prefix']."_receive_store";
            $receive_query = "SELECT receive_id, supplier_id, delivery_note  FROM $table_name5 WHERE receive_id = '".$b8."'  ";
			$receive_result = mySQL_query($receive_query);
            $c1 = mysql_result($receive_result, 0, "supplier_id");
			$c3  = mysql_result($receive_result, 0, "delivery_note");		
		    $table_name6 = $_SESSION['db_prefix']."_suppliers";
            $supplier_query = "SELECT account_name FROM $table_name6 WHERE supplier_id = '".$c1."'  ";
            $supplier_result = mySQL_query($supplier_query);
            $c2 = mysql_result($supplier_result, 0, "account_name");
			$delnoteTT = "<table id=table_tool_tip width=250 ><tr><td  width=75>Delivery note:</td><td width=175>".$c3."</td></tr></table><br><b>Click for details</b>";	
			$supplierTT = "<table id=table_tool_tip width=250 ><tr><td  width=75>Supplier:</td><td width=175>".$c2."</td></tr></table><br><b>Click for details</b>";
						
		}
		
		if ($b10==21) {
			$table_name5 = $_SESSION['db_prefix']."_receive_store";
            $receive_query = "SELECT receive_id, supplier_id, delivery_note  FROM $table_name5 WHERE receive_id = '".$b8."'  ";
			$receive_result = mySQL_query($receive_query);
            $c1 = mysql_result($receive_result, 0, "supplier_id");
			$c3  = mysql_result($receive_result, 0, "delivery_note");		
		    $table_name6 = $_SESSION['db_prefix']."_suppliers";
            $supplier_query = "SELECT account_name FROM $table_name6 WHERE supplier_id = '".$c1."'  ";
            $supplier_result = mySQL_query($supplier_query);
            $c2 = mysql_result($supplier_result, 0, "account_name");
			$delnoteTT = "<table id=table_tool_tip width=250 ><tr><td  width=75>Delivery note:</td><td width=175>".$c3."</td></tr></table><br><b>Click for details</b>";	
			$supplierTT = "<table id=table_tool_tip width=250 ><tr><td  width=75>Supplier:</td><td width=175>".$c2."</td></tr></table><br><b>Click for details</b>";
						
		}
		
		//stock delivered to department		
		if ($b10==30) {
			
			$departmentTT = "<table id=table_tool_tip width=250 ><tr><td  width=75>Department:</td><td width=175>".$b8."</td></tr></table>";		
		}
		
		//stock delivered to employee		
		if ($b10==31) {
			$table_name7 = $_SESSION['db_prefix']."_employee";
            $employee_query = "SELECT emp_first_name, emp_last_name FROM $table_name7 WHERE emp_id = '".$b8."'  ";
            $employee_result = mySQL_query($employee_query);
            $e1 = mysql_result($employee_result, 0, "emp_first_name")." ".mysql_result($employee_result, 0, "emp_last_name");
					
			$employeeTT = "<table id=table_tool_tip width=250 ><tr><td  width=75>Employee:</td><td width=175>".$e1."</td></tr></table><br><b>Click for details</b>";
						
		}
		
		//stock supplied on jobcard		
		if ($b10==32) {
			$table_name = $_SESSION['db_prefix']."_compiled_jobs";
			$job_query = "SELECT project, cust_id  FROM $table_name WHERE job_card_no =  '".$b8."'  ";
			$job_result = mySQL_query($job_query);
			$project = mysql_result($job_result, 0, "project");
			$cust_id = mysql_result($job_result, 0, "cust_id");
			
			$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");
 			}
					
			$job_cardTT = "<table id=table_tool_tip width=250 ><tr><td  width=75>Project:</td><td width=175>".$project."</td></tr><tr><td>Customer:</td><td>".$cust_name."</td></tr></table><br><b>Click for details</b>";
						
		}
		
		//stock supplied on jobcard		
		if ($b10==33) {
			$table_name = $_SESSION['db_prefix']."_compiled_jobs";
			$job_query = "SELECT project, cust_id  FROM $table_name WHERE job_card_no =  '".$b8."'  ";
			$job_result = mySQL_query($job_query);
			$project = mysql_result($job_result, 0, "project");
			$cust_id = mysql_result($job_result, 0, "cust_id");
			
			$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");
 			}
					
			$job_cardTT = "<table id=table_tool_tip width=250 ><tr><td  width=75>Project:</td><td width=175>".$project."</td></tr><tr><td>Customer:</td><td>".$cust_name."</td></tr></table><br><b>Click for details</b>";
						
		}
		
		if ($b10==34) {
			$table_name = $_SESSION['db_prefix']."_compiled_jobs";
			$job_query = "SELECT project, cust_id  FROM $table_name WHERE job_card_no =  '".$b8."'  ";
			$job_result = mySQL_query($job_query);
			$project = mysql_result($job_result, 0, "project");
			$cust_id = mysql_result($job_result, 0, "cust_id");
			
			$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");
 			}
					
			$job_cardTT = "<table id=table_tool_tip width=250 ><tr><td  width=75>Project:</td><td width=175>".$project."</td></tr><tr><td>Customer:</td><td>".$cust_name."</td></tr></table><br><b>Click for details</b>";
						
		}
		
		//stock delivered to employee		
		if ($b10==36) {
			$table_name7 = $_SESSION['db_prefix']."_employee";
            $employee_query = "SELECT emp_first_name, emp_last_name FROM $table_name7 WHERE emp_id = '".$b8."'  ";
            $employee_result = mySQL_query($employee_query);
            $e1 = mysql_result($employee_result, 0, "emp_first_name")." ".mysql_result($employee_result, 0, "emp_last_name");
					
			$employeeTT = "<table id=table_tool_tip width=250 ><tr><td  width=75>Employee:</td><td width=175>".$e1."</td></tr></table><br><b>Click for details</b>";
						
		}
		
		//stock delivered to employee		
		if ($b10==37) {
						
		}
		
		if ($b10==38) {
			$table_name = $_SESSION['db_prefix']."_maintenance_jobs";
			$job_query = "SELECT project, cust_id  FROM $table_name WHERE maintenance_card_no =  '".$b8."'  ";
			$job_result = mySQL_query($job_query);
			$project = mysql_result($job_result, 0, "project");
			$cust_id = mysql_result($job_result, 0, "cust_id");
			
			$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");
 			}
					
			$maintenance_cardTT = "<table id=table_tool_tip width=250 ><tr><td  width=75>Project:</td><td width=175>".$project."</td></tr><tr><td>Customer:</td><td>".$cust_name."</td></tr></table><br><b>Click for details</b>";
						
		}
		
		if ($b10==39) {
			$table_name = $_SESSION['db_prefix']."_cash_supply";
			$cust_query = "SELECT cust_id  FROM $table_name WHERE cash_supply_no =  '".$b30."'  ";
			$cust_result = mySQL_query($cust_query);
			$cust_id = mysql_result($cust_result, 0, "cust_id");
			
			$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");
 			}
					
			$cash_supplyTT = "<table id=table_tool_tip width=250 ><tr><td  width=75>Cash supply</td><td width=175>&nbsp;</td></tr><tr><td>Customer:</td><td>".$cust_name."</td></tr></table><br><b>Click for details</b>";
						
		}
		
		if ($b10==40) {
			$table_name = $_SESSION['db_prefix']."_maintenance_jobs";
			$job_query = "SELECT project, cust_id  FROM $table_name WHERE maintenance_card_no =  '".$b8."'  ";
			$job_result = mySQL_query($job_query);
			$project = mysql_result($job_result, 0, "project");
			$cust_id = mysql_result($job_result, 0, "cust_id");
			
			$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");
 			}
					
			$job_cardTT = "<table id=table_tool_tip width=250 ><tr><td  width=75>Project:</td><td width=175>".$project."</td></tr><tr><td>Customer:</td><td>".$cust_name."</td></tr></table><br><b>Click for details</b>";
						
		}		

		if ($b10==41) {
			$table_name = $_SESSION['db_prefix']."_maintenance_jobs";
			$job_query = "SELECT project, cust_id  FROM $table_name WHERE maintenance_card_no =  '".$b8."'  ";
			$job_result = mySQL_query($job_query);
			$project = mysql_result($job_result, 0, "project");
			$cust_id = mysql_result($job_result, 0, "cust_id");
			
			$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");
 			}
					
			$job_cardTT = "<table id=table_tool_tip width=250 ><tr><td  width=75>Project:</td><td width=175>".$project."</td></tr><tr><td>Customer:</td><td>".$cust_name."</td></tr></table><br><b>Click for details</b>";
						
		}
		
		if ($b10==50) {
			$table_name = $_SESSION['db_prefix']."_direct_return";
			$return_query = "SELECT return_from FROM $table_name WHERE direct_return_no =  '".$b8."'  ";
			$return_result = mySQL_query($return_query);
			$return_from = mysql_result($return_result, 0, "return_from");
								
			$directTT = "<table id=table_tool_tip width=250 ><tr><td  width=75>Direct return</td><td width=175>".$b8."</td></tr></table><br><b>Click for details</b>";
						
		}
		
		
		$b9 = mysql_result($displayResult, $i, "entryDate");
		$b20 = mysql_result($displayResult, $i, "userId");
		
		
		
		
		$entryTT="<label class=tip_text_label_bold>Entered on: ". date('d-m-Y  --- H:i', strtotime($b9)) . " by: ". $b20."</label>";
		
		
		?>
        <tr class="alt">
          <td width="20"><a href=""onmouseover="ddrivetip('<?php echo $entryTT ?>', 250)" onMouseOut="hideddrivetip()";><?php echo $b1?></a></td>
          <td width="23"><a href=""onmouseover="ddrivetip('<?php echo $entryTT ?>', 250)" onMouseOut="hideddrivetip()";><?php echo date("d-m-Y", strtotime($b9));?></a></td>
          <td><?php if ($b10==5) { ?>
            Stock count<a href="" onMouseOver="ddrivetip('<?php echo $stockCountTT ?>' , 200)" onMouseOut="hideddrivetip()";></a>
            <?php } ?>
            <?php if ($b10==10) { ?>
            <a href="store_item_display.php?store_item_id=<?php echo $b5?>" onMouseOver="ddrivetip('<?php echo $itemTT ?>' , 200)" onMouseOut="hideddrivetip()";>Item added to store</a>
            <?php } ?>
            <?php if ($b10==20) { ?>
            Stock received, del note: <a href="receive_note.php?receive_id=<?php echo $b8?>" onMouseOver="ddrivetip('<?php echo $delnoteTT ?>' , 200)" onMouseOut="hideddrivetip()";><?php echo $c3 ?></a> - supplier: <a href="supplier_details.php?supplier_id=<?php echo $c1?>" onMouseOver="ddrivetip('<?php echo $supplierTT ?>' , 200)" onMouseOut="hideddrivetip()";><?php echo $c2 ?></a>
            <?php } ?>
            <?php if ($b10==21) { ?>
            Quantity edited on received note, del note: <a href="receive_note.php?receive_id=<?php echo $b8?>" onMouseOver="ddrivetip('<?php echo $delnoteTT ?>' , 200)" onMouseOut="hideddrivetip()";><?php echo $c3 ?></a> - supplier: <a href="supplier_details.php?supplier_id=<?php echo $c1?>" onMouseOver="ddrivetip('<?php echo $supplierTT ?>' , 200)" onMouseOut="hideddrivetip()";><?php echo $c2 ?></a>
            <?php } ?>
            <?php if ($b10==30) { ?>
            Issued to: <a href="" onMouseOver="ddrivetip('<?php echo $departmentTT ?>' , 200)" onMouseOut="hideddrivetip()";><?php echo $b8 ?></a>
            <?php } ?>
            <?php if ($b10==31) { ?>
            Issued to: <a href="../hr_module/employee_details.php?emp_id=<?php echo $b8 ?>" onMouseOver="ddrivetip('<?php echo $employeeTT ?>' , 200)" onMouseOut="hideddrivetip()";><?php echo $e1 ?></a>
            <?php } ?>
            <?php if ($b10==32) { ?>
            Issued for job card: <a href="../store/supply_job.php?job_card_no=<?php echo $b8 ?>&supply_job_no=<?php echo $b30 ?>" onMouseOver="ddrivetip('<?php echo $job_cardTT ?>' , 200)" onMouseOut="hideddrivetip()";><b><?php echo $b8 ?></b></a>
            <?php } ?>
            <?php if ($b10==33) { ?>
            Additional issue on job card: <a href="../store/supply_job.php?job_card_no=<?php echo $b8 ?>&supply_job_no=<?php echo $b30 ?>" onMouseOver="ddrivetip('<?php echo $job_cardTT ?>' , 200)" onMouseOut="hideddrivetip()";><b><?php echo $b8 ?></b></a>
            <?php } ?>
            <?php if ($b10==34) { ?>
            Returned on job card: <a href="../store/job_return.php?job_card_no=<?php echo $b8 ?>&job_return_no=<?php echo $b30 ?>" onMouseOver="ddrivetip('<?php echo $job_cardTT ?>' , 200)" onMouseOut="hideddrivetip()";><b><?php echo $b8 ?></b></a>
            <?php } ?>
            <?php if ($b10==36) { ?>
            Retruned from: <a href="../hr_module/employee_details.php?emp_id=<?php echo $b8 ?>" onMouseOver="ddrivetip('<?php echo $employeeTT ?>' , 200)" onMouseOut="hideddrivetip()";><?php echo $e1 ?></a>
            <?php } ?>
            <?php if ($b10==37) { ?>
            Issued to: <?php echo $b8 ?></a>
            <?php } ?>
            <?php if ($b10==38) { ?>
            Maintenance supply: <a href="../maintenance/maintenance_card.php?maintenance_card_no=<?php echo $b8 ?>" onMouseOver="ddrivetip('<?php echo $maintenance_cardTT ?>' , 250)" onMouseOut="hideddrivetip()";><b><?php echo $b8 ?></b></a>
            <?php } ?>
            <?php if ($b10==39) { ?>
            Cash supply: <a href="direct_delivery.php?cash_supply_no=<?php echo $b30 ?>" onMouseOver="ddrivetip('<?php echo $cash_supplyTT ?>' , 250)" onMouseOut="hideddrivetip()";><b><?php echo $b30 ?></b></a>
            <?php } ?>
            <?php if ($b10==40) { ?>
            Additional supply maintenance card: <a href="../store/supply_job.php?job_card_no=<?php echo $b8 ?>&supply_job_no=<?php echo $b30 ?>" onMouseOver="ddrivetip('<?php echo $job_cardTT ?>' , 200)" onMouseOut="hideddrivetip()";><b><?php echo $b8 ?></b></a>
            <?php } ?>
            <?php if ($b10==41) { ?>
            Returned from maintenance card: <a href="../store/job_return.php?job_card_no=<?php echo $b8 ?>&job_return_no=<?php echo $b30 ?>" onMouseOver="ddrivetip('<?php echo $job_cardTT ?>' , 200)" onMouseOut="hideddrivetip()";><b><?php echo $b8 ?></b></a>
            <?php } ?>
            <?php if ($b10==50) { ?>
            Direct return: <a href="../store/direct_return.php?direct_return_no=<?php echo $b8 ?>" onMouseOver="ddrivetip('<?php echo $directTT ?>' , 200)" onMouseOut="hideddrivetip()";><b><?php echo $b8 ?></b></a> from <?php echo $b30 ?>
            <?php } ?>
            </td>
          <td align="right"><?=$b3?></td>
          <td align="right"><?=$b7?></td>
          <td><?php echo date("d-m-Y", strtotime($b4));?></td>
        </tr>
        <?php
		$i++;
		  
	}
	
	?>
      </tbody>
    </table>
  </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'); ?>
