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


<!--reference to main.css removed-->
<?php
include('../include/session.php');
?>

<?php
$team_return_no=$_GET['team_return_no'];


	  
	 $table_name = $_SESSION['db_prefix']."_team_return";
	 $return_query = "SELECT *  FROM $table_name WHERE  team_return_no = '".$team_return_no."' ";
	 $return_result = mySQL_query($return_query);
	 $return_num = mysql_num_rows($return_result);
	 
	 $team = mysql_result($return_result, 0, "team_id");
	 $return_date = mysql_result($return_result, 0, "issue_date");
	 $issued_by = mysql_result($return_result, 0, "issued_by");
	 $authorised_by = mysql_result($return_result, 0, "authorised_by");
	 
	 $table_name = $_SESSION['db_prefix']."_team_return_lines";
	 $line_query = "SELECT *  FROM $table_name WHERE  team_return_no = '".$team_return_no."' ";
	 $line_result = mySQL_query($line_query);
	 $line_num = mysql_num_rows($line_result);
	 

$employeeTT = "";   

?>
<!--style sheets-->
<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");
$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">
          <table width="809" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td><label class="label_page_head">Returned from: </label>
                &nbsp;&nbsp;&nbsp;
              <label class="label_page_head_2"> <?php echo $team ?></label></td>
            </tr>
          </table>
          </div>
          <div class="page_middle_frame">
        <div class="page_inside_frame">
          <table width="620" id="table_display" >
            <tr>
              <td align="left" valign="top">Returned from:</td>
              <td align="left" valign="top"><?php echo $team ?></td>
              <td align="left" valign="top">Team return no:</td>
              <td align="left" valign="top"><?php echo $team_return_no ?>&nbsp;</td>
            </tr>
            <tr>
              <td width="114" align="left" valign="top">Date:</td>
              <td width="155" align="left" valign="top"><?php echo date("d-m-Y", strtotime($return_date )) ?></td>
              <td width="146" align="left" valign="top">&nbsp;</td>
              <td width="185" align="left" valign="top">&nbsp;</td>
            </tr>
            <tr>
              <td align="left" valign="top">Returned to:</td>
              <td align="left" valign="top"><?php echo $issued_by ?></td>
              <td align="left" valign="top">&nbsp;</td>
              <td align="left" valign="top">&nbsp;</td>
            </tr>
            <tr>
              <td colspan="4" align="left" valign="top">&nbsp;</td>
            </tr>
          </table>
        </div>
        <div class="page_inside_frame">
          <table width="620" id="table_display" >
            <tr>
              <td width="211" height="26" align="left" valign="top">Item</td>
              <td width="116" align="left" valign="top">Group</td>
              <td width="51" align="left" valign="top">Quantity</td>
              <td width="106" align="left" valign="top">Unit price</td>
              <td width="112" align="left" valign="top">Total</td>
            </tr>
            <?php
				$i=0;
				$sub_tot=0;
				$a6_total=0;
				 while ($i<$line_num){
					 $a0 = mysql_result($line_result, $i, "team_line_id");
					 $a1 = mysql_result($line_result, $i, "store_item_id");
					 $table_name = $_SESSION['db_prefix']."_store_items";
						$item_query = "SELECT item_name, subCategory, unit 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");
						$a4 = mysql_result($item_result, 0, "subCategory");
					 $a2 = mysql_result($line_result, $i, "quantity");
					 $a3 = mysql_result($line_result, $i, "price");
					$a5=$a2*$a3;
					$a6_total=$a6_total+$a5;
					 
				 ?>
            <tr>
              <td valign="top"><?php echo $a1a ?></td>
              <td valign="top"><?php echo $a4 ?></td>
              <td valign="top"><?php echo $a2 ?></td>
              <td align="right" valign="top"><div align="right"><?php echo $a3." /".$a3a ?></div></td>
              <td align="right" valign="top"><div align="right"><?php echo number_format($a5, 2, '.', ',')?></div></td>
            </tr>
            <?php 
			   // $a6_total=$a6_total+$a6;
				$i++;
				 }
				 ?>
            <tr>
              <td colspan="4" align="left" valign="top">&nbsp;</td>
              <td align="left" valign="top"></td>
            </tr>
            <tr>
              <td colspan="4" align="left" valign="top"><div align="right">Total:</div></td>
              <td align="left" valign="top"><div align="right"><?php echo number_format($a6_total, 2, '.', ',') ?></div></td>
            </tr>
          </table>
          <br>
          <br>
     
</div>
<div class="page_inside_frame">
<a href="team_return_print.php?team_supply_no=<?php echo $team_return_no ?>" target="_blank"><input name="print_button" type="button" class="imagebutton" value="Print issue " /></a>
</div>
</div>  
</div>
<?php include ('../navigation/side_bar.php'); ?>


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