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

?>
<style>

@font-face {
    font-family: 'Calligrapher';
    src: url('/wilson/prgent/invoice/Calligrapher%20font.ttf') format('truetype');
}

table, th {
    border: 1px solid black;
}
</style>
 
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<title>wilson Invoice</title>

</head>
<body bgcolor="#FFFFFF" class="Normall" lang=EN-US>
<?



		$sno=1;
		$invresult = mysql_query("select  distinct bcode,prodcode,prepare_time,invdate from salesreg where account_year='$account_year1' and invno = '$invno' and compcode = '$compcode'  ") or die(mysql_error());			
		$row=mysql_fetch_row($invresult);
		

		$bcode = $row[0];
		$prodcode = $row[1]; 
		$date = substr($tdate,8,2).'-'.substr($tdate,5,2).'-'.substr($tdate,0,4);
		$date = british($row[3]);
		$prepare_time= $date.'/'.$row[2];
		
		$open_result = mysql_query("select  order_record from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no != 'TOTAL' and compcode = '$compcode' order by po_no ") or die(mysql_error());		
		$open_row = mysql_fetch_row($open_result);
		$open_record = $open_row[0];
		
		$open_result = mysql_query("select open_order from orders where record = '$open_record' ") or die(mysql_error());
		$open_row = mysql_fetch_row($open_result);
		$open_order = $open_row[0];
		

		$temp_order='';
		$orderno='';
		$schedule_no='';
		$poresult = mysql_query("select  po_no,po_date,schedule_no,schedule_date from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no != 'TOTAL' and compcode = '$compcode' order by po_no ") or die(mysql_error());
		while($porow =mysql_fetch_row($poresult))
		{

					$po_date = substr($porow[1],8,2).'-'.substr($porow[1],5,2).'-'.substr($porow[1],0,4);
					$schedule_date = substr($porow[3],8,2).'-'.substr($porow[3],5,2).'-'.substr($porow[3],0,4);
					//if($temp_order == '')
					//{
						if($porow[0] !='')
						{
							if($open_order == 'No')
							{
								$orderno = $orderno.$porow[0].'/'.$po_date.',';
							}
							else
							{
								$orderno = $porow[0].'/'.$po_date.',';
							}
						}
						//$temp_order = $porow[0];					
					//}
					     if($porow[2] !='')
					     {		
   					     $schedule_no = $schedule_no.$porow[2].'/'.$schedule_date.',';
					     }
		}
		
	$orderno = substr_replace($orderno, '', strlen($orderno)-1,1);	
	$result = mysql_query("select  name,address1,address2,city,state,pin,cst,tin,telno,email from company where compcode ='$compcode' ") or die(mysql_error());
	$row=mysql_fetch_row($result);
	$name=$row[0];
	$address = $row[1].',&nbsp;'.$row[2].',<br>'.$row[3].'-&nbsp;'.$row[5].',&nbsp;'.$row[4];
	$tin=$row[7];
	$cst=$row[6];
	$city=$row[3];	
    $tel_no = $row[8].'&nbsp;Mail:&nbsp;'.$row[9];
	//$email=$row[9];
	$vendercode=$row[10];
				

		$totline=0;
if($head == 'Yes')
{		
?>		
		
<table>
    <tr>
    <td width="246" height="21" align="right" colspan="100%"><font  face="Arial, Helvetica, sans-serif" size="-1"><b>Original for Buyer</b></font></td></tr>
<tr>
  <td width="900" height="634">

   <table width="900" border=0 cellpadding=0 cellspacing=0 class=MsoTableGrid>
  <tr>
    <td width="127" rowspan="4">       <img src="../../images/logo.jpg" width="84" height="82" align="right"></td>
     
    <td width="651" align="center"><div align="center"><font style="font-family: Calligrapher;" size="+3"><? echo($name);?></font></div></td>
    <td width="116" align="center">&nbsp;</td>
    </tr>

	    <tr>
	      <td width="651" align="center"><div align="center"><font  face="Arial, Helvetica, sans-serif"><? echo($address);?></font></div></td>
	      <td width="116" height="21" align="center">&nbsp;</td>
        </tr>
		    <tr>
		      <td width="651" align="center"><div align="center"><font  face="Arial, Helvetica, sans-serif">Phone : &nbsp;<? echo($tel_no);?></td>
		      <td width="116" height="21" align="center">&nbsp;</td>
	        </tr>

		    <tr>
		      <td width="651" align="center"><div align="center"><font  face="Arial, Helvetica, sans-serif"><b>GST No: : &nbsp;<? echo($tin);?>&nbsp;&nbsp;STATE CODE : 33<br>MSME Regn. No : &nbsp;UDYAM-TN-03-0140740</b></font></div></td>
		      <td width="116" height="21" align="center">&nbsp;</td>
	        </tr>

</table>
   <table width="900" border=0 >



  <tr>
    <td  align="center"><font  face="Arial, Helvetica, sans-serif">
      <h3>TAX INVOICE </h3>
    </font></td>
    <td align="center">&nbsp;</td>
    </tr>
  </table>
 
  	<?	
	}
else
{
	?>
<br><br><br><br>
	<?
}
		$result = mysql_query("select  name,address1,address2,city,state,pin,cst,gstin,std,telno,eccno,state_code,vendercode from buy where bcode ='$bcode' ") or die(mysql_error());
		$row=mysql_fetch_row($result);
		$bname=$row[0];
			$bcity=$row[3];
		$baddress = $row[1].',&nbsp;'.$row[2].'<br>'.$row[3].',&nbsp;'.$row[4].',&nbsp;'.$row[5];
//$baddress = $row[1].',&nbsp;'.$row[2];
		
		if($vendercode !='')
		{
			$baddress = $baddress.'Vendercode:'.$row[12];
		}
		$btin='GST No::&nbsp;'.$row[7].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>STATE CODE:&nbsp;'.$row[11];
		$btel_no = $row[8].'&nbsp;-&nbsp;'.$row[9];

		
?>
<table width="900"  border="0" rules="cols">
    <tr>       <td  valign=top class="Normall" ><font  face="Arial, Helvetica, sans-serif">
	  Name &amp; Address of  Buyer&nbsp;<br/><b>M/s.&nbsp; <? echo($bname);?></b></font></td>
      <td width="225" rowspan="2"   align="right" valign=top class="Normall"><div align="left"><strong><font  face="Arial, Helvetica, sans-serif"> Order No:
        <?=$orderno?>
      </font></strong></div></td>
      <td width="246"   align="left" valign=top class="Normall"><div align="left"><font  face="Arial, Helvetica, sans-serif"> <b>Invoice
        No. &nbsp; <? echo($invno.'/'.$account_year);?></b></font></div></td></tr>
		  <tr>
		        <td width="403"  valign=top class="Normall" ><font  face="Arial, Helvetica, sans-serif">&nbsp;<? echo($baddress);?></font></td>
            <td width=246  align="right" class="Normall"><div align="left"><font  face="Arial, Helvetica, sans-serif"> <b> Date : &nbsp;<? echo($date);?></b></font></div></td>
    </tr>
	     <tr> 
      <td width=403 valign=top class="Normall"><font  face="Arial, Helvetica, sans-serif"></font></td>
      <td width="225" rowspan="2" align="right"><div align="left"><strong><font  face="Arial, Helvetica, sans-serif">Schedule No:&nbsp;
        <?=$schedule_no.'/'.$schedule_date?>
      </font></strong></div></td>
      <td align="right"><strong>
        <div align="left"><font  face="Arial, Helvetica, sans-serif">Prepare Date and Time:
          <?=$prepare_time?>
        </font></div></td></tr>
	  <tr><td width=403 valign=top class="Normall"><font  face="Arial, Helvetica, sans-serif"><b><? echo($btin);?></b></font></td>
	    <td width=246 valign=top class="Normall" align="right"><div align="left"><strong><font  face="Arial, Helvetica, sans-serif">Reverse Charges : Nil</font></strong></div></td>
	</table>
<?		

		
		
		$presult = mysql_query("select  bcode,prodcode from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no!='TOTAL' and compcode = '$compcode' ") or die(mysql_error());
		$prow= mysql_fetch_row($presult);
		$bcode = $prow[0];
		$prodcode =$prow[1];
		

		$tresult = mysql_query("select tariff from product where product.bcode =  '$bcode' and product.prodcode = '$prodcode'   ") or die(mysql_error());		
		$trow= mysql_fetch_row($tresult);
		$tariff = $trow[0];
				
?>

  <table width="900" border=0 cellpadding=0 cellspacing=0  rules = "cols" >
    <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=121 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif">HSN /ACS</font></td>	      <td width=199 valign=top class="Normall"  align="center"><div align="left"><font  face="Arial, Helvetica, sans-serif"> Drawing No/ Material Code</font></div></td>  
      <td width=198 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif"> Description of Goods</font></td>

      <td width=94 valign=top class="Normall"  align="center"><div align="right"><font  face="Arial, Helvetica, sans-serif"> Quantity(Nos)</font></div></td>
      <td width=85 valign=top class="Normall"  align="center"><div align="center"><font  face="Arial, Helvetica, sans-serif"> Rate </font></div></td>

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

    </tr>

	<tr>
	<td><hr/></td>
	<td><hr/></td>
	<td><hr/></td>
	<td><hr/></td>
	<td><hr/></td>

	<td><hr/></td>
		<td><hr/></td>

	</tr>
<?
$x=1;	
				
		$result = mysql_query("select distinct drawing_no,bcode,prodcode,hsncode from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no != 'TOTAL' and compcode = '$compcode' ") or die(mysql_error());
		while($row =mysql_fetch_row($result))
		{

			$invresult = mysql_query("select  sum(quantity),avg(rate),sum(value) from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no='$row[0]' and compcode = '$compcode' ") or die(mysql_error());
			$invrow= mysql_fetch_row($invresult);
			$qty = $invrow[0];
			$rate = round($invrow[1],2);
			$value = $invrow[2];


			$tresult = mysql_query("select prodname from product where product.bcode like  '$row[1]%' and product.prodcode like '$row[2]%'   ") or die(mysql_error());		
			$trow= mysql_fetch_row($tresult);
			$prodname = $trow[0];			
			
?>
	   <tr height="30"> 
      <td width=42 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif"><? echo($x);?>  </font></td>

      <td width=121 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif"><? echo($tariff);?>   </font></td>
	        <td width=199 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif" ><? echo($row[0]);?>   </font></td>     

      <td width=198 valign=top align="left" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo($prodname);?>  </font></td>
 
	  
      <td width=94 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($qty,0));?>  </font></td>
      <td width=85 valign=top align="right" class="Normall"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($rate,2));?>  </font></div></td>	  
      <td width=141 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($value,2,'.',''));?>  </font></td>
  				  	  
      </tr>
  	  <?
	  $x++;
		}
for($ind=$x;$ind<15;$ind++)
{

	?>
	   <tr height="30"> 
      <td width=42 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif">&nbsp; </font></td>
      <td width=121 valign=top class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp;  </font></td>
      <td width=199 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif" >&nbsp;  </font></td>

      <td width=198 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp; </font></td>
      <td width=94 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp;  </font></td>
      <td width=85 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp;  </font></td>
      <td width=141 valign=top class="Normall"><div align="center"><font  face="Arial, Helvetica, sans-serif">  </font></div></td>
     
      </tr>	
	<?
	
	}
				

?>
	<tr>
	<td><hr/></td>
	<td><hr/></td>

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

<?		
		$result = mysql_query("select distinct packing_percent,packing_amt,sgst_amt,cgst_amt,igst_amt,vat_percent,vat_amount,freight,total,round_off,gtotal ,value,taxtype from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no = 'TOTAL' and compcode = '$compcode' ") or die(mysql_error());
		$row = mysql_fetch_row($result);
		$packing_percent = $row[0];
		$packing_amt=$row[1];
		$sgst_amt=$row[2];
		$cgst_amt=$row[3];
		$igst_amt = $row[4];
		$tax_rate1=$row[5];
		if($sgst_amt >0)
		{
					$tax_rate = $row[5]/2;
		}
		if($igst_amt >0)
		{
					$tax_rate = $row[5];
		}
		$vat_amt=$row[6];
		$freight=$row[7];
		$total =$row[8];
		$round_off=$row[9];
		$billamt = $row[10];
		$value=$row[11];
		$taxtype = $row[12];
		
		$firsttotal = $value+$packing_amt;
		$secondtotal = $firsttotal + $bed_amt+$cess_amt+$hcess_amt;
		$thirdtotal = $secondtotal + $vat_amt;

		?>
		
		   <tr> 

      <td colspan="6" align="center" valign=top class="Normall" ><font  face="Arial, Helvetica, sans-serif"> Total</font>        <div align="center"><font  face="Arial, Helvetica, sans-serif"></font></div>        <font  face="Arial, Helvetica, sans-serif">  </font><font  face="Arial, Helvetica, sans-serif"> </font></td>
<td width=141 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($value,2));?>  </font></td>	  				  	  
      </tr>
	

	</table>
    		<table width="900" border="0"  rules="all">
      <?      
            	if($packing_amt >0)
	{
	?>
	<tr>

	<td valign=top  class="Normall" colspan="2" align="right"><font  face="Arial, Helvetica, sans-serif"> Packing and Forwarding Charges</font></td>
	<td width="142"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo($packing_amt);?></font></div></td>
	</tr>
	<?
	}
	?>
	<tr>

	<td valign=top  class="Normall" colspan="2" align="right"><font  face="Arial, Helvetica, sans-serif"> TAX @ &nbsp;<?=$tax_rate1?>%&nbsp;</font></td>
	<td width="142"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo($vat_amt);?></font></div></td>
	</tr>


 <?           	
    
	if($sgst_amt>0)
	{
	?>
	<tr class="border_bottom">

	<td width="478"><div align="right"><font  face="Arial, Helvetica, sans-serif"> SGST &nbsp;@&nbsp;<?=$tax_rate?>&nbsp;% &nbsp;&nbsp;=><? echo($sgst_amt);?></font>
	  
	  </div></td>


	<td valign=top  class="Normall"  align="left" ><div align="right"><font  face="Arial, Helvetica, sans-serif"> CGST &nbsp;@&nbsp;<?=$tax_rate?>&nbsp;%&nbsp;=><? echo($cgst_amt);?></font>
	  
	  </div></td><td>&nbsp;</td>
	</tr>
    <?	
		}
	if($igst_amt>0)
	{
	?>
	<tr class="border_bottom"><td>&nbsp;</td>
<td><div align="right"><font  face="Arial, Helvetica, sans-serif"> IGST &nbsp;@&nbsp;<?=$tax_rate?>&nbsp;%=><? echo($igst_amt);?></font></div></td>
	
	</tr>
    <?	
		}		
			
    
    
	if($freight >0)
	{
	?>
	<tr>

	<td valign=top  class="Normall" colspan="2" align="right"><font  face="Arial, Helvetica, sans-serif"> Freight </font></td>
	<td width="142"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo($freight);?></font></div></td>
	</tr>
	<?
	}	

	if($round_off!=0)
	{
	?>
	<tr>

	<td valign=top  class="Normall" colspan="2" align="right"><font  face="Arial, Helvetica, sans-serif"> Round Off</font></td>
	<td width="142"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($round_off,2));?></font></div></td>
	</tr>
	<?
	}
	
	?>
	


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

	<td width=264   class="Normall" align="right"><font  face="Arial, Helvetica, sans-serif" ><b> Total Rs.</b></font></td>
	<td width="142"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><b><? echo(number_format($billamt,2,'.',''));?></b></font></div></td>
	</tr>
	<tr><td height="40" colspan="99"><font  face="Arial, Helvetica, sans-serif"><b>&nbsp;&nbsp;Rupees &nbsp;<? echo(connum($billamt));?>&nbsp;only.</b></td>
	</tr>
	<tr>
	<td height="127"  align="left"><div align="justify"><font  face="Arial, Helvetica, sans-serif">Declaration:Certified that all the particulars shown in the above Tax Invoice are true and correct in all respects. </font></div></td>
	<td  align="center" colspan="2"><p><font  face="Arial, Helvetica, sans-serif"><b>For &nbsp;<?=$name?></b></font>
	</p>
	  <p>&nbsp;</p>  <p>&nbsp;</p>
	  <p><strong><font  face="Arial, Helvetica, sans-serif">Authorised Signatory</font> </strong></p></td>
	</tr>
	<?
		if($saletype == 'CFORM')
		{
			$nar = 'CST &nbsp;'.round($vat_percent,0).'%&nbsp; against C FORM'; 
		}
		else
		{
			$nar = '';
		}
	?>
	
	</table>
	<table width="900" border=0 cellpadding=0 cellspacing=0 >
	
	<tr><td width="450"><font size="-1">
    1. Goods once sold will not be taken back.<br>
2. Interest @ 18% P.A. will be charged, if not paid within stipulated payment terms.<br>
3. Subject to <?=$city?> Jurisdiction.<br>
4. Rejection, if any, will be accepted only in the original condition of our supplies.<br>
    </font></td>
	<td width="445" align="right"><font size="-1"><?=$nar?></font></td>
	</tr> 
	</table>

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

			
<DIV style="page-break-before:always"></DIV>

				
<?
// SECOND INVOICE.




		$sno=1;
		$invresult = mysql_query("select  distinct bcode,prodcode,prepare_time,invdate from salesreg where account_year='$account_year1' and invno = '$invno' and compcode = '$compcode'  ") or die(mysql_error());			
		$row=mysql_fetch_row($invresult);
		

		$bcode = $row[0];
		$prodcode = $row[1]; 
		$date = substr($tdate,8,2).'-'.substr($tdate,5,2).'-'.substr($tdate,0,4);
		$date = british($row[3]);
		$prepare_time= $date.'/'.$row[2];

		$open_result = mysql_query("select  order_record from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no != 'TOTAL' and compcode = '$compcode' order by po_no ") or die(mysql_error());		
		$open_row = mysql_fetch_row($open_result);
		$open_record = $open_row[0];
		
		$open_result = mysql_query("select open_order from orders where record = '$open_record' ") or die(mysql_error());
		$open_row = mysql_fetch_row($open_result);
		$open_order = $open_row[0];
		

		$temp_order='';
		$orderno='';
		$schedule_no='';
		$poresult = mysql_query("select  po_no,po_date,schedule_no,schedule_date from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no != 'TOTAL' and compcode = '$compcode' order by po_no ") or die(mysql_error());
		while($porow =mysql_fetch_row($poresult))
		{

					$po_date = substr($porow[1],8,2).'-'.substr($porow[1],5,2).'-'.substr($porow[1],0,4);
					$schedule_date = substr($porow[3],8,2).'-'.substr($porow[3],5,2).'-'.substr($porow[3],0,4);
					//if($temp_order == '')
					//{
							if($open_order == 'No')
							{
								$orderno = $orderno.$porow[0].'/'.$po_date.',';
							}
							else
							{
								$orderno = $porow[0].'/'.$po_date.',';
							}
						//$temp_order = $porow[0];					
					//}
					     if($porow[2] !='')
					     {		
   					     $schedule_no = $schedule_no.$porow[2].'/'.$schedule_date.',';
					     }
		}
		
	$orderno = substr_replace($orderno, '', strlen($orderno)-1,1);	
	$result = mysql_query("select  name,address1,address2,city,state,pin,cst,tin,telno,email from company where compcode ='$compcode' ") or die(mysql_error());
	$row=mysql_fetch_row($result);
	$name=$row[0];
	$address = $row[1].',&nbsp;'.$row[2].',&nbsp;'.$row[3].'-&nbsp;'.$row[5].',&nbsp;'.$row[4];
	$tin=$row[7];
	$cst=$row[6];
	$city=$row[3];	
    $tel_no = $row[8].'&nbsp;Mail:&nbsp;'.$row[9];
	//$email=$row[9];
	$vendercode=$row[10];
				

		$totline=0;
if($head == 'Yes')
{		
?>		
		
<table>
    <tr>
    <td width="246" height="21" align="right" colspan="100%"><font  face="Arial, Helvetica, sans-serif" size="-1"><b>Duplicate for Transporter</b></font></td></tr>
<tr>
  <td width="900" height="634">

   <table width="900" border=0 cellpadding=0 cellspacing=0 class=MsoTableGrid>
  <tr>
    <td width="127" rowspan="4">       <img src="../../images/logo.jpg" width="84" height="82" align="right"></td>
     
    <td width="651" align="center"><div align="center"><font size="+3" style="font-family: Calligrapher;"><? echo($name);?></font></div></td>
    <td width="116" align="center">&nbsp;</td>
    </tr>

	    <tr>
	      <td width="651" align="center"><div align="center"><font  face="Arial, Helvetica, sans-serif"><? echo($address);?></font></div></td>
	      <td width="116" height="21" align="center">&nbsp;</td>
        </tr>
		    <tr>
		      <td width="651" align="center"><div align="center"><font  face="Arial, Helvetica, sans-serif">Phone : &nbsp;<? echo($tel_no);?></td>
		      <td width="116" height="21" align="center">&nbsp;</td>
	        </tr>

		    <tr>
		      <td width="651" align="center"><div align="center"><font  face="Arial, Helvetica, sans-serif"><b>GST No: : &nbsp;<? echo($tin);?>&nbsp;&nbsp;STATE CODE : 33 <br> MSME Regn. No : &nbsp;UDYAM-TN-03-0140740</b></font></div></td>
		      <td width="116" height="21" align="center">&nbsp;</td>
	        </tr>
</table>
   <table width="900" border=0 >



  <tr>
    <td  align="center"><font  face="Arial, Helvetica, sans-serif">
      <h3>TAX INVOICE </h3>
    </font></td>
    <td align="center">&nbsp;</td>
    </tr>
  </table>
 
  	<?	
	}
else
{
	?>
<br><br><br><br>
	<?
}
		$result = mysql_query("select  name,address1,address2,city,state,pin,cst,gstin,std,telno,eccno,state_code,vendercode from buy where bcode ='$bcode' ") or die(mysql_error());
		$row=mysql_fetch_row($result);
		$bname=$row[0];
			$bcity=$row[3];
		$baddress = $row[1].',&nbsp;'.$row[2].',<br>'.$row[3].',&nbsp;'.$row[4].',&nbsp;'.$row[5];
//$baddress = $row[1].',&nbsp;'.$row[2];
		
		if($vendercode !='')
		{
			$baddress = $baddress.'Vendercode:'.$row[12];
		}
		$btin='GST No::&nbsp;'.$row[7].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>STATE CODE:&nbsp;'.$row[11];
		$btel_no = $row[8].'&nbsp;-&nbsp;'.$row[9];

		
?>
<table width="900"  border="0" rules="cols">
    <tr>       <td  valign=top class="Normall" ><font  face="Arial, Helvetica, sans-serif">
	  Name &amp; Address of  Buyer&nbsp;<br/><b>M/s.&nbsp; <? echo($bname);?></b></font></td>
      <td width="225" rowspan="2"   align="right" valign=top class="Normall"><div align="left"><strong><font  face="Arial, Helvetica, sans-serif"> Order No:
        <?=$orderno?>
      </font></strong></div></td>
      <td width="246"   align="left" valign=top class="Normall"><div align="left"><font  face="Arial, Helvetica, sans-serif"> <b>Invoice
        No. &nbsp; <? echo($invno.'/'.$account_year);?></b></font></div></td></tr>
		  <tr>
		        <td width="403"  valign=top class="Normall" ><font  face="Arial, Helvetica, sans-serif">&nbsp;<? echo($baddress);?></font></td>
            <td width=246  align="right" class="Normall"><div align="left"><font  face="Arial, Helvetica, sans-serif"> <b> Date : &nbsp;<? echo($date);?></b></font></div></td>
    </tr>
	     <tr> 
      <td width=403 valign=top class="Normall"><font  face="Arial, Helvetica, sans-serif"></font></td>
      <td width="225" rowspan="2" align="right"><div align="left"><strong><font  face="Arial, Helvetica, sans-serif">Schedule No:&nbsp;
        <?=$schedule_no.'/'.$schedule_date?>
      </font></strong></div></td>
      <td align="right"><strong>
        <div align="left"><font  face="Arial, Helvetica, sans-serif">Prepare Date and Time:
          <?=$prepare_time?>
        </font></div></td></tr>
	  <tr><td width=403 valign=top class="Normall"><font  face="Arial, Helvetica, sans-serif"><b><? echo($btin);?></b></font></td>
	    <td width=246 valign=top class="Normall" align="right"><div align="left"><strong><font  face="Arial, Helvetica, sans-serif">Reverse Charges : Nil</font></strong></div></td>
	</table>
<?		

		
		
		$presult = mysql_query("select  bcode,prodcode from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no!='TOTAL' and compcode = '$compcode' ") or die(mysql_error());
		$prow= mysql_fetch_row($presult);
		$bcode = $prow[0];
		$prodcode =$prow[1];
		
	
		$tresult = mysql_query("select tariff from product where product.bcode like  '$bcode%' and product.prodcode like '$prodcode%'   ") or die(mysql_error());		
		$trow= mysql_fetch_row($tresult);
		$tariff = $trow[0];
				
?>

  <table width="900" border=0 cellpadding=0 cellspacing=0  rules = "cols" >
    <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=121 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif">HSN /ACS</font></td>	      <td width=199 valign=top class="Normall"  align="center"><div align="left"><font  face="Arial, Helvetica, sans-serif"> Drawing No/ Material Code</font></div></td>  
      <td width=198 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif"> Description of Goods</font></td>

      <td width=94 valign=top class="Normall"  align="center"><div align="right"><font  face="Arial, Helvetica, sans-serif"> Quantity(Nos)</font></div></td>
      <td width=85 valign=top class="Normall"  align="center"><div align="center"><font  face="Arial, Helvetica, sans-serif"> Rate </font></div></td>

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

    </tr>

	<tr>
	<td><hr/></td>
	<td><hr/></td>
	<td><hr/></td>
	<td><hr/></td>
	<td><hr/></td>

	<td><hr/></td>
		<td><hr/></td>

	</tr>
<?
$x=1;	
				
		$result = mysql_query("select distinct drawing_no,bcode,prodcode,hsncode from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no != 'TOTAL' and compcode = '$compcode' ") or die(mysql_error());
		while($row =mysql_fetch_row($result))
		{

			$invresult = mysql_query("select  sum(quantity),avg(rate),sum(value) from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no='$row[0]' and compcode = '$compcode' ") or die(mysql_error());
			$invrow= mysql_fetch_row($invresult);
			$qty = $invrow[0];
			$rate = round($invrow[1],2);
			$value = $invrow[2];


			$tresult = mysql_query("select prodname from product where product.bcode like  '$row[1]%' and product.prodcode like '$row[2]%'   ") or die(mysql_error());		
			$trow= mysql_fetch_row($tresult);
			$prodname = $trow[0];			
			
?>
	   <tr height="30"> 
      <td width=42 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif"><? echo($x);?>  </font></td>

      <td width=121 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif"><? echo($tariff);?>   </font></td>
	        <td width=199 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif" ><? echo($row[0]);?>   </font></td>     

      <td width=198 valign=top align="left" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo($prodname);?>  </font></td>
 
	  
      <td width=94 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($qty,0));?>  </font></td>
      <td width=85 valign=top align="right" class="Normall"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($rate,2));?>  </font></div></td>	  
      <td width=141 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($value,2,'.',''));?>  </font></td>
  				  	  
      </tr>
  	  <?
	  $x++;
		}
for($ind=$x;$ind<15;$ind++)
{

	?>
	   <tr height="30"> 
      <td width=42 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif">&nbsp; </font></td>
      <td width=121 valign=top class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp;  </font></td>
      <td width=199 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif" >&nbsp;  </font></td>

      <td width=198 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp; </font></td>
      <td width=94 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp;  </font></td>
      <td width=85 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp;  </font></td>
      <td width=141 valign=top class="Normall"><div align="center"><font  face="Arial, Helvetica, sans-serif">  </font></div></td>
     
      </tr>	
	<?
	
	}
				

?>
	<tr>
	<td><hr/></td>
	<td><hr/></td>

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

<?		
		$result = mysql_query("select distinct packing_percent,packing_amt,sgst_amt,cgst_amt,igst_amt,vat_percent,vat_amount,freight,total,round_off,gtotal ,value,taxtype from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no = 'TOTAL' and compcode = '$compcode' ") or die(mysql_error());
		$row = mysql_fetch_row($result);
		$packing_percent = $row[0];
		$packing_amt=$row[1];
		$sgst_amt=$row[2];
		$cgst_amt=$row[3];
		$igst_amt = $row[4];
		$tax_rate1=$row[5];
		if($sgst_amt >0)
		{
					$tax_rate = $row[5]/2;
		}
		if($igst_amt >0)
		{
					$tax_rate = $row[5];
		}
		$vat_amt=$row[6];
		$freight=$row[7];
		$total =$row[8];
		$round_off=$row[9];
		$billamt = $row[10];
		$value=$row[11];
		$taxtype = $row[12];
		
		$firsttotal = $value+$packing_amt;
		$secondtotal = $firsttotal + $bed_amt+$cess_amt+$hcess_amt;
		$thirdtotal = $secondtotal + $vat_amt;

		?>
		
		   <tr> 

      <td colspan="6" align="center" valign=top class="Normall" ><font  face="Arial, Helvetica, sans-serif"> Total</font>        <div align="center"><font  face="Arial, Helvetica, sans-serif"></font></div>        <font  face="Arial, Helvetica, sans-serif">  </font><font  face="Arial, Helvetica, sans-serif"> </font></td>
<td width=141 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($value,2));?>  </font></td>	  				  	  
      </tr>
	

	</table>
    		<table width="900" border="0"  rules="all">
      <?      
            	if($packing_amt >0)
	{
	?>
	<tr>

	<td valign=top  class="Normall" colspan="2" align="right"><font  face="Arial, Helvetica, sans-serif"> Packing and Forwarding Charges</font></td>
	<td width="142"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo($packing_amt);?></font></div></td>
	</tr>
	<?
	}
	?>
	<tr>

	<td valign=top  class="Normall" colspan="2" align="right"><font  face="Arial, Helvetica, sans-serif"> TAX @ &nbsp;<?=$tax_rate1?>%&nbsp;</font></td>
	<td width="142"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo($vat_amt);?></font></div></td>
	</tr>


 <?           	
    
	if($sgst_amt>0)
	{
	?>
	<tr class="border_bottom">

	<td width="478"><div align="right"><font  face="Arial, Helvetica, sans-serif"> SGST &nbsp;@&nbsp;<?=$tax_rate?>&nbsp;% &nbsp;&nbsp;=><? echo($sgst_amt);?></font>
	  
	  </div></td>


	<td valign=top  class="Normall"  align="left" ><div align="right"><font  face="Arial, Helvetica, sans-serif"> CGST &nbsp;@&nbsp;<?=$tax_rate?>&nbsp;%&nbsp;=><? echo($cgst_amt);?></font>
	  
	  </div></td><td>&nbsp;</td>
	</tr>
    <?	
		}
	if($igst_amt>0)
	{
	?>
	<tr class="border_bottom"><td>&nbsp;</td>
<td><div align="right"><font  face="Arial, Helvetica, sans-serif"> IGST &nbsp;@&nbsp;<?=$tax_rate?>&nbsp;%=><? echo($igst_amt);?></font></div></td>
	
	</tr>
    <?	
		}		
			
    
    
	if($freight >0)
	{
	?>
	<tr>

	<td valign=top  class="Normall" colspan="2" align="right"><font  face="Arial, Helvetica, sans-serif"> Freight </font></td>
	<td width="142"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo($freight);?></font></div></td>
	</tr>
	<?
	}	

	if($round_off!=0)
	{
	?>
	<tr>

	<td valign=top  class="Normall" colspan="2" align="right"><font  face="Arial, Helvetica, sans-serif"> Round Off</font></td>
	<td width="142"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($round_off,2));?></font></div></td>
	</tr>
	<?
	}
	
	?>
	


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

	<td width=264   class="Normall" align="right"><font  face="Arial, Helvetica, sans-serif" ><b> Total Rs.</b></font></td>
	<td width="142"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><b><? echo(number_format($billamt,2,'.',''));?></b></font></div></td>
	</tr>
	<tr><td height="40" colspan="99"><font  face="Arial, Helvetica, sans-serif"><b>&nbsp;&nbsp;Rupees &nbsp;<? echo(connum($billamt));?>&nbsp;only.</b></td>
	</tr>
	<tr>
	<td height="127"  align="left"><div align="justify"><font  face="Arial, Helvetica, sans-serif">Declaration:Certified that all the particulars shown in the above Tax Invoice are true and correct in all respects. </font></div></td>
	<td  align="center" colspan="2"><p><font  face="Arial, Helvetica, sans-serif"><b>For &nbsp;<?=$name?></b></font>
	</p>
	  <p>&nbsp;</p>  <p>&nbsp;</p>
	  <p><strong><font  face="Arial, Helvetica, sans-serif">Authorised Signatory</font> </strong></p></td>
	</tr>
	<?
		if($saletype == 'CFORM')
		{
			$nar = 'CST &nbsp;'.round($vat_percent,0).'%&nbsp; against C FORM'; 
		}
		else
		{
			$nar = '';
		}
	?>
	
	</table>
	<table width="900" border=0 cellpadding=0 cellspacing=0 >
	
	<tr><td width="450"><font size="-1">
    1. Goods once sold will not be taken back.<br>
2. Interest @ 18% P.A. will be charged, if not paid within stipulated payment terms.<br>
3. Subject to <?=$city?> Jurisdiction.<br>
4. Rejection, if any, will be accepted only in the original condition of our supplies.<br>
    </font></td>
	<td width="445" align="right"><font size="-1"><?=$nar?></font></td>
	</tr> 
	</table>

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

<DIV style="page-break-before:always"></DIV>
<?
// THIRD INVOICE.




		$sno=1;
		$invresult = mysql_query("select  distinct bcode,prodcode,prepare_time,invdate from salesreg where account_year='$account_year1' and invno = '$invno' and compcode = '$compcode'  ") or die(mysql_error());			
		$row=mysql_fetch_row($invresult);
		

		$bcode = $row[0];
		$prodcode = $row[1]; 
		$date = substr($tdate,8,2).'-'.substr($tdate,5,2).'-'.substr($tdate,0,4);
		$date = british($row[3]);
		$prepare_time= $date.'/'.$row[2];
		$open_result = mysql_query("select  order_record from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no != 'TOTAL' and compcode = '$compcode' order by po_no ") or die(mysql_error());		
		$open_row = mysql_fetch_row($open_result);
		$open_record = $open_row[0];
		
		$open_result = mysql_query("select open_order from orders where record = '$open_record' ") or die(mysql_error());
		$open_row = mysql_fetch_row($open_result);
		$open_order = $open_row[0];
		

		$temp_order='';
		$orderno='';
		$schedule_no='';
		$poresult = mysql_query("select  po_no,po_date,schedule_no,schedule_date from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no != 'TOTAL' and compcode = '$compcode' order by po_no ") or die(mysql_error());
		while($porow =mysql_fetch_row($poresult))
		{

					$po_date = substr($porow[1],8,2).'-'.substr($porow[1],5,2).'-'.substr($porow[1],0,4);
					$schedule_date = substr($porow[3],8,2).'-'.substr($porow[3],5,2).'-'.substr($porow[3],0,4);
					//if($temp_order == '')
					//{
							if($open_order == 'No')
							{
								$orderno = $orderno.$porow[0].'/'.$po_date.',';
							}
							else
							{
								$orderno = $porow[0].'/'.$po_date.',';
							}
						//$temp_order = $porow[0];					
					//}
					     if($porow[2] !='')
					     {		
   					     $schedule_no = $schedule_no.$porow[2].'/'.$schedule_date.',';
					     }
		}
		
	$orderno = substr_replace($orderno, '', strlen($orderno)-1,1);	
	$result = mysql_query("select  name,address1,address2,city,state,pin,cst,tin,telno,email from company where compcode ='$compcode' ") or die(mysql_error());
	$row=mysql_fetch_row($result);
	$name=$row[0];
	$address = $row[1].',&nbsp;'.$row[2].',&nbsp;'.$row[3].'-&nbsp;'.$row[5].',&nbsp;'.$row[4];
	$tin=$row[7];
	$cst=$row[6];
	$city=$row[3];	
    $tel_no = $row[8].'&nbsp;Mail:&nbsp;'.$row[9];
	//$email=$row[9];
	$vendercode=$row[10];
				

		$totline=0;
if($head == 'Yes')
{		
?>		
		
<table>
    <tr>
    <td width="246" height="21" align="right" colspan="100%"><font  face="Arial, Helvetica, sans-serif" size="-1"><b>Triplicate for Assessee</b></font></td></tr>
<tr>
  <td width="900" height="634">

   <table width="900" border=0 cellpadding=0 cellspacing=0 class=MsoTableGrid>
  <tr>
    <td width="127" rowspan="4">       <img src="../../images/logo.jpg" width="84" height="82" align="right"></td>
     
    <td width="651" align="center"><div align="center"><font size="+3" style="font-family: Calligrapher;"><? echo($name);?></font></div></td>
    <td width="116" align="center">&nbsp;</td>
    </tr>

	    <tr>
	      <td width="651" align="center"><div align="center"><font  face="Arial, Helvetica, sans-serif"><? echo($address);?></font></div></td>
	      <td width="116" height="21" align="center">&nbsp;</td>
        </tr>
		    <tr>
		      <td width="651" align="center"><div align="center"><font  face="Arial, Helvetica, sans-serif">Phone : &nbsp;<? echo($tel_no);?></td>
		      <td width="116" height="21" align="center">&nbsp;</td>
	        </tr>

		    <tr>
		      <td width="651" align="center"><div align="center"><font  face="Arial, Helvetica, sans-serif"><b>GST No: : &nbsp;<? echo($tin);?>&nbsp;&nbsp;STATE CODE : 33<br> MSME Regn. No : &nbsp;UDYAM-TN-03-0140740 </b></font></div></td>
		      <td width="116" height="21" align="center">&nbsp;</td>
	        </tr>
</table>
   <table width="900" border=0 >



  <tr>
    <td  align="center"><font  face="Arial, Helvetica, sans-serif">
      <h3>TAX INVOICE </h3>
    </font></td>
    <td align="center">&nbsp;</td>
    </tr>
  </table>
 
  	<?	
	}
else
{
	?>
<br><br><br><br>
	<?
}
		$result = mysql_query("select  name,address1,address2,city,state,pin,cst,gstin,std,telno,eccno,state_code,vendercode from buy where bcode ='$bcode' ") or die(mysql_error());
		$row=mysql_fetch_row($result);
		$bname=$row[0];
			$bcity=$row[3];
		$baddress = $row[1].',&nbsp;'.$row[2].'<br>'.$row[3].',&nbsp;'.$row[4].',&nbsp;'.$row[5];
//$baddress = $row[1].',&nbsp;'.$row[2];
		
		if($vendercode !='')
		{
			$baddress = $baddress.'Vendercode:'.$row[12];
		}
		$btin='GST No::&nbsp;'.$row[7].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>STATE CODE:&nbsp;'.$row[11];
		$btel_no = $row[8].'&nbsp;-&nbsp;'.$row[9];

		
?>
<table width="900"  border="0" rules="cols">
    <tr>       <td  valign=top class="Normall" ><font  face="Arial, Helvetica, sans-serif">
	  Name &amp; Address of  Buyer&nbsp;<br/><b>M/s.&nbsp; <? echo($bname);?></b></font></td>
      <td width="225" rowspan="2"   align="right" valign=top class="Normall"><div align="left"><strong><font  face="Arial, Helvetica, sans-serif"> Order No:
        <?=$orderno?>
      </font></strong></div></td>
      <td width="246"   align="left" valign=top class="Normall"><div align="left"><font  face="Arial, Helvetica, sans-serif"> <b>Invoice
        No. &nbsp; <? echo($invno.'/'.$account_year);?></b></font></div></td></tr>
		  <tr>
		        <td width="403"  valign=top class="Normall" ><font  face="Arial, Helvetica, sans-serif">&nbsp;<? echo($baddress);?></font></td>
            <td width=246  align="right" class="Normall"><div align="left"><font  face="Arial, Helvetica, sans-serif"> <b> Date : &nbsp;<? echo($date);?></b></font></div></td>
    </tr>
	     <tr> 
      <td width=403 valign=top class="Normall"><font  face="Arial, Helvetica, sans-serif"></font></td>
      <td width="225" rowspan="2" align="right"><div align="left"><strong><font  face="Arial, Helvetica, sans-serif">Schedule No:&nbsp;
        <?=$schedule_no.'/'.$schedule_date?>
      </font></strong></div></td>
      <td align="right"><strong>
        <div align="left"><font  face="Arial, Helvetica, sans-serif">Prepare Date and Time:
          <?=$prepare_time?>
        </font></div></td></tr>
	  <tr><td width=403 valign=top class="Normall"><font  face="Arial, Helvetica, sans-serif"><b><? echo($btin);?></b></font></td>
	    <td width=246 valign=top class="Normall" align="right"><div align="left"><strong><font  face="Arial, Helvetica, sans-serif">Reverse Charges : Nil</font></strong></div></td>
	</table>
<?		

		
		
		$presult = mysql_query("select  bcode,prodcode from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no!='TOTAL' and compcode = '$compcode' ") or die(mysql_error());
		$prow= mysql_fetch_row($presult);
		$bcode = $prow[0];
		$prodcode =$prow[1];
		
	
		$tresult = mysql_query("select tariff from product where product.bcode like  '$bcode%' and product.prodcode like '$prodcode%'   ") or die(mysql_error());		
		$trow= mysql_fetch_row($tresult);
		$tariff = $trow[0];
				
?>

  <table width="900" border=0 cellpadding=0 cellspacing=0  rules = "cols" >
    <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=121 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif">HSN /ACS</font></td>	      <td width=199 valign=top class="Normall"  align="center"><div align="left"><font  face="Arial, Helvetica, sans-serif"> Drawing No/ Material Code</font></div></td>  
      <td width=198 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif"> Description of Goods</font></td>

      <td width=94 valign=top class="Normall"  align="center"><div align="right"><font  face="Arial, Helvetica, sans-serif"> Quantity(Nos)</font></div></td>
      <td width=85 valign=top class="Normall"  align="center"><div align="center"><font  face="Arial, Helvetica, sans-serif"> Rate </font></div></td>

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

    </tr>

	<tr>
	<td><hr/></td>
	<td><hr/></td>
	<td><hr/></td>
	<td><hr/></td>
	<td><hr/></td>

	<td><hr/></td>
		<td><hr/></td>

	</tr>
<?
$x=1;	
				
		$result = mysql_query("select distinct drawing_no,bcode,prodcode,hsncode from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no != 'TOTAL' and compcode = '$compcode' ") or die(mysql_error());
		while($row =mysql_fetch_row($result))
		{


			$invresult = mysql_query("select  sum(quantity),avg(rate),sum(value) from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no='$row[0]'  and compcode = '$compcode'") or die(mysql_error());
			$invrow= mysql_fetch_row($invresult);
			$qty = $invrow[0];
			$rate = round($invrow[1],2);
			$value = $invrow[2];


			$tresult = mysql_query("select prodname from product where product.bcode like  '$row[1]%' and product.prodcode like '$row[2]%'   ") or die(mysql_error());		
			$trow= mysql_fetch_row($tresult);
			$prodname = $trow[0];			
			
?>
	   <tr height="30"> 
      <td width=42 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif"><? echo($x);?>  </font></td>

      <td width=121 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif"><? echo($tariff);?>   </font></td>
	        <td width=199 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif" ><? echo($row[0]);?>   </font></td>     

      <td width=198 valign=top align="left" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo($prodname);?>  </font></td>
 
	  
      <td width=94 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($qty,0));?>  </font></td>
      <td width=85 valign=top align="right" class="Normall"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($rate,2));?>  </font></div></td>	  
      <td width=141 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($value,2,'.',''));?>  </font></td>
  				  	  
      </tr>
  	  <?
	  $x++;
		}
for($ind=$x;$ind<15;$ind++)
{

	?>
	   <tr height="30"> 
      <td width=42 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif">&nbsp; </font></td>
      <td width=121 valign=top class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp;  </font></td>
      <td width=199 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif" >&nbsp;  </font></td>

      <td width=198 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp; </font></td>
      <td width=94 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp;  </font></td>
      <td width=85 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp;  </font></td>
      <td width=141 valign=top class="Normall"><div align="center"><font  face="Arial, Helvetica, sans-serif">  </font></div></td>
     
      </tr>	
	<?
	
	}
				

?>
	<tr>
	<td><hr/></td>
	<td><hr/></td>

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

<?		
		$result = mysql_query("select distinct packing_percent,packing_amt,sgst_amt,cgst_amt,igst_amt,vat_percent,vat_amount,freight,total,round_off,gtotal ,value,taxtype from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no = 'TOTAL' and compcode = '$compcode' ") or die(mysql_error());
		$row = mysql_fetch_row($result);
		$packing_percent = $row[0];
		$packing_amt=$row[1];
		$sgst_amt=$row[2];
		$cgst_amt=$row[3];
		$igst_amt = $row[4];
		$tax_rate1=$row[5];
		if($sgst_amt >0)
		{
					$tax_rate = $row[5]/2;
		}
		if($igst_amt >0)
		{
					$tax_rate = $row[5];
		}
		$vat_amt=$row[6];
		$freight=$row[7];
		$total =$row[8];
		$round_off=$row[9];
		$billamt = $row[10];
		$value=$row[11];
		$taxtype = $row[12];
		
		$firsttotal = $value+$packing_amt;
		$secondtotal = $firsttotal + $bed_amt+$cess_amt+$hcess_amt;
		$thirdtotal = $secondtotal + $vat_amt;

		?>
		
		   <tr> 

      <td colspan="6" align="center" valign=top class="Normall" ><font  face="Arial, Helvetica, sans-serif"> Total</font>        <div align="center"><font  face="Arial, Helvetica, sans-serif"></font></div>        <font  face="Arial, Helvetica, sans-serif">  </font><font  face="Arial, Helvetica, sans-serif"> </font></td>
<td width=141 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($value,2));?>  </font></td>	  				  	  
      </tr>
	

	</table>
    		<table width="900" border="0"  rules="all">
      <?      
            	if($packing_amt >0)
	{
	?>
	<tr>

	<td valign=top  class="Normall" colspan="2" align="right"><font  face="Arial, Helvetica, sans-serif"> Packing and Forwarding Charges</font></td>
	<td width="142"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo($packing_amt);?></font></div></td>
	</tr>
	<?
	}
	?>
	<tr>

	<td valign=top  class="Normall" colspan="2" align="right"><font  face="Arial, Helvetica, sans-serif"> TAX @ &nbsp;<?=$tax_rate1?>%&nbsp;</font></td>
	<td width="142"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo($vat_amt);?></font></div></td>
	</tr>


 <?           	
    
	if($sgst_amt>0)
	{
	?>
	<tr class="border_bottom">

	<td width="478"><div align="right"><font  face="Arial, Helvetica, sans-serif"> SGST &nbsp;@&nbsp;<?=$tax_rate?>&nbsp;% &nbsp;&nbsp;=><? echo($sgst_amt);?></font>
	  
	  </div></td>


	<td valign=top  class="Normall"  align="left" ><div align="right"><font  face="Arial, Helvetica, sans-serif"> CGST &nbsp;@&nbsp;<?=$tax_rate?>&nbsp;%&nbsp;=><? echo($cgst_amt);?></font>
	  
	  </div></td><td>&nbsp;</td>
	</tr>
    <?	
		}
	if($igst_amt>0)
	{
	?>
	<tr class="border_bottom"><td>&nbsp;</td>
<td><div align="right"><font  face="Arial, Helvetica, sans-serif"> IGST &nbsp;@&nbsp;<?=$tax_rate?>&nbsp;%=><? echo($igst_amt);?></font></div></td>
	
	</tr>
    <?	
		}		
			
    
    
	if($freight >0)
	{
	?>
	<tr>

	<td valign=top  class="Normall" colspan="2" align="right"><font  face="Arial, Helvetica, sans-serif"> Freight </font></td>
	<td width="142"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo($freight);?></font></div></td>
	</tr>
	<?
	}	

	if($round_off!=0)
	{
	?>
	<tr>

	<td valign=top  class="Normall" colspan="2" align="right"><font  face="Arial, Helvetica, sans-serif"> Round Off</font></td>
	<td width="142"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($round_off,2));?></font></div></td>
	</tr>
	<?
	}
	
	?>
	


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

	<td width=264   class="Normall" align="right"><font  face="Arial, Helvetica, sans-serif" ><b> Total Rs.</b></font></td>
	<td width="142"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><b><? echo(number_format($billamt,2,'.',''));?></b></font></div></td>
	</tr>
	<tr><td height="40" colspan="99"><font  face="Arial, Helvetica, sans-serif"><b>&nbsp;&nbsp;Rupees &nbsp;<? echo(connum($billamt));?>&nbsp;only.</b></td>
	</tr>
	<tr>
	<td height="127"  align="left"><div align="justify"><font  face="Arial, Helvetica, sans-serif">Declaration:Certified that all the particulars shown in the above Tax Invoice are true and correct in all respects. </font></div></td>
	<td  align="center" colspan="2"><p><font  face="Arial, Helvetica, sans-serif"><b>For &nbsp;<?=$name?></b></font>
	</p>
	  <p>&nbsp;</p>  <p>&nbsp;</p>
	  <p><strong><font  face="Arial, Helvetica, sans-serif">Authorised Signatory</font> </strong></p></td>
	</tr>
	<?
		if($saletype == 'CFORM')
		{
			$nar = 'CST &nbsp;'.round($vat_percent,0).'%&nbsp; against C FORM'; 
		}
		else
		{
			$nar = '';
		}
	?>
	
	</table>
	<table width="900" border=0 cellpadding=0 cellspacing=0 >
	
	<tr><td width="450"><font size="-1">
    1. Goods once sold will not be taken back.<br>
2. Interest @ 18% P.A. will be charged, if not paid within stipulated payment terms.<br>
3. Subject to <?=$city?> Jurisdiction.<br>
4. Rejection, if any, will be accepted only in the original condition of our supplies.<br>
    </font></td>
	<td width="445" align="right"><font size="-1"><?=$nar?></font></td>
	</tr> 
	</table>


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

<DIV style="page-break-before:always"></DIV>
<?
// EXTRA COPY.




		$sno=1;
		$invresult = mysql_query("select  distinct bcode,prodcode,prepare_time,invdate from salesreg where account_year='$account_year1' and invno = '$invno' and compcode = '$compcode'  ") or die(mysql_error());			
		$row=mysql_fetch_row($invresult);
		

		$bcode = $row[0];
		$prodcode = $row[1]; 
		$date = substr($tdate,8,2).'-'.substr($tdate,5,2).'-'.substr($tdate,0,4);
		$date = british($row[3]);
		$prepare_time= $date.'/'.$row[2];
		$open_result = mysql_query("select  order_record from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no != 'TOTAL' and compcode = '$compcode' order by po_no ") or die(mysql_error());		
		$open_row = mysql_fetch_row($open_result);
		$open_record = $open_row[0];
		
		$open_result = mysql_query("select open_order from orders where record = '$open_record' ") or die(mysql_error());
		$open_row = mysql_fetch_row($open_result);
		$open_order = $open_row[0];
				

		$temp_order='';
		$orderno='';
		$schedule_no='';
		$poresult = mysql_query("select  po_no,po_date,schedule_no,schedule_date from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no != 'TOTAL' and compcode = '$compcode' order by po_no ") or die(mysql_error());
		while($porow =mysql_fetch_row($poresult))
		{

					$po_date = substr($porow[1],8,2).'-'.substr($porow[1],5,2).'-'.substr($porow[1],0,4);
					$schedule_date = substr($porow[3],8,2).'-'.substr($porow[3],5,2).'-'.substr($porow[3],0,4);
					//if($temp_order == '')
					//{
							if($open_order == 'No')
							{
								$orderno = $orderno.$porow[0].'/'.$po_date.',';
							}
							else
							{
								$orderno = $porow[0].'/'.$po_date.',';
							}
						//$temp_order = $porow[0];					
					//}
					     if($porow[2] !='')
					     {		
   					     $schedule_no = $schedule_no.$porow[2].'/'.$schedule_date.',';
					     }
		}
		
	$orderno = substr_replace($orderno, '', strlen($orderno)-1,1);	
	$result = mysql_query("select  name,address1,address2,city,state,pin,cst,tin,telno,email from company where compcode ='$compcode' ") or die(mysql_error());
	$row=mysql_fetch_row($result);
	$name=$row[0];
	$address = $row[1].',&nbsp;'.$row[2].',&nbsp;'.$row[3].'-&nbsp;'.$row[5].',&nbsp;'.$row[4];
	$tin=$row[7];
	$cst=$row[6];
	$city=$row[3];	
    $tel_no = $row[8].'&nbsp;Mail:&nbsp;'.$row[9];
	//$email=$row[9];
	$vendercode=$row[10];
				

		$totline=0;
if($head == 'Yes')
{		
?>		
		
<table>
    <tr>
    <td width="246" height="21" align="right" colspan="100%"><font  face="Arial, Helvetica, sans-serif" size="-1"><b>Extra Copy</b></font></td></tr>
<tr>
  <td width="900" height="634">

   <table width="900" border=0 cellpadding=0 cellspacing=0 class=MsoTableGrid>
  <tr>
    <td width="127" rowspan="4">       <img src="../../images/logo.jpg" width="84" height="82" align="right"></td>
     
    <td width="651" align="center"><div align="center"><font size="+3" style="font-family: Calligrapher;"><? echo($name);?></font></div></td>
    <td width="116" align="center">&nbsp;</td>
    </tr>

	    <tr>
	      <td width="651" align="center"><div align="center"><font  face="Arial, Helvetica, sans-serif"><? echo($address);?></font></div></td>
	      <td width="116" height="21" align="center">&nbsp;</td>
        </tr>
		    <tr>
		      <td width="651" align="center"><div align="center"><font  face="Arial, Helvetica, sans-serif">Phone : &nbsp;<? echo($tel_no);?></td>
		      <td width="116" height="21" align="center">&nbsp;</td>
	        </tr>

		    <tr>
		      <td width="651" align="center"><div align="center"><font  face="Arial, Helvetica, sans-serif"><b>GST No: : &nbsp;<? echo($tin);?>&nbsp;&nbsp;STATE CODE : 33 <br>MSME Regn. No : &nbsp;UDYAM-TN-03-0140740</b></font></div></td>
		      <td width="116" height="21" align="center">&nbsp;</td>
	        </tr>
</table>
   <table width="900" border=0 >



  <tr>
    <td  align="center"><font  face="Arial, Helvetica, sans-serif">
      <h3>TAX INVOICE </h3>
    </font></td>
    <td align="center">&nbsp;</td>
    </tr>
  </table>
 
  	<?	
	}
else
{
	?>
<br><br><br><br>
	<?
}
		$result = mysql_query("select  name,address1,address2,city,state,pin,cst,gstin,std,telno,eccno,state_code,vendercode from buy where bcode ='$bcode' ") or die(mysql_error());
		$row=mysql_fetch_row($result);
		$bname=$row[0];
			$bcity=$row[3];
		$baddress = $row[1].',&nbsp;'.$row[2].'<br>'.$row[3].',&nbsp;'.$row[4].',&nbsp;'.$row[5];
//$baddress = $row[1].',&nbsp;'.$row[2];
		
		if($vendercode !='')
		{
			$baddress = $baddress.'Vendercode:'.$row[12];
		}
		$btin='GST No::&nbsp;'.$row[7].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>STATE CODE:&nbsp;'.$row[11];
		$btel_no = $row[8].'&nbsp;-&nbsp;'.$row[9];

		
?>
<table width="900"  border="0" rules="cols">
    <tr>       <td  valign=top class="Normall" ><font  face="Arial, Helvetica, sans-serif">
	  Name &amp; Address of  Buyer&nbsp;<br/><b>M/s.&nbsp; <? echo($bname);?></b></font></td>
      <td width="225" rowspan="2"   align="right" valign=top class="Normall"><div align="left"><strong><font  face="Arial, Helvetica, sans-serif"> Order No:
        <?=$orderno?>
      </font></strong></div></td>
      <td width="246"   align="left" valign=top class="Normall"><div align="left"><font  face="Arial, Helvetica, sans-serif"> <b>Invoice
        No. &nbsp; <? echo($invno.'/'.$account_year);?></b></font></div></td></tr>
		  <tr>
		        <td width="403"  valign=top class="Normall" ><font  face="Arial, Helvetica, sans-serif">&nbsp;<? echo($baddress);?></font></td>
            <td width=246  align="right" class="Normall"><div align="left"><font  face="Arial, Helvetica, sans-serif"> <b> Date : &nbsp;<? echo($date);?></b></font></div></td>
    </tr>
	     <tr> 
      <td width=403 valign=top class="Normall"><font  face="Arial, Helvetica, sans-serif"></font></td>
      <td width="225" rowspan="2" align="right"><div align="left"><strong><font  face="Arial, Helvetica, sans-serif">Schedule No:&nbsp;
        <?=$schedule_no.'/'.$schedule_date?>
      </font></strong></div></td>
      <td align="right"><strong>
        <div align="left"><font  face="Arial, Helvetica, sans-serif">Prepare Date and Time:
          <?=$prepare_time?>
        </font></div></td></tr>
	  <tr><td width=403 valign=top class="Normall"><font  face="Arial, Helvetica, sans-serif"><b><? echo($btin);?></b></font></td>
	    <td width=246 valign=top class="Normall" align="right"><div align="left"><strong><font  face="Arial, Helvetica, sans-serif">Reverse Charges : Nil</font></strong></div></td>
	</table>
<?		

		
		 
		$presult = mysql_query("select  bcode,prodcode from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no!='TOTAL' and compcode = '$compcode' ") or die(mysql_error());
		$prow= mysql_fetch_row($presult);
		$bcode = $prow[0];
		$prodcode =$prow[1];
		
	
		$tresult = mysql_query("select tariff from product where product.bcode like  '$bcode%' and product.prodcode like '$prodcode%'   ") or die(mysql_error());		
		$trow= mysql_fetch_row($tresult);
		$tariff = $trow[0];
				
?>

  <table width="900" border=0 cellpadding=0 cellspacing=0  rules = "cols" >
    <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=121 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif">HSN /ACS</font></td>	      <td width=199 valign=top class="Normall"  align="center"><div align="left"><font  face="Arial, Helvetica, sans-serif"> Drawing No/ Material Code</font></div></td>  
      <td width=198 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif"> Description of Goods</font></td>

      <td width=94 valign=top class="Normall"  align="center"><div align="right"><font  face="Arial, Helvetica, sans-serif"> Quantity(Nos)</font></div></td>
      <td width=85 valign=top class="Normall"  align="center"><div align="center"><font  face="Arial, Helvetica, sans-serif"> Rate </font></div></td>

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

    </tr>

	<tr>
	<td><hr/></td>
	<td><hr/></td>
	<td><hr/></td>
	<td><hr/></td>
	<td><hr/></td>

	<td><hr/></td>
		<td><hr/></td>

	</tr>
<?
$x=1;	
				
		$result = mysql_query("select distinct drawing_no,bcode,prodcode,hsncode from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no != 'TOTAL' and compcode = '$compcode' ") or die(mysql_error());
		while($row =mysql_fetch_row($result))
		{


			$invresult = mysql_query("select  sum(quantity),avg(rate),sum(value) from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no='$row[0]' and compcode = '$compcode' ") or die(mysql_error());
			$invrow= mysql_fetch_row($invresult);
			$qty = $invrow[0];
			$rate = round($invrow[1],2);
			$value = $invrow[2];


			$tresult = mysql_query("select prodname from product where product.bcode like  '$row[1]%' and product.prodcode like '$row[2]%'   ") or die(mysql_error());		
			$trow= mysql_fetch_row($tresult);
			$prodname = $trow[0];			
			
?>
	   <tr height="30"> 
      <td width=42 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif"><? echo($x);?>  </font></td>

      <td width=121 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif"><? echo($tariff);?>   </font></td>
	        <td width=199 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif" ><? echo($row[0]);?>   </font></td>     

      <td width=198 valign=top align="left" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo($prodname);?>  </font></td>
 
	  
      <td width=94 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($qty,0));?>  </font></td>
      <td width=85 valign=top align="right" class="Normall"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($rate,2));?>  </font></div></td>	  
      <td width=141 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($value,2,'.',''));?>  </font></td>
  				  	  
      </tr>
  	  <?
	  $x++;
		}
for($ind=$x;$ind<15;$ind++)
{

	?>
	   <tr height="30"> 
      <td width=42 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif">&nbsp; </font></td>
      <td width=121 valign=top class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp;  </font></td>
      <td width=199 valign=top class="Normall" align="center"><font  face="Arial, Helvetica, sans-serif" >&nbsp;  </font></td>

      <td width=198 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp; </font></td>
      <td width=94 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp;  </font></td>
      <td width=85 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif">&nbsp;  </font></td>
      <td width=141 valign=top class="Normall"><div align="center"><font  face="Arial, Helvetica, sans-serif">  </font></div></td>
     
      </tr>	
	<?
	
	}
				

?>
	<tr>
	<td><hr/></td>
	<td><hr/></td>

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

<?		
		$result = mysql_query("select distinct packing_percent,packing_amt,sgst_amt,cgst_amt,igst_amt,vat_percent,vat_amount,freight,total,round_off,gtotal ,value,taxtype from salesreg where account_year='$account_year1' and invno = '$invno'  and drawing_no = 'TOTAL' and compcode = '$compcode' ") or die(mysql_error());
		$row = mysql_fetch_row($result);
		$packing_percent = $row[0];
		$packing_amt=$row[1];
		$sgst_amt=$row[2];
		$cgst_amt=$row[3];
		$igst_amt = $row[4];
		$tax_rate1=$row[5];
		if($sgst_amt >0)
		{
					$tax_rate = $row[5]/2;
		}
		if($igst_amt >0)
		{
					$tax_rate = $row[5];
		}
		$vat_amt=$row[6];
		$freight=$row[7];
		$total =$row[8];
		$round_off=$row[9];
		$billamt = $row[10];
		$value=$row[11];
		$taxtype = $row[12];
		
		$firsttotal = $value+$packing_amt;
		$secondtotal = $firsttotal + $bed_amt+$cess_amt+$hcess_amt;
		$thirdtotal = $secondtotal + $vat_amt;

		?>
		
		   <tr> 

      <td colspan="6" align="center" valign=top class="Normall" ><font  face="Arial, Helvetica, sans-serif"> Total</font>        <div align="center"><font  face="Arial, Helvetica, sans-serif"></font></div>        <font  face="Arial, Helvetica, sans-serif">  </font><font  face="Arial, Helvetica, sans-serif"> </font></td>
<td width=141 valign=top align="right" class="Normall"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($value,2));?>  </font></td>	  				  	  
      </tr>
	

	</table>
    		<table width="900" border="0"  rules="all">
      <?      
            	if($packing_amt >0)
	{
	?>
	<tr>

	<td valign=top  class="Normall" colspan="2" align="right"><font  face="Arial, Helvetica, sans-serif"> Packing and Forwarding Charges</font></td>
	<td width="142"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo($packing_amt);?></font></div></td>
	</tr>
	<?
	}
	?>
	<tr>

	<td valign=top  class="Normall" colspan="2" align="right"><font  face="Arial, Helvetica, sans-serif"> TAX @ &nbsp;<?=$tax_rate1?>%&nbsp;</font></td>
	<td width="142"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo($vat_amt);?></font></div></td>
	</tr>


 <?           	
    
	if($sgst_amt>0)
	{
	?>
	<tr class="border_bottom">

	<td width="478"><div align="right"><font  face="Arial, Helvetica, sans-serif"> SGST &nbsp;@&nbsp;<?=$tax_rate?>&nbsp;% &nbsp;&nbsp;=><? echo($sgst_amt);?></font>
	  
	  </div></td>


	<td valign=top  class="Normall"  align="left" ><div align="right"><font  face="Arial, Helvetica, sans-serif"> CGST &nbsp;@&nbsp;<?=$tax_rate?>&nbsp;%&nbsp;=><? echo($cgst_amt);?></font>
	  
	  </div></td><td>&nbsp;</td>
	</tr>
    <?	
		}
	if($igst_amt>0)
	{
	?>
	<tr class="border_bottom"><td>&nbsp;</td>
<td><div align="right"><font  face="Arial, Helvetica, sans-serif"> IGST &nbsp;@&nbsp;<?=$tax_rate?>&nbsp;%=><? echo($igst_amt);?></font></div></td>
	
	</tr>
    <?	
		}		
			
    
    
	if($freight >0)
	{
	?>
	<tr>

	<td valign=top  class="Normall" colspan="2" align="right"><font  face="Arial, Helvetica, sans-serif"> Freight </font></td>
	<td width="142"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo($freight);?></font></div></td>
	</tr>
	<?
	}	

	if($round_off!=0)
	{
	?>
	<tr>

	<td valign=top  class="Normall" colspan="2" align="right"><font  face="Arial, Helvetica, sans-serif"> Round Off</font></td>
	<td width="142"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><? echo(number_format($round_off,2));?></font></div></td>
	</tr>
	<?
	}
	
	?>
	


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

	<td width=264   class="Normall" align="right"><font  face="Arial, Helvetica, sans-serif" ><b> Total Rs.</b></font></td>
	<td width="142"  align="right"><div align="right"><font  face="Arial, Helvetica, sans-serif"><b><? echo(number_format($billamt,2,'.',''));?></b></font></div></td>
	</tr>
	<tr><td height="40" colspan="99"><font  face="Arial, Helvetica, sans-serif"><b>&nbsp;&nbsp;Rupees &nbsp;<? echo(connum($billamt));?>&nbsp;only.</b></td>
	</tr>
	<tr>
	<td height="127"  align="left"><div align="justify"><font  face="Arial, Helvetica, sans-serif">Declaration:Certified that all the particulars shown in the above Tax Invoice are true and correct in all respects. </font></div></td>
	<td  align="center" colspan="2"><p><font  face="Arial, Helvetica, sans-serif"><b>For &nbsp;<?=$name?></b></font>
	</p>
	  <p>&nbsp;</p>  <p>&nbsp;</p>
	  <p><strong><font  face="Arial, Helvetica, sans-serif">Authorised Signatory</font> </strong></p></td>
	</tr>
	<?
		if($saletype == 'CFORM')
		{
			$nar = 'CST &nbsp;'.round($vat_percent,0).'%&nbsp; against C FORM'; 
		}
		else
		{
			$nar = '';
		}
	?>
	
	</table>
	<table width="900" border=0 cellpadding=0 cellspacing=0 >
	
	<tr><td width="450"><font size="-1">
    1. Goods once sold will not be taken back.<br>
2. Interest @ 18% P.A. will be charged, if not paid within stipulated payment terms.<br>
3. Subject to <?=$city?> Jurisdiction.<br>
4. Rejection, if any, will be accepted only in the original condition of our supplies.<br>
    </font></td>
	<td width="445" align="right"><font size="-1"><?=$nar?></font></td>
	</tr> 
	</table>


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





                                                                             
</body>
</html>

