<?php include("../../include/dbconnect.php");?>
<title>MIN Statement Print</title>
<body bgcolor="#ffffff"  topmargin=0>
<?

$todate = $from_date;
$sdate = $from_date;
$edt = $to_date;
$from_date = substr($from_date,6,4).'-'.substr($from_date,3,2).'-'.substr($from_date,0,2);
$to_date = substr($to_date,6,4).'-'.substr($to_date,3,2).'-'.substr($to_date,0,2);
?>
			<TABLE cellSpacing=0 width="987"  >
			<TR>
			<TD align=center width="1003"  height=25><FONT 
			face=arial  size=+1  color="#0000FF">WILSON PRESS TOOLS</FONT></TD></TR>
			<TR>
			<TD align=center width="1003"  height=25><FONT 
			face=arial  size=+1 color="#0000FF" >MIN Statement FROM &nbsp; <? echo($sdate);?>&nbsp;TO&nbsp;<? echo($edt);?></FONT></TD></TR>			
			</TABLE>
<?

$areatotal=0;
$areadebit=0;
$areacredit=0;
$grtotal=0;
$ind=0;
$bcheck=' ';
for($bind=0;$bind <count($bcode);$bind++)
{
	$subresult = mysql_query("select name,unit from buy where bcode ='$bcode[$bind]' ") or die(mysql_error());
	$subrow = mysql_fetch_row($subresult);
			$bname = $subrow[0].'&nbsp;&nbsp;'.$subrow[1];
	
	
	
	?>

	<TABLE cellSpacing=0 width="989"  bgColor=#cef1ff>
	<TBODY>
	<TR>
	<TD align=left width="1202" bgColor=#cbe1fa height=25><FONT 
	face=arial color=#000080 size=2><? echo($bname);?></FONT></TD></TR></TBODY></TABLE>
	
		
	
	   
<table width="989" border=1 cellspacing=0 cellpadding=0>
  <tr  > 
    <td width=43 align=center><font color=#000080 size=2 
	height="15">Sl.No</font></td>
    <td width=255 align=center><font color=#000080 size=2 face=arial
	height="15">Component Name</font></td>
    <td width=116 align=center><font color=#000080 size=2 face=arial
	height="15">Drawing No</font></td>
    <td width=122 align=center><font color="#CC0066" size=2 face=arial
	height="15">Invoice No</font></td>
    <td width=68 align=center><font color=#000080 size=2 face=arial
	height="15">Qty </font></td>
     <td width=121 align=center><font color=#000080 size=2 face=arial
	height="15">MIN No </font></td>
    <td width=106 align=center><font color=#000080 size=2 face=arial
	height="15">Min Date</font></td>	
    <td width=80 align=center><font color=#000080 size=2 face=arial
	height="15">Approved Qty</font></td>
    <td width=58 align=center><font color=#000080 size=2 face=arial
	height="15">Rej. Qty</font></td>

  <tr>
    <td height="21">&nbsp;</td>
  </tr>
  <?
	$ind=1;
	$temp= ' ';
	$tprodcode='';	

	$query ="select  bcode,prodcode,drawing_no,quantity,invno,invdate,min_no,min_date,approved_qty,rejected_qty from salesreg where bcode='$bcode[$bind]' and (min_date >='$from_date' and min_date <='$to_date') and min_no != ' '  order by invno,invdate,min_no,min_date ";
	$result = mysql_query($query);
	while($row=mysql_fetch_row($result))
	{
		$bcode1 = $row[0];
		$prodcode =$row[1];
		$drawing_no=$row[2];
		$qty=$row[3];
		$invno = $row[4];
		$invdate = substr($row[5],8,2).'-'.substr($row[5],5,2).'-'.substr($row[5],0,4);
		$min_no=$row[6];
		$min_date =substr($row[7],8,2).'-'.substr($row[7],5,2).'-'.substr($row[7],0,4);
		$approved_qty=$row[8];
		$rejected_qty = $row[9];

		
	
		$subresult = mysql_query("select prodname from product where bcode='$bcode1' and prodcode='$prodcode' ") or die(mysql_error());
		$subrow = mysql_fetch_row($subresult);
		$prodname = $subrow[0].'&nbsp;(&nbsp;'.$drawing_no.'&nbsp;)';

		if($tprodcode != $prodcode and $tprodcode != '') 
		{
			?>
			<tr  ><td  colspan="100%">&nbsp;</td></tr>
			<?
		}	
		?>	
		<tr bgcolor="#EEEFAF"> 
		<td width=43 align=center><font color=#000080 size=2 face=arial><? echo($ind);?></font></td>
		<td width=255 align=left><font color=#000080 size=2 face=arial
		height="15"><? echo($prodname);?></font></td>
		<td width=116 align=left><font color=#000080 size=2 face=arial
		height="15"><? echo($drawing_no);?></font></td>
		<td width=122 align=left><font color=#000080 size=2 face=arial
		height="15"><? echo($invno);?> /<?  echo($invdate);?></font></td>

		<td width=68 align=right><font color=#000080 size=2 face=arial
		height="15"><?  echo(round($qty,0))	?></font></td>
		
		<td width=121 align=right><font color="#CC0066" size=2 face=arial
		height="15"><?  echo($min_no);?></font></td>
		
		<td width=106 align=right><font color="#CC0066" size=2 face=arial
		height="15"><? echo($min_date);?></font></td>
		
		<td width=80 align=right><font color=#000080 size=2 face=arial
		height="15">
		<? if($approved_qty>0) echo(round($approved_qty,0));else echo("&nbsp;");?>
		</font></td>
		<td width=58 align=right><font color=#000080 size=2 face=arial
		height="15">
		<? if($rejected_qty>0) echo(round($rejected_qty,0));else echo("&nbsp;");?>
		</font></td>		
		<?
		$tprodcode=$prodcode;
		$ind++;
	}
}
?>
</table>
<br>
<br><font size=1><center><a href="../../index.html">Return to Index page</a></center></font>
