<?php ob_start();
$PageSecurity = 2;
include('includes/session.inc');
$title = _('View Material Receipt');
include('includes/header.inc');
if($_REQUEST['action']=='view' && isset($_GET['id']))
{
	$sql="Select * from material_receipt where id='".$_GET['id']."'";
	$result=DB_query($sql,$db);
	$myrow=DB_fetch_array($result);
}
?><head>

<h2 align="center"><strong>Material Reciept No. - <?php echo $myrow['voucher_no'];?></strong></h2></head>
<br>
<br>
<fieldset>
<table width="60%" border="0" cellspacing="1" cellpadding="2" align="center">
  <tr>
    <td width="55%"><table width="99%" border="0" cellspacing="1" cellpadding="2">
      <tr>
        <th width="39%" height="26" scope="row"><strong>RECEIVE FROM</strong></th>
        <td width="61%"><?php 
		$site_sql1="Select locationname from locations where loccode='".$myrow['from_site']."'";
		$site_res1=DB_query($site_sql1,$db);
		$site_row1=DB_fetch_array($site_res1);
		echo $site_row1['locationname'];?></td>
      </tr>
      <tr>
        <th scope="row"><strong>TO</strong></th>
        <td><?php 
		$site_sql2="Select locationname from locations where loccode='".$myrow['to_site']."'";
		$site_res2=DB_query($site_sql2,$db);
		$site_row2=DB_fetch_array($site_res2);
		echo $site_row2['locationname'];?></td>
      </tr>
      <tr>
        <th scope="row"><strong>STORE</strong></th>
        <td><?php 
		$store_sql="select distinct StoreName from storetype where StoreCode='0".$myrow['store']."' ";
		$store_res=DB_query($store_sql,$db);
		$store_row=DB_fetch_array($store_res);
		echo $store_row['StoreName'];?></td>
      </tr>
    </table></td>
    <td width="45%"><table width="100%" border="0" cellspacing="1" cellpadding="2">
      <tr>
        <th width="41%" height="26" scope="row"><strong>VOUCHER NUMBER </strong></th>
        <td width="59%"><?php echo $myrow['voucher_no'];?></td>
      </tr>
      <tr>
        <th scope="row"><strong>VOUCHER DATE </strong></th>
        <td><?php echo ConvertSQLDate($myrow['voucher_date']);?></td>
      </tr>

    </table></td>
  </tr>
</table>
<br>
<br>
<?php 
$sql2="Select * from material_receipt_details where material_receipt_id='".$_GET['id']."'";
$result2=DB_query($sql2,$db);
?>
<table width="100%" border="0" cellspacing="1" cellpadding="2">
  <tr>
    <th scope="col"><strong>ITEM CODE </strong></th>
    <th scope="col"><strong>ITEM NAME </strong></th>
    <th scope="col"><strong>QUANTITY RECEIVED</strong></th>
    <th scope="col"><strong>NARRATION</strong></th>
  </tr>
<?php
while($myrow2=DB_fetch_array($result2))
{
?> 
  <tr>
    <td><?php echo $myrow2['item_code'];?></td>
    <td><?php echo $myrow2['item_description'];?></td>
    <td><?php echo $myrow2['received_quantity'];?></td>
    <td><?php echo $myrow2['narration'];?></td>
  </tr>
<?php } ?>
<br>
<br>
</table>
<p>&nbsp;</p>
<table width="30%" align="left">
<tr>
<th width="80%"><strong>TOTAL QUANTITY RECEIVED </strong></th>
<td width="20%"><?php 
$qty_res=DB_query("Select sum(received_quantity) as total_qty from material_receipt_details where material_receipt_id='".$_GET['id']."'",$db);
$qty_row=DB_fetch_array($qty_res);
echo $qty_row['total_qty'];?></td>
</tr>
</table>
</fieldset>
<?php 
include('includes/footer.inc');
?>