<?php include("../../include/dbconnect.php"); ?>

<table width=800  border=0>
<tr><td align ="center"><h4><font face="Arial, Helvetica, sans-serif">Closing Stock as on &nbsp;<?echo(date(d).'-'.date(m).'-'.date(Y));?></font></h4></td></tr></table>
<hr align="left" width = 800></hr>
<table width="800" border="0">
  <tr>
    <td width="100" align="center"><font face="Arial, Helvetica, sans-serif">Sl.No</font></td>  
    <td width="300"><font face="Arial, Helvetica, sans-serif">Product</font></td>
    <td width="100"  align="right"><font face="Arial, Helvetica, sans-serif">Stock</font></td>
    <td width="100" align="right"><font face="Arial, Helvetica, sans-serif">Minim Qty</font></td>
    <td width="100" align="right"><font face="Arial, Helvetica, sans-serif">Shortage</font></td>		
  </tr>
</table>
<hr align="left" width = 800 ></hr>

<?
$temp=' ';
$totvalue=0;
	$subtot=0;
	$qtytot=0;
	$result = mysql_query("select category from matprodcat where catcode = '$matcat' ") or die(mysql_error());
	$row = mysql_fetch_row($result);
	$category = $row[0];

	?>
	<table width="797" border="0">
	<tr>
	<td width="469" colspan="100%" align="center"><font size="+1" color="#CC0000"><b><? echo($category);?></b> </font></td>

	</tr>
	</table>
	<table width="800" border="0">
	
	<?

	//sort($prodcode);	
for($ind=0;$ind<count($prodcode);$ind++)
{	


	
	$result = mysql_query("select prodname,minimum_qty from rawmaterial where prodcode = '$prodcode[$ind]' order by prodcode,prodname") or die(mysql_error());
	$row=mysql_fetch_row($result);



		$prodname = $row[0];
		$minimum_qty=$row[1];
		$presult = mysql_query("select sum(balance) from mat_purreg where  prodcode = '$prodcode[$ind]'  ") or die(mysql_error());
		$prow = mysql_fetch_row($presult);
		$qtyonhand =$prow[0];
//		$qtyonhand_nos = $prow[1];
	//	if($qtyonhand_nos >0)
	//	{
	//		$qtyonhand = $qtyonhand.'('.$qtyonhand_nos.'&nbsp;Nos)';
	//	}
		
		?>   
		<tr>
    <td width="100" align="center"><font face="Arial, Helvetica, sans-serif"><? echo($ind+1);?></font></td>		
		<td width="300"><font face="Arial, Helvetica, sans-serif"><? echo($prodname);?>  </font></td>
		<td width="100" align="right"><font face="Arial, Helvetica, sans-serif"><? echo($qtyonhand);?></font></td>
		<td width="100" align="right"><font face="Arial, Helvetica, sans-serif"><? echo(number_format($minimum_qty,2,'.',''));?></font></td>
		<td width="100" align="right"><font face="Arial, Helvetica, sans-serif" color="#FF0000"> 
	    <? if($minimum_qty > $qtyonhand) echo(number_format($minimum_qty-$qtyonhand,2,'.',''));?> </font></td>						
		</tr>
			
		 <?  

}

?>
		</table>
 <hr align = "left" width = 800></hr>



    <br>
    <br><font size=1><center><a href= "/wilson/stores.html">Return to index page</center></font>
</body>
</form>



