PK

ADDRLIN : /home/anibklip/pcfcindia.com/2025-26/print/
FLL :
Current File : /home/anibklip/pcfcindia.com/2025-26/print/printinvc.php

<?php
session_start();

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


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

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

$sql1 = "SELECT * FROM invoices WHERE invid='$_GET[iid]'";
$result1 = mysql_query($sql1) or die('error in fetch 2');
$row1 = mysql_fetch_array($result1);

if (!$row1['qty']) {
	$row1['qty'] = 1;
}
$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 onLoad1="window.print(); window.close();">

	<?php
	if ($row[cancel]) {
		?>
		<div class="cancel_div"><img src="../cancelled.png" width="670" alt="Cancel" /></div>
		<?
	}
	?>
	<p>&nbsp;</p>
	<p>&nbsp;</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'];
				// echo "saaaa: $ctype";
				if ($ctype == "alp") {
					$table = "cert_alp";
				}
				if ($ctype == "aqis") {
					$table = "cert_aqis";
				}
				if ($ctype == "ppq") {
					$table = "cert_aqis";
				}
				if ($ctype == "nspm") {
					$table = "cert_nspm";
				}

				if ($ctype == "aus" || $ctype == "ausnew") {
					$table = "cert_aqis";
				} else {
					$certido = $row1['certid'];
					$find = array('ALP', 'AQIS', 'PPQ', 'AUS-NEW', 'AUS', 'NSPM');
					$replace = array('', '', '', '', '', '');
					$ccid = str_replace($find, $replace, $row1['certid']);
					$ctable = strtolower(str_replace("$ccid", "", "$certido"));
					// echo "$certido | $ccid | $ctable <br>";

					if ($ctable == "aus") {
						$table = "cert_aqis";
					}
					if ($ctable == "aus-new") {
						$table = "cert_aqis";
					}

					if ($ctable == "ppq") {
						$table = "cert_aqis";
					} else {
						$table = "cert_$ctable";
					}

					if ($ctype == "nspm") {
						$table = "cert_nspm";
					}
				}
				// echo "$table <br>";

				$find = array('ALP', 'AQIS', 'PPQ', 'AUS-NEW', 'AUS', 'NSPM');
				$replace = array('', '', '', '', '', '');
				$ccid = str_replace($find, $replace, $row1['certid']);
				$table = str_replace("aus-new", "aqis", $table);
				$table = str_replace("aus", "aqis", $table);

				$sql2 = "SELECT * FROM  $table WHERE certificateno='$ccid'";
				// echo "$sql2 <br>";
				$result2 = mysql_query($sql2) or die(mysql_error() . ' error in fetch 3');
				$row2 = mysql_fetch_array($result2, MYSQLI_ASSOC);
                //echo "<pre>"; print_r($row2); echo "</pre>";
				//echo $row2['ajtid'];

				//echo $row2[licetype];
				if ($row2['ajtid'] == '') {
					if ($row2['licetype'] == "export") {
						$sql = "SELECT * FROM head WHERE headid='$row2[nameaddress]'";
					} else {
						$sql = "SELECT * FROM head WHERE headid='$row2[declarednameaddress]'";
					}
					//echo "$sql <br>";
					$result = mysql_query($sql) or die(mysql_error() . 'error in fetch 4');
					while ($row = mysql_fetch_array($result, MYSQLI_ASSOC)) {
						echo "<strong>M/S&nbsp;&nbsp;{$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, MYSQLI_ASSOC)) {
						echo "<strong>M/S&nbsp;&nbsp;{$rowo['ajcomp']}</strong><br>{$rowo['ajaddress']} <br><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, MYSQLI_ASSOC)) {
							$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, MYSQLI_ASSOC)) {
								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">
				<br><strong>&nbsp; Container No.</strong>
				<?php
				// echo $ctable;
				if ($ctable == 'aus' || $ctable == 'aus-new') {
					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,MYSQLI_ASSOC);
				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 $ctable;
				if ($ctable == 'aus' || $ctable == 'aus-new') {
					echo $row2['consignment_link'];
				} else {
					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
				// echo "<pre>";print_r($row2);echo "</pre>";

				$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-NEW','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" || $ctable == "aus-new") {
						$table = "cert_aqis";
					}

					if ($ctable == "ppq") {
						$table = "cert_aqis";
					} else {
						$table = "cert_$ctable";
					}
					if ($ctable == "nspm") {
						$table = "cert_nspm";
					}
				}
				if ($ctype == "nspm") {
					$table = "cert_nspm";
				}

				$find = array('ALP', 'AQIS', 'PPQ', 'AUS-NEW','AUS', 'NSPM');
				$replace = array('', '', '', '','','');
				$ccid = str_replace($find, $replace, $row1['certid']);
				$table = str_replace("aus-new", "aqis", "$table");
				$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, MYSQLI_ASSOC)) {
					//print_r($row231);
					if ($ctable == "aus") {
						echo $row231['commodity'];
					} else {
						echo $row231['desgood'] . "";
					}
				}
				if ($table == "cert_alp" || $table == "cert_nspm") {
					$port = $row231['country'];
				} else {
					$port = $row231['countrydes'];
				}

				echo "<br><br><strong>Destination Port: </strong>" . $port . "<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