<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--reference to main.css removed-->
<?php
include ("../navigation/header.php");
$page_name = "Stores-main";
include ("../navigation/access.php");

if ($permission_num==1) {
	include ("../navigation/store_sidebar.php");


?>
</head>
<?php
$receive_no=$_GET['receive_no'];

$table_name = $_SESSION['db_prefix']."_tile_receive";
$receive_query = "SELECT *  FROM $table_name WHERE  receive_no = '".$receive_no."' ";
$receive_result = mySQL_query($receive_query);
$b0 = mysql_result($receive_result, 0, "receive_date");
$b3 = mysql_result($receive_result, 0, "receive_no");
$b4 = mysql_result($receive_result, 0, "branch");
$b5 = mysql_result($receive_result, 0, "cust_id");

$table_name2 = $_SESSION['db_prefix']."_customer";
				$customer_query = "SELECT account_type, title, name_2, comp_name FROM $table_name2 WHERE cust_id ='".$b5."' ";
				$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_receive_lines";
$line_query = "SELECT * FROM $table_name WHERE  receive_no = '".$receive_no."' ";
$line_result = mySQL_query($line_query);
$line_num = mysql_num_rows($line_result);


?>
<!--style sheets-->

<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />

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

<body>
<div class="main_frame" style=" height:auto; min-height:560px;">
  <table id="tableMain" >
    <!--begin of tableMain-->
    <tr>
      <td width="830" height="62" valign="top" ><div class="page_head_frame">
          <table width="809" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td><label class="label_page_head">Received from:</label>
                &nbsp;&nbsp;&nbsp;
                <label class="label_page_head_2">Radstone</label></td>
            </tr>
          </table>
        </div>
        <br />
        <br /></td>
      <!--center of tableMain--> 
    </tr>
    <tr>
      <td height="93"><!--center of tableMain-->
        
        <div class="page_middle_frame">
          <table width="592" id="table_display" >
            <tr>
              <td width="114" align="left" valign="top">Received from:</td>
              <td width="155" align="left" valign="top">Radstone</td>
              <td width="146" align="left" valign="top">Date:</td>
              <td width="157" align="left" valign="top"><?php echo date("d-m-Y", strtotime($b0 )) ?></td>
            </tr>
            <tr>
              <td align="left" valign="top">Receive no:</td>
              <td align="left" valign="top"><?php echo $receive_no ?></td>
              <td align="left" valign="top">&nbsp;</td>
              <td align="left" valign="top">&nbsp;</td>
            </tr>
            <tr>
              <td align="left" valign="top">Received for:</td>
              <td align="left" valign="top"><?php echo $cust_name ?></td>
              <td align="left" valign="top">&nbsp;</td>
              <td align="left" valign="top">&nbsp;</td>
            </tr>
            <tr>
              <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">&nbsp;</td>
            </tr>
            <tr>
              <td colspan="4" align="left" valign="top">&nbsp;</td>
            </tr>
          </table>
        </div></td>
    </tr>
    <tr>
      <td><div class="page_middle_frame">
          <table width="592" id="table_display" >
            <tr>
              <td height="26" colspan="2" align="left" valign="top">Item</td>
              <td width="97" align="left" valign="top">quantity</td>
              <td width="68" align="left" valign="top">price (BWP)</td>
              <td width="122" 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, "receive_line_id");
					 $a1 = mysql_result($line_result, $i, "store_item_id");
					 $table_name = $_SESSION['db_prefix']."_store_items";
						$item_query = "SELECT item_name, 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");
					 $a2 = mysql_result($line_result, $i, "quantity");
					 $a3 = mysql_result($line_result, $i, "price");
					$a5=$a2*$a3;
					$a6_total=$a6_total+$a5;
					 
				 ?>
            <tr>
              <td colspan="2" valign="top"><?php echo $a1a ?></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="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"></td>
            </tr>
            <tr>
              <td colspan="2" align="left" valign="top">&nbsp;</td>
              <td colspan="2" align="right" 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>
        </div></td>
    </tr>
  </table>
  <!--end of tableMain--> 
  
</div>
<?php include ('../navigation/side_bar.php'); ?>

</body>
<?php } else { ?>
<script> needToConfirm = false; </script>
<?php
$_SESSION['denied_return'] = "store/store_main.php?date=0&branch=&subCatSelect=Tiles";	
include ("../navigation/store_sidebar.php");?>
<body onLoad="accessdenied(); return false">
</body>
<?php }
?>
</html>