<?php
ob_start();
$PageSecurity = 11;

/* Session started in header.inc for password checking and authorisation level check */
include('includes/DefinePOClass.php');
include('includes/DefineSerialItems.php');
include('includes/session.inc');
include('includes/SQL_CommonFunctions.inc');

$title = _('Quality Control');
include('includes/header.inc');
?>

<table width="80%" border="1" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr >
    <td width="21%">&nbsp;</td>
    <td width="12%">&nbsp;</td>
    <td width="20%">&nbsp;</td>
    <td width="20%">&nbsp;</td>
    <td width="13%">&nbsp;</td>
    <td width="14%">&nbsp;</td>
    <td width="27%">&nbsp;</td>
  </tr>

 
 
  <tr  height="30">
    <td style="background-color:#999999">Mrn Number</td>
    <td style="background-color:#999999">Supplier Code</td>
    <td style="background-color:#999999">Supplier Name</td>
    <td style="background-color:#999999">PO Number</td>
    <td style="background-color:#999999">PO Date</td>
    <td style="background-color:#999999">&nbsp;</td>
    <td style="background-color:#999999">&nbsp;</td>
  </tr>
 
   <?php
  $sql = "SELECT  addMRN.MRNNo, addMRN.supplierno,addMRN.suppliername,addMRN.ReceivedAgainst, addMRN.OrderDate FROM addMRN "; 
 $result = DB_query($sql,$db);
 while ($myrow = DB_fetch_array($result)) {
 ?> 
  
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  
  <tr class="OddTableRows">
    <td><?php echo $myrow['MRNNo'];  ?></td>
    <td><?php echo $myrow['supplierno'];  ?></td>
    <td><?php echo $myrow['suppliername'];  ?></td>
    <td><?php echo $myrow['ReceivedAgainst'];  ?></td>
    <td><?php echo ConvertSQLDate($myrow['OrderDate']);  ?></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="7">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="7"><table width="80%" border="1" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="20%" style="background-color:#999999">Item Code</td>
        <td width="29%" style="background-color:#999999">Item Description</td>
        <td width="25%" style="background-color:#999999">Qty Received</td>
        <td width="26%" style="background-color:#999999">Qty Accepted</td>
      </tr>
	   <?php
      $MRN_sql = "select addmrnqty.itemcode, addmrnqty.desc, addmrnqty.reciveqty, addmrnqty.POQty from addmrnqty Where order_no='".$myrow['ReceivedAgainst']."' order By itemcode ASC"; 
       $MRN_result = DB_query($MRN_sql,$db);
        while ($MRN_myrow = DB_fetch_array($MRN_result)) {
       ?> 
      <tr>
        <td><?php echo $MRN_myrow['itemcode'];  ?></td>
        <td><?php echo $MRN_myrow['desc'];  ?></td>
        <td><?php echo $MRN_myrow['reciveqty'];  ?></td>
        <td><?php echo $MRN_myrow['POQty'];  ?></td>
      </tr>
       <?php } ?>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
		<?php 
		$Receive_Quntaty = "select Sum(reciveqty) from addmrnqty Where order_no='".$myrow['ReceivedAgainst']."'";
		$Receiv_result = DB_query($Receive_Quntaty,$db);
		$Receiv_myrow = DB_fetch_assoc($Receiv_result);
		
		?>
          <tr>
            <td width="61%"> <span style="background-color:#999999">Total Qty Received</span></td>
            <td width="39%"><DIV align="center"><?php echo $Receiv_myrow['Sum(reciveqty)'];  ?></DIV></td>
          </tr>
        </table></td>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
		<?php 
		$Accepted_SQL = "select Sum(POQty) from addmrnqty Where order_no='".$myrow['ReceivedAgainst']."'";
		$Accepted_result = DB_query($Accepted_SQL,$db);
		$Accepted_myrow = DB_fetch_assoc($Accepted_result);
		?>
          <tr>
            <td width="44%"><span style="background-color:#999999">Qty Accepted</span></td>
            <td width="56%"> <DIV align="center"><?php echo $Accepted_myrow['Sum(POQty)']; ?></DIV></td>
          </tr>
        </table></td>
      </tr>
	 
    </table></td>
  </tr>
  <?php } ?>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table></td>
  </tr>
</table>


 
<?
include('includes/footer.inc');
?>