<?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>Orders View</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>View and Edit Labour 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))
{
	
	$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>
<?
$result = mysql_query("SELECT distinct product.prodcode,product.prodname,product.drawing_no FROM product WHERE   product.bcode= '$myCustomer' order by prodname,drawing_no ") or die(mysql_error());
 ?> 
  
<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='Product' onChange="javascript:submit();">
<?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>
</table>
  
  
  
  
  
</form>
  <table class=MsoTableGrid border=0 cellspacing=0 cellpadding=0>
<tr >
<td width="139" height="31" align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Labour Orders - Edit View
  &nbsp;</b></font></td></tr>
<?

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


$result = mysql_query("SELECT distinct orders.record,product.prodname,orders.drawing_no,order_no,order_date,schedule_no,schedule_date,due_date,order_qty,schedule_qty,issued_qty,balance_qty,rate,plan_type,part_qty1,due_date1,part_qty2,due_date2,part_qty3,due_date3,part_qty4,due_date4,part_qty5,due_date5,inv_nos,inv_date,app_qty,app_status,rejected_qty,min_no,return_date,remarks FROM orders,product WHERE (orders.bcode ='$myCustomer') and  orders.prodcode= '$myProduct' and (orders.prodcode=product.prodcode and product.bcode = '$myCustomer') and plan_type='Labour' group by orders.record order by schedule_no,schedule_date ") or die(mysql_error());



$number_cols=mysql_num_fields($result);
echo "<table border=1> \n";
echo "<tr align=center> \n";
for($i=0;$i<$number_cols;$i++)
{


echo "<th>" . mysql_field_name($result,$i).   "</th>\n";
}
echo "<tr>\n";

//layout table

while($row = mysql_fetch_row($result))
{
echo "<tr align=left> \n";
echo "<td>";
if(!isset($row[0])) //test for null value
{
echo "NULL";
}
else
{
?>
<a href = "editview.php?record=<?echo($row[0]);?>"><?echo($row[0]);?></a>
<?

}

for($i=1;$i<$number_cols;$i++)
{
echo "<td>";
if(!isset($row[$i])) //test for null value
{
echo "NULL";
}
else
{
echo $row[$i];
}
echo "</td>\n";
}
echo "</tr> \n";
}
echo"</table>";

?>
<input type="hidden" name="fname" value="<?echo $filename;?>">
<form><br><br><font size=1><center><a href= "index.html">Return to index page</center></font>
                                                                             
</body>
