PK

ADDRLIN : /home/anibklip/ulpc.in/2022-23/form/
FLL :
Current File : //home/anibklip/ulpc.in/2022-23/form/insert_nspm_sub.php

<?php
	session_start();
	require_once '../common/common.php';
	require_once '../common/secure.php';
	include("../connexion.php");
	include("../head.php");
	
	// Certificate
	//echo "<pre>"; print_r($_POST); echo "</pre>";
	
	$certno=$_REQUEST['sub_cert_id'];
	
	$find = array('ALP','AQIS','PPQ','AUS','NSPM');
	$replace = array('','','','','');
	$certno = str_replace($find, $replace, $certno);
	
	echo $sqlo="SELECT count(*) FROM certificate_sub where certificateno='".$_REQUEST[sub_cert_id]."' ";
	$resulto=mysql_fetch_array(mysql_query($sqlo));
	$count=$resulto[0];
	if($count==0){
		$sub_c= $certno."/A";
	}else if($count==1){
		$sub_c= $certno."/B";
	}else if($count==2){
		$sub_c= $certno."/C";
	}else if($count==3){
		$sub_c= $certno."/D";
	}else if($count==4){
		$sub_c= $certno."/E";
	}else if($count==5){
		$sub_c= $certno."/F";
	}else if($count==6){
		$sub_c= $certno."/G";
	}else if($count==7){
		$sub_c= $certno."/H";
	}else if($count==8){
		$sub_c= $certno."/I";
	}else if($count==9){
		$sub_c= $certno."/J";
	}else {
		$sub_c= $certno."/K";
	}
	
	$q="select certificateno from certificate_sub where 1 order by certificateno desc ";
	$q=mysql_query($q) or die(mysql_error());
	if($r=mysql_fetch_array($q)){
		$certno_n=$r[0];
	}
	
	$q="select certificateno from cert_ppq where 1 order by certificateno desc ";
	$q=mysql_query($q) or die(mysql_error());
	if($r=mysql_fetch_array($q)){
		$certno_p=$r[0];
	}
	
	if($certno_n >= $certno_p){
		$certno=$certno_n;
	}else{
		$certno=$certno_p;
	}
	$certno=$certno+1;
	//echo $certno; die();
	
	$din=date('D, d M Y + H:i:s a');
	$fields="certificate_sub set
		issuedate=				'$_POST[issuedate]', 
		namefumigant=			'$_POST[namefumigant]', 
		dosagefumigant=			'$_POST[dosagefumigant]', 
		datefumigantion=		'$_POST[datefumigantion]', 
		fumi_completed=			'$_POST[fumi_completed]', 
		durationfumigantion=	'$_POST[durationfumigantion]', 
		airtemp=			'$_POST[airtemp]', 
		declentry=			'$_POST[declentry]', 
		contype=			'$_POST[desc]', 
		airspace=			'$_POST[airspace]', 
		conslinkno=			'$_POST[conslinkno]', 
		portcountry=		'$_POST[port]', 
		nameship=			'$_POST[vessal]', 
		nameaddress=		'$_POST[nameaddress]', 
		declarednameaddress='$_POST[declarednameaddress]', 
		consignment=		'$_POST[contype]', 
		quantitydeclared=	'$_POST[quantitydeclared]', 
		desgood=			'$_POST[packing]', 
		brand=				'$_POST[brand]', 
		distmarks=			'$_POST[distmarks]', 
		clnid=				'$_POST[clntid]', 
		licetype=			'$_POST[dtype]', 
		certypo=			'$_POST[formno]', 
		ajtid=				'$_POST[ajtname]', 
		ctime=				'$din', 
		placefumigantion=	'$_POST[placefumigantion]', 
		presstest=			'$_POST[gsheet]', 
		gas_tight_value=	'$_POST[gas_tight_value]', 
		decla=				'$_POST[decla]', 
		country=			'$_POST[country]', 
		shiper_containerno=	'$_POST[shiper_containerno]', 
		shiper_containerno_shw=	'$_POST[shiper_containerno_shw]', 
		consignment_details_shw=	'$_POST[consignment_details_shw]', 
		consignment_details='$_POST[consignment_details]'
	";
	$sql="INSERT INTO $fields";
	if($_POST[cert_id]){
		$sql="update $fields where certificateno='$_POST[cert_id]' ";
		$msg="Certificate Updated Sucessfully ";
	}else{
		$sql="INSERT INTO $fields, certificateno='$_REQUEST[sub_cert_id]', sub_certificateno='$sub_c' ";
		$msg="New Entry Sucessfully Entered";
	}
	//echo "<pre>$sql</pre>"; //die("");
	
	$result=mysql_query($sql) or die(mysql_error().'<br><br>Error in creating Certificate');
	if($_POST[cert_id]){
		$certificateno=$_POST[cert_id];
	}else{
		$certificateno=mysql_insert_id();
	}
	//print "no=".$certificateno."<br />";
	?>
<?php 
	if($_REQUEST[stax]=='yes'){
		$srtax=$_REQUEST[srtax];
	}else{
		$srtax=0;
	}
	
	$dis_test=$_REQUEST[discount];
	if($dis_test==''){
		$dis_amt=0;
	}else{
		$dis_amt=$_REQUEST[discount];
	}
	
	if($_REQUEST[famount]>0){
		if($_SESSION['city']=="ludhiana"){
			$dat=date("Y-m-d");
			if($_SESSION['formthree']=='inserted'){
				$dat=date("Y-m-d");
				$sql="INSERT INTO invoices(clnid, ajtid, certid, dtd, famount, tamount, mamount, amount, discount, servicetax, grandtotal, invstatus, cmntz, branch, hsn, uom, gst_combine, qty, product)
				VALUES('$_REQUEST[clntid]', '$_REQUEST[ajtname]', '$certino', '$dat', '$_REQUEST[famount]', '$_REQUEST[tamount]', '$_REQUEST[mamount]', '$_REQUEST[amount]', '$_REQUEST[discount]', '$srtax', '$_REQUEST[finalone]', 'pending', '$_REQUEST[particular]', '$_SESSION[city]', '$_REQUEST[hsn]', '$_REQUEST[uom]', '$_REQUEST[gst_combine]', '$_REQUEST[qty]', '$_REQUEST[product]')";
				$result=mysql_query($sql) or die('error in inserting ');
				$invoiceid=mysql_insert_id();
			}
	
			if($_SESSION['formfive']=='inserted'){
				$dat=date("Y-m-d");
				$sql="INSERT INTO invoices(clnid, ajtid, certid, dtd, famount, tamount, mamount, amount, discount, servicetax, grandtotal, invstatus, cmntz, branch, hsn, uom, gst_combine, qty, product)
				VALUES('$_REQUEST[clntid]', '$_REQUEST[ajtname]', '$certino', '$dat', '$_REQUEST[famount]', '$_REQUEST[tamount]', '$_REQUEST[mamount]', '$_REQUEST[amount]', '$_REQUEST[discount]', '$srtax', '$_REQUEST[finalone]', 'pending', '$_REQUEST[particular]', '$_SESSION[city]', '$_REQUEST[hsn]', '$_REQUEST[uom]', '$_REQUEST[gst_combine]', '$_REQUEST[qty]', '$_REQUEST[product]')";
				$result=mysql_query($sql) or die('error in inserting ');
				$invoiceid=mysql_insert_id();
			}
		}else{
			$dat=date("Y-m-d");
			if($_SESSION['formthree']=='inserted'){
				$dat=date("Y-m-d");
				$sql="INSERT INTO invoices(clnid, ajtid, certid, dtd, famount, tamount, mamount, amount, discount, servicetax, grandtotal, invstatus, cmntz, branch, hsn, uom, gst_combine, qty, product)
				VALUES('$_REQUEST[clntid]', '$_REQUEST[ajtname]', '$certino', '$dat', '$_REQUEST[famount]', '$_REQUEST[tamount]', '$_REQUEST[mamount]', '$_REQUEST[amount]', '$_REQUEST[discount]', '$srtax', '$_REQUEST[finalone]', 'pending', '$_REQUEST[particular]', '$_SESSION[city]', '$_REQUEST[hsn]', '$_REQUEST[uom]', '$_REQUEST[gst_combine]', '$_REQUEST[qty]', '$_REQUEST[product]')";
				$result=mysql_query($sql) or die('error in inserting ');
				$invoiceid=mysql_insert_id();
			}
	
			if($_SESSION['formfive']=='inserted'){
				$dat=date("Y-m-d");
				$sql="INSERT INTO invoices(clnid, ajtid, certid, dtd, famount, tamount, mamount, amount, discount, servicetax, grandtotal, invstatus, cmntz, branch, hsn, uom, gst_combine, qty, product)
				VALUES('$_REQUEST[clntid]', '$_REQUEST[ajtname]', '$certino', '$dat', '$_REQUEST[famount]', '$_REQUEST[tamount]', '$_REQUEST[mamount]', '$_REQUEST[amount]', '$_REQUEST[discount]', '$srtax', '$_REQUEST[finalone]', 'pending', '$_REQUEST[particular]', '$_SESSION[city]', '$_REQUEST[hsn]', '$_REQUEST[uom]', '$_REQUEST[gst_combine]', '$_REQUEST[qty]', '$_REQUEST[product]')";
				$result=mysql_query($sql) or die('error in inserting ');
				$invoiceid=mysql_insert_id();
			}
		}
	}
	$_SESSION['formthree']='wrong';
	$_SESSION['formfive']='wrong';
	?>
<table align="center" width="100%" border="0">
	<tr>
		<td>New NSMP Certificate Sucessfully Entered</td>
		<td>Certificate # <?php print $sub_c;?></td>
		<!-- <td>Invoice ID# <?php print $invoiceid;?></td> -->
	</tr>
	<tr>
		<td>
			<?php
			if(isset($_REQUEST['formno']) && $_REQUEST['formno']=="e" ) {
				echo '<form action="printcertsse.php" method="get" target="_blank">';	
			}else{
				echo '<form action="../print/nspm_sub.php" method="get" target="_blank">';
			}
			?>
			<input type="hidden" name="id" value="<?php echo $certificateno; ?>">
			<input type="submit" value="Print Certificate"></form>
		</td>
		<td align=center><a href=certificate.php>Click here to Get Back Home</a></td>
		<!-- <td align=right>
			<form action="../print/printinvc.php" method="get" target="_blank">
				<input type="hidden" name="iid" value="<?php echo"$invoiceid";?>">
				<input type="hidden" name="cype" value="ppq">
				<input type="submit" value="Print Invoice">
			</form>
		</td> -->
		<td><a href="cretid_report.php?cid=<?=$certificateno;?>" target="_blank">Fumigation Record</a></td>
	</tr>
</table>
<?php
include"../foot.php";
?>
<br><br><br>


PK 99