<body background="i.jpg">
<?php include("../../include/dbconnect.php");


// Get all _POST VALUES HERE..

foreach($_POST as $p=>$t)
{
	$_POST[$p] = trim($t);
}

$myCustomer = $_POST['Customer'];



foreach($_POST as $q=>$r)
{
	$_POST[$q] = trim($r);
}

$myProduct = $_POST['Product'];

foreach($_POST as $m=>$n)
{
	$_POST[$m] = trim($n);
}

$myCat = $_POST['Cat'];

?>
<title>Approved / Rejected Qty Entry</title>
<body background=blater01.gif  topmargin=0>
<center> 
<table cellpadding=0 cellspacing=4 width=590>
  <tr> 
    <td style="padding:3px;" colspan=2 bgcolor="#93BEE2"><font face="Verdana, Arial, Helvetica, sans-serif"><b><b>Approved / Rejected Qty Entry</b></font></td>
  </tr>
  <tr valign="top"> 
    <td colspan=2> <font >&nbsp;</font> </td>
  </tr>
</table>
<table border=0 cellpadding=3 cellspacing=4 width="590">
<tr> 
<td width="139" height="31" align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Customer / Client
  &nbsp;</b></font></td><td>
<?

// Pull all the data from Customer master & populate it

$stQuery = mysql_query("select bcode,name,unit from buy order by name")or die( mysql_error() );


?>
<form name='myForm01' method='POST' action='<?=$_SERVER[PHP_SELF]?>'>
  <SELECT name='Customer' onChange="javascript:submit();">
    <?
echo "<option selected value=\" 0\"> Select Customer";
while($row = mysql_fetch_row($stQuery))
{
	
	$temp = $row[1].'&nbsp;&nbsp;'.$row[2];
	if(isset($myCustomer) && eregi("$myCustomer",$row[0]))
	{
		echo "<option selected value=\"$row[0]\">$temp";
	}
	else{
		echo "<option value=\"$row[0]\">$temp";
	}
}
?>
  </SELECT></td></tr>
<tr> 
<td width="139" height="31" align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Category
  &nbsp;</b></font></td><td>

<?  
$result= mysql_query(" select catcode,category from prodcat order by category")or die( mysql_error() );
 ?>
  <SELECT name='Cat' onChange="javascript:submit();">
    <?
echo "<option selected value=\" 0\"> Select Category";
while($row = mysql_fetch_row($result))
{
	
	//$temp = $row[1].'&nbsp;&nbsp;'.$row[2];
	if(isset($myCat) && eregi("$myCat",$row[0]))
	{
		echo "<option selected value=\"$row[0]\">$row[1]";
	}
	else{
		echo "<option value=\"$row[0]\">$row[1]";
	}
}
?>
  </SELECT></td></tr>  
  </table>
 </form>
<table width="862" border="1"  cellpadding="1">  
	<tr >
	<td bgcolor="#CCCC66"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Product</b></font></td>
	<td width="17" bgcolor="#FF66CC"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Drawing No</b></font></td>
	<td width="53" bgcolor="#99CCCC"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Invoice No</b></font></td>
	<td width="68" bgcolor="#FFCC66"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Quantity</b></font></td>
	<td width="60" bgcolor="#CECECE"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Min No</b></font></td>
	<td width="60" bgcolor="#CECECE"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Min Date</b></font></td>
	<td width="60" bgcolor="#CECECE"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Approved Qty</b></font></td>
	<td width="60" bgcolor="#CECECE"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Rejected Qty</b></font></td>
	<td width="157" bgcolor="#CECECE"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b> Remarks</b></font>	</td>												
	</tr>

<?
$sdt = date(d).'-'.date(m).'-'.date(Y); 
// Pull all Customers from Customer  based on Selected Customer id and populate it.




// This form contain a hidden field CustomerID which can be later used in next  page..
?>
<form name='myForm02' method='POST' action='reject_entry_new.php' >
<input type="hidden" name="bcode" value=<?echo($myCustomer);?>>
<?
$ind=0;
$sBuyQuery = mysql_query("SELECT  labourinv.record,product.prodname,labourinv.drawing_no,labourinv.invno,labourinv.quantity,min_no,min_date,approved_qty,rejected_qty,remarks from labourinv,product where labourinv.bcode = '$myCustomer' and labourinv.prodcode != ' '  and labourinv.drawing_no=product.drawing_no and product.groupcode ='$myCat'  ") or die(mysql_error());
while($row1 = mysql_fetch_row($sBuyQuery))
{

		?>
		<input type="hidden" name="record[<? echo($ind);?>]" value="<?	echo($row1[0]); ?>">
		<tr >
		
		<td bgcolor="#CCCC66"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?	echo($row1[1]); ?></b></font></td>
		<td width="17" bgcolor="#FF66CC"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?	echo($row1[2]); ?></b></font></td>
		<td width="53" bgcolor="#99CCCC" align="center"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?	echo($row1[3]); ?></b></font></td>
		<td width="68" bgcolor="#FFCC66"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><?	echo($row1[4]); ?></b></font></td>
		<td width="60" bgcolor="#CECECE"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><input type="text"    onKeyPress="return event.keyCode!=13"   size="10" name="min_no[<? echo($ind);?>]" value="<?	echo($row1[5]); ?>"></b></font></td>
		<td width="60" bgcolor="#CECECE"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><input type="text"    onKeyPress="return event.keyCode!=13"   size="10" name="min_date[<? echo($ind);?>]" value="<?	echo($row1[6]); ?>"></b></font></td>
		<td width="60" bgcolor="#CECECE"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><input type="text"    onKeyPress="return event.keyCode!=13"   size="10" name="approved_qty[<? echo($ind);?>]" value="<?	echo($row1[7]); ?>"></b></font></td>
		<td width="60" bgcolor="#CECECE"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><input type="text"    onKeyPress="return event.keyCode!=13"   size="10" name="rejected_qty[<? echo($ind);?>]" value="<?	echo($row1[8]); ?>"></b></font></td>
		<td width="157" bgcolor="#CECECE"><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b> <textarea name = "remarks[<? echo($ind);?>]" cols="20" rows="2"> <?	echo($row1[9]); ?></textarea></b></font>
		</td>												
		</tr>
		<?
		$ind++;	


}





?>

</table>
 
  
  
  <table cellpading=0 cellspacing=10 width= 50>
    <tr> 
      <td> <blockquote> <input type =submit name="submit" value = "Submit"></td></blockquote>
  </table>
</table>


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