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

<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<title>The KVAT Rules, 2005 Form No</title></head>
<body bgcolor="#FFFFFF" class="Normall" lang=EN-US>
<?





$aresult = mysqli_query($conn,"select distinct account_year,cenvat_regno,service_tax_no from branches") or die(mysqli_error());
$arow = mysqli_fetch_row($aresult);
$account_year = $arow[0];
$cenvat = $arow[1];
$servicetax = $arow[2];


	
	$result = mysqli_query($conn,"select distinct inv_date, form20 ,pur_no,pur_date,desp_no ,vehicle_no,schedule,value,vat_percent,vat_amount,taxtype,vatcess_amt,packing,total ,payterms,bcode from salesreg where compcode ='$compcode' and inv_no ='$inv_no' and prodcode ='Total'  and account_year ='$account_year' ") or die(mysqli_error());
	$row = mysqli_fetch_row($result);
	$form20=$row[1];
	$date = substr($row[0],8,2).'-'.substr($row[0],5,2).'-'.substr($row[0],0,4);
	$pur_no=$row[2];
	$pur_date= substr($row[3],8,2).'-'.substr($row[3],5,2).'-'.substr($row[3],0,4);
	$desp_no=$row[4];
	$vehicle_no=$row[5];
	$schedule = $row[6];
	$netvalue = $row[7];
	$tax_rate = $row[8];
	$taxamt =$row[9];
	$cess = $row[10];
	$cess_amt= $row[11];
	$packing =$row[12];
	$total = $row[13];
	$addon_term = $row[14];

	
	$result = mysqli_query($conn,"select  name,address1,address2,city,state,pin,cst,tin,telno,email from company where compcode ='$compcode' ") or die(mysqli_error());
	$row=mysqli_fetch_row($result);
	$name=$row[0];
	$address = $row[1].',&nbsp;'.$row[2].',&nbsp;'.$row[3].'-&nbsp;'.$row[5].',&nbsp;'.$row[4];
		$ad = $row[1].','.$row[2].','.$row[3].',-'.$row[5].'. Tel No: '.$row[8];	
	$tin=$row[7];
	$cst=$row[6];
	$city=$row[3];	
    $tel_no = $row[8];
	$email=$row[9];
	
	$result = mysqli_query($conn,"select  distinct bcode  from salesreg where inv_no='$inv_no' and compcode ='$compcode'  and account_year ='$account_year' ") or die(mysqli_error());
	$row=mysqli_fetch_row($result);
	$bcode =$row[0];
	if($bcode != '0')
	{
		$result = mysqli_query($conn,"select  name,address1,address2,city,state,pin,cst,tin,std,telno from buy where bcode ='$bcode' ") or die(mysqli_error());
		$row=mysqli_fetch_row($result);
		$bname=$row[0];
			$bcity=$row[3];
		$baddress = $row[1].',&nbsp;'.$row[2];
		$baddress1 = $row[3].',&nbsp;'.$row[4].',&nbsp;'.$row[5];
		$btin='CST:&nbsp;'.$row[6].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TIN:&nbsp;'.$row[7];
		$btel_no = $row[8].'&nbsp;-&nbsp;'.$row[9];
	}
	else
	{
		$result = mysqli_query($conn,"select  name,address1,address2,city,state,pin,phone from bill_patient where inv_no='$inv_no'   and account_year ='$account_year' ") or die(mysqli_error());
		$row=mysqli_fetch_row($result);
		$bname=$row[0];
			$bcity=$row[3];
		if($row[1] != '')
		{
			$baddress = $row[1];
		}
		if($row[2] != '')
		{
			$baddress = $baddress.',&nbsp;'.$row[2];
		}

		if($row[3] != '')
		{
			$baddress1 = $baddress1.',&nbsp;'.$row[3];
		}
		
		if($row[4] != '')
		{
			$baddress1 = $baddress1.',&nbsp;'.$row[4];
		}
		if($row[5] != '')
		{
			$baddress1 = $baddress1.',&nbsp;'.$row[5];
		}
		$btel_no = $row[6];

	}	
	

	
		

?>
<table>

<tr><td width="893">


  <br>

   <table width="894" border=0 cellpadding=0 cellspacing=0 class=MsoTableGrid>
  <tr><td width="9"></td><td width="850" align="center"><font size="+3" face="Arial, Helvetica, sans-serif"><? echo($name);?></font></td></tr>

	    <tr><td width="9" height="21"></td><td width="850" align="center"><font  face="Arial, Helvetica, sans-serif"><? echo($address);?></font></td></tr>
		    <tr><td width="9" height="21"></td><td width="850" align="center"><font  face="Arial, Helvetica, sans-serif">Phone : &nbsp;<? echo($tel_no);?>&nbsp;&nbsp;Mail:&nbsp;<?=$email?>,&nbsp;&nbsp;Web:www.classicbelts.com</font></td></tr>
  
    <tr>
    <td width="246" height="21" align="center" colspan="100%"><font  face="Arial, Helvetica, sans-serif"><b>TIN:&nbsp;<? echo($tin);?>&nbsp;&nbsp;CST:&nbsp;<?=$cst?></b></font></td></tr>
    <tr>
    <td width="246" height="27" align="center" colspan="100%"><font  face="Arial, Helvetica, sans-serif">Excise details: Range: Palakkad,Division II B Palakkad II, Commissionerate: Kozhikkode</font></td></tr>
        <tr>
    <td width="246" height="25" align="center" colspan="100%"><font  face="Arial, Helvetica, sans-serif"><b>CENVAT No:<?=$cenvat?>&nbsp;&nbsp;Service Tax Reg No:&nbsp;<?=$servicetax?></b></font></td></tr>
</table>
   <table width="896" border=1 cellpadding=0 cellspacing=0 class=MsoTableGrid rules="cols">
 <tr>
 <td  colspan="100%" align="center"><font  face="Arial, Helvetica, sans-serif" >The KVAT Rules, 2005 Form No.8 For VAT dealers other than Manufacturers [See Rule 58(10)]</font></td>
 </tr>
 <tr><td colspan="100%"> <p align=center style='text-align:center'><b><font  face="Arial, Helvetica, sans-serif">Tax Invoice-Cash/Credit</font></b></p></td></tr>
</table>

<table width="896" border="1" rules="cols">

    <tr>       <td  valign=top class="Normall" ><font  face="Arial, Helvetica, sans-serif">
	  Name &amp; Address of Dealer / Buyer&nbsp;<br/><b>M/s.&nbsp; <? echo($bname);?></b></font></td>
      <td width="419"   align="left" valign=center class="Normall"><div align="right"><font  face="Arial, Helvetica, sans-serif"> <b>Invoice
        No. &nbsp; <? echo($inv_no);?></b></font></div></td></tr>
		  <tr>
		        <td width="461"  valign=center class="Normall" ><font  face="Arial, Helvetica, sans-serif"><? echo($baddress);?></br>
	            <?=$baddress1?></font></td>
      <td width=419  align="right" class="Normall"><div align="right"><font  face="Arial, Helvetica, sans-serif"> <b> Date : &nbsp;<? echo($date);?></b></font></div></td>
    </tr>
	     <tr> 
      <td width=461 valign=top class="Normall"><font  face="Arial, Helvetica, sans-serif">Phone &nbsp; <? echo($btel_no);?></font></td>
      <td></td></tr>
	  <tr><td width=461 valign=top class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo($btin);?></font></td>
	  </tr>
	</table>



   <table width="866" border=0 cellpadding=0 cellspacing=0 class=MsoTableGrid>
    <tr> 
</tr>
      <tr> 
</tr>

	  </table>
  <table width="896" border=1 cellpadding=0 cellspacing=0  rules = "cols" class=MsoTableGrid>
    <tr> 
      <td width=42 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif" > <span class=SpellE>Sl.No.</font></td>
      <td width=84 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif">Commodity Code</font></td>	  
      <td width=314 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif"> Description of Goods</font></td>

      <td width=56 valign=top class="Normall"  align="center"><div align="center"><font  face="Arial, Helvetica, sans-serif"> Rate </font></div></td>


      <td width=56 valign=top class="Normall"  align="center"><div align="right"><font  face="Arial, Helvetica, sans-serif"> Quantity</font></div></td>
          <td width=49 valign=top class="Normall"  align="center"><div align="center"><font  face="Arial, Helvetica, sans-serif">Unit</font></div></td>
      <td width=63 valign=top class="Normall"  align="center"><div align="right"><font  face="Arial, Helvetica, sans-serif"> Value</font></div></td>			
      <td width=47 valign=top class="Normall"  align="center"><div align="right"><font  face="Arial, Helvetica, sans-serif"> Tax % </font></div></td>
          <td width=57 valign=top class="Normall"  align="center"><div align="right"><font  face="Arial, Helvetica, sans-serif"> Tax Amount </font></div></td>
      <td width=63 valign=top class="Normall" align="center"><div align="right"><font  face="Arial, Helvetica, sans-serif"> Gross Value</font></div></td>
    </tr>

	<tr>

	<td><hr/></td>
	<td><hr/></td>
	<td><hr/></td>
	<td><hr/></td>
	<td><hr/></td>
	<td><hr align="center"/></td>
	<td><hr/></td>
		<td><hr/></td>
	<td><hr/></td>
<td><hr/></td>
	</tr>
	
	<?
	
	

//$total =0;
$sl = 1;

	
	$x=1;
	
	$valuetot =0;
	$vattot =0;
	$grosstot = 0;
	$distot = 0;
$myresult = mysqli_query($conn,"select distinct prodcode,quantity,rate,value,discount,discount_amt ,vat_percent,vat_amount,specification from salesreg where account_year='$account_year' and inv_no = '$inv_no'  and quantity > 0  and compcode = '$compcode' ") or die(mysqli_error());
while($myrow = mysqli_fetch_row($myresult))
{
	$prodcode = $myrow[0];
	$qty = $myrow[1];
	$rate = $myrow[2];
	$value = $myrow[3];
	$discount = $myrow[4];
	//$discount_amount = $myrow[5];
	$vat_percent = $myrow[6];
	$vatamt = $myrow[7];
	$specification = $myrow[8];
	$amount = round($value - $discount_amount + $vatamt,2);
	//$distot = $distot + $discount_amount;

	$presult = mysqli_query($conn,"select prodname,schedule,packing from product where prodcode = '$prodcode' ") or die(mysqli_error());
	$prow = mysqli_fetch_row($presult);
	$product= $prow[0];
	if($specification != '')
	{
		$product = $product.'('.$specification.')';
	}
	$schedule = $prow[1];
	$unit  = $prow[2];
	$vattot = $vattot + $vatamt;
	$valuetot = $valuetot + ($value - $discount_amount);
	$grosstot = $grosstot + $amount;
	
	$pn1 = substr($product,0,24);
	$pn2 = substr($product,24,24);
	if($discount >0)
	{
		$di = round($discount,0).'%';
	}
	else
	{
		$di = '   ';
	}
	$sl++;	


		?>
	   <tr height="30"> 
      <td width=42 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif"><? echo($x);?>  </font></td>
	        <td width=84 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif" ><? echo($schedule);?>   </font></td>
      <td width=314 valign=top class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo($product);?>   </font></td>


      <td width=56 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($rate,2));?>  </font></td>
	  
      <td width=56 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo($qty);?>  </font></td>
      <td width=49 valign=top align="right" class="Normall"><div align="center"><font  face="Arial, Helvetica, sans-serif"><? echo($unit);?>  </font></div></td>	  
      <td width=63 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($value,2,'.',''));?>  </font></td>
      <td width=47 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo($vat_percent);?>  </font></td>	  
	        <td width=57 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo($vatamt);?>  </font></td>
      <td width=63 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($amount,2));?>  </font></td>	  				  	  
      </tr>
  	  <?
	  $x++;
	}
	while($x < 15)
	{
	?>
	   <tr> 
      <td width=42 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif">&nbsp; </font></td>
      <td width=84 valign=top class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp;  </font></td>
      <td width=314 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif" >&nbsp;  </font></td>

      <td width=41 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp;  </font></td>
      <td width=56 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp;  </font></td>
      <td width=49 valign=top class="Normall"><div align="center"><font  face="Arial, Helvetica, sans-serif">  </font></div></td>
      <td width=63 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif" >&nbsp;  </font></td>

      <td width=47 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp; </font></td>
      <td width=57 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp;  </font></td>
      <td width=63 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp;  </font></td>	  
      </tr>	
	<?
	$x++;
	}
	
	$myresult = mysqli_query($conn,"select packing from salesreg where account_year='$account_year' and inv_no = '$inv_no'  and prodcode = 'TOTAL' and compcode = '$compcode' ") or die(mysqli_error());
	$myrow = mysqli_fetch_row($myresult);
	$packing = $myrow[0];
	$total = $myrow[0] +$grosstot;
	

$nt = round($total,0);
$diff = $nt - $total;




	


	?>
	
	
	<tr>
	<td><hr/></td>
	<td><hr/></td>
	<td><hr/></td>
	<td><hr/></td>
	<td><hr/></td>
	<td><hr/></td>
	<td><hr align="center"/></td>
	<td><hr/></td>
		<td><hr/></td>
	<td><hr/></td>

	</tr>
	
	   <tr> 
      <td valign=top class="Normall" align="center" colspan="4"><font  face="Arial, Helvetica, sans-serif"> Total</font></td>

	  
      <td width=56 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"> </font></td>
      <td width=49 valign=top align="right" class="Normall"><div align="center"><font  face="Arial, Helvetica, sans-serif"></font></div></td>	  
      <td width=63 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($valuetot,2));?>  </font></td>
      <td width=47 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif">  </font></td>	  
	        <td width=57 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($vattot,2));?>  </font></td>
      <td width=63 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($grosstot,2));?>  </font></td>	  				  	  
      </tr>
	

	</table>
	
	
	<table width="896" border="1" >
	<?
	if($packing > 0)
	{
	?>
	<tr>

	<td valign=top  class="Normall" colspan="3" align="right"><font  face="Arial, Helvetica, sans-serif"> Packing and Forwarding Charges </font></td>
	<td width="172"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo($packing);?></font></div></td>
	</tr>
	<?
	}
	$bamt =  $total ;
	$billamt = round($bamt);
	$diff = $billamt- $bamt;	
?>
	
	<tr>

	<td valign=top  class="Normall" colspan="3" align="right"><font  face="Arial, Helvetica, sans-serif"> Round off</font></td>
	<td width="172"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo(round($diff,2));?></font></div></td>
	</tr>

	
	
	<tr>
	<td valign=top  class="Normall" colspan="2"><font  face="Arial, Helvetica, sans-serif">E&amp;OE</font></td>
	    

	<td width=193 valign=top  class="Normall"><div align="right"><font  face="Arial, Helvetica, sans-serif"><b>Grand Total </b> Rs.</font></div></td>
	<td width="172"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><b><? echo(number_format($billamt,2,'.',''));?></b></font></div></td>
	</tr>
	<?
	if($distot >0)
	{
	?>
		<tr>

	<td valign=top  class="Normall" colspan="3" align="right"><font  face="Arial, Helvetica, sans-serif"> Total Discount </font></td>
	<td width="172"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo(round($distot,2));?></font></div></td>
	</tr>
	<?
	}
	?>	
	<tr>
	<td valign=top  class="Normall" align="left" colspan="100%"><font  face="Arial, Helvetica, sans-serif"><b>&nbsp;&nbsp;Rupees &nbsp;<? echo(connum($billamt));?>&nbsp;only.</b></font></td>
	</tr>
	
	<tr>
	<td valign=top  class="Normall" colspan="2"><font  face="Arial, Helvetica, sans-serif">Order Ref No:<?=$pur_no?></font></td>
	    

	<td width=193 valign=top  class="Normall"><font  face="Arial, Helvetica, sans-serif">Documents through :<?=$form20?></font></td>
	<td width="172"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif">Mode of Transport:<?=$vehicle_no?></font></div></td>
	</tr>    
    
	<tr><td width="507" align="justify"><font  face="Arial, Helvetica, sans-serif">
	DECLARATION: ( To be furnished by the seller)  Certified that all the particulars shown in the above Tax Invoice are true and correct in all respect and the goods on which the tax charged and collected are in accordance with the  provisions of the KVAT ACT, 2003 and the rules  made .  It is also certified that my/our Registration under KVAT ACT 2003 is not subject to any  suspension/cancellation and it is valid on the date of this Bill.
	</font></td>
	   
	
	<td  align="center" colspan="3"><p><font  face="Arial, Helvetica, sans-serif">for 
	  <?=$name?></font>
	</p>
	  <p>&nbsp;</p>
	  <p><strong><font  face="Arial, Helvetica, sans-serif">Authorised Signatory</font> </strong></p></td>
	</tr>
	
	
	    </table>
	
	
	                                                                                            
	<table class=MsoTableGrid border=0 cellspacing=0 cellpadding=0><tr>
	  <td  colspan="100%" align="justify"><p>1.Products are despatched after our usual careful checking of the consignment in respect of contents and packing. Our responsibility ceases once the goods leave our Factory premises.
	    <br/>2.Goods once sold will not be taken back
	    <br/>3. Interest @24% per annum will be charged if not paid by due date from date of this bill.
	    <br/>4.All disputes are subjected to 
	      <?=$city?>
Jurisdiction only
	    <br/>5. No acknowledgement of payments is valid unless granded on the companies official receipt form</p></td>
	</tr>                                                      
	          <tr><td>&nbsp;</td></tr>                                                                      
	 </table>

</td></tr></table>

</body>
</html>

