<?php include("../../include/dbconnect.php"); 
// Get all _POST VALUES HERE..

  foreach($_POST as $p=>$t)
  {
     $_POST[$p] = trim($t);
  }

  $myDate = $_POST['Date'];
  
  ?>
<body background=blater01.gif  topmargin=0>
<center>
<h2><b>View / Edit Prepared PO </h2></b>

<?php

// Pull all the data from Date master & populate it

$stQuery = mysql_query("select distinct po_date from matpo  order by po_date desc");

?>
  <form name='myForm01' method='POST' action='<?=$_SERVER[PHP_SELF]?>'>
  <SELECT name='Date' onChange="javascript:submit();">

<?
     echo "<option selected value=\" 0\"> Select Date";
    while($row = mysql_fetch_row($stQuery))
    {

		$temp = british($row[0]);
        if(isset($myDate) && eregi("$myDate",$row[0]))
	    {
            echo "<option selected value=\"$row[0]\">$temp";
        }
        else{
            echo "<option value=\"$row[0]\">$temp";
        }
    }
?>
        </SELECT>
</td></tr>
</form>
<?

    $sBuyQuery = mysql_query("SELECT distinct matpo.record,matpo.compcode,matpo.print_status,matpo.reference,matpo.po_no,matpo.po_date,supplier.name,rawmaterial.prodname,matpo.specifications,matpo.qty,matpo.rate,matpo.unit,matpo.delivery_date,matpo.sales_tax,matpo.excise_duty,matpo.documents,matpo.pay_terms,matpo.desp_mode,matpo.despatch_from,matpo.received_qty,matpo.rejected_qty,matpo.received_date,matpo.remarks,matpo.account_year FROM matpo,supplier,rawmaterial WHERE (po_date ='$myDate') and matpo.bcode=supplier.bcode and matpo.prodcode=rawmaterial.prodcode  order by po_date,po_no ") or die(mysql_error());


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

  <form name='myForm02' >
<?



$number_cols=mysql_num_fields($sBuyQuery);
echo "<table border=1> \n";
echo "<tr align=center> \n";
for($i=0;$i<$number_cols;$i++)
{
echo "<th>" . mysql_field_name($sBuyQuery,$i).   "</th>\n";
}
echo "<tr>\n";

//layout table


while($row = mysql_fetch_row($sBuyQuery))
{
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>";

?>



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

