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

?>

<title>Approval </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>Approval </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">
       


  <form name='myForm02' method='POST' action='app_post.php' >
	  <table border=1 cellpadding=3 cellspacing=4 width="966" bordercolor="#FF0000">
        <tr> 
        <td align="center" width="37" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Indent No & Date</font></b></font></td>		
        <td align="center" width="174" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Material</font></b></font></td>
        <td align="center" width="52" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Avail.Stock </font></b></font></td>		
        <td align="center" width="98" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Req. Qty </font></b></font></td>
        <td align="right" width="61" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Last Pur.Rate</font></b></font></td>	 
        <td align="center" width="100" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Used for</font></b></font></td>	 		
        <td align="center" width="131" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Specification</font></b></font></td>	 
        <td align="center" width="61" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Required Date</font></b></font></td>	 		
        <td align="center" width="63" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font  color="#990066">Check the box to Approve</font></b></font></td>	 		
 </tr>
<?
$ind=1;
$result = mysql_query("select record,qty,date,prodcode,used_for,req_date,remarks,indent_no,unit from matindent where approved = 'No' and received_qty != qty order by date,req_date,prodcode") or die(mysql_error());
while($row=mysql_fetch_row($result))
{
	$date = substr($row[2],8,2).'-'.substr($row[2],5,2).'-'.substr($row[2],0,4);
	$req_date = substr($row[5],8,2).'-'.substr($row[5],5,2).'-'.substr($row[5],0,4);
	$qty=$row[1];
	$prodcode=$row[3];
	$used_for=$row[4];
	$remarks=$row[6];
	$indent_no=$row[7].'/'.$date;
	$unit = $row[8];

    $sProdQuery = mysql_query("SELECT distinct prodname FROM rawmaterial  where prodcode = '$row[3]' ") or die(mysql_error());
	$prodrow=mysql_fetch_row($sProdQuery);
	$prodname=$prodrow[0];

	$rateselect = mysql_query("select max(po_date) from matpo where prodcode ='$prodcode' ") or die(mysql_error());
	$raterow=mysql_fetch_row($rateselect);
	$po_date = $raterow[0];
	
	$rateselect = mysql_query("select rate from matpo where prodcode ='$prodcode' and po_date = '$po_date' ") or die(mysql_error());
	$raterow=mysql_fetch_row($rateselect);
	$rate = $raterow[0];
	
	$presult = mysql_query("select sum(balance) from mat_purreg where  prodcode = '$prodcode[$ind]'  ");
	$prow = mysql_fetch_row($presult);
	$qtyonhand =$prow[0]	
	
?>

	<input type="hidden" name=" record[<? echo($ind);?>]" value = "<? echo($row[0]);?> ">
<?

?>
        <td width="37" > <? echo($indent_no);?></td>
        <td width="174" > <? echo($prodname);?></td>
        <td width="52" > <? echo($stock);?></td>		
	<td width="98" ><input type="text"    onKeyPress="return event.keyCode!=13"    size="8" name=" qty[<? echo($ind);?>]" value = "<? echo($qty);?> "><? echo($unit);?>
        <td width="61" > <? echo($rate);?></td>
        <td width="100" > <? echo($used_for);?></td>
        <td width="131" > <? echo($remarks);?></td>
        <td width="61" > <? echo($req_date);?></td>
        
    <td width="63" > <input  type="checkbox"   onKeyPress="return event.keyCode!=13"     align="absmiddle"  name="app[<? echo($ind);?>]" value="Yes">Yes</td>
  </tr>										
<?
$ind++;
}
$dat = date(d).'-'.date(m).'-'.date(Y);
?>

     
</table>	
	  <table border=0 cellpadding=3 cellspacing=4 width="781" >	  
	  
      <tr > 
        <td width="139" height="31" align="right" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Approved By
          &nbsp;</font></b></font></td>
        <td width="145" > <input type="text"    onKeyPress="return event.keyCode!=13"   size="60" name="approved_by" value= > 
        </td>
        <td width="96" ></td><td width="83" ></td>
      </tr>	  
	  
      <tr > 
        <td width="139" height="31" align="right" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Approval Date
          &nbsp;</font></b></font></td>
        <td width="145" > <input type="text"    onKeyPress="return event.keyCode!=13"   size="12" name="today" value= <? echo($dat);?> > 
        </td>
        <td width="96" ></td><td width="83" ></td>
      </tr>	  
	  
  <tr> 
    <td align="right" width="302" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Confirm  Approval 
      </b></font></td>
    <td width="449" ><input type="radio"    onKeyPress="return event.keyCode!=13"   name="upd" value = "No"> <font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Not 
      Confirm </b></font>&nbsp; <tr> 
    <td width="302" ></td>
    <td width="449" ><input type="radio"    onKeyPress="return event.keyCode!=13"   name="upd" value = "Yes"> <font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Confirm 
      </b></font> </td>
  </tr>
  <tr> 
    <td width="302" ></td>
    <td width="449" >&nbsp; </td>      
	
</table>	
<table cellpading=0 cellspacing=10 width= 50>
<tr><td>
 <blockquote>  <input type =submit name="submit" value = "Submit"></td></blockquote>

</table>

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