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

$todate = $startdt;
$sdate = $startdt;
$edt = $enddt;
//$startdt = substr($startdt,6,4).'-'.substr($startdt,3,2).'-'.substr($startdt,0,2);
//$enddt = substr($enddt,6,4).'-'.substr($enddt,3,2).'-'.substr($enddt,0,2);

$enddt = date(Y).'-'.date(m).'-'.date(d); 

$areatotal=0;
$areadebit=0;
$areacredit=0;
$grtotal=0;
$ind=0;
$bcheck=' ';
?>
			<TABLE cellSpacing=0 width="922"  >
			<TR>
			<TD align=center width="922"  height=25><FONT 
			face=arial  size=+1  color="#0000FF">WILSON PRESS TOOLS</FONT></TD></TR>
			<TR>
			<TD align=center width="922"  height=25><FONT 
			face=arial  size=+1 color="#0000FF" >PENDING ORDERS STATUS REPORT AS ON DATE</FONT></TD></TR>			
			</TABLE>

	<table width=922>
  <TR bgColor=#cbe1fa colspan="3">	
	<td width=50 align=center><FONT color=#000080 size=2 face=arial
    height="15">Sl.No</td>
	<td width=200 align=left><FONT color=deeppink size=2 face=arial
    height="15">Product</FONT></td>
	<td width=85 align=left><FONT color=#000080 size=2 face=arial
    height="15">Drawing No</FONT></td>		
	<td width=85 align=right><FONT color=#000080 size=2 face=arial
    height="15">Schedule No</FONT></td>
	<td width=85 align=right><FONT color=#000080 size=2 face=arial
    height="15">Schedule Date</FONT></td>
	<td width=85 align=right><FONT color=#000080 size=2 face=arial
    height="15">Schedule Qty</FONT></td>
	<td width=85 align=right><FONT color=#000080 size=2 face=arial
    height="15">Issued Qty</FONT></td>
	<td width=85 align=right><FONT color=#000080 size=2 face=arial
    height="15">Balance </FONT></td>
	<td width=85 align=right><FONT color=#000080 size=2 face=arial
    height="15">Due Date</FONT></td>										
	<tr><td>&nbsp;</td></tr>
	</table>

<?


$buyres = mysql_query("select distinct buy.bcode from buy, orders where buy.bcode = orders.bcode and orders.balance_qty >0 order by buy.name") or die(mysql_error());
while($buysel = mysql_fetch_row($buyres))
{
		$tprodcode='';
			$bcode = $buysel[0];		
		$result = mysql_query("select distinct bcode, prodcode,drawing_no,schedule_no,schedule_date,due_date,order_qty,issued_qty,balance_qty,part_qty1,record,schedule_qty from orders where balance_qty >0   and bcode = '$buysel[0]' order by drawing_no,schedule_date,due_date") or die(mysql_error());
		while($row=mysql_fetch_row($result))
		{

			$prodcode =$row[1];
			$drawing_no=$row[2];
			$schedule_no=$row[3];
			$schedule_date = substr($row[4],8,2).'-'.substr($row[4],5,2).'-'.substr($row[4],0,4);
			$due_date=substr($row[5],8,2).'-'.substr($row[5],5,2).'-'.substr($row[5],0,4);
			$order_qty=$row[6];
			$issued_qty=$row[7];
			$balance_qty=$row[8];
			$part_qty1= $row[9];
			$record=$row[10];
			$schedule_qty=$row[11];
			$ddate=$row[5];
			$subresult = mysql_query("select name,unit from buy where bcode ='$bcode' ") or die(mysql_error());
			$subrow = mysql_fetch_row($subresult);
					$bname = $subrow[0].'&nbsp;&nbsp;'.$subrow[1];
		
			$subresult = mysql_query("select prodname from product where bcode='$bcode' and prodcode='$prodcode' ") or die(mysql_error());
			$subrow = mysql_fetch_row($subresult);
			$prodname = $subrow[0];
			if($bcheck != $bname)
			{
				?>
				<TABLE cellSpacing=0 width="922" >
				<TBODY>
				<tr  ><td  colspan="100%">&nbsp;</td></tr>		
				<TR>
				<TD align=left width="922"  bgcolor="#CCCCFF"height=25><FONT 
				face=arial color=#000080 size=2><? echo($bname);?></FONT></TD></TR></TBODY></TABLE>
				<?
				$bcheck = $bname;
			}
			?>
			<table width=922>
			<?
			  if($tprodcode != $prodcode and $tprodcode != '') 
			  {
			  ?>
				<tr  ><td  colspan="100%">&nbsp;</td></tr>
			  <?
			  }	
			  ?>	
			<TR bgcolor="#D6DD7D" colspan="3">	
			<td width=52 align=center><FONT color=deeppink size=2 face=arial
			height="15"><? echo($ind+1);echo(")");?></FONT></td>
			<td width=208 align=left><FONT color="#990033" size=2 face=arial
			height="15"><? echo($prodname );?></FONT></td>
			<td width=88 align=left><FONT color=#000080 size=2 face=arial
			height="15"><? echo($drawing_no );?></FONT></td>		
			<td width=88 align=right><FONT color=#000080 size=2 face=arial
			height="15"><? echo($schedule_no );?></FONT></td>
			<td width=88 align=right><FONT color=#000080 size=2 face=arial
			height="15"><? echo($schedule_date );?></FONT></td>
			<td width=88 align=right><FONT color=#000080 size=2 face=arial
			height="15"><? echo($schedule_qty );?></FONT></td>
			<td width=88 align=right><FONT color=#000080 size=2 face=arial
			height="15"><? echo($issued_qty );?></FONT></td>
			<td width=87 align=right><FONT color=#000080 size=2 face=arial
			height="15"><? echo($balance_qty );?></FONT></td>
			<?
			if($ddate <= $enddt)
			{
			?>
			<td width=95 align=right><FONT color=#000080 size=2 face=arial
			height="15"><? if($due_date != '00-00-0000') echo($due_date );?><blink><font color="#FF0000"> <b>Due</b></font></blink></FONT></td>										
			<?
			}
			elseif($ddate > $enddt)
			{
			?>
			<td width=95 align=right><FONT color=#000080 size=2 face=arial
			height="15"><? if($due_date != '00-00-0000') echo($due_date );?></FONT></td>										
			<?	
			
			}
			?>
			
			</table>
			<?
			if($part_qty1 >0)
			{
				$partresult = mysql_query("select part_qty1,due_date1,part_qty2,due_date2,part_qty3,due_date3,part_qty4,due_date4,part_qty5,due_date5 from orders where record='$record' ") or die(mysql_error());
				$partrow = mysql_fetch_row($partresult);
				$part_qty1=$partrow[0];
				$due_date1=substr($partrow[1],8,2).'-'.substr($partrow[1],5,2).'-'.substr($partrow[1],0,4);
				$part_qty2=$partrow[2];
				$due_date2=substr($partrow[3],8,2).'-'.substr($partrow[3],5,2).'-'.substr($partrow[3],0,4);
				$part_qty3=$partrow[4];
				$due_date3=substr($partrow[5],8,2).'-'.substr($partrow[5],5,2).'-'.substr($partrow[5],0,4);
				$part_qty4=$partrow[6];
				$due_date4=substr($partrow[7],8,2).'-'.substr($partrow[7],5,2).'-'.substr($partrow[7],0,4);
				$part_qty5=$partrow[8];
				$due_date5=substr($partrow[9],8,2).'-'.substr($partrow[9],5,2).'-'.substr($partrow[9],0,4);
				if($part_qty1 >0)
				{
					?>
					<table width=922>
					<TR bgColor=#cbe1fa colspan="3">	
					<td width=109 align=center>&nbsp;</td>
					<td width=611 align=center><FONT color=deeppink size=2 face=arial
					height="15">Part Qty</FONT></td>
					<td width=89 align=right><FONT color=#000080 size=2 face=arial
					height="15"><? echo($part_qty1 );?></FONT></td>		
					<td width=93 align=right><FONT color=#000080 size=2 face=arial
					height="15"><? echo($due_date1);?></FONT></td></table>
					<?
				}
				if($part_qty2 >0)
				{
					?>
					<table width=922>
					<TR bgColor=#cbe1fa colspan="3">	
					<td width=109 align=center>&nbsp;</td>
					<td width=611 align=center><FONT color=deeppink size=2 face=arial
					height="15">Part Qty</FONT></td>
					<td width=89 align=right><FONT color=#000080 size=2 face=arial
					height="15"><? echo($part_qty2 );?></FONT></td>		
					<td width=93 align=right><FONT color=#000080 size=2 face=arial
					height="15"><? echo($due_date2);?></FONT></td></table>
					<?
				}
				if($part_qty3 >0)
				{
					?>
					<table width=922>
					<TR bgColor=#cbe1fa colspan="3">	
					<td width=109 align=center>&nbsp;</td>
					<td width=611 align=center><FONT color=deeppink size=2 face=arial
					height="15">Part Qty</FONT></td>
					<td width=89 align=right><FONT color=#000080 size=2 face=arial
					height="15"><? echo($part_qty3 );?></FONT></td>		
					<td width=93 align=right><FONT color=#000080 size=2 face=arial
					height="15"><? echo($due_date3);?></FONT></td></table>
					<?
				}	
				if($part_qty4 >0)
				{
					?>
					<table width=922>
					<TR bgColor=#cbe1fa colspan="3">	
					<td width=109 align=center>&nbsp;</td>
					<td width=611 align=center><FONT color=deeppink size=2 face=arial
					height="15">Part Qty</FONT></td>
					<td width=89 align=right><FONT color=#000080 size=2 face=arial
					height="15"><? echo($part_qty4 );?></FONT></td>		
					<td width=93 align=right><FONT color=#000080 size=2 face=arial
					height="15"><? echo($due_date4);?></FONT></td></table>
					<?
				}	
				if($part_qty5 >0)
				{
					?>
					<table width=922>
					<TR bgColor=#cbe1fa colspan="3">	
					<td width=109 align=center>&nbsp;</td>
					<td width=611 align=center><FONT color=deeppink size=2 face=arial
					height="15">Part Qty</FONT></td>
					<td width=89 align=right><FONT color=#000080 size=2 face=arial
					height="15"><? echo($part_qty5 );?></FONT></td>		
					<td width=93 align=right><FONT color=#000080 size=2 face=arial
					height="15"><? echo($due_date5);?></FONT></td></table>
					<?
				}						
			?>
			</table>
				
			<?
			}
			$ind++;
					$tprodcode=$prodcode;
		}
}
?>
<br><br><font size=1><center><a href="../../index.html">Return to Index page</a></center></font>
