<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'];





?>
<title>Daily Transaction</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>Prepare  Purchase Order</b></font></td>
  </tr>
  <tr valign="top"> 
    <td colspan=2> <font >&nbsp;</font> </td>
  </tr>
</table>
<table border=0 cellpadding=3 cellspacing=4 width="556">
<tr> 
<td width="139" height="31" align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Supplier</b></font></td><td>
<?

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

$stQuery = mysql_query("select bcode,name,unit from supplier 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>
  
 
  
</form><tr >

<form name='myForm02' method='POST' action='entry.php' >
<input type="hidden" name="bcode" value=<?echo($myCustomer);?>>




<center>

       





      <?
      $sdt = date(d).'-'.date(m).'-'.date(Y); 
	  // Pull all the data from Standard master & populate it
	  
$sBuyQuery = mysql_query("SELECT distinct taxtype,document_type,despatch_from,excise_duty,credit,type FROM supplier WHERE (bcode ='$myCustomer') order by supplier.name ") or die(mysql_error());
$srow=mysql_fetch_row($sBuyQuery);
$taxtype=$srow[0];
$document_type=$srow[1];
$desp_from=$srow[2];
$ex_duty=$srow[3];	  
$pay_terms=$srow[4];
$potype=$srow[5];


$txresult = mysql_query("select short from salestax where taxtype = '$taxtype'") or die(mysql_error());
$trow = mysql_fetch_row($txresult);
$ttype = $trow[0];

$maxresult = mysql_query("select max(po_no) from matpo where account_year = '$account_year' order by po_no") or die(mysql_error());
$maxrow = mysql_fetch_row($maxresult);
$pono = $maxrow[0]+1;


?>



<tr > 
        <td width="139" height="31" align="right" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Company Name
          &nbsp;</font></b></font></td><td>

   <SELECT name='compcode' >

<?
    $sBuyQuery = mysql_query("SELECT distinct compcode,name FROM company order by name");

    while($row = mysql_fetch_row($sBuyQuery))
    {

            echo "<option value=\"$row[0]\">$row[1]";
        
    }
?>
        </SELECT>
</td></tr>
      <tr > 
        <td width="139" height="31" align="right" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">P O No
          &nbsp;</font></b></font></td>
        <td width="145" > <input type="text"    onKeyPress="return event.keyCode!=13"   name="po_no" value= <?php echo($pono); ?> > 
        </td>

      </tr>


      <tr > 
        <td width="139" height="31" align="right" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Date of P O
          &nbsp;</font></b></font></td>
        <td width="145" > <input type="text"    onKeyPress="return event.keyCode!=13"   name="today" value= <?php echo($sdt); ?> > 
        </td>

      </tr>


		</table>
		
	  <table border=0 cellpadding=3 cellspacing=4 width="558">
        <tr> 
        <td width="42" height="19" align="center" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Material</font></b></font></td>
        <td align="center" width="46" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Qty</font></b></font></td>

        <td align="center" width="68" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Rate</font></b></font></td>	 
        <td align="center" width="77" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Unit</font></b></font></td>	 
        <td align="right" width="77" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Del. Date</font></b></font></td>	 						
        <td align="center" width="184" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Remarks</font></b></font></td>	 				
	 		
	 </tr>

<?		
		for($ind=0;$ind<=4;$ind++)
		{

    $sProdQuery = mysql_query("SELECT distinct matindent.record,rawmaterial.prodname,matindent.approved_qty - po_issued_qty,unit FROM rawmaterial,matindent where matindent.prodcode = rawmaterial.prodcode and matindent.approved='Yes' and approved_qty - po_issued_qty > 0  order by rawmaterial.prodname ") or die(mysql_error());
?>
<tr><td>
   <SELECT name='record[<? echo($ind);?>]' >

<?
     echo "<option selected value=\" 0\"> Select Material";
    while($row = mysql_fetch_row($sProdQuery))
    {
			$temp= $row[1].'&nbsp;(&nbsp;App Pend.Qty:&nbsp;'.$row[2].'&nbsp;'.$row[3].')';
            echo "<option value=\"$row[0]\">$temp";
        
    }
?>
        </SELECT>
</td>



	  <?
	      $sPQuery = mysql_query("SELECT distinct packing FROM product  ");
	  ?>
        <td width="46" > <input type="text"    onKeyPress="return event.keyCode!=13"    maxlength="7" size="7" name="qty[<? echo($ind);?>]" value= ' ' > </td>

        <td width="68" > <input type="text"    onKeyPress="return event.keyCode!=13"   size="10" name="rate[<? echo($ind);?>]" value= ' ' > </td>
		
        <td width="77" >
		<select name ="unit[<? echo($ind);?>]">
		<option value="Kgs">Per Kg</option>
		<option value="MT">Per MT</option>
		<option value="Ltrs">Per Ltr</option>
		<option value="Nos">Per Nos</option>
		<option value="Pair">Per Pair</option>
		<option value="Set">Per Set</option>
		<option value="Case">Per Case</option>										
		</select>
		 </td>		
		
        <td width="77" > <input type="text"    onKeyPress="return event.keyCode!=13"    maxlength="11" size="11" name="date[<? echo($ind);?>]" value= '<?php echo($sdt); ?> ' > </td>						
        <td width="184" > <input type="text"    onKeyPress="return event.keyCode!=13"   name="remarks[<? echo($ind);?>]" value= ' ' > </td>
		
</tr>
<?
}?>

   		</table>
		
	  <table border=0 cellpadding=3 cellspacing=4 width="558">  
      <tr > 
        <td width="171" height="31" align="right" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Reference
          &nbsp;</font></b></font></td>
        <td width="363" > <input type="text"    onKeyPress="return event.keyCode!=13"   name="reference" value= '' > 
        </td>

      </tr>	 

      <tr > 
        <td width="171" height="31" align="right" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Sales Tax
          &nbsp;</font></b></font></td>
        <td width="363" > <input type="text"    onKeyPress="return event.keyCode!=13"   name="sales_tax" value= '<? echo($ttype);?> ' > 
        </td>

      </tr>
	  
      <tr > 
        <td width="171" height="31" align="right" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Excise Duty
          &nbsp;</font></b></font></td>
        <td width="363" > <input type="text"    onKeyPress="return event.keyCode!=13"   name="excise_duty" value= '<? echo($ex_duty);?>' > 
        </td>

      </tr>	  


      <tr > 
        <td width="171" height="31" align="right" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Documents
          &nbsp;</font></b></font></td>
        <td width="363" > <input type="text"    onKeyPress="return event.keyCode!=13"   name="documents" value= '<? echo($document_type);?>' > 
        </td>

      </tr>
	  
      <tr > 
        <td width="171" height="31" align="right" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Payment Terms
          &nbsp;</font></b></font></td>
        <td width="363" > <input type="text"    onKeyPress="return event.keyCode!=13"   name="payment_terms" value= '<? echo($pay_terms);?>' > 
        </td>

      </tr>	 	 
	  
  
      <tr > 
        <td width="171" height="31" align="right" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Despatch From
          &nbsp;</font></b></font></td>
        <td width="363" > <input type="text"    onKeyPress="return event.keyCode!=13"   name="despatch_from" value= '<? echo($desp_from);?>' > 
        </td>

      </tr>	  		   	 
	  
      <tr > 
        <td width="171" height="31" align="right" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Mode of Despatch
          &nbsp;</font></b></font></td>
        <td width="363" > <input type="text"    onKeyPress="return event.keyCode!=13"   name="mode_despatch" value= '' > 
        </td>

      </tr>	 
	  
  <tr> 
    <td align="right" width="171" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Post Data 
      </b></font></td>
    <td width="363" ><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="171" ></td>
    <td width="363" ><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="171" ></td>
    <td width="363" >&nbsp; </td>      
		
	
<table cellpading=0 cellspacing=10 width= 50>
<tr><td>
 <blockquote>  <input type =submit name="submit" value = "Submit"></blockquote></td>
</table>
</table>

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