PK

ADDRLIN : /home/anibklip/ulpc.in/bk2018-19/print/
FLL :
Current File : /home/anibklip/ulpc.in/bk2018-19/print/printinvc old.php

<?php
session_start();

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

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
		}
		.right{float:right;}
		td{font-size:80%;}
		.vertline{
		background:url('../images/vertline.jpg') no-repeat center center;
		}
	</style>
</head>
<br><br>
<body onLoad1="window.print(); window.close();">
	<body>
		<table width="98%">
			<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[iid]";?>/<? echo $rowu['year'];?></strong></td>
			<td align="right"><strong>Invoice Date.&nbsp;<?php echo"$dtd"; ?></strong></td>
			</tr>
			<tr>
				<td colspan="2"><br>
					<?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"));
						
						
							if($ctable=="aus"){
							$table="cert_aqis";
							}
							if($ctable=="ppq"){
							$table="cert_ppq";
							}
							else{
							$table="cert_$ctable";
							}
						}

						if($ctype=="ppq"){
							$table="cert_ppq";
						}
						
						if($terminal=="1"){
							@include("../../bkp2014-2015/connexion.php");
						}
						else{
							include("../connexion.php");
						}
						$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('error in fetch 3 -'.mysql_error());
						$row2=mysql_fetch_array($result2);
						
						if($row1['ajtid']=='')
						{
						$sql="SELECT headname,headaddress,headphone FROM head WHERE headid='$row1[clnid]'";
						$result=mysql_query($sql) or die('error in fetch 4');
						while($row=mysql_fetch_array($result))
						{
						 echo "<strong>M/S&nbsp;&nbsp;{$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 5');
						while($rowo=mysql_fetch_array($resulto))
						{
						 echo "<strong>M/S&nbsp;&nbsp;{$rowo['ajcomp']}</strong><br>{$rowo['ajaddress']}";
						}
						}
						?>
				</td>
			</tr>
			<tr >
				<td align="center" class="printo"><strong style="float:left;"></td>
				<td class="printo"><strong>&nbsp;Destination Port.</strong></td>
				<td colspan="2" class="printo">
					<span class="left"><strong>&nbsp;&nbsp;Particulars</strong></span>
					<span class="right"><strong>Amount&nbsp;&nbsp;</strong></span>
				</td>
			</tr>
			<tr>
				<td class="printo">&nbsp;<?php //$particular = $_GET['particular']; echo "$particular"; ?>
					<br><strong>&nbsp; Container No.</strong><br>&nbsp;<?php if($ctable=='aus'){echo"$row2[nameship]";} else{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>&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]";?> 
				</td>
				<td width="20%" align="center" valign="middle" bordercolor="#000000" class="printo"> &nbsp; <?php echo"$row2[declentry]";?> &nbsp;</td>
				<td colspan="2" align="right" class="printo vertline">
					<table width="100%" border="0">
						<tr>
							<td>Fumigation Amount</td>
							<td align="right">Rs. <?php $amount = $row1['famount']; echo"$amount";?>/-</td>
						</tr>
						<?php $tamount = $row1['tamount']; if($tamount!="0"){ ?>
						<tr>
							<td>Travel Expenses</td>
							<td align="right">Rs. <?php echo"$tamount";?>/-</td>
						</tr>
						<?php } ?>
						<?php $mamount = $row1['mamount']; if($mamount!="0"){ ?>
						<tr>
							<td>Miscellenous Expenses</td>
							<td align="right">Rs. <?php $amount = $row1['mamount']; echo"$amount";?>/-</td>
						</tr>
						<?php } ?>
					</table>
				</td>
			</tr>
			<tr>
				<td align="right" colspan="3" class="printo">Sub-Total</td>
				<td class="printo" align="right">Rs. <b><?php $amount = $row1['amount']; echo"$amount";?>/-</td>
			</tr>
			<tr>
				<td colspan="4" class="printo"><?php 
					$ajtid = $row1['ajtid'];
					if($ajtid!='')
					{
					$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 
				$discount = $row1['discount']; if($discount!=0){
				?>
			<tr>
				<td align="right" colspan="3" class="printo">Discount:<i>(<?php $discount = $row1['discount']; if($discount==0){echo"n/a";} else {echo "$discount %";} ?>)</i></td>
				<td  align="right" class="printo">
					<?php 
						$fdiscount=$amount*$discount/100;
						if($row1['discount']!=0){
						$amount = $row1['amount'];
						$discount = $row1['discount'];
						$fdiscount=$amount*$discount/100;
						echo"Rs. $fdiscount /-";
						} 
						else {
						echo "n/a";
						}?>
				</td>
			</tr>
			<?php
				}
				?>
			<tr>
				<td colspan="3" align="right" class="printo">ServiceTax :<i>(<?php $servicetax = $row1['servicetax']; if($servicetax!=0){echo"$servicetax %";} else {echo "n/a";}?>)</i></td>
				<td  align="right" class="printo">
					<?php if($row1['servicetax']!=0){
						$amount = $row1['amount'];
						$fgrandtotal=$amount-$fdiscount;
						$staxnet=$fgrandtotal*$row1['servicetax']/100;
						echo"Rs. $staxnet /-";
						} 
						else {
						$staxnet=0;
						echo "n/a";
						}?>
				</td>
			</tr>
			</td></tr>
			<?php
				$amount = $row1['amount'];
				$fgrandtotal=$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=3 class=printo><b>&nbsp;Rupees $result Only/-</b>\n</td>";
					}
					?> 
				<td   align="right" class="printo">Rs. <?php echo"<strong>$finalone</strong>";?>/-
				</td>
			</tr>
			<?php 
				if(isset($_GET['stax']) && $_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. AADFU7505M  </br>   <br></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