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

$table_name = $_SESSION['db_prefix']."_order_return";
$additional_query = "SELECT order_no, order_reference  FROM $table_name WHERE order_return_no = '".$order_return_no."' ";
$additional_result = mySQL_query($additional_query);
$additional_num = mysql_num_rows($additional_result);
$order_no = mysql_result($additional_result, 0, "order_no");
$order_reference = mysql_result($additional_result, 0, "order_reference");

//$quote='no';
$table_name = $_SESSION['db_prefix']."_orders";
$order_query = "SELECT * FROM $table_name WHERE order_reference = '".$order_reference."' ";
$order_result = mySQL_query($order_query);
$cust_id = mysql_result($order_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");
		$name = mysql_result($customer_result, 0, "comp_name"); 
		
			
$table_name = $_SESSION['db_prefix']."_order_return";
$return_id_query = "SELECT order_return_id,  order_no, return_date, returned_to FROM $table_name WHERE  order_return_no = '".$order_return_no."' ";
$return_id_result = mySQL_query($return_id_query);
$return_id_num = mysql_num_rows($return_id_result);
$order_return_id = mysql_result($return_id_result, 0, "order_return_id");
$return_date = mysql_result($return_id_result, 0, "return_date");
$forman_name = 	mysql_result($return_id_result, 0, "returned_to");		
			
$table_name = $_SESSION['db_prefix']."_order_return_lines";
$item_query = "SELECT store_item_id, item_name, quantity, stock_return FROM $table_name WHERE  order_return_no = '".$order_return_no."' ";
$item_result = mySQL_query($item_query);
$item_num = mysql_num_rows($item_result);

$report_name = 'Return';
$report_no = $order_return_id;
?>

<!--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 Return <?php echo $order_return_id ?></title>

</head>

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

<div class="print_standard_frame">

</div>
<br>

  <div class="print_standard_frame">
        <table width="652" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="483">Return from order no <?php echo $order_no ?> delivered to:</td>
    <td width="169">Return date: <?php echo date("d-m-Y", strtotime($return_date)) ?></td>
  </tr>
</table>
<br>
<?php 
		include ('../include/customer_block.php');
?>
</div>

<div class="print_standard_frame">
<table width="650" id="table_details_display">
  <tr>
    <td width="97">Return no:</td>
    <td width="157"><?php echo $order_return_no ?></td>
    <td width="156">&nbsp;</td>
    <td width="170">&nbsp;</td>
  </tr>
  <tr>
    <td>Return  date:</td>
    <td><?php echo date("d-m-Y", strtotime($return_date)) ?></td>
    <td>Received by :</td>
    <td><?php echo $forman_name ?></td>
  </tr>
</table>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;
<table width="650" id="table_details_display">
  <tr>
    <td width="448">Item</td>
    <td width="89" align="center">Returned</td>
    <td width="92" align="center">Back to stock</td>
  </tr>
  <?php
  $i=0;
  while ($i<$item_num) {
	  $store_item_id = mysql_result($item_result, $i, "store_item_id");
	  $spec_name = mysql_result($item_result, $i, "item_name");
	   
	
	       		$table_name = $_SESSION['db_prefix']."_store_items";
				$name_query = "SELECT item_name FROM $table_name WHERE store_item_id = '".$store_item_id."'  ";
				$name_result = mySQL_query($name_query);
				$store_item_name = mysql_result($name_result, 0, "item_name");
				
		
			
			
	  $delivered = mysql_result($item_result, $i, "quantity");
	  $stock_return = mysql_result($item_result, $i, "stock_return");
	  
	  ?>
  <tr>
    <td><?php echo $store_item_name ?></td>
    <td align="center"><?php echo $delivered ?></td>
    <td align="center"><?php echo $stock_return ?>&nbsp;</td>
  </tr>
  <?php
  $i++;
  }
  ?>
</table>

</div>

</div>
</div>

</body>

</html>