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

   
		$table_name = $_SESSION['db_prefix']."_tile_orders";
		$order_query = "SELECT *  FROM $table_name WHERE order_no = '".$order_no."'";
		
		
		$order_result = mySQL_query($order_query);
		$cust_id=mysql_result($order_result, 0, "cust_id");
		$branch=mysql_result($order_result, 0, "branch");
		$status=mysql_result($order_result, 0, "status");
		$direct=mysql_result($order_result, 0, "direct");
		$pallets=mysql_result($order_result, 0, "pallets");
		$order_date=mysql_result($order_result, 0, "order_date");
		$order_book_no=mysql_result($order_result, 0, "order_book_no");
		
		$quote='no';
		
		$table_name2 = $_SESSION['db_prefix']."_customer";
				$customer_query = "SELECT account_type, title, name_2, comp_name FROM $table_name2 WHERE cust_id ='".$cust_id."' ";
				$customer_result = mySQL_query($customer_query);
				$customer_num = mysql_num_rows($customer_result);	
				$account_type = mysql_result($customer_result, 0, "account_type");
				if ($account_type=="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");
 				}
				 		
				
		$table_name = $_SESSION['db_prefix']."_tile_order_lines";
		$line_query = "SELECT *  FROM $table_name WHERE order_no = '".$order_no."' ";
		$line_result = mySQL_query($line_query);
		$line_num = mysql_num_rows($line_result);
	
	$quote_no = $order_no;
	
$report_name = 'Tile order';
$report_no = $order_no;
?>

<!--style sheets-->
<link href="../css/print.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" type="image/x-icon" href="../images/favicon.ico">
<title>Tiles delivery <?php echo $delivery_no ?></title>

</head>

<body>

<script>
window.onload = function () {
  window.print();
  setTimeout(function(){window.close();}, 100);
}
</script>

<?php include('../include/print_header.php'); ?>
<div class="print_main_frame" style="height:auto; margin-left:50px;">
<br>
<br>

<div class="print_standard_frame">
<?php if ($direct=='yes') { ?> 
<img src="../images/exclamation_mark.png" width="24" height="24">&nbsp;&nbsp;<label class="print_header_label_std">This order is to be delivered directly by Radstone.</label>
<?php } ?>
</div>
<br>

<div class="print_standard_frame">
        <label class="print_header_label_std">This order is for: </label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Order date:  <?php echo date("d-m-Y", strtotime($order_date)) ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Vertex book order no:&nbsp;&nbsp;&nbsp;<?php echo $order_book_no ?> 
        <?php 
		include ('../include/customer_block.php');
		?>
  </div><br>
<br>
<div class="print_standard_frame">
<label class="print_header_label_std">Items on the order:</label>
         <table width="650" id="table_display" >
           <tr>
             <td height="26" colspan="2" align="left" valign="top">Item</td>
             <td width="116" align="left" valign="top">Group</td>
             <td width="71" align="left" valign="top">Unit</td>
             <td width="56" align="left" valign="top">quantity</td>
             <td width="85" align="left" valign="top">price</td>
             <td width="73" align="left" valign="top">total</td>
           </tr>
           <?php
				$i=0;
				$sub_tot=0;
				$a5_total=0;
				 while ($i<$line_num){
					 $a0 = mysql_result($line_result, $i, "order_line_id");
					 $a1 = mysql_result($line_result, $i, "store_item_id");
					 $table_name = $_SESSION['db_prefix']."_store_items";
						$item_query = "SELECT item_name, unit, subCategory FROM $table_name WHERE store_item_id = '".$a1."' ";
						$item_result = mySQL_query($item_query);
						$a1a = mysql_result($item_result, 0, "item_name");
						$a3a = mysql_result($item_result, 0, "unit");
						$a4a = mysql_result($item_result, 0, "subCategory");
					 $a2 = mysql_result($line_result, $i, "quantity");
					 $a3 = mysql_result($line_result, $i, "purchase_price");
					 
					$a5=$a2*$a3;
					$a5_total=$a5_total+$a5;
					 
				 ?>
           <tr>
             <td colspan="2" valign="top"><?php echo $a1a ?></td>
             <td valign="top"><?php echo $a4a ?></td>
             <td valign="top"><?php echo $a3a ?></td>
             <td valign="top"><?php echo $a2 ?></td>
             <td align="right" valign="top"><?php echo $a3. "  /" .$a3a ?>&nbsp;</td>
             <td align="right" valign="top"><?php echo number_format($a5, 2, '.', ',')?></td>
           </tr>
           <?php 
			   // $a6_total=$a6_total+$a6;
				$i++;
				 }
				 ?>
           <tr>
             <td colspan="2" align="left" valign="top">&nbsp;</td>
             <td align="left" valign="top">&nbsp;</td>
             <td align="left" valign="top">&nbsp;</td>
             <td align="left" valign="top">&nbsp;</td>
             <td align="left" valign="top">Total:</td>
             <td align="right" valign="top"><?php echo number_format($a5_total, 2, '.', ',') ?></td>
           </tr>
         </table>
  </div>
         <br>
&nbsp;&nbsp;&nbsp;<?php echo $pallets ?> pallets to be used for this order.         
<br>

</div>
</div>    
  
</div>


</body>
