<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>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>Schedule 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  where buyertype != 'LABOUR' 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>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>  

  
</form>
<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 FROM orders,product WHERE (orders.bcode ='$myCustomer') and product.groupcode ='$myCat' and (product.prodcode=orders.prodcode and product.bcode ='$myCustomer') and open_order='Yes' group by orders.record  order by product.prodname ") or die(mysql_error());


// This form contain a hidden field CustomerID which can be later used in next  page..
?>
<form name='myForm02' method='POST' action='entry2.php' >
<input type="hidden" name="bcode" value=<?echo($myCustomer);?>>


<SELECT name=record  >
<?
echo "<option selected value=\" 0\"> Select Product";
while($row1 = mysql_fetch_row($sBuyQuery))
{
	$temp = $row1[1].'&nbsp;(Dr.No.&nbsp;:'.$row1[2].'&nbsp;)'.'&nbsp;(Order.No.&nbsp;:'.$row1[3].'&nbsp;)';
	echo "<option value=\"$row1[0]\">$temp";
}

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




<?



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

  
<tr > 
  <td width="139" height="31" align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Schedule No 
    &nbsp;</b></font></td>
  <td width="145" > <input type="text"    onKeyPress="return event.keyCode!=13"   name="schedule_no"  value= '' > 
  </td>
</tr>  

<tr > 
  <td width="139" height="31" align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Schedule Date 
    &nbsp;</b></font></td>
  <td width="145" > <input type="text"    onKeyPress="return event.keyCode!=13"   name="schedule_date" 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>Quantity 
    &nbsp;</b></font></td>
  <td width="145" > <input type="text"    onKeyPress="return event.keyCode!=13"   name="order_qty"  value= '' > 
  </td>
</tr>
 

  
<tr > 
  <td width="139" height="31" align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Due Date 
    &nbsp;</b></font></td>
  <td width="145" > <input type="text"    onKeyPress="return event.keyCode!=13"   name="due_date" value= <?php echo($sdt); ?> > 
  </td></tr>  
  
 
  
    <tr> 
    <td align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Plan this Order as</b></font></td>
    <td> <input type="radio"    onKeyPress="return event.keyCode!=13"   name="plan_type" value = "Normal"> <font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Normal 
    </b></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="radio"    onKeyPress="return event.keyCode!=13"   name="plan_type" value = "Additional"> <font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Additional
      </b></font>&nbsp;</td>
  </tr> 
  
  
  <?
  $year1= date(Y);
  $year2=$year1+1;
  $year3= $year1-1;
  ?>
 </table>
<table cellpadding=0 cellspacing=4 width=590>  
<tr> 
<td width="139" height="31" align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Add this Schedule to </b></font></td><td>
<td>
  <SELECT name='month'>

	<option value="01">January
	<option value="02">February	
	<option value="03">March
	<option value="04">April		
	<option value="05">May
	<option value="06">June
	<option value="07">July		
	<option value="08">August
	<option value="09">September					
	<option value="10">October	
	<option value="11">November
	<option value="12">December
  </SELECT>
  
   <SELECT name='year'>
	<option value="<? echo($year3);?>"><? echo($year3);?>
	<option value="<? echo($year1);?>"><? echo($year1);?>
	<option value="<? echo($year2);?>"><? echo($year2);?>	
  </SELECT></td>
  
  </tr>
 </table>
<table cellpadding=0 cellspacing=4 width=590>   
  <tr > 
<td width="139" height="31" align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Tentative Qty
    &nbsp;</b></font></td>
  <td> <input type="text"    onKeyPress="return event.keyCode!=13"   name="tentative_qty"  value= '' > 
  </td>
</tr>  
  
  <tr> 
    <td align="right" ><font color="#FF0000" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Confirm</b></font></td>
    <td> <input type="radio"    onKeyPress="return event.keyCode!=13"   name="cnf" value = "No" checked> <font color="#FF0000" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>No 
    </b></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="radio"    onKeyPress="return event.keyCode!=13"   name="cnf" value = "Yes"> <font color="#FF0000" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Yes
      </b></font>&nbsp;</td>
  </tr>   
  </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>
