<body background="../../images/vinod.JPG">
<?php include("../../include/dbconnect.php");


// Get all _POST VALUES HERE..

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

$myCompany = $_POST['Company'];

foreach($_POST as $h=>$i)
{
	$_POST[$h] = trim($i);
}
$myDate = $_POST['Date'];

$aresult = mysqli_query($conn,"select distinct account_year from branches") or die(mysqli_error());
$arow = mysqli_fetch_row($aresult);
$account_year = $arow[0];
?>
<title>Invoice Printing</title>
<body background="../../images/vinod.JPG">  
<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>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">
<?

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

$result= mysqli_query($conn," select distinct compcode,name from company  order by name")or die( mysqli_error() );


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

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

  <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[0]";
	  	}
	  	else
	  	{
			echo "<option value=\"$row1[0]\">$row1[0]";
	  	}
	}
?>
</select>  
</td></tr>  
<?
$result2= mysqli_query($conn," select distinct inv_date from salesreg8b where compcode = '$myCompany'  and account_year ='$account_year' order by inv_date 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 ( $row2= mysqli_fetch_row($result2))
      {
	  	$temp = british($row2[0]);
	  	if(isset($myDate) && preg_match("/" . preg_quote($myDate, '/') . "/", $row2[0]))
		{
			echo "<option selected value=\"$row2[0]\">$temp";
	  	}
	  	else
	  	{
			echo "<option value=\"$row2[0]\">$temp";
	  	}
	}
?>
</select>  
</td></tr>
  
  
  
  
  
</form><tr >
<td width="139" height="31" align="right" ><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>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 inv_no,bcode FROM salesreg8b WHERE (inv_date ='$myDate') and compcode = '$myCompany'  order by compcode,inv_no ") or die(mysqli_error());


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

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

<SELECT name=inv_no  >
<?
while($row1 = mysqli_fetch_row($sBuyQuery))
{
	$bresult = mysqli_query($conn,"select name from buy where bcode = '$row1[1]'") or die(mysqli_error());
	$brow = mysqli_fetch_row($bresult);
	$temp = $row1[0].'&nbsp;&nbsp;'.$brow[0];
	$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>
<font size=1> 
<center><a href="index.html">
  Return to Index page 
</center>
</font> 
