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


$direct_return_no = $_GET['direct_return_no'];

			
$table_name = $_SESSION['db_prefix']."_direct_return";
$return_query = "SELECT direct_return_id, return_from, return_date, returned_by, authorised_by FROM $table_name WHERE  direct_return_no = '".$direct_return_no."' ";
$return_result = mySQL_query($return_query);
$direct_return_id = mysql_result($return_result, 0, "direct_return_id");
$return_from = mysql_result($return_result, 0, "return_from");
$return_date = 	mysql_result($return_result, 0, "return_date");	
$returned_by = 	mysql_result($return_result, 0, "returned_by");	
$authorised_by = 	mysql_result($return_result, 0, "authorised_by");		
			
$table_name = $_SESSION['db_prefix']."_direct_return_lines";
$item_query = "SELECT store_item_id, item_name, quantity, price FROM $table_name WHERE  direct_return_id = '".$direct_return_id."' ";
$item_result = mySQL_query($item_query);
$item_num = mysql_num_rows($item_result);

?>

<!--style sheets-->
<link href="../css/main.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />

<!--jscript-->
<script type="text/javascript" src="../jscript/tablesort.js"></script>
<script language="JavaScript" src="../jscript/tooltip.js"  type="text/javascript"></script> 

</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" style="height:auto;">
 <div class="page_head_frame">
     <label class="label_page_head">Direct return</label>
   
      </div>
 <div class="page_middle_frame">
 


<div class="page_inside_frame">
<font size=+1;>Returned by</font><font size=+1;> : <?php echo $returned_by ?></font><br><br>
Direct return no: <?php echo $direct_return_no ?>&nbsp;&nbsp;&nbsp;&nbsp;Return  date: <?php echo date("d-m-Y", strtotime($return_date)) ?><br><br>
<table width="553" id="table_details_display">
  <tr>
    <td width="448">Item</td>
    <td width="89" align="center">Returned</td>
    </tr>
  <?php
  $i=0;
  while ($i<$item_num) {
	  $store_item_id = mysql_result($item_result, $i, "store_item_id");
	  $item_name = mysql_result($item_result, $i, "item_name");
	  $returned = mysql_result($item_result, $i, "quantity");
	  
	 $table_name = $_SESSION['db_prefix']."_store_items";
	 $name_query = "SELECT item_name, register 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");
				
	 
	  
	  
	  ?>
  <tr>
    <td><?php echo $store_item_name ?> </td>
    <td align="center"><?php echo $returned ?></td>
    </tr>
  <?php
  $i++;
  }
  ?>
</table>

</div>

<div class="page_inside_frame">
<a href="direct_return_print.php?direct_return_no=<?php echo $direct_return_no  ?>" target="_blank"><input name="print_button" type="button" class="imagebutton" value="Print return sheet"></a>
</div>

</div>
</div>

<?php include ('../navigation/side_bar.php'); ?>

</body>
<?php } else {
$_SESSION['denied_return'] = "store/store_main.php";	
include ("../navigation/store_sidebar.php");?>
	<body onLoad="accessdenied(); return false">
	</body>
<?php }
?>
</html>