PK

ADDRLIN : /home/anibklip/ulpc.in/bkp19-20/print/
FLL :
Current File : //home/anibklip/ulpc.in/bkp19-20/print/printinvc.php

<?php
session_start();

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);

function numberToWords ($number){
	$words = array ('zero',
			'one',
			'two',
			'three',
			'four',
			'five',
			'six',
			'seven',
			'eight',
			'nine',
			'ten',
			'eleven',
			'twelve',
			'thirteen',
			'fourteen',
			'fifteen',
			'sixteen',
			'seventeen',
			'eighteen',
			'nineteen',
			'twenty',
			30=> 'thirty',
			40 => 'fourty',
			50 => 'fifty',
			60 => 'sixty',
			70 => 'seventy',
			80 => 'eighty',
			90 => 'ninety',
			100 => 'hundred',
			1000=> 'thousand');

	if (is_numeric ($number)){
		$number = (int) round($number);
		if ($number < 0){
			$number = -$number;
			$number_in_words = 'minus ';
		}
		if ($number > 1000){
			$number_in_words = $number_in_words . numberToWords(floor($number/1000)) . " " . $words[1000];
			$hundreds = $number % 1000;
			$tens = $hundreds % 100;
			if ($hundreds > 100){
				$number_in_words = $number_in_words . ", " . numberToWords ($hundreds);
			}elseif ($tens){
				$number_in_words = $number_in_words . " and " . numberToWords ($tens);
			}
		}elseif ($number > 100){
			$number_in_words = $number_in_words . numberToWords(floor ($number / 100)) . " " . $words[100];
			$tens = $number % 100;
			if ($tens){
				$number_in_words = $number_in_words . " and " . numberToWords ($tens);
			}
		}elseif ($number > 20){
			$number_in_words = $number_in_words . " " . $words[10 * floor ($number/10)];
			$units = $number % 10;
			if ($units){
				$number_in_words = $number_in_words . numberToWords ($units);
			}
		}else{
			$number_in_words = $number_in_words . " " . $words[$number];
		}
		return $number_in_words;
	}
	return false;
}


include("../connexion.php");

$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);


$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:1px solid #000000; padding:1px;
		font-family:arial; font-size:12px; line-height:20px;
		}
		#maintbl th{
		border:2px solid #000000; padding:3px; background:#dfdfdf;
		font-family:arial; font-size:12px; line-height:20px;
		}
		.right{float:right;}
		.vertline{
		background:url('../images/vertline.jpg') no-repeat center center;
		}
	</style>
</head>
<body onLoad1="window.print(); window.close();">
	
	<?php
	if($row[cancel]){
		?>
		<div class="cancel_div"><img src="../cancelled.png" width="670" alt="Cancel" /></div>
		<?
	}
	?><br><br>
	<h2 align="center">TAX INVOICE</h2>
	<table border="1" width="95%" id="maintbl" cellpadding="0" style="">
		<!-- <tr>
			<td colspan="7" align="center">
				<p>&nbsp;</p>
				<h2>INVOICE</h2>
			</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> 
				<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=="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";
						}
					}
					if($ctype=="ppq"){
						$table="cert_ppq";
					}
					$find = array('ALP','AQIS','PPQ','NSPM');
					$replace = array('','','','');
					$ccid = str_replace($find, $replace, $row1[certid]);
					$table=str_replace("aus", "aqis", "$table");
					$table="cert_ppq";
					
					$sql2="SELECT * FROM  $table WHERE certificateno='$ccid'";
					$result2=mysql_query($sql2) or die(mysql_error().' error in fetch 3');
					if($row2=mysql_fetch_array($result2)){
						//print_r($row2);
					}else{
						//echo "NO RECORD";
					}

					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&nbsp;&nbsp;{$row['headname']}</strong><br>{$row['headaddress']} <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&nbsp;&nbsp;{$rowo['ajcomp']}</strong><br>{$rowo['ajaddress']} <br />";
							echo "GST: $rowo[gst]";
						}
					}
					?>
				<span style="float:right;">State Code: 03</span>
			</td>
			<td colspan="4">&nbsp;</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">&nbsp;
					<?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 "&nbsp;A/C&nbsp;&nbsp;{$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>&nbsp;A/C&nbsp;&nbsp;{$row['headname']}";
								}else{
									echo ",&nbsp;A/C&nbsp;&nbsp;{$row['headname']}";
								}
							}
							$j++;
						}
					}
					?>
			</td>
		</tr>
		<?php
			}
			?>
		<tr>
			<td colspan="3">
				<strong>&nbsp; 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>&nbsp;Sub Container No.</strong>";
					}
					$i=1;
					while($row23=mysql_fetch_array($result23)){
						if($i==$row231){
							echo "&nbsp;$i.&nbsp;".$row23[conslinkno]."";
						}else if($i%4==0){
							echo "&nbsp;$i.&nbsp;".$row23[conslinkno].",<br>";
						}else{
							echo "&nbsp;$i.&nbsp;".$row23[conslinkno].",";
						}
						$i++;
					}
					?>
				<br>&nbsp;as per your <?php echo $row2[distmarks];?>
				<!-- <?php
					if($row['conslinkno']==""){
						?>
					<strong>&nbsp;Charges for Fumigation Export Cargo<br /><br /><strong>&nbsp;as per Invoice No.:</strong>
					<?php echo $row['distmarks'];?>
					<?php
						}else{
							?>
					<strong>&nbsp;Charges of Fumigation Container No.</strong> <?php echo $row['conslinkno'];?><br /><br /><strong>&nbsp;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_aqis";
					}
					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_aqis";
						}else{
							$table="cert_$ctable";
						}
					}
					$find = array('ALP','AQIS','PPQ','AUS','NSPM');
					$replace = array('','','','','');
					$ccid = str_replace($find, $replace, $row1[certid]);
					$table=str_replace("aus", "aqis", "$table");
					$table="cert_ppq";
					$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['contype'];
					}

					echo "<br>Destination Port: ".$row231['country'];
					?>
			</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: GST 18%</td>
			<td colspan="2" align="right">
				<strong><?php echo number_format($stax,2);?></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<br />
							Bank Account Number: 1794002100118329<br />
							Bank Branch IFSC: PUNB0179400<br /><br />";
					}else if($_SESSION['city']=="amritser"){
						echo "Bank Name: Punjab National Bank<br />
						Bank Account Number: 1794002100118329<br />
						Bank Branch IFSC: PUNB0179400<br /><br />";
					}
					?>
				<!-- <strong>PAN NO.:</strong> AAIFP 5255A <br /> -->
				<strong> GST NO.:</strong> 03AADFU7505M1Z2
			</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, UNIVERSAL FUMIGATION SERVICES<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