<!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']."_special_orders";	 	
$display_query = "SELECT * FROM $table_name WHERE date_ordered BETWEEN '".$start."' AND '".$end."' ";
$display_result = execsql($display_query);
$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">Special order items</label></div>

<div class="page_middle_frame">

<?php
$page='special_order_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": [[ 3, "desc" ]],
					"aoColumns": [
								{"iDataSort": 1},
								{"bVisible": false},
                              	{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true},
								{"iDataSort": 6},
								{"bVisible": false},
								{"iDataSort": 8},
								{"bVisible": false},
                              	{"bSortable": true},
                             	{"iDataSort": 11},
								{"bVisible": false},
								{"bSortable": true}					
								 ]
				} );
			} );
		</script>    	
<table width="661" id="scroll_table" class="data_display" >
	<thead>
		<tr>
		  <th width="44" align="center">Date</th>
		  <th width="25" align="center">&nbsp;</th>
		  <th width="191" align="center">Item name</th>
		  <th width="45" align="center">Job card</th>
          <th width="61" align="center" >Quantity<br>
            ordered</th>
          <th width="61" align="center" >Purchase<br>
            date</th>
          <th width="61" align="center" >&nbsp;</th>
		  <th width="63" align="center" >Date <br>
		    received</th>
		  <th width="63" align="center" >&nbsp;</th>
		  <th width="65" align="center" >Quantity <br>
		    received</th>
		  <th width="62" align="center" >Date<br>
		    supplied</th>
		  <th width="62" align="center" >&nbsp;</th>
		  <th width="65" align="center" >Quantity <br>
		    supplied</th>
		  </tr>
	</thead>
	<tbody>
  <?php
    $b9=0;
	$b4tot='0.00';
	$b5tot='0.00';
	$i = 0;
	while($i < $display_num){
		 $b0 = mysql_result($display_result, $i, "special_order_id");
		 $b1 = mysql_result($display_result, $i, "date_ordered");
		 
			
		$b3 = mysql_result($display_result, $i, "special_name");
		$b4 = mysql_result($display_result, $i, "quantity_ordered"); 
		$b5 = mysql_result($display_result, $i, "job_card_no"); 
		$b6 = mysql_result($display_result, $i, "date_received"); 
		$b7 = mysql_result($display_result, $i, "quantity_received"); 
		$b8 = mysql_result($display_result, $i, "price_ordered"); 
		$b9 = mysql_result($display_result, $i, "price_received"); 
		$b10 = mysql_result($display_result, $i, "date_purchased"); 
		$b11 = mysql_result($display_result, $i, "date_supplied"); 
		$b12 = mysql_result($display_result, $i, "quantity_supplied"); 
		
			
			
		$table_name = $_SESSION['db_prefix']."_compiled_jobs";
		$job_query = "SELECT cust_id, date, project FROM $table_name WHERE job_card_no = '".$b5."' ";
		$job_result = mySQL_query($job_query);
		$job_num = mysql_num_rows($job_result);
		$cust_id = mysql_result($job_result, 0, "cust_id");
		$date = mysql_result($job_result, 0, "date");
		$project = mysql_result($job_result, 0, "project");
		
		$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");
 			}
		
		
				
		$itemTT =
		   "<b>Special order:</b><br><table id=table_tool_tip width=250 border=0 ><tr><td>Item:</td><td>".$b3."</td></tr><tr><td>Ordered for:</td><td>".$cust_name."</td></tr><tr><td>Project:</td><td>".$project."</td></tr><tr><td>Date:</td><td>".date("d-m-Y", strtotime($date))."</td></tr></table><br>";
		   
		$jobTT =
		   "<b>Special order:</b><br><table id=table_tool_tip width=250 border=0 ><tr><td>Job card no:</td><td>".$b5."</td></tr><tr><td>Project:</td><td>".$project."</td></tr><tr><td>Ordered for:</td><td>".$cust_name."</td></tr><tr><td>Date:</td><td>".date("d-m-Y", strtotime($date))."</td></tr></table><br><b>Click to view job card.</b>";   
		
	   
		
		?>
		<tr >
		  <td ><?php echo date("d-m-Y", strtotime($b1 ))?></td>
		  <td ><?php echo $b1 ?>&nbsp;</td>
		  <td align="left"><a href="" onMouseOver="ddrivetip('<?php echo $itemTT ?>', 250)"; onMouseOut="hideddrivetip()"><?php echo $b3?></a></td>
		  <td align="center"><a href="../orders/job_card.php?job_card_no=<?php echo $b5 ?>" onMouseOver="ddrivetip('<?php echo $jobTT ?>', 250)"; onMouseOut="hideddrivetip()"><?php echo $b5 ?></a></td>
			<td align="center"><?php echo $b4 ?></td>
			<td align="center"><?php if ($b10!='') {echo date("d-m-Y", strtotime($b10));}?></td>
			<td align="center"><?php echo $b10 ?></td>
			<td align="center"><?php if ($b6!='') {echo date("d-m-Y", strtotime($b6));}?></td>
			<td align="center"><?php echo $b6 ?></td>
			<td align="center"><?php echo $b7 ?></td>
			<td align="center"><?php if ($b11!='') {echo date("d-m-Y", strtotime($b11));}?></td>
			<td align="center"><?php echo $b11 ?></td>
			<td align="center"><?php echo $b12 ?></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>
		  <td align="right">&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'); ?>