PK

ADDRLIN : /home/anibklip/ulpc.in/bkp2023-24/
FLL :
Current File : //home/anibklip/ulpc.in/bkp2023-24/statement.php

<?php 
	session_start();
	require_once 'common/common.php';
	require_once 'common/secure.php';
	//include("connexion.php");
	
	if($_GET['action']=="accuntdetails"){
		$_SESSION['action']="accuntdetails";
	}
	
	if($_SESSION['action']=="accuntdetails"){
		include ("head_account.php");	
	}else{
		include "head.php";	
	}
?>
</table>
<br><br>
<p align="left"><font color="#006699">&nbsp;&nbsp;Monthly Statement for Client id # <?php echo"$clnt"; ?></font></p>
<table cellspacing="3" align="center" width="100%" border="4" cellpadding="3">
<tr>
  <td><strong>Date</strong></td>
  <td><strong>Inv. No.</strong></td>
  <td><strong>Cert. No.</strong></td>
  <td><strong>Desc.</strong></td>
  <td><strong>Cont. no</strong></td>
  <td><strong>Country</strong></td>
  <td><strong>Status</strong></td>
  <td><strong>Amount</strong></td>
  <td><strong>Pay</strong></td>
  <td><strong>Print</strong></td>
</tr>
<?php
//$sql="SELECT desgood,conslinkno,countrydes FROM certificate WHERE clnid='$_GET[clnt]' AND ajtid='0'";
if($_SESSION['city']=="ludhiana")
{
include("connexion1.php");		
	if($_GET['clnt']=='all')
	{
		$sql="SELECT desgood,conslinkno,countrydes FROM certificate";
	}
	else{
		$sql="SELECT * FROM invoices WHERE clnid='$_GET[clnt],'";
	}
}
else{
//include("connexion2.php");
	if($_GET['clnt']=='all')
	{
		$sql="SELECT desgood,conslinkno,countrydes FROM certificate";
	}
	else{
		$sql="SELECT * FROM invoices WHERE clnid='$_GET[clnt],'";
		//$sql="SELECT desgood,conslinkno,countrydes FROM certificate WHERE clnid='$_GET[clnt]'";	
	}
}

//echo $sql;
$result=mysql_query($sql) or die(mysql_error().'error in fetch 1');
while($row=mysql_fetch_array($result)){
	$grdtotal+=$row[grandtotal];

	$desc="{$row['desgood']}";
	$container="{$row['conslinkno']}";
	$county="{$row['countrydes']}";
	?>
	<?php
	//******************ONLY COMMENT REMOVE*****************************************

	//$sql="SELECT * FROM invoices Where clnid='$_GET[clnt]' AND (ajtid='0' or ajtid='') and  branch='$_SESSION[city]'";

	$certido = $row['certid'];
	$find = array('ALP','AQIS','PPQ','AUS');
	$replace = array('','','','');
	$ccid = str_replace($find, $replace, $row[certid]);
	$ctable = strtolower(str_replace("$ccid","","$certido"));
	
	if($ctable=="aus"){
		$table="cert_aqis";
	}
	if($ctable=="ppq"){
		$table="cert_ppq";
	}else{
		$table="cert_$ctable";
	}

	//echo "aaaaaaaa - $table";

	if($_SESSION['city']=="ludhiana"){
		include("connexion2.php");
		//$sql="SELECT * FROM invoices Where clnid='$_GET[clnt],' AND branch='$_SESSION[city]'";
		$sql="SELECT * FROM invoices as i, $table as cr Where cr.certificateno='$ccid' and i.clnid='$_GET[clnt],' AND i.branch='$_SESSION[city]'";
	}else{
		include("connexion2.php");
		$sql="SELECT * FROM invoices Where clnid='$_GET[clnt],' AND branch='$_SESSION[city]'";	
	}
	//echo "<br> $sql";
	$result=mysql_query($sql) or die(mysql_error().'error in fetch 2');
	
	if (mysql_num_rows($result) == 0){
		echo "<tr>
			<td colspan=8 align=center>
				<font color=red><strong><br>No Due Invoice records Found </strong>. Please Select the another Client</font><br><br>
			</td>
		</tr>";
	}

	while($row=mysql_fetch_array($result)){
		$sno++;
		//$c=$sno-1;
		/*if($_SESSION['city']=="ludhiana"){
			include("connexion1.php");	
			$sql_crt="SELECT desgood,conslinkno,countrydes,cancel_reason,cancel_status FROM certificate WHERE certificateno='".$row['certid']."'";
		}else{
			include("connexion2.php");
			$sql_crt="SELECT desgood,conslinkno,countrydes,cancel_reason,cancel_status FROM certificate WHERE certificateno='".$row['certid']."'";	
		}
		$result_crt=mysql_query($sql_crt) or die(mysql_error());
		$row_crt=mysql_fetch_array($result_crt);
		print_r($row_crt);*/

		echo"<tr>
		  <td>{$row['dtd']}</td>       
		  <td>{$row['invid']}</td>  
		  <td>{$row['certid']}</td>      
		  <td>{$row['desgood']}</td>
		  <td>{$row['conslinkno']}</td>
		  <td>{$row['countrydes']}</td>
		  <td>";
				echo $row['invstatus']."&nbsp;";
				if($_SESSION['city']=="ludhiana")
				{
					include("connexion1.php");	
					$sql_Balcrt="SELECT * FROM balance_amt WHERE invoice_id='".$row['invid']."' AND bm_status='pending'";			
				}
				else
				{
					include("connexion2.php");
					$sql_Balcrt="SELECT * FROM balance_amt WHERE invoice_id='".$row['invid']."' AND bm_status='pending'";
				}
				
				$result_balCrt=mysql_query($sql_Balcrt);
				$num_balcrt=mysql_num_rows($result_balCrt);
				if($num_balcrt!=0)
				{
					echo '<a href="pay.php?act=balamt&b_invid='.$row['invid'].'&cltid='.$_GET['clnt'].'">Balance</a>';
				}
			echo "</td>    
		  <td>";
			if($row['invstatus']=='pending')
			{
				echo '<span style="color: #F83A3A;">'.$row['grandtotal'].'</span>';
			}
			else
			{
				echo '<span style="color: #009600;">'.$row['grandtotal'].'</span>';
			}
			echo"</td>
		  <td>";
		
			if($row_crt['cancel_status']=='0')
			{
				if($row['invstatus']=='pending')
				{
					//echo "<a href='pay.php?act=pay&id=".$row['invid']."&cid=".$_GET['clnt']."'>Pay</a>
					//<input type='checkbox' name='paymore' value='id=".$row['invid']."&cid=".$_GET['clnt']."' />";
					echo "<form action='pay.php' method='post'>
						Pay<input type='checkbox' name='paymore[]' value='id/cid=".$row['invid']."/".$_GET['clnt']."' />";
				}
				else
				{
					$id_cid=$row['invid'].'/'.$_GET['clnt'];
					echo '<a href="paid_detail.php?clint=search&act=pay&info='.$id_cid.'&clnt='.$_GET['clnt'].'">Received</a>';
				}
			}
			else
			{
				echo "<a href='cert_canceled.php?id=".$row['invid']."'>Cancelled</a>";
			}			
		echo "</td>";
		//echo "<td><a target='_blank' href='invoice_print.php?act=print&clnt_id=".$_GET['clnt']."&id=".$row['invid']."'>Print</a></td>";
		echo "<td><a target='_blank' href='print/printinvc.php?iid=".$row['invid']."'>Print</a></td>";
		echo "</tr>";
	}
	//<td><a href='printinvc3.php?act=print&clnt_id=".$_GET['clnt']."&id=".$row['invid']."'>Print</a></td>

	/*?>
	<tr>
		<td colspan="6" align="center"></td>
		<td>Total Dues</td>
		<td><span style="color: #F83A3A;">
		<?php
			if($_SESSION['city']=="ludhiana")
			{
				include("connexion2.php");
				$sql2="SELECT sum(grandtotal) FROM invoices Where clnid='$_GET[clnt]' AND branch='$_SESSION[city]' AND invstatus='pending'";
			}
			else
			{
				include("connexion2.php");
				$sql2="SELECT sum(grandtotal) FROM invoices Where clnid='$_GET[clnt]' AND branch='$_SESSION[city]' AND invstatus='pending'";	
			}
		
			
			$result2=mysql_query($sql2) or die('error in fetch 3');
			$num_row=mysql_num_rows($result2);
			if($num_row!=0)
			{
				$row2=mysql_fetch_array($result2);
				$total_pendind=$row2['sum(grandtotal)'];
				if($total_pendind==0){
					echo 'No Dues';
				}else{
					echo $total_pendind;	
				}
			}
					
		?></span>
		</td>
		<td>
		<?php
			if($_SESSION['city']=="ludhiana")
			{
				include("connexion2.php");
				$sql0="SELECT * FROM invoices Where clnid='$_GET[clnt]' AND branch='$_SESSION[city]' AND invstatus='pending'";
			}
			else
			{
				include("connexion2.php");
				$sql0="SELECT * FROM invoices Where clnid='$_GET[clnt]' AND branch='$_SESSION[city]' AND invstatus='pending'";	
			}
			$result0=mysql_query($sql0);
			$num_row=mysql_num_rows($result0);
			if($num_row!=0)
			{
				if($row_crt['cancel_status']=='0')
				{
					$frm_url=$_GET['clnt'];
					echo '<input type="hidden" name="frm_url" value='.$frm_url.' />
					<input type="hidden" name="act" value="pay" />
					<input type="submit" name="submit" value="pay">';
				}	
			}	
		?>
		</form>
		</td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td colspan="6" align="center"></td>
		<td>Received Total</td>
		<td><span style="color: #009600;">
		<?php
			if($_SESSION['city']=="ludhiana")
			{
				include("connexion2.php");
				$sql_rec="SELECT sum(grandtotal) FROM invoices Where clnid='$_GET[clnt]' AND branch='$_SESSION[city]' AND invstatus='paid'";
			}
			else
			{
				include("connexion2.php");
				$sql_rec="SELECT sum(grandtotal) FROM invoices Where clnid='$_GET[clnt]' AND branch='$_SESSION[city]' AND invstatus='paid'";	
			}
		
			
			$result_rec=mysql_query($sql_rec) or die('error in fetch 4');
			$row_rec=mysql_fetch_array($result_rec);
			$total_rec=$row_rec['sum(grandtotal)'];
			
			if($total_rec==0){
				echo 'No Received';
			}else{
				echo $total_rec;	
			}
		?></span>
		</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
	<? */ ?>
	<tr>
		<td colspan="6" align="center"></td>
		<td>Grand Total</td>
		<td><strong>
		<?php 
			echo number_format($grdtotal,2);	//$gtotal=$total_pendind+$total_rec;
		?></strong>
		</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
<tr><td colspan="10" align="center" height="80"><center><a href="search.php"><strong><u>Search again</u></strong></a></center></td></tr>
</table>
<?php
}
 "foot.php";
?>


PK 99