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

<?php 
include('../include/session.php');
			
		$table_name2 = $_SESSION['db_prefix']."_store_items_special"; 
				
		$items_query = "SELECT * FROM $table_name2  ORDER BY item_name ASC";	
		$items_result = execsql($items_query);
    	$items_num = mysql_num_rows($items_result);
		
		    	
?>
<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />
<link rel="stylesheet" type="text/css" href="../css/scroll_table.css" />
<link href="../css/main.css" rel="stylesheet" type="text/css">

</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">Special order  items list <?php echo $subCatText ?></label>
  </div>
 

<div class="page_inside_frame">
<!--jscript-->
<script language="JavaScript" src="../jscript/tooltip.js"  type="text/javascript"></script>
<script type="text/javascript" language="javascript" src="../jscript/jquery.dataTables.js"></script> 
<script type="text/javascript" charset="utf-8">
			$(document).ready(function() {
				$('#scroll_table_1').dataTable( {
					"sScrollY": "410px",
					"bPaginate": false,
					"bScrollCollapse": true,
					"aaSorting": [[ 0, "asc" ]],
					"aoColumns": [
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true}
								 ]
				} );
			} );
		</script>
  <table width="665" id="scroll_table_1" class="data_display">
      <thead>
        <tr>
          <th align="center">Product Name</th>
          <th align="center">Job card</th>
          <th width="117" align="center">Customer</th>
          <th width="65" align="center">Received</th>
          <th width="66" align="center">Supplied</th>
          <th width="44" align="center">Stock</th>
          <th width="69" align="center">Date received</th>
          <th width="61" align="center">Date supplied</th>
          <th width="26" align="center">&nbsp;</th>
        </tr>
      </thead>
      <tbody>
        <?php 
    $i=0;
    while($i < $items_num){
	       $b1 = mysql_result($items_result, $i, "special_store_item_id");
	       $b2 = mysql_result($items_result, $i, "item_name");
	       $b3 = mysql_result($items_result, $i, "ordered_for");
		   
		   		$table_name = $_SESSION['db_prefix']."_compiled_jobs";
				$job_query = "SELECT cust_id, project FROM $table_name WHERE job_card_no = '".$b3."' ";
				$job_result = mySQL_query($job_query);
				$cust_id = mysql_result($job_result, 0, "cust_id");
				$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);
				$a1 = mysql_result($customer_result, 0, "account_type");
				if ($a1=="corporate") { 
					$comp_name = mysql_result($customer_result, 0, "comp_name"); 
				} 
				else {
					$comp_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, "phone");
				$contact_1 = mysql_result($customer_result, 0, "contact_1");
				$cell_1 = mysql_result($customer_result, 0, "cell_1");
				
		   
	       $b5 = mysql_result($items_result, $i, "quantity");
	       $b7 = mysql_result($items_result, $i, "receive_date");
		   $b9 = mysql_result($items_result, $i, "supplier_id");
		   $b10 = mysql_result($items_result, $i, "price");
		   $b11 = mysql_result($items_result, $i, "receive_id");
		   $b12 = mysql_result($items_result, $i, "supplied_quantity");
		   $b13 = mysql_result($items_result, $i, "supply_date");
		   
		   $b14 = $b5-$b12;
		   
		   	$table_name2 = $_SESSION['db_prefix']."_suppliers";
			$account_name_query = "SELECT account_name FROM $table_name2 WHERE supplier_id ='".$b9."' ";
			$account_name_result = mySQL_query($account_name_query);
			$account_name_num = mysql_num_rows($account_name_result);	
			$account_name = mysql_result($account_name_result, 0, "account_name"); 
		  
	  		
		  $productTT ="<table id=table_tool_tip width=250 ><tr><td  width=75>Product:</td><td width=175>".$b2."</td></tr><tr><td>Supplier:</td><td>".$account_name."</td></tr><tr><td>Price:</td><td>".$b10."</td></tr></table><br><b>Click for details</b>";	
			
		  $jobTT ="<table id=table_tool_tip width=250 ><tr><td  width=75>Job card no:</td><td width=175>".$b3."</td></tr><tr><td>Project:</td><td>".$project."</td></tr><tr><td>Customer:</td><td>".$comp_name."</td></tr></table><br><b>Click for details</b>";
				
			$customerTT ="<table id=table_tool_tip width=250 ><tr><td  width=75>Customer:</td><td width=175>".$comp_name."</td></tr><tr><td>Phone</td><td>".$phone."</td></tr><tr><td>Contacte</td><td>".$contact_1."</td></tr><tr><td>Cell:</td><td>".$cell_1."</td></tr></table><br><b>Click for details</b>";		
				
				
		      
    ?>
        <tr class="alt">
          <td width="131" align="left"><a href="../store/receive_note.php?receive_id=<?php echo $b11 ?> " onMouseover="ddrivetip('<?php echo $productTT ?>', 250)"; onMouseout="hideddrivetip()"><?php echo $b2 ?></a></td>
          <td width="46" align="center"><a href="../orders/compiled_job.php?job_card_no=<?php echo $b3?>" onMouseover="ddrivetip('<?php echo $jobTT?>', 250)"; onMouseout="hideddrivetip()"><?php echo $b3 ?></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 $comp_name ?></a>&nbsp;</td>
          <td align="center"><?php echo number_format($b5 , 0, '.', ','); ?></td>
          <td align="center"><?php echo $b12 ?>&nbsp;</td>
          <td align="center"><?php echo $b14 ?></td>
          <td align="center"><?php echo date("d-m-Y", strtotime($b7)) ?>&nbsp;</td>
          <td align="center"><?php if ($b13!='') {echo date("d-m-Y", strtotime($b13)); } ?>&nbsp;</td>
          <td align="center">&nbsp;</td>
        </tr>
        <?php 
		$i++;
    	}
    	?>
      </tbody>
    </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'); ?>
