<? 
session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
 return;
}

include("../opendb.php");
include("../test.php");
$result=mysqli_query($db,"select * from veh_invoice where invno='$invno' and taxtype='VAT' and brcode='$brcode'");
$row=mysqli_fetch_array($result);
if($row[tp]!='8b')
{
 print "<script> alert('Bill is not 8B'); </script>";
}

$re=mysqli_query($db,"select * from branch where brcode='$brcode'");
$brow=mysqli_fetch_array($re);
?>
<style>
td,body{font-family:arial;background-color:white;font-size:12}
</style>
<table width=100% BORDER=0>
<tr><td>TIN: <?print $brow[tin]?><BR>(TAX PAYERS IDENTIFICATION NO.)
<?
$brname=explode(',',$branch);
?>
</td><td align=right>CST Reg. No.:<?print $brow[cstno]?></td></tr>
<?if($brcode<>'PSN672')
{
?>
<tr><td align=center COLSPAN=2><span style={letter-spacing:5}><b><?print STRTOUPPER($brname[0])?></b> </span> <br>AUTHORISED DEALER FOR EICHER VEHICLES<BR>
Regd.Off. 35/189, NH 47, PALARIVATTOM, COCHIN, PIN.682 025<BR>
<?
}
else
{
?>
<tr><td align=center COLSPAN=2><span style={letter-spacing:5}><b><?print STRTOUPPER($brname[0])?></b> </span> <br>AUTHORISED DEALER FOR EICHER GENSET<BR>
<?
}
?>
<?Print $brow[braddr].'<br>'.$brow[brcity].',Phone:'.$brow[brphone]?>
</td></tr>

<!-- <tr><td align=center COLSPAN=2>FORM NO 8A</TD></TR> -->
<tr><td align=center COLSPAN=2><span style={letter-spacing:5}> 
<?
if($row[taxtype]=='VAT')

print "FORM ";
print $row[tp];
?>

</span></TD></TR>
<tr><td align=center COLSPAN=2><span style={letter-spacing:5}> 
<?
if($row[taxtype]=='VAT' && $row[tp]=='8b')
print "RETAIL - INVOICE - $row[taxtype]";
else
print "$row[taxtype] - INVOICE ";

?>

</TABLE>
<br>
<center>
<TABLE CELLSPACING=1 CELLPADDING=1 BGCOLOR=BLACK border=1>
<tr align=center><td>Invoice No <br>& Date</td><td>Delivery Note <br>No. & Date</td><td>Purchase Order <br>NO.&Date</td><td>Despatch<br>Doc.No. &Dt. </td><td>Terms of Delivery</td></tr>
<tr>
<?if($brcode<>'PSN672')
{
?>
<td align=center><b> <font size=3><?print $invno.'<br>'.datetohtml($row[invdate])?></td>
<?
}
else
{
?>
<td align=center><b> <font size=3>GEN <?print $invno.'<br>'.datetohtml($row[invdate])?></td>
<?
}?>

<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
</table>
</center>
<?
if($row[type]=='d')
{
$r=mysqli_query($db,"select * from sup_master where supname='$row[cust]' and branch='$brcode'");
$cus_row=mysqli_fetch_array($r);
$pan=$cus_row[web];
}
else
{
$r=mysqli_query($db,"select * from cust_master where code='$row[cust]' and branch='$brcode'");
$cus_row=mysqli_fetch_array($r);
$pan=$cus_row[kgst];

}
?>
<?
if($row[invdate]>='2016-01-01')
{

if($pan=='')
{
Print "<script>alert('Customer PAN Number is Mandatory');</script>";
return;
}
}
?>
<blockquote>
<? print $cus_row[1].'<br>'.str_replace(',','<br>',$cus_row[2]).'<br>'.$cus_row[3].''.$cus_row[4].' Pin:'.$cus_row[pin].'<br><br> PAN :' .$pan.'<br>'?>
<?
if($typ=='d' || $row[tp]!='8b')
print "Tin : ".$cus_row[tin];
?>
</blockquote>

Hypothicated to:
<blockquote>
<?
 $fff=mysqli_query($db,"select city from fin_master where finname='$row[fin]' and branch='$brcode'")or die(mysqli_error());
 $fi_row=mysqli_fetch_row($fff);
print $row[fin].','.$fi_row[0]?>
</blockquote>
<TABLE CELLSPACING=1 CELLPADDING=1 BGCOLOR=BLACK width=100% border=1>
<tr align=center><td>SL<br>No.</td><td>Description </td><td>ITem Code </td><td>Tax<br>Rate
<td>Unit Price </td><td>Qty</td><td>Gross Value</td><td>Cash<br>Disc</td><td>Net Value</td>
<td>Tax Amount</td>
<?if($brcode<>'PSN672')
{
?>
<td>Cess% </td><td>Cess Amt</td>
<?
}
?>
<td>Grand Total</td>
<?if($brcode<>'PSN672')
{
?>
<td>Discount<br>Gifts Free</td>
<?
}
?>
</tr>
<tr valign=top><td>1</td><td><?print $row[config]?></td><td>&nbsp;</td>
<td><?print $row[taxp].'%'?></td><td align=right><?print $row[unit]?></td><td align=right>1</td>
<td align=right><?print $row[netamt]?></td><td><?print $row[disc]?></td>
<td align=right><?print $row[amt2]?></td><td align=right><?print $row[tax]?></td>
<?if($brcode<>'PSN672')
{
?>
<td align=right><?print $row[cessp]?></td><td align=right><?print $row[cessamt]?></td>
<?
}
?>
<td align=right><?print $row[netamt]?></td>
<?if($brcode<>'PSN672')
{
?>
<td align=center>-<br><br><br>
<?
}
?>
</td></tr>
<tr><td>&nbsp;</td><td>T O T A L</TD><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
<td align=right><?print $row[netamt]?></td><td><?print $row[disc]?></td><td align=right><?print $row[amt2]?>
<td align=right><?print $row[tax]?></td>
<?if($brcode<>'PSN672')
{
?>
<td align=right><?print $row[cessp]?></td>
<td align=right><?print $row[cessamt]?></td>
<?
}
?>
<td align=right><font size=3><?print $row[netamt]?></td>
<?if($brcode<>'PSN672')
{
?>
<td align=center>- </td>
<?
}
?>
</tr>
</table>
<font size=3>(<?print word($row[netamt])?> only)</font>
<br><BR>
<table border=0 width=90%>
<tr><td width=115>EMLDA NO</TD><TD>: <font size=3><?print $row[da]?></td></tr>
<tr><td>ENGINE NO</TD><TD>:<font size=3> <?print $row[engno]?></td></tr>
<?if($brcode<>'PSN672' || $brcode == 'PSN705')
{
?>
<tr><td>CHASSIS NO</TD><TD>:<font size=3> <?print $row[chasis]?></td></tr>
<?
}
else
{
?>
<tr><td>ALTERNATOR NO</TD><TD>:<font size=3> <?print $row[chasis]?></td></tr>
<?
}
?>
<tr><td>COLOR</TD><TD>:<font size=3> <?print $row[color]?></td></tr>
<tr><td></td><td width=150>&nbsp;</td><td align=center> Goods once sold will not be taken back</td></tr>
<tr><td>E & OE</TD></TR>
</TABLE>
<P ALIGN=JUSTIFY>
<U>DECLARATION</U><BR>
<?

if($brcode=='AUT009')
{
?>
Certified that all the particulars shown in the above Tax Invoice are true and correct to all respects and the goods on which the tax charged and collected are in accordance with the provision of the KVAT ACT 2003 and the rules made there under.  It is also certified that my/our Registration under KVAT ACT 2003 is not subject to any suspension/cancellation and it is valid as on the date of this Bill.
<?
}
else
{
?>
Certified that all the particulars shown in the above Tax Invoice are true and correct to all respects and the goods on which the tax charged and collected are in accordance with the provision of the KVAT ACT 2003 and the rules made there under.  It is also certified that my/our Registration under KVAT Act 2003 is not subject to any suspension/cancellation and it is valid as on the date of this Bill.
<?
}
?>
</p>
Received the above genset in good condition.
<br><br><br>
<table width=100%>
<tr><td>Customer Signature</td><td width=500 align=right> For <?print $brname[0]?></td></tr>
<tr><td colspan=3 ALIGN=right><BR><BR><BR>Authorised Signatory</td></tr>
<tr><td colspan=3 align=center><b>PSN - 92 YEARS OF REPUTATION & TRUST</TD></TR>
</TABLE>
<BR>&nbsp;
