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


?>
<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  where buyertype != 'LABOUR' and buyertype != 'EXPORT' and buyertype != 'TEMP' 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>
  
 
  
</form>

<?

// 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='entry.php' >
<input type="hidden" name="bcode" value=<?echo($myCustomer);?>>
</table>
<table border=0 cellpadding=3 cellspacing=4 width="449">
  <tr> 
    <td align="center" width="277" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Product & Order No </b></font></td>
    <td align="center" width="174" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Qty</b></font></td></tr>


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

$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 and app_status !='Yes' order by product.prodname,schedule_date ") or die(mysql_error());

?>
<tr><td>
<SELECT name='record[<? echo($ind);?>]'  >
<?
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;'.'Pend Qty :&nbsp;'.$row1[4];
	echo "<option value=\"$row1[0]\">$temp";
}

?>
</SELECT>
</td>

  <td width="174" > <input type="text"    onKeyPress="return event.keyCode!=13"   name="qty[<? echo($ind);?>]"  > 
  </td>
</tr>











<?
}


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

$sBuyQuery = mysql_query("SELECT distinct orders.record,orders.schedule_no,schedule_date,balance_qty FROM orders WHERE (orders.bcode ='$myCustomer') and (open_order='Y' and balance_qty >0) and schedule_no !='' order by schedule_no ") or die(mysql_error());
?>

  
</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>Company
  &nbsp;</b></font></td>

<td>

<?


$sBuyQuery = mysql_query("SELECT distinct compcode,name from company order by name ") or die(mysql_error());


?>
<SELECT name=compcode  >
<?
echo "<option selected value=\" 0\"> Select Company";
while($row1 = mysql_fetch_row($sBuyQuery))
{
	$temp = $row1[1];
	echo "<option value=\"$row1[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>Date 
    &nbsp;</b></font></td>
  <td width="145" > <input type="text"    onKeyPress="return event.keyCode!=13"   name="invdt" value= <?php echo($sdt); ?> > 
  </td></tr>  
  

  


<tr> 
<td width="139" height="31" align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Type of Sales </b></font></td>
<td width="145" align="left" >
  <SELECT name='typeofsale'>

	<option value="STATE">WITH IN STATE
	<option value="INTERSTATE"> INTER STATE
  </SELECT>
 </td>
 <tr> 
 
  <?php
$bankQuery=mysql_query("select taxtype, description, tax,tariff from salestax order by tariff desc ") or die(mysql_error());
?>

  <td width="74" height="31" align="left" ><strong><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>GST TYPE</font></strong></td>
<td> <SELECT name='Tax'  >
<?php
    echo "<option selected value=\" 0\"> Select Tax";
    while($row = mysql_fetch_row($bankQuery))
    {
   	$temp = 'HSN&nbsp;&nbsp;'.$row[3].'&nbsp;&nbsp; (Tax %&nbsp;'.$row[2].')';


		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>Packing Charges(%)
    &nbsp;</b></font></td>
  <td> <input type="text"    onKeyPress="return event.keyCode!=13"   name="packing_percentage"  value= '0' > 
  </td>
</tr>  
  <tr > 
<td width="139" height="31" align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Transport Charges
    &nbsp;</b></font></td>
  <td> <input type="text"    onKeyPress="return event.keyCode!=13"   name="transport_charges"  value= '0' > 
  </td>
</tr>  
  
  <tr > 
<td width="139" height="31" align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Time or Preparation
    &nbsp;</b></font></td>
  <td> <input type="text"    onKeyPress="return event.keyCode!=13"   name="prepare_time"  value= '<?php echo(date("H.i")); ?>' > 
  </td>
</tr>

  <tr > 
<td width="139" height="31" align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Time of Removal
    &nbsp;</b></font></td>
  <td> <input type="text"    onKeyPress="return event.keyCode!=13"   name="removal_time"  value= '<?php echo(date("H.i")); ?>' > 
  </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>
