<body background="">

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

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

$myCompany = $_POST['Company'];

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

$myTax = $_POST['Tax'];


// Get all _POST VALUES HERE..
foreach($_POST as $q=>$r)
{
	$_POST[$q] = trim($r);
}
$myDate = $_POST['Date'];
?>

<title>Print INVOICE</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>INVOICE Print </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">


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


  <?php
$bankQuery=mysqli_query($conn,"select taxtype, description, tax from salestax order by description") or die(mysqli_error());
?>

    <td width="59" height="31" align="left" ><strong><font color="#003366" size="1" face="Verdana, Arial, Helvetica, sans-serif">Invoice Type</font></strong></td>
    <td><select name='Tax' onChange="javascript:submit();" >
      <?php
    echo "<option selected value=\" 0\"> Taxtype";
    while($row = mysqli_fetch_row($bankQuery))
    {
   	$temp = $row[1].'&nbsp;' .$row[2].'%';
	if(isset($myTax) && preg_match("/" . preg_quote($myTax", '/') . "/", $row[0]))
	{
		echo "<option selected value=\"$row[0]\">$temp";
	}
	else{
		echo "<option value=\"$row[0]\">$temp";
	}
 }
?>
    </select></td>
  
  </tr>

<?


// Pull all the data from Area master & populate it
$result = mysqli_query($conn,"select account_year from branches  ") or die(mysqli_error());
$row = mysqli_fetch_row($result);
$account_year = $row[0];




$result= mysqli_query($conn," select distinct poinv_date from purchasereg  where account_year='$account_year' and compcode = '$compcode' and taxtype = '$myTax' and prodcode ='TOTAL' order by poinv_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 ( $row1= mysqli_fetch_row($result))
      {
	  	$dts = substr($row1[0],8,2).'-'.substr($row1[0],5,2).'-'.substr($row1[0],0,4);
	  	if(isset($myDate) && preg_match("/" . preg_quote($myDate", '/') . "/", $row1[0]))
		{
			echo "<option selected value=\"$row1[0]\">$dts";
	  	}
	  	else
	  	{
			echo "<option value=\"$row1[0]\">$dts";
	  	}
	}
?>
</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 No 
  &nbsp;</b></font></td><td>
<?
// Pull all Customers from Customer  based on Selected Area id and populate it.
$sBuyQuery = mysqli_query($conn,"SELECT distinct poinv_no  FROM purchasereg WHERE (poinv_date ='$myDate') and compcode = '$compcode' and taxtype = '$myTax' and prodcode ='TOTAL'  order by poinv_no ");
// This form contain a hidden field AreaID which can be later used in next  page..
?>
<form name='myForm02' method='POST' action='tax_invoice.php' >

<input type="hidden" name="poinv_date" value=<? echo($myDate); ?> >
<input type="hidden" name="account_year" value= <? echo($account_year);?> >
<input type="hidden" name="taxtype" value= <?=$myTax?> >
<SELECT name=poinv_no >
<?

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>
<font size=1> 
<center><br><font size=1><center><a href= "index.html">Return to index page</a></center></font>
</center>
</font> 
                                                                             
</body></form>
