<?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>Product wise Pending Orders</title>

<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>Product wise pending Orders</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=\" 0\"> Select Customer";
while($row = mysql_fetch_row($stQuery))
{
	   if($row[3]== 'LABOUR')
	   {
		   	$type='------>>'.$row[3];
		}
		elseif($row[3]!= 'LABOUR')
		{
			$type ='';
		}	
	$temp = $row[1].'&nbsp;&nbsp;'.$row[2].$type;
	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>    
<?
$result = mysql_query("SELECT distinct product.prodcode,product.prodname,product.drawing_no FROM product WHERE   product.bcode= '$myCustomer' and groupcode ='$myCat' order by prodname,drawing_no ") or die(mysql_error());
 ?> 
 </form>
<form name='myForm02' method='POST' action='order_book2.php'>
<input name="bcode" type="hidden" value="<? echo($myCustomer);?>">
<tr > 
  <td width="139" height="31" align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Product & Drawing No    &nbsp;</b></font></td><td>

  <SELECT name='prodcode[]' multiple size="10" >
<?php 
	 echo "<option selected value=\" 0\"> Select Product";	  
      while ( $row1= mysql_fetch_row($result))
      {

	  	$temp = $row1[1].'&nbsp;&nbsp;(&nbsp;'.$row1[2].'&nbsp;)';
	  	if(isset($myProduct) && eregi("$myProduct",$row1[0]))
		{
			echo "<option selected value=\"$row1[0]\">$temp";
	  	}
	  	else
	  	{
			echo "<option value=\"$row1[0]\">$temp";
	  	}
	}
?>
</select>  
</td></tr>

  
  
  

  


<?
$today = 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>Starting Date
  &nbsp;</b></font></td><td>
<input type="text"    onKeyPress="return event.keyCode!=13"   class="Wf" name="startdt" size=12 value=<?php echo($today); ?>></td></tr>

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

</td></tr>


    <tr> 
    <td align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>List by</b></font></td></tr>
    <tr><td>&nbsp;</td><td align="left"> <input type="radio"    onKeyPress="return event.keyCode!=13"   name="order_type" value = "schedule_date"> <font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Schedule Date</b></font></td></tr>
 <tr><td>&nbsp;</td><td align="left"> <input type="radio"    onKeyPress="return event.keyCode!=13"   name="order_type" value = "order_date"> <font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Order Date</b></font></td></tr>
 <tr><td>&nbsp;</td><td align="left"><input type="radio"    onKeyPress="return event.keyCode!=13"   name="order_type" value = "inv_date"> <font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Invoice Date</b></font></td></tr>
 <tr><td>&nbsp;</td><td align="left"><input type="radio"    onKeyPress="return event.keyCode!=13"   name="order_type" value = "due_date"> <font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Due Date</td></tr>
  </tr> 

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

<center><font color="#000080"><font size="+1"><a href="../../index.html">Exit </a></font></center>

</body>
</form>
