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


include('../include/period_select_date.php');	 
 
$table_name = $_SESSION['db_prefix']."_maintenance_additional_supply";	 	
$display_query = "SELECT additional_supply_id, additional_supply_no, maintenance_card_no, issue_date FROM $table_name WHERE issue_date BETWEEN '".$start."' AND '".$end."' ";
	
	$display_result = execsql($display_query);
	$i = 0;
	$display_num = mysql_num_rows($display_result); 
		?> 

<!--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/store_sidebar.php");
$page_name = "Stores-main";
include ("../navigation/access.php");
if ($permission_num==1) {
?>
<div class="main_frame">
<div class="page_head_frame">
  <label class="label_page_head">Maintenance  additional supplies</label></div>

<div class="page_middle_frame">

<?php
$page='additional_maintenance_supply_list.php';
$reference_name='';
$reference='';
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": [[ 2, "desc" ]],
					"aoColumns": [
								{"iDataSort": 1},
								{"bVisible": false},
                              	{"iDataSort": 3},
								{"bVisible": false},
                             	{"bSortable": true},
								{"bSortable": true},
								{"iDataSort": 7},
								{"bVisible": false}			
								 ]
				} );
			} );
		</script>    	
<table width="661" id="scroll_table" class="data_display" >
	<thead>
		<tr>
		  <th width="64">Date</th>
		  <th width="25">&nbsp;</th>
		  <th width="65">Supply no</th>
		  <th width="23">&nbsp;</th>
          <th width="75" >Job card</th>
		  <th width="206" >Project</th>
		  <th width="144" >Customer</th>
		  <th width="23" >&nbsp;</th>
		  </tr>
	</thead>
	<tbody>
  <?php
    $b9=0;
	$b4tot='0.00';
	$b5tot='0.00';
	while($i < $display_num){
		 $b0 = mysql_result($display_result, $i, "additional_supply_id");
		 $b1 = mysql_result($display_result, $i, "issue_date");
		 $b4 = mysql_result($display_result, $i, "additional_supply_no");
		   
		 $b2 = mysql_result($display_result, $i, "maintenance_card_no"); 
		 $table_name3 = $_SESSION['db_prefix']."_maintenance_jobs";
		 $job_query = "SELECT cust_id, date, start_date, project, project_no, project_area, project_place FROM $table_name3 WHERE maintenance_card_no = '".$b2."' " ;
		 $job_result = execsql($job_query);
		 $job_num = mysql_num_rows($job_result);
		 $cust_id = mysql_result($job_result, 0, "cust_id");
		 $project = mysql_result($job_result, 0, "project");
		 $project_no = mysql_result($job_result, 0, "project_no");
		 $project_area = mysql_result($job_result, 0, "project_area");
		 $project_place = mysql_result($job_result, 0, "project_place");
		 
		 
		 $table_name2 = $_SESSION['db_prefix']."_customer";
		 $customer_query = "SELECT account_type, comp_name, title, name_2, phone, contact_1, cell_1 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");
 			}			
		$phone = mysql_result($customer_result, 0, "account_type");
		$contact = mysql_result($customer_result, 0, "contact_1");
		$cell = mysql_result($customer_result, 0, "cell_1");
		

		//$b8 = mysql_result($displayResult, $i, "reference");
		
		$supplyTT = 
		   "<table id=table_tool_tip width=200 ><tr><td>Supply no:</td><td>".$b4."</td></tr><tr><td>Job card:</td><td>".$b2."</td></tr><tr><td>Supply date</td><td>".date("d-m-Y", strtotime( $b1))."</td></tr></table><b>Click for details</b>";
		
		$jobTT = 
		   "<table id=table_tool_tip width=200 ><tr><td>Job card:</td><td>".$b2."</td></tr><tr><td>Project:</td><td>".$project."</td></tr><tr><td></td><td>".$cust_name."</td></tr></table><b>Click for details</b>";
				
		 $projectTT =
		   "<table id=table_tool_tip width=200 ><tr><td>Project:</td><td>".$project."</td></tr><tr><td>Location:</td><td>".$project_no." ".$project_area."</td></tr><tr><td></td><td>".$project_place."</td></tr></table><b>Click for details</b>";
		
	   
		$customerTT =
		   "<table id=table_tool_tip width=200 ><tr><td  width=75>Name:</td><td width=175>".$cust_name."</td></tr><tr><td  width=75>Phone:</td><td width=175>".$phone."</td></tr><tr><td  width=75>Contact:</td><td width=175>".$contact."</td></tr><tr><td  width=75>Cell:</td><td width=175>".$cell."</td></tr></table><b>Click for details</b>";   
		
		?>
		<tr >
		  <td ><?php echo date("d-m-Y", strtotime($b1 ))?></td>
		  <td ><?php echo $b1 ?>&nbsp;</td>
		  <td align="left"><a href="maintenance_additional_supply.php?additional_supply_no=<?php echo $b4 ?>&job_card_no=<?php echo $b2?>" onMouseover="ddrivetip('<?php echo $supplyTT ?>', 250)"; onMouseout="hideddrivetip()"><?php echo $b4 ?></a></td>
		  <td align="left"><?php echo $b4 ?></td>
			<td align="left"><a href="../maintenance/maintenance_card.php?maintenance_card_no=<?php echo $b2 ?> " onMouseOver="ddrivetip('<?php echo $jobTT ?>', 200)"; onMouseOut="hideddrivetip()"><?php echo $b2?></a></td>
			<td align="left"><a href="../maintenance/maintenance_card.php?maintenance_card_no=<?php echo $b2 ?> " onMouseover="ddrivetip('<?php echo $projectTT ?>', 200)"; onMouseout="hideddrivetip()"><?php echo $project ?></a>&nbsp;</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>&nbsp;</td>
			<td align="left"><?php echo $cust_name ?></td>
	      </tr>
		     
		<?php
		$i++; 
	}
	?>
    </tbody>
    <tfoot>
    <tr >
		  <td >&nbsp;</td>
		  <td >&nbsp;</td>
		  <td align="left">&nbsp;</td>
		  <td align="left">&nbsp;</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>
</body>
<?php } else { 
    $_SESSION['denied_return'] = "store/store_main.php";	?>
<body onLoad="accessdenied(); return false">
</body>
<?php }
?>
<?php include ('../navigation/side_bar.php'); ?>