
PK 
<?php
session_start();
require_once 'common/common.php';
require_once 'common/secure.php';
include "head.php";
include("connexion.php");
$sqlu="SELECT * FROM signature";
//$sqlu="SELECT * FROM signature WHERE user_id='".$_SESSION['user_id']."'";
$resultu=mysql_query($sqlu) or die('error in fetch');
$rowu=mysql_fetch_array($resultu);
//jk......................................................
if($_GET['act']=='print_ajent')
{
$sql_inv="SELECT
inv.dtd,
inv.amount,
inv.discount,
inv.servicetax,
inv.ajtid,
cft.*
FROM
invoices inv,certificate cft
WHERE
inv.clnid='".$_GET['clnt_id']."'
AND
inv.invid='".$_GET['invid']."'
AND
inv.certid=cft.certificateno
AND
inv.ajtid='".$_GET['sech_by_ajt']."'";
}
else
{
$sql_inv="SELECT
inv.dtd,
inv.amount,
inv.discount,
inv.servicetax,
inv.ajtid,
cft.*
FROM
invoices inv,certificate cft
WHERE
inv.clnid='".$_GET['clnt_id']."'
AND
inv.invid='".$_GET['id']."'
AND
inv.certid=cft.certificateno";
}
$result_inv=mysql_query($sql_inv);
$result_inv=mysql_fetch_array($result_inv);
//jk......................................................
?><head>
<style type="text/css">
.printo
{
border:solid
}
</style>
</head>
<br><br>
<body onLoad="window.print(); window.close();">
<table width="95%">
<tr>
<td height="45" colspan="3" align="center">
<center> <h3>INVOICE </h3></center></td></tr>
<td align="left" colspan="2"><strong>Invoice no.<?
//echo $_SESSION['city'];
if($_SESSION['city']=="ludhiana")
{
echo "LDH";
}
else if($_SESSION['city']=="amritser")
{
echo "ASR";
}
//$sqlu="SELECT * FROM signature WHERE user_id='$_SESSION[user_id]'";
$sqlu="SELECT * FROM signature";
$resultu=mysql_query($sqlu) or die('error in fetch');
$rowu=mysql_fetch_array($resultu);
if($_GET['act']=='print_ajent')
{
$sql_inv_detl="SELECT * FROM invoices WHERE clnid='".$_GET['clnt_id']."' AND invid='".$_GET['invid']."'";
}
else
{
$sql_inv_detl="SELECT * FROM invoices WHERE clnid='".$_GET['clnt_id']."' AND invid='".$_GET['id']."'";
}
$resultu_inv_detl=mysql_query($sql_inv_detl) or die('error in fetch');
$rowu_inv_detl=mysql_fetch_array($resultu_inv_detl);
?>/<?php echo $rowu_inv_detl['clnid'];?>/<? echo $rowu['year'];?></strong></td>
<td align="right"><strong>Invoice Date. <?php
$inv_dat=explode("-",$result_inv['dtd']);
echo $inv_dat2=$inv_dat[2].'-'.$inv_dat[1].'-'.$inv_dat[0];
?></strong></td></tr>
<tr>
<td colspan="2"><br>
<?php
if($result_inv['ajtid']=='0')
{
$sql="SELECT headname,headaddress,headphone FROM head WHERE headid='".$_GET['clnt_id']."'";
$result=mysql_query($sql) or die('error in fetch');
while($row=mysql_fetch_array($result))
{
echo "<strong>M/S {$row['headname']}</strong><br>{$row['headaddress']}";
}
}
else
{
$sqlo="SELECT ajname,ajcomp,ajaddress FROM ajent WHERE ajid='".$result_inv['ajtid']."'";
$resulto=mysql_query($sqlo) or die('error in fetch');
while($rowo=mysql_fetch_array($resulto))
{
echo "<strong>M/S {$rowo['ajcomp']}</strong><br>{$rowo['ajaddress']}";
}
}
?>
</td>
</tr>
<tr ><td colspan="2" align="center" class="printo"><strong style="float:left;">Certificate no.<?
//echo $_SESSION['city'];
if($_SESSION['city']=="ludhiana")
{
echo "LDH";
}
else if($_SESSION['city']=="amritser")
{
echo "ASR";
}
?>/<?php echo $result_inv['certificateno'];?>/<? echo $rowu['year'];?></strong>/<strong>Particulars</strong></td>
<td align="center" class="printo"><strong>Amount</strong></td>
</tr>
<tr><td class="printo"> <br />
<br><strong> Container No.</strong><br> <?php echo $result_inv['conslinkno'];?><br><br> as per your <?php echo $result_inv['distmarks'];?> </td>
<td width="20%" align="left" valign="top" bordercolor="#000000" class="printo"><br>
<br><strong> Destination Port.</strong><br> <?php echo $result_inv['declentry'];?><br><br></td>
<td width="26%" align="right" class="printo">
<br>Rs. <?php echo $amt=$result_inv['amount'];?>/-<br><br></td></tr>
<tr><td colspan="3" class="printo"><?php
if($_GET[ajtname]!='0')
{
$sql="SELECT headname,headaddress,headphone FROM head WHERE headid='$_GET[clntid]'";
$result=mysql_query($sql) or die('error in fetch');
while($row=mysql_fetch_array($result))
{
echo " A/C {$row['headname']}";
}
}
?></td></tr>
<tr><td align="right" colspan="2" class="printo">Discount:<i>(<?php if($result_inv['discount']=='0'){echo"n/a";} else {echo $dct=$result_inv['discount']."%";} ?>)</i></td>
<td align="right" class="printo">
<?php if($result_inv['discount']!='0'){
$fdiscount=$result_inv['amount']*$result_inv['discount']/100;
echo"Rs. $fdiscount /-";
}
else {
echo "n/a";
}?></td></tr>
<tr><td colspan="2" align="right" class="printo">ServiceTax :<i>(<?php if($result_inv['servicetax']=='yes'){echo $stax=$result_inv['servicetax']."%";} else {echo "n/a";}?>)</i></td>
<td colspan="2" align="right" class="printo">
<?php if($result_inv['servicetax']=='yes'){
$fgrandtotal=$result_inv['amount']-$fdiscount;
$staxnet=$fgrandtotal*$result_inv['servicetax']/100;
echo"Rs. $staxnet /-";
}
else {
$staxnet=0;
echo "n/a";
}?></td></tr>
</td></tr>
<?php
$fgrandtotal=$result_inv['amount']-$fdiscount;
$finalone=$fgrandtotal+$staxnet;
$finalone=number_format($finalone, 0);
$patterns[0] = "/,/";
$replacements[0] = "";
$finalone= preg_replace($patterns, $replacements, $finalone);
?>
<tr>
<?php
function num2text($num)
{
if(!ctype_digit((string)$num))
{
user_error("num2text(): supplied arg is not an integer value.",
E_USER_WARNING);
return FALSE;
}
if($num < 1)
{
user_error("num2text(): supplied arg must be a positive integer.",
E_USER_WARNING);
return FALSE;
}
$words = array(
'digits' => array(
1 => 'One','Two','Three','Four','Five','Six','Seven','Eight','Nine',
'Ten','Eleven','Twelve','Thirteen','Fourteen','Fifteen','Sixteen',
'Seventeen','Eighteen','Nineteen'
),
'tens' => array(
20 => 'Twenty', 30 => 'Thirty', 40 => 'Forty', 50 => 'Fifty',
60 => 'Sixty', 70 => 'Seventy', 80 => 'Eighty', 90 => 'Ninety'
)
);
switch(TRUE)
{
case ($num < 20):
$text = $words['digits'][$num];
break;
case ($num < 100):
$tens = floor($num/10) * 10;
$digits = $num % 10;
$text = $words['tens'][$tens];
if($digits)
{
$text .= '-'.$words['digits'][$digits];
}
break;
case ($num < 1000):
$hundreds = floor($num/100);
$text = $words['digits'][$hundreds].' Hundred ';
$remainder = $num % 100;
if($remainder)
{
$text .= num2text($remainder);
}
break;
case ($num < 1000000):
$thousands = floor($num/1000);
$remainder = $num % 1000;
$text = num2text($thousands).' Thousand ';
if($remainder)
{
$text .= num2text($remainder);
}
break;
case ($num < 1000000000):
$millions = floor($num/1000000);
$remainder = $num % 1000000;
$text = num2text($millions).' Million ';
if($remainder)
{
$text .= num2text($remainder);
}
break;
default:
user_error("num2text(): value entered is > 999,999,999",
E_USER_WARNING);
return FALSE;
}
return(trim($text));
}
// TEST:
$test = array($finalone);
foreach($test as $num)
{
// $result = num2text($num);
//if($result === FALSE) { $result = 'FALSE'; }
echo "<td align=left colspan=2 class=printo><b> Rupees $result Only/-</b>\n</td>";
}
?>
<td align="right" class="printo">Rs. <?php echo"<strong>$finalone</strong>";?>/-
</td></tr>
<?php if($_GET[stax]=='yes'){
$srtax="$_GET[srtax]";
}
else {
$srtax=0;
}?>
</table><br />
<table width="95%"><tr><td colspan="2">All Payments to be made A/c Payee cheque /D.D only</td></tr>
<tr>
<td colspan="2">PAN NO. AAIFP 5255A </br> SERVICE TAX NO: AAIFP 5255AST001 <br>
E. & O E.</td></tr>
<tr><td width="50%"></td><td align="right" width="50%">for UNIVERSAL FUMIGATION SERVICES</td></tr>
<tr><td width="50%"></td><td align="right" width="50%"><br><br>Authorised Signatory</td></tr></table>
</body>


PK 99