<?php
if($_REQUEST['print']!=''){
 $PageSecurity = 3;
error_reporting(0);	
if($_REQUEST['route']=='' )
{
include('includes/SQL_CommonFunctions.inc');
include('includes/session.inc');
include('includes/function_lib.php');
}
}
  echo '<link href="'.$rootpath. '/css/'. $_SESSION['Theme'] .'/default.css" rel="stylesheet" type="text/css" />';
?>
<script type="text/javascript" language="javascript">
  function toggle_visibility(id) {
	
	 
       var e = document.getElementById(id);
	       e.style.display = 'none';
		       //alert(e.style.display);
			   window.print();
    }

</script>
<div style="width:820px; margin-left:auto; margin-right:auto;">
<h3 style="text-align:center; font-size:18px; margin:0px;">TAX INVOICE <span style="font-size:12px; font-weight:normal;">(Rule 11)</span></h3>
<p style="margin:0px; text-align:right; margin-right:3px; font-size:11px;"><?php 
if($_REQUEST['print']=='Buyer'){echo "<b><span style='font-size:22px;'>Original For Buyer</span></b>";}
if($_REQUEST['print']=='Transporter'){echo "<b><span style='font-size:22px;'>Duplicate For Transporter</span></b>";}
if($_REQUEST['print']=='Assessee'){echo "<b><span style='font-size:22px;'>Triplicate For Assessee</span></b>";}
if($_REQUEST['print']=='Quarduplicate'){echo "<b><span style='font-size:22px;'>Quarduplicate</span></b>";}
?>	</p>
<fieldset style="-moz-border-radius:6px; -webkit-border-radius:6px;">
<div>
<!-- table 1 start --><div style="width:auto; float:left; padding:10px;">

<table width="100%" border="0" cellspacing="0" cellpadding="0" style="font-size:13px; font-family:Arial">
<?php 
	$SQLIno=DB_query("select * from locations where CompanyId='".$_SESSION['ACGCompanyId']."' ",$db);
	$InoRow=DB_fetch_array($SQLIno);
?>
  <tr>
    <td width="54%">Regn No.</td>
    <td width="4%">:</td>
    <td width="42%" style="white-space:nowrap"><?php echo $InoRow['ce_regn_no']; ?></td>
  </tr>
  <tr>
    <td>ECC NO.</td>
    <td>:</td>
    <td><?php echo $InoRow['eccno']; ?></td>
  </tr>
  <tr>
    <td>TIN NO.</td>
    <td>:</td>
    <td><?php echo $InoRow['tin_no']; ?></td>
  </tr>
  <tr>
    <td>PAN NO.</td>
    <td>:</td>
    <td><?php echo $InoRow['panno']; ?></td>
  </tr>
  <tr>
    <td>Range</td>
    <td>:</td>
    <td><?php echo $InoRow['site_range']; ?></td>
  </tr>
  <tr>
    <td>Division</td>
    <td>:</td>
    <td><?php echo $InoRow['division']; ?></td>
  </tr>
  <tr>
    <td>Commissionerate</td>
    <td>:</td>
    <td><?php echo $InoRow['commissionerate']; ?></td>
  </tr>
</table>



</div><!-- table 1 close -->
<!-- table 2 start --><div style="width:430px; float:left; padding:10px;">

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?php 
	$Company=DB_query("select * from companies where CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
	$CompanyRow=DB_fetch_array($Company);
?>
  <tr>
    <td style="width:80px;"><img src="images/compaint.jpg" /></td>
    <td style="font-family:Arial; text-align:right;"><h2 style="margin:0px; font-size:18px"><?php echo $CompanyRow['CompanyName']; ?></h2>
		<span style="font-size:15px;"><?php echo $CompanyRow['Address1']; ?><br />
		<strong><?php echo $InoRow['locationname']; ?></strong> - <?php echo $InoRow['deladd1'].','.$InoRow['deladd2'].' '.$InoRow['deladd3']; ?><br />
		Tel : <?php echo $InoRow['phone1']; ?></span>
	
	
	</td>
  </tr>
 
  <tr>
    <td colspan="2" style="height:15px;"></td>
  </tr>
 
 
  <tr>
    <td colspan="2" style="font-size:14px;">(Regd. Office : <?php echo $InoRow['regd_off1']; ?><br />
	<?php echo $InoRow['regd_off2']; ?> <?php echo $InoRow['regd_off3']; ?>
	)</td>
  </tr>
</table>
</div><!-- table 2 Close -->
<!-- table 4 start --><div style="width:100px; float:right; margin-right:15px;">

	<fieldset>
	
		<table width="100%" border="0" cellspacing="0" cellpadding="0" style="font-size:12px; height:100px;">
  <tr>
    <td align="center">Pre Authenticated</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td align="center">Partner/Authorised Signatory</td>
  </tr>
</table>
	</fieldset>
</div><!-- table 4 close -->
</div>
</fieldset>
<div style="clear:both;"></div>
<br />
<!-- Start 2 Para -->
<div>
<fieldset style="-moz-border-radius:6px; -webkit-border-radius:6px; margin:0px; padding:0px;">
<!-- Pata 2 Table 1 start --><div style="width:50%; float:left; border-right:#000000 solid 1px; margin:0px; padding-left:10px; padding-top:10px; padding-bottom:10px;">

<table width="100%" border="0" cellspacing="0" cellpadding="0" style="font-size:12px">
<?php 
$DetailsIno=DB_query("select * from invoice where invoice_id='".$_REQUEST['InvoiceId']."'",$db);
$DetInoRow=DB_fetch_array($DetailsIno);
?>
  <tr>
    <td width="46%">Buyer :</td>
    <td width="54%"><?php
	$accledger=DB_query("select ledgertype,vender_client,AccountName from accountledger where AccountsID='".$DetInoRow['client_id']."'",$db);
	$accledgerRow=DB_fetch_array($accledger);
	if($accledgerRow['ledgertype']=='leads')
	{
			$ClientID=$s->GetFieldValue('accountledger',"AccountsID='".$DetInoRow['client_id']."'",'AccountName');
	 echo   $s->GetFieldValue('clientmaster',"id='".$ClientID."'",'c_name'); 
	 }
	 else
	 {
	echo $s->GetFieldValue('accountledger',"AccountsID='".$DetInoRow['client_id']."'",'AccountName'); 
	 }
	 ?>
	 </td>
  </tr>
  <tr>
    <td colspan="2" style="height:70px;"></td>
  </tr>
  <tr>
    <td>CST/VAT No :</td>
    <td>
<?php 	echo   $s->GetFieldValue('clientmaster',"id='".$ClientID."'",'client_code'); ?>
	</td>
  </tr>
  <tr>
    <td>ECC No :</td>
    <td><?php echo $InoRow['eccno']; ?></td>
  </tr>
  <tr>
    <td>PO No. & Date :</td>
    <td><?php
	$PODate=DB_query("select orderDate from salesorder where id='".$DetInoRow['partyPO']."'",$db);
	$PODateRow=DB_fetch_array($PODate);
	 echo $DetInoRow['partyPO'].'&nbsp;&amp;&nbsp;' .ConvertSQLDate($PODateRow['orderDate']) ?></td>
  </tr>
  <tr>
    <td>Name of Excisable Commodity :</td>
    <td>
	<?php
	$excisableSql=DB_query("Select * from excisable_commodity_master where id='".$DetInoRow['excisableComm']."'",$db);
	$excisableRow=DB_fetch_array($excisableSql);
echo	$excisableRow['commodityName'];
	?>
	</td>
  </tr>
  <tr>
    <td>Tariff Heading :</td>
    <td><?php echo $excisableRow['tarrifHeading']; ?></td>
  </tr>
</table>
</div><!-- Pata 2 Table 2 Close-->

<!-- Pata 2 Table 1 start --><div style="width:45%; float:left; padding-left:20px; padding-top:10px; ">


<table width="90%" border="0" cellspacing="0" cellpadding="0" style="font-size:12px;">
  <tr>
    <td width="43%">Vendor Code :</td>
    <td width="57%">
	<?php 
	//echo "select * from accountledger where AccountsId='".$DetInoRow['client_id']."'";
	 $AccountSQL=DB_query("select * from accountledger where AccountsId='".$DetInoRow['client_id']."'",$db);
		$AccountSQLRow=DB_fetch_array($AccountSQL);
		if($AccountSQLRow['ledgertype']=='client')
		{
		$getclient_mstid=$AccountSQLRow['vender_client'];;
	 	 }
		 else
		{
		$getclient_mstid=$AccountSQLRow['AccountName'];
		} 
	$Vendor=DB_query("Select * from clientmaster where id='".$getclient_mstid."'",$db);
	$VendorRow=DB_fetch_array($Vendor);
	echo $VendorRow['client_code'];
	?>
	</td>
  </tr>
  <tr>
    <td>Our Ref. No :</td>
    <td>
	<?php 
	$OurRef=DB_query("select * from dispatch where againstSOP='".$DetInoRow['partyPO']."' and status='0' and CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
	$OurRefRow=DB_fetch_array($OurRef);
echo	$OurRefRow['our_refno'];
	?>
	
	</td>
  </tr>
  <tr>
    <td>Invoice No :</td>
    <td><table width="200">
  <tr>
    <td width="68"><?php echo $DetInoRow['invoiceNo']; ?></td>
    <td width="53" align="right">Date</td>
    <td width="63" align="right"><?php echo ConvertSQLDate($DetInoRow['invoiceDate']); ?></td>
  </tr>
</table></td>
  </tr>
  <tr>
    <td>Form :</td>
    <td><table width="200">
  <tr>
    <td width="72"><?php
	$formSql=DB_query("Select * from form_type_master where CompanyId='".$_SESSION['ACGCompanyId']."' and id='".$DetInoRow['formType']."'",$db);
	$formSqlRow=DB_fetch_array($formSql);
	
	 echo $formSqlRow['form_name']; ?></td>
    <td width="51" align="right">No</td>
    <td width="61"><?php echo $DetInoRow['formNo']; ?></td>
  </tr>
</table>
</td>
  </tr>
  <tr>
    <td>Despatch Thru :</td>
    <td><?php echo $DetInoRow['dispatchThrough']; ?></td>
  </tr>
  <tr>
    <td>GR No :</td>
    <td><?php echo $DetInoRow['grNo']; ?></td>
  </tr>
  <tr>
    <td>Destination :</td>
    <td><?php echo $OurRefRow['desitination']; ?></td>
  </tr>
  <tr>
    <td>Payment Terms :</td>
    <td>
	<?php 
	$payterm=DB_query("select * from paymentterms where termsindicator='".$DetInoRow['payTerms']."'",$db);
	$paytermRow=DB_fetch_array($payterm);
	echo $paytermRow['terms'];
	?></td>
  </tr>
</table>



</div><!-- Pata 2 Table 2 close -->
<div style="clear:both;"></div>

</fieldset><!-- Close 2 Para -->
</div>
<br />
<!-- Start 3 Para --><div>
<fieldset style="-moz-border-radius:6px; -webkit-border-radius:6px; margin:0px; padding:0px;">
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="font-size:12px">
  <tr>
    <td width="4%" rowspan="2" align="center" style="border-bottom:#000000 solid 1px;border-right:#000000 solid 1px;">Sl.</td>
    <td width="26%" rowspan="2" align="center" style="border-bottom:#000000 solid 1px;border-right:#000000 solid 1px;">Description</td>
    <td width="9%" rowspan="2" align="center" style="border-bottom:#000000 solid 1px;border-right:#000000 solid 1px;">Shade<br />
      Name</td>
    <td width="5%" rowspan="2" align="center" style="border-bottom:#000000 solid 1px;border-right:#000000 solid 1px;">Qty.</td>
    <td width="6%" rowspan="2" align="center" style="border-bottom:#000000 solid 1px;border-right:#000000 solid 1px;">MRP<br />
      Per<br />
      Unit</td>
    <td width="7%" rowspan="2" align="center" style="border-bottom:#000000 solid 1px;border-right:#000000 solid 1px;">Ass. Price</td>
    <td width="10%" rowspan="2" align="center" style="border-bottom:#000000 solid 1px;border-right:#000000 solid 1px;">Total<br />
      Assessable<br />
      Value</td>
    <td width="6%" rowspan="2" align="center" style="border-bottom:#000000 solid 1px;border-right:#000000 solid 1px;">Rate of<br />
      Excise<br />
      Duty</td>
    <td width="9%" rowspan="2" align="center" style="border-bottom:#000000 solid 1px;border-right:#000000 solid 1px;">Amount of<br />
      Excise Duty<br />
      Payable</td>
    <td colspan="2" align="center" style="padding-top:5px; padding-bottom:5px; border-bottom:#000000 solid 1px;">SALES PRICE</td>
  </tr>
  <tr style="text-align:center">
    <td width="8%" height="31" style="border-bottom:#000000 solid 1px;border-right:#000000 solid 1px;">Per<br />Unit Rs.</td>
    <td width="10%" style="border-bottom:#000000 solid 1px;">TOTAL<br />Amount Rs.</td>
  </tr>
  <?php 
  //echo $_REQUEST['InvoiceId'];
  $ItemList=DB_query("select * from invoice_details where invoiceid='".$_REQUEST['InvoiceId']."'",$db);
  $i=0;
  $totalBox=0;
  while($ItemListRow=DB_fetch_array($ItemList))
  {
  ?>
  <tr style="text-align:center">
    <td style="padding-top:5px; padding-bottom:5px; border-right:#000000 solid 1px;"><?php echo $i+1; ?></td>
    <td style="border-right:#000000 solid 1px;"><?php echo $item=$s->GetFieldValue('item_master',"id='".$ItemListRow['ItemCode']."'",'item_name'); ?></td>
    <td style="border-right:#000000 solid 1px;"><?php echo $item=$s->GetFieldValue('item_master',"id='".$ItemListRow['ItemCode']."'",'item_name'); ?></td>
    <td style="border-right:#000000 solid 1px;"><?php echo $ItemListRow['Quantity']; ?></td>
    <td style="border-right:#000000 solid 1px;"><?php echo '1'; ?></td>
    <td style="border-right:#000000 solid 1px;"><?php echo $ItemListRow['RatePerThousand']; ?></td>
    <td style="border-right:#000000 solid 1px;"><?php echo $ItemListRow['Amount']; ?></td>
    <td style="border-right:#000000 solid 1px;"><?php 
	//echo $ItemListRow['EdRate'];
	
					$salesSql=DB_query("select * from  excise_tax",$db);
					while($salesRow=DB_fetch_array($salesSql))
					{
						
						if($ItemListRow['EdRate']==$salesRow['id'])
							{						
						 echo $salesRow['def_rate'].'%';
						 
						 }
					}
					?></td>
    <td style="border-right:#000000 solid 1px;"><?php echo $ItemListRow['EdAmount']; ?></td>
    <td style="border-right:#000000 solid 1px;"><?php echo $ItemListRow['RatePerThousand']; ?></td>
    <td><?php echo $Total=$ItemListRow['Amount']+$ItemListRow['EdAmount']; ?></td>
  </tr>
  <?php 
		$totalBox=$totalBox+$item;
		$i++;}
		if($i=='0'){
			$i=0;
		}
		else
			$i=$i;
		for($i;$i<10;$i++)
		{	//echo $i+1;
		 ?>
  
  <tr>
    <td style="border-right:#000000 solid 1px;"><?php echo $i+1; ?></td>

    <td style="border-right:#000000 solid 1px;">&nbsp;</td>
    <td style="border-right:#000000 solid 1px;">&nbsp;</td>
    <td style="border-right:#000000 solid 1px;">&nbsp;</td>
    <td style="border-right:#000000 solid 1px;">&nbsp;</td>
    <td style="border-right:#000000 solid 1px;">&nbsp;</td>
    <td style="border-right:#000000 solid 1px;">&nbsp;</td>
    <td style="border-right:#000000 solid 1px;">&nbsp;</td>
    <td style="border-right:#000000 solid 1px;">&nbsp;</td>
    <td style="border-right:#000000 solid 1px;">&nbsp;</td>
    <td style="border-right:#000000 thin 1px;">&nbsp;</td>
  </tr>
  <?php }?>
  
  
   <tr>
    <td style="border-right:#000000 solid 1px; border-top:#000000 solid 1px;border-bottom:#000000 solid 1px; padding-top:5px; padding-bottom:5px;">&nbsp;</td>

    <td style="border-right:#000000 solid 1px; border-top:#000000 solid 1px;border-bottom:#000000 solid 1px;">&nbsp;</td>
    <td style="border-right:#000000 solid 1px; border-top:#000000 solid 1px;border-bottom:#000000 solid 1px;">&nbsp;</td>
    <td style="border-right:#000000 solid 1px; border-top:#000000 solid 1px;border-bottom:#000000 solid 1px;">&nbsp;</td>
    <td style="border-right:#000000 solid 1px; border-top:#000000 solid 1px;border-bottom:#000000 solid 1px;">&nbsp;</td>
    <td style="border-right:#000000 solid 1px; border-top:#000000 solid 1px;border-bottom:#000000 solid 1px;">&nbsp;</td>
    <td style="border-right:#000000 solid 1px; border-top:#000000 solid 1px;border-bottom:#000000 solid 1px;">&nbsp;</td>
    <td style="border-right:#000000 solid 1px; border-top:#000000 solid 1px;border-bottom:#000000 solid 1px;">&nbsp;</td>
    <td style="border-right:#000000 solid 1px; border-top:#000000 solid 1px;border-bottom:#000000 solid 1px;">&nbsp;</td>
    <td style="border-right:#000000 solid 1px; border-top:#000000 solid 1px;border-bottom:#000000 solid 1px;">&nbsp;</td>
    <td style="border-top:#000000 solid 1px;border-bottom:#000000 solid 1px;">&nbsp;</td>
  </tr>
  
  <tr style="text-align:center">
    <td colspan="10" style="border-right:#000000 solid 1px; padding-left:10px;">
	
	
	<table width="99%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="30%">Total Excise Duty Payable</td>
    <td width="35%">(Rs. <?php echo $DetInoRow['exciseValue']; ?>)</td>
	<td width="9%">&nbsp;</td>
	<td width="26%">Value of Goods</td>
  </tr>
  <tr>
    <td>Excise Duty in Words Rupees.</td>
    <td><?php echo $DetInoRow['excise_duty_inwords']; ?></td>
	<td>&nbsp;</td>
	<td>Add : Excise Duty</td>
  </tr>
  <tr>
    <td colspan="4" style="height:20px;"></td>
  </tr>
  <tr>
    <td>S. No. of Debit in PLA</td>
    <td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>Add : Edu. Cess @ 2%</td>
  </tr>
  <tr>
    <td>Sl. No. of RG-23A Part- II</td>
    <td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>Add : SHE Cess @ 1%</td>
  </tr>
  <tr>
    <td>Sl. No. of RG -23C Oart-II</td>
    <td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>Total Taxable</td>
  </tr>
  <tr>
    <td>Date & Time of Issue of Invoice</td>
    <td><?php echo ConvertSQLDate($DetInoRow['invoiceDate']).'&nbsp;&amp;&nbsp;'.$DetInoRow['invoiceTime']; ?></td>
	<td>&nbsp;</td>
	<td>Add : CST / VAT</td>
  </tr>
  <tr>
    <td>Date & Time of Removal of Goods</td>
    <td><?php echo ConvertSQLDate($DetInoRow['removalDate']).'&nbsp;&amp;&nbsp;'.$DetInoRow['removalTime']; ?></td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
  </tr>
  <tr>
    <td>Mode of Transport</td>
    <td>........................</td>
	<td>&nbsp;</td>
	<td>GRAND TOTAL</td>
  </tr>
</table>
	</td>


    <td>
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><?php echo $DetInoRow['basicAmount']; ?></td>
  </tr>
  <tr>
    <td><?php echo $DetInoRow['exciseValue']; ?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><?php echo $DetInoRow['ECessValue']; ?></td>
  </tr>
  <tr>
    <td><?php echo $DetInoRow['SAHCessValue']; ?></td>
  </tr>
  <tr>
    <td><?php echo $DetInoRow['taxableAmount']; ?></td>
  </tr>
  <tr>
    <td>
	<?php
    	    	$salesSql=DB_query("Select * from sales_tax_master where salestax_id='".$DetInoRow['VatCst']."'",$db);
				$salesRow=DB_fetch_array($salesSql);
//echo $salesRow['tax_code'].'<br/>'; 
echo $DetInoRow['VatCstValue'];?> 
	</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td style="padding-top:2px; padding-bottom:5px;border-top:#000000 solid 1px;border-bottom:#000000 solid 1px;"><?php echo $DetInoRow['grandTotal']; ?></td>
  </tr>
</table>

	
	</td>
  </tr>


  <tr>
    <td colspan="11" style="height:20px;">&nbsp;</td>
  </tr>
</table>
<div>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="37%">&nbsp;</td>
    <td width="23%" align="center"><strong>For <?php echo $CompanyRow['CompanyName']; ?></strong></td>
  </tr>
  <tr>
    <td style="padding-left:10px;">Certified that the particulars given above are true and corect and the<br />
	amount indicated represent the price actually charged and that there<br />
	is no flow additional consideration directly or indirectly for the buyer
	</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td align="center"><strong>Authorised Signatory</strong></td>
  </tr>
  <tr>
    <td colspan="2" style="height:10px"></td>
  </tr>
  
</table>


</div>







</fieldset>

 <div id="foo"><p align="center">
<a href="#" onclick="javascript:toggle_visibility('foo');" >Print</a>  
</div><!-- Close 3 Para -->



</div>