
PK 
<?php
session_start();
include("../connexion.php");
function numberTowords($num) {
$ones = array(
1 => "one",
2 => "two",
3 => "three",
4 => "four",
5 => "five",
6 => "six",
7 => "seven",
8 => "eight",
9 => "nine",
10 => "ten",
11 => "eleven",
12 => "twelve",
13 => "thirteen",
14 => "fourteen",
15 => "fifteen",
16 => "sixteen",
17 => "seventeen",
18 => "eighteen",
19 => "nineteen"
);
$tens = array(
1 => "ten",
2 => "twenty",
3 => "thirty",
4 => "forty",
5 => "fifty",
6 => "sixty",
7 => "seventy",
8 => "eighty",
9 => "ninety"
);
$hundreds = array(
"hundred",
"thousand",
"million",
"billion",
"trillion",
"quadrillion"
); //limit t quadrillion
$num = number_format($num, 2, ".", ",");
$num_arr = explode(".", $num);
$wholenum = $num_arr[0];
$decnum = $num_arr[1];
$whole_arr = array_reverse(explode(",", $wholenum));
krsort($whole_arr);
$rettxt = "";
foreach($whole_arr as $key => $i) {
if ($i < 20) {
$rettxt.= $ones[$i];
}
elseif($i < 100) {
$rettxt.= $tens[substr($i, 0, 1)];
$rettxt.= " ".$ones[substr($i, 1, 1)];
} else {
$rettxt.= $ones[substr($i, 0, 1)].
" ".$hundreds[0];
$rettxt.= " ".$tens[substr($i, 1, 1)];
$rettxt.= " ".$ones[substr($i, 2, 1)];
}
if ($key > 0) {
$rettxt.= " ".$hundreds[$key].
" ";
}
}
if ($decnum > 0) {
$rettxt.= " and ";
if ($decnum < 20) {
$rettxt.= $ones[$decnum];
}
elseif($decnum < 100) {
$rettxt.= $tens[substr($decnum, 0, 1)];
$rettxt.= " ".$ones[substr($decnum, 1, 1)];
}
}
return $rettxt;
}
$sqlu="SELECT * FROM signature WHERE user_id='$_SESSION[user_id]'";
$resultu=mysql_query($sqlu) or die('error in fetch 1');
$rowu=mysql_fetch_array($resultu);
include("../connexion2.php");
$sql1="SELECT * FROM invoices WHERE invid='$_GET[iid]'";
$result1=mysql_query($sql1) or die('error in fetch 2');
$row1=mysql_fetch_array($result1);
$terminal = $row1['terminal'];
function sqldate($date){
$val = $date;
$chk = explode("-", $val);
$dat =$chk[2]."/".$chk[1]."/".$chk[0];
return $dat;
}
$dtd=sqldate($row1['dtd']);
?>
<head>
<style type="text/css">
.printo {
border:solid
}
.cancel_div{z-index:1; position:absolute; opacity:0.2; padding:140px 8px;}
body {
margin-left: 70px;
}
#maintbl{
border-collapse:collapse;
}
#maintbl td{
border:2px solid #000000; padding:3px;
font-family:arial; font-size:13px; line-height:15px;
}
#maintbl th{
border:2px solid #000000; padding:3px; background:#dfdfdf;
font-family:arial; font-size:16px; line-height:17px;
}
.right{float:right;}
.vertline{
background:url('../images/vertline.jpg') no-repeat center center;
}
</style>
</head>
<body onLoad="window.print(); window.close();">
<?php
if($row[cancel]){
?>
<div class="cancel_div"><img src="../cancelled.png" width="670" alt="Cancel" /></div>
<?
}
?>
<?include("../connexion.php");?>
<p> </p><p> </p>
<table border="1" width="95%" id="maintbl" cellpadding="0" style="">
<tr>
<td colspan="7" align="center">
<h3>INVOICE</h3>
</td>
</tr>
<tr>
<td colspan="3" align="left">
Invoice No. :
<strong>
<?php
if($_SESSION['city']=="ludhiana"){
echo "LDH";
}else if($_SESSION['city']=="amritser"){
echo "ASR";
}
?>
/
<?php echo"$_GET[iid]";?>/<? echo $rowu['year'];?>
</strong><br />
Invoice Date: <strong><?php echo date("d-m-Y", strtotime($row1[dtd]))?></strong> <br />
State: <strong>Punjab</strong> <br />
<span style="float:right;">State Code <span style="border:1px solid #000000; padding:0px 8px;">03</span></span></td>
<td colspan="4" align="left" width="40%">
<!--Trasnportaion Mode : <br />
Vehicle No : <br />
Date of Supply : <br />
Place of Supply : <br />-->
</td>
</tr>
<tr>
<td colspan="7">Details of Receiver / Billed to: </td>
</tr>
<tr>
<td colspan="3">
<?php
$ctype = $_GET['cype'];
if($ctype=="alp"){
$table="cert_alp";
}
if($ctype=="aqis"){
$table="cert_aqis";
}
if($ctype=="ppq"){
$table="cert_ppq";
}
if($ctype=="aus"){
$table="cert_aqis";
}else{
$certido = $row1['certid'];
$find = array('ALP','AQIS','PPQ','AUS','NSPM');
$replace = array('','','','','');
$ccid = str_replace($find, $replace, $row1[certid]);
$ctable = strtolower(str_replace("$ccid","","$certido"));
//echo "$ctype s $ccid $ctable 1" ;
if($ctable=="aus"){
$table="cert_aqis";
}
if($ctable=="ppq"){
$table="cert_ppq";
}else{
$table="cert_$ctable";
}
}
$find = array('ALP','AQIS','PPQ','AUS');
$replace = array('','','','');
$ccid = str_replace($find, $replace, $row1[certid]);
$table=str_replace("aus", "aqis", "$table");
$sql2="SELECT * FROM $table WHERE certificateno='$ccid'";
$result2=mysql_query($sql2) or die(mysql_error().' error in fetch 3');
$row2=mysql_fetch_array($result2);
if($row1['ajtid']==''){
$sql="SELECT * FROM head WHERE headid='$row1[clnid]'";
$result=mysql_query($sql) or die(mysql_error().'error in fetch 4');
while($row=mysql_fetch_array($result)){
echo "<strong>M/S {$row['headname']}</strong><br>{$row['headaddress']} <br /><br />";
echo "GST: $row[gst]";
}
}else{
$sqlo="SELECT * FROM ajent WHERE ajid='$row1[ajtid]'";
$resulto=mysql_query($sqlo) or die(mysql_error().'error in fetch 5');
while($rowo=mysql_fetch_array($resulto)){
echo "<strong>M/S {$rowo['ajcomp']}</strong><br>{$rowo['ajaddress']} <br><br>";
echo "GST: $rowo[gst]";
}
}
?>
<span style="float:right;">State Code:03</span>
</td>
<td colspan="4"> </td>
</tr>
<tr>
<th width="50">Sr. No</th>
<th>Name of Service</th>
<th width="120">SAC</th>
<th>UOM</th>
<th>QTY</th>
<th>Rate</th>
<th>Amount</th>
</tr>
<tr>
<td align="center">1</td>
<td><?php echo($row1['product']); ?></td>
<td valign="top"><?php echo($row1['hsn']); ?></td>
<td valign="top"><?php echo($row1['uom']); ?></td>
<td valign="top" align="right"><?php echo($row1['qty']); ?></td>
<td valign="top" align="right"><?php echo number_format($row1['famount']/$row1['qty'],2); ?></td>
<td valign="top" align="right"><?php echo($row1['famount']); ?></td>
</tr>
<tr>
<td align="center">2</td>
<td>Travel Expenses</td>
<td valign="top">NA</td>
<td valign="top">NA</td>
<td valign="top" align="right">NA</td>
<td valign="top" align="right"><?php echo $row1['tamount']; ?></td>
<td valign="top" align="right"><?php echo $row1['tamount']; ?></td>
</tr>
<tr>
<td align="center">3</td>
<td>Miscellenous Expenses</td>
<td valign="top">NA</td>
<td valign="top">NA</td>
<td valign="top" align="right">NA</td>
<td valign="top" align="right"><?php echo $row1['mamount']; ?></td>
<td valign="top" align="right"><?php echo($row1['mamount']); ?></td>
</tr>
<?php
if($row1['ajtid']!=""){
?>
<tr>
<td colspan="3" align="center">
<div align="left">
<?php
$exp1 = explode(',',$row1['clnid']);
$ln1 = count($exp1);
for($i=1; $i<$ln1; $i++){
if($i==1){
echo "<strong>".$exp1[$i]."</strong>";
}else{
echo ", ".$exp1[$i];
}
}
?>
</div>
</td>
</tr>
<?php
}
?>
<!-- <tr>
<td colspan="7"><strong>Additional Declaration:</strong> <?php echo $row1[particular]?></td>
</tr> -->
<?php
$ajtid = $row1['ajtid'];
if($ajtid!=''){
?>
<tr>
<td colspan="7" class="printo">
<?php
$sql="SELECT headname,headaddress,headphone FROM head WHERE headid='$row1[clnid]'";
$result=mysql_query($sql) or die('error in fetch');
while($row=mysql_fetch_array($result)){
echo " A/C {$row['headname']}";
}
$sql23="SELECT * FROM certificate_sub WHERE certificateno='$row1[certid]'";
$result23=mysql_query($sql23) or die('error in fetch');
$rownum=mysql_num_rows($result23);
$j=1;
if($rownum!=0){
while($row23=mysql_fetch_array($result23)){
$sql="SELECT headname,headaddress,headphone FROM head WHERE headid='$row23[clnid]'";
$result=mysql_query($sql) or die('error in fetch');
while($row=mysql_fetch_array($result)){
if($j%3==0){
echo ",<br> A/C {$row['headname']}";
}else{
echo ", A/C {$row['headname']}";
}
}
$j++;
}
}
?>
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="3">
<br><strong> Container No.</strong>
<?php
//echo $ctable;
if($ctable=='aus'){
echo"$row2[nameship]";
} else{
echo"$row2[conslinkno]";
}
?>
<br>
<?php
$sql23="SELECT * FROM certificate_sub WHERE certificateno='$row1[certid]'";
$result23=mysql_query($sql23) or die('error in fetch');
$row231=mysql_num_rows($result23);
if($row231!=0){
echo "<strong> Sub Container No.</strong>";
}
$i=1;
while($row23=mysql_fetch_array($result23)){
if($i==$row231){
echo " $i. ".$row23[conslinkno]."";
}else if($i%4==0){
echo " $i. ".$row23[conslinkno].",<br>";
}else{
echo " $i. ".$row23[conslinkno].",";
}
$i++;
}
?>
<br> as per your <?php echo"$row2[distmarks]";?>
<!-- <?php
if($row['conslinkno']==""){
?>
<strong> Charges for Fumigation Export Cargo<br /><br /><strong> as per Invoice No.:</strong>
<?php echo $row['distmarks'];?>
<?php
}else{
?>
<strong> Charges of Fumigation Container No.</strong> <?php echo $row['conslinkno'];?><br /><br /><strong> as per Invoice No.:</strong>
<?php echo $row['distmarks'];?>
<?php
}
?> -->
</td>
<td colspan="4"><strong>Description of Goods:</strong>
<?php
$ctype = $_GET['cype'];
if($ctype=="alp"){
$table="cert_alp";
}
if($ctype=="aqis"){
$table="cert_aqis";
}
if($ctype=="ppq"){
$table="cert_ppq";
}
if($ctype=="aus"){
$table="cert_aqis";
}else{
$certido = $row1['certid'];
$find = array('ALP','AQIS','PPQ','AUS');
$replace = array('','','','');
$ccid = str_replace($find, $replace, $row1[certid]);
$ctable = strtolower(str_replace("$ccid","","$certido"));
//echo "$ctype s $ccid $ctable 1" ;
if($ctable=="aus"){
$table="cert_aqis";
}
if($ctable=="ppq"){
$table="cert_ppq";
}else{
$table="cert_$ctable";
}
}
$find = array('ALP','AQIS','PPQ','AUS');
$replace = array('','','','');
$ccid = str_replace($find, $replace, $row1[certid]);
$table=str_replace("aus", "aqis", "$table");
$sql23="SELECT * FROM $table WHERE certificateno='$ccid'";
//$sql23="SELECT * FROM certificate_sub WHERE certificateno='$row1[certid]'";
//echo $sql23;
$result23=mysql_query($sql23) or die('error in fetch');
if($row231=mysql_fetch_array($result23, MYSQL_ASSOC)){
//print_r($row231);
echo $row231['desgood'];
}
echo "<br><br><strong>Destination Port: </strong>".$row231['countrydes']."<br>";
?>
</td>
</tr>
<?php
$amount = $row1['amount'];
$fgrandtotal=$amount-$fdiscount;
$stax=$fgrandtotal*18/100;
?>
<tr>
<td rowspan="<?php echo ($row1[gst_combine]==1?"3":"5")?>" colspan="3">
<strong>Total Invoice Amount in words</strong><br /><br />
<?php echo ucwords(numberTowords($row1['amount']+$stax));?> Only.
</td>
<td colspan="2">Total Amount Before Tax</td>
<td colspan="2" align="right"><strong><?php echo $row1['amount']?></strong></td>
</tr>
<?php
if($row1[gst_combine]==0){
?>
<tr>
<td colspan="2">Add: CGST 9%</td>
<td colspan="2" align="right"><strong><?php echo number_format($stax/2,2);?></strong></td>
</tr>
<tr>
<td colspan="2">Add: SGST 9%</td>
<td colspan="2" align="right"><strong><?php echo number_format($stax/2,2);?></strong></td>
</tr>
<?php
}
?>
<tr>
<td colspan="2">Tax Amount: <?php echo ($row1[gst_combine]==1?"I":"")?>GST 18%</td>
<td colspan="2" align="right">
<strong>
<?php
if($row1['servicetax']!=0){
echo number_format($stax,2);
}else {
$staxnet=0;
echo "n/a";
}
?>
</strong>
</td>
</tr>
<tr>
<td colspan="2">Total Amount After Tax</td>
<td colspan="2" align="right"><strong><?php echo number_format($row1['amount']+$stax);?></strong></td>
</tr>
<tr>
<td colspan="3">
<strong>Bank Details</strong><br /><br />
<?php
if($_SESSION['city']=="ludhiana"){
echo "Bank Name: Punjab National Bank, LDH<br />
Bank Account Number: 1453002122224123<br />
Bank Branch IFSC: PUNB0145300<br /><br />";
}else if($_SESSION['city']=="amritser"){
echo "Bank Name: Punjab National Bank, ASR<br />
Bank Account Number: 1794002100115553<br />
Bank Branch IFSC: PUNB0179400<br /><br />";
}
?>
<strong>PAN NO.:</strong> AAIFP 5255A <br />
<strong> GST NO.:</strong> 03AAIFP5255A1ZO
</td>
<td rowspan="2" colspan="4" align="right">
<center><small>Certified that the Particulars Given Above are true and correct:</small></center><br /><br />
<strong>For, PEST CONTROL & FUMIGATION COMPANY<br /><br /><br /><br /><br />Authorised Signatory</strong>
</td>
</tr>
<tr>
<td colspan="3" align="center"><strong>Terms and Conditions</strong></td>
</tr>
</table>
</body>


PK 99