<body background="i.jpg">
<? include("../../include/dbconnect.php");


// Get all _POST VALUES HERE..

foreach($_POST as $q=>$r)
{
	$_POST[$q] = trim($r);
}

$myDate = $_POST['Date'];



// Get all _POST VALUES HERE..

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

$aresult = mysqli_query($conn,"select distinct account_year,name from company") or die(mysqli_error());
$arow = mysqli_fetch_row($aresult);
$account_year = $arow[0];

?>
<title>Trading Invoice Printing</title>
<body background="../../images/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>Trading Invoice  Printing</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">
<?
$result= mysqli_query($conn," select distinct compcode,name from company  order by name")or die( mysqli_error() );


?>
<form name='myform' method='POST' action='<?=$_SERVER['PHP_SELF']?>'>
    

  
  
<tr > 
    <td width="112" height="31" align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Company 
      Type &nbsp;</b></font></td>
    <td width="174">

  <SELECT name='Company' onChange="javascript:submit();">
<?php 
	// echo "<option selected value=\" 0\"> Select Company";	  
      while ( $row1= mysqli_fetch_row($result))
      {
	  	if(isset($myCompany) && preg_match("/" . preg_quote($myCompany", '/') . "/", $row1[0]))
		{
			echo "<option selected value=\"$row1[0]\">$row1[1]";
	  	}
	  	else
	  	{
			echo "<option value=\"$row1[0]\">$row1[1]";
	  	}
	}
?>
</select>  
</td>
</tr>
<?

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

$result= mysqli_query($conn," select distinct invdate from trading where account_year = '$account_year'   order by invdate desc")or die( mysqli_error() );


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

  <SELECT name='Date' onChange="javascript:submit();">
<?php 
	 echo "<option selected value=\" 0\"> Select Date";	  
      while ( $row1= mysqli_fetch_row($result))
      {
	  	$tmp = british($row1[0]);
	  	if(isset($myDate) && preg_match("/" . preg_quote($myDate", '/') . "/", $row1[0]))
		{
			echo "<option selected value=\"$row1[0]\">$tmp";
	  	}
	  	else
	  	{
			echo "<option value=\"$row1[0]\">$tmp";
	  	}
	}
?>
</select>  
</td></tr>
  
  
  
  
  
</form><tr >
<td width="139" height="31" align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>Trading Invoice Nos 
  &nbsp;</b></font></td><td>
<?

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


$sBuyQuery = mysqli_query($conn,"SELECT distinct invno FROM trading WHERE (invdate ='$myDate') and compcode = '$myCompany'  order by compcode,invno ");


// This form contain a hidden field AreaID which can be later used in next  page..
?>
<form name='myForm02' method='POST' action='invoice.php' >

<input type="hidden" name="compcode" value=<?echo($myCompany);?>>
<input type="hidden" name="account_year" value=<?echo($account_year);?>>

<SELECT name=invnos[] multiple size="5"  >
<?
while($row1 = mysqli_fetch_row($sBuyQuery))
{
	$temp = $row1[0].'&nbsp;&nbsp;'.$row1[1];
	$ino=$row1[0];
	echo "<option value=\"$ino\">$temp";
}

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




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

<br>
 
