<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>

<table width="100%" border="1" cellspacing="0" cellpadding="3" style="border-collapse:collapse;">
  <tr>
    <th><strong>Sr No</strong></th>
    <th><strong>Branch</strong></th>
    <th><strong>MRN No </strong></th>
	<th><strong>MRN Date</strong></th>
	<th><strong>Vendor</strong></th>
	<th><strong>Item  Details</strong></th>
	<th><strong>Remarks</strong></th>
    <th><strong>QC Status</strong></th>	
    <th><strong></strong></th>
  </tr>
  <?php
  $mrnsql=DB_query("select * from addmrn where companyID='".$_SESSION['ACGCompanyId']."'
                   and MRNDate  BETWEEN '".$_SESSION['financialYrStart']."'   AND '".$_SESSION['financialYrEnd']."'",$db);
  $i=1;
  while($myrow1=DB_fetch_assoc($mrnsql)){
  	$myrow[]=$myrow1;
	}	
	if(!empty($myrow)){
	foreach ($myrow as $val){
	 $checklistsql=DB_query("SELECT count(ad.mst_itemid) as cn,a.id FROM addmrn a,addmrnqty ad WHERE a.id=ad.issue_id AND
a.companyID='".$_SESSION['ACGCompanyId']."' AND a.MRNDate BETWEEN '".$_SESSION['financialYrStart']."'  AND '".$_SESSION['financialYrEnd']."' and a.id='".$val['id']."' ",$db);
	while($checkres=DB_fetch_assoc($checklistsql))
	{
		//echo $checkres['cn'];
		//echo DB_num_rows($checklistsql)."jknhknhjkn";
		$detall=DB_query("select * from qc_incoming_inspection where mrn_id='".$checkres['id']."' ",$db);
			//echo DB_num_rows($detall);
if(DB_num_rows($detall)!=$checkres['cn']){
	 ?>
  <tr bgcolor="#FFFFFF">
  	<td ><?php echo $i;?></td>
	<td><?php echo  $s->getField('locations','loccode',$val['site'],'locationname'); ?></td>
    <td><?php echo $val['MRNNo'];?></td>
    <td><?php echo ConvertSQLDate($val['MRNDate']);?></td>
    <td><?php 	echo $s->getField('suppliers','id',$val['ReceivedFrom'],'vendor_name');?></td>
	<td style="padding:0px;"><table width="100%" cellpadding="0" cellspacing="0" border="0">
		<?php  
				$mrndetsql=DB_query("select * from addmrnqty where issue_id='".$val['id']."' ",$db);  
				while($itm_det=DB_fetch_assoc($mrndetsql)) {
				$item=DB_query("select * from qc_incoming_inspection where  mrn_id='".$val['id']."' and mst_itemid='".$itm_det['mst_itemid']."' ",$db);
				if(DB_num_rows($item)>0)
				$bgcolor="#808000";
				else
				$bgcolor="#FFF"
				?>
			<tr>	
				<td bgcolor="<?php echo $bgcolor; ?>"><?php $itm_name= $s->getField('item_master','id',$itm_det['mst_itemid'],'item_name'); echo $itm_name."-".$itm_det['batch_no'];   ?></td>
			</tr>
			<?php } ?> 
		</table>
	</td>
	 <td><?php echo $val['RemarksIfAny']?></td>
	  <td><?php if($val['qc_status']==0){ echo "Pending";} else if($val['qc_status']==1){echo "Inspected";} ?></td>
	  <td><a href="index.php?route=QC/transactions/goods_incoming_inspection&modid=<?php echo $_REQUEST['modid'] ?>&frmid=<?php echo $_REQUEST['frmid'] ?>&mrnid=<?php echo  $val['id'];?>"><input type="button"  value="To QC" class="search"></a></td>
  </tr>
  <?php 
  	}}
  $i++;}	}	
  else
  {?>
  <tr>
  <td colspan="12"><h3 align="center"><strong>No Record Found</strong></h3></td>
  </tr>
  <?php 	
  }
  ?>
</table>

</body>
</html>
