
PK 
<?
include("connexion.php");
$sqlu="SELECT * FROM signature WHERE user_id='$_SESSION[user_id]'";
$resultu=mysql_query($sqlu) or die('error in fetch');
$rowu=mysql_fetch_array($resultu);
include("connexion2.php");
$sql1="SELECT * FROM invoices WHERE invid='$_GET[id]'";
$result1=mysql_query($sql1) or die('error in fetch');
$row1=mysql_fetch_array($result1);
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
}
</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.<? if($_SESSION['city']=="ludhiana")
{
echo "LDH";
}
else if($_SESSION['city']=="amritser")
{
echo "ASR";
}
?>/<?php echo"$_GET[id]";?>/<? echo $rowu['year'];?></strong></td>
<td align="right"><strong>Invoice Date. <?php echo"$dtd"; ?></strong></td></tr>
<tr>
<td colspan="2"><br>
<?php
include("connexion.php");
$sql2="SELECT * FROM certificate WHERE certificateno='$row1[certid]'";
$result2=mysql_query($sql2) or die('error in fetch');
$row2=mysql_fetch_array($result2);
if($row1[ajtid]=='0')
{
$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 "<strong>M/S {$row['headname']}</strong><br>{$row['headaddress']}";
}
}
else
{
$sqlo="SELECT ajname,ajcomp,ajaddress FROM ajent WHERE ajid='$row1[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";
}
if($row2[certypo]=="a" || $row2[certypo]=="b"){
?>
/0<?php echo"$row2[certno]";?>
<?
}else{
?>
/<?php echo"$row1[certid]";?>
<?
}
?>
/<? echo $rowu['year'];?></strong><strong>Particulars</strong></td>
<td align="center" class="printo"><strong>Amount</strong></td>
</tr>
<tr><td class="printo"> <?php echo"$_GET[particular]"; ?>
<br><strong> Container No.</strong><br> <?php echo"$row2[conslinkno]";?><br>
<?
$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]";?> </td>
<td width="20%" align="left" valign="top" bordercolor="#000000" class="printo"><br>
<br><strong> Destination Port.</strong><br> <?php echo"$row2[countrydes]";?><br><br></td>
<td width="26%" align="right" class="printo">
<br>Rs. <?php echo"$row1[amount]";?>/-<br><br></td></tr>
<tr><td colspan="3" class="printo"><?php
if($row1[ajtid]!='0')
{
$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%2==0)
{
echo ",<br> A/C {$row['headname']}";
}
else
{
echo ", A/C {$row['headname']}";
}
}
$j++;
}
}
}
?></td></tr>
<tr><td align="right" colspan="2" class="printo">Discount:<i>(<?php if($row1[discount]==0){echo"n/a";} else {echo "$row1[discount] %";} ?>)</i></td>
<td align="right" class="printo">
<?php if($row1[discount]!=0){
$fdiscount=$row1[amount]*$row1[discount]/100;
echo"Rs. $fdiscount /-";
}
else {
echo "n/a";
}?></td></tr>
<tr><td colspan="2" align="right" class="printo">ServiceTax :<i>(<?php if($row1[servicetax]!=0){echo"$row1[servicetax] %";} else {echo "n/a";}?>)</i></td>
<td colspan="2" align="right" class="printo">
<?php if($row1[servicetax]!=0){
$fgrandtotal=$row1[amount]-$fdiscount;
$staxnet=$fgrandtotal*$row1[servicetax]/100;
echo"Rs. $staxnet /-";
}
else {
$staxnet=0;
echo "n/a";
}?></td></tr>
</td></tr>
<?php
$fgrandtotal=$row1[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 PEST CONTROL & FUMIGATION COMPANY</td></tr>
<tr><td width="50%"></td><td align="right" width="50%"><br><br>Authorised Signatory</td></tr></table>
</body>


PK 99