<?php include("../../include/dbconnect.php");


// Get all _POST VALUES HERE..

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

  $myDate = $_POST['Date'];
?>

<title>Invoiced Items View / Edit</title>
<body background=blater01.gif  topmargin=0>
<center>
<table cellpadding=0 cellspacing=4 width=790>
<tr>
<td style="padding:3px;" colspan=2 bgcolor="#93BEE2"><font face="Verdana, Arial, Helvetica, sans-serif"><b><b>Invoiced Items View / Edit</b></font></td>
</tr><tr valign="top"><td colspan=2>
<font >&nbsp;</font>
</td>
</tr>
</table>
<table border=0 cellpadding=3 cellspacing=4 width="970">
       

      <tr > 
        <td width="139" height="31" align="right" ><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#003366">Date of Indent
          &nbsp;</font></b></font></td><td>

<?

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

$stQuery = mysql_query("select distinct invdate  from salesreg order by invdate");

?>
  <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 = substr($row[0],8,2).'-'.substr($row[0],5,2).'-'.substr($row[0],0,4);
        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>
<form name='myForm02' method='POST'  >
  <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>Schedules
  &nbsp;</b></font></td></tr>
<?

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

//$result =mysql_query("select salesreg.record,invno,invdate,salesreg.compcode,product.prodname,product.drawing_no,buy.name,quantity,rate,value,packing_percent,packing_amt,bed,bed_amt,cess,cess_amt,vat_percent,vat_amount,freight,total,round_off,gtotal,invstatus,po_no,po_date,schedule_no,schedule_date,month,year,salesreg.taxtype,duty_posted,prepare_time,remove_time,account_year from salesreg,product,buy where (product.prodcode = salesreg.prodcode and product.bcode= salesreg.bcode) and salesreg.bcode = buy.bcode or salesreg.drawing_no='TOTAL' and salesreg.invdate = '$myDate' ") or die(mysql_error());
$result =mysql_query("select distinct salesreg.record,invno,invdate,salesreg.compcode,buy.name,salesreg.drawing_no,quantity,rate,value,packing_percent,packing_amt,taxcode, sgst_amt, cgst_amt, igst_amt, vat_percent, vat_amount,freight,total,round_off,gtotal,invstatus,po_no,po_date,schedule_no,schedule_date,month,year,salesreg.taxtype,duty_posted,prepare_time,remove_time,account_year from salesreg,buy,product where  buy.bcode= salesreg.bcode and salesreg.invdate = '$myDate'   group by salesreg.record") 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>
