<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);
}

$myRecord = $_POST['Record'];


?>
<title>Schedule 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>Invoice Preparation</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=\"  \"> 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>Product & Order No
  &nbsp;</b></font></td><td>
<?

// Pull all Customers from Customer  based on Selected Customer id and populate it.


$sBuyQuery = mysql_query("SELECT distinct orders.record,product.prodname,orders.drawing_no,orders.order_no,orders.balance_qty,orders.schedule_no,schedule_date FROM orders,product WHERE (orders.bcode ='$myCustomer') and product.prodcode=orders.prodcode  and product.bcode = '$myCustomer' and   balance_qty >0  ") or die(mysql_error());


// This form contain a hidden field CustomerID which can be later used in next  page..
?>



  <SELECT name='Record' onChange="javascript:submit();">
<?
echo "<option selected value=\" 0\"> Select Product";
while($row1 = mysql_fetch_row($sBuyQuery))
{
	if (!empty($row1[5]) or $row1[6] != "0000-00-00")
	{
		$sch= '(&nbsp;Sch No&nbsp;'.$row1[5].'&nbsp;'.substr($row1[6],8,2).'-'.substr($row1[6],5,2).'-'.substr($row1[6],0,4).'&nbsp;)';
	}
	elseif(empty($row1[5]))
	{
		$sch='';
	}
	
	$temp = $row1[1].'&nbsp;(Dr.No.&nbsp;:'.$row1[2].'&nbsp;)'.'&nbsp;(Order.No.&nbsp;:'.$row1[3].'&nbsp;)'.'&nbsp;'.$sch.'&nbsp;';
	if(isset($myRecord) && eregi("$myRecord",$row1[0]))
	{
		echo "<option selected value=\"$row1[0]\">$temp";
	}
	else{
		echo "<option value=\"$row1[0]\">$temp";
	}
}		


?>
</SELECT></td></tr>
</form>




<form name='myForm02' method='POST' action='rem_entry.php' >
<input type="hidden" name="record" value=<?echo($myRecord);?>>





<?




$sBuyQuery = mysql_query("SELECT  remarks FROM orders WHERE record='$myRecord' ") or die(mysql_error());
$sRem = mysql_fetch_row($sBuyQuery);
$remarks1 = $sRem[0];

$sBuyQuery = mysql_query("SELECT  remarks FROM salesreg WHERE order_record='$myRecord' ") or die(mysql_error());
$sRem = mysql_fetch_row($sBuyQuery);
$remarks2 = $sRem[0];


$remarks = $remarks1.$remarks2; 

?>



 
  

    <tr > 
  <td width="139" height="31" align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Remarks
    &nbsp;</b></font></td>
  	<td width=274> <textarea name = "remarks" cols="50" rows="5" ><? echo($remarks);?></textarea>
    	</td>
  </td>
</tr>   


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


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