0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 3.137.219.221


Current Path : /var/www/html/gug/
Upload File :
Current File : /var/www/html/gug/appPaymentDetAPI.php

<?php
	
	ini_set('max_execution_time', 600);
	require('includes/dbconnect.php'); //include database connection

	if(!isset($_POST['appno']) || !isset($_POST['univcode']) || !isset($_POST['amount']) 
		|| !isset($_POST['collcode']) || !isset($_POST['regno']))
	{
		$statusCode = 0;
		$statusMessage = "All parameters required. Please try again";
		
		$jsonLoginArray = array("statusCode" => $statusCode, "statusMessage" => $statusMessage);
		$returnString = json_encode($jsonLoginArray);
		print $returnString;
		exit;
	}

	$appno     = stripslashes($_POST['appno']);

	$studQuery = "SELECT fregno, fcollcode,ftotalfee, funivcode,appno,fdegree  FROM appcandsum, control  
				where APPNO='{$appno}'";

	$studResult =  $conn->query($studQuery);


	if(mysqli_num_rows($studResult) != 1)
	{
		$statusCode = 0;
		$statusMessage = "Invalid Challan Number. Please try again";
		
		$jsonLoginArray = array("statusCode" => $statusCode, "statusMessage" => $statusMessage);
		$returnString = json_encode($jsonLoginArray);
		print $returnString;
		exit;
	}
	else 
	{	
		$row1 = mysqli_fetch_array($studResult,MYSQLI_ASSOC);		

		$statusCode = 1;


		
		$funivcode = stripslashes($_POST['univcode']);
		$famount   = stripslashes($_POST['amount']);
		$fcollcode = stripslashes($_POST['collcode']);
		$fregno    = stripslashes($_POST['regno']);


		if($appno != $row1['appno'])
		{

			$statusCode = 0;
			$statusMessage = "Invalid application number. Please try again";
			
			$jsonLoginArray = array("statusCode" => $statusCode, "statusMessage" => $statusMessage);
			$returnString = json_encode($jsonLoginArray);
			print $returnString;
			exit;
		}

		if($fregno != $row1['fregno'])
		{

			$statusCode = 0;
			$statusMessage = "Invalid register number. Please try again";
			
			$jsonLoginArray = array("statusCode" => $statusCode, "statusMessage" => $statusMessage);
			$returnString = json_encode($jsonLoginArray);
			print $returnString;
			exit;
		}

		if($famount != $row1['ftotalfee'])
		{

			$statusCode = 0;
			$statusMessage = "Amount not matching. Please try again";
			
			$jsonLoginArray = array("statusCode" => $statusCode, "statusMessage" => $statusMessage);
			$returnString = json_encode($jsonLoginArray);
			print $returnString;
			exit;
		}	

		$productinfo = $row1['appno'];
		$fname = "HDFC Cash Mode";
		$collcode = $row1['fcollcode'];
		$degree = $row1['fdegree'];
		$regno = $row1['fregno'];

		$update="update appcandsum set FPAYMENTREMARKS='{$productinfo}',FPAYMENTSTATUS='success',
		FPAYMENTCONFIRM='success',FACKDATE=now(),FACKUSER='{$fname}',FPAYGATEWAY = '{$fname}'
		where APPNO='{$productinfo}'";
		$result = $conn->query($update);


		$update_cand_sum = "UPDATE appcandsum a,candsum c
		SET 
		c.FEXAMFEEA=if(ifnull(c.FEXAMFEEA,0) <=0,ifnull(a.FEXAMFEEA,0),ifnull(c.FEXAMFEEA,0)),
		c.FEXAMFEEB=if(ifnull(c.FEXAMFEEB,0) <=0,ifnull(a.FEXAMFEEB,0),ifnull(c.FEXAMFEEB,0)),
		c.FEXAMFEEC=if(ifnull(c.FEXAMFEEC,0) <=0,ifnull(a.FEXAMFEEC,0),ifnull(c.FEXAMFEEC,0)),
		c.FEXAMFEED=if(ifnull(c.FEXAMFEED,0) <=0,ifnull(a.FEXAMFEED,0),ifnull(c.FEXAMFEED,0)),
		c.FEXAMFEEE=if(ifnull(c.FEXAMFEEE,0) <=0,ifnull(a.FEXAMFEEE,0),ifnull(c.FEXAMFEEE,0)),
		c.FEXAMFEEF=if(ifnull(c.FEXAMFEEF,0) <=0,ifnull(a.FEXAMFEEF,0),ifnull(c.FEXAMFEEF,0)),
		c.FEXAMFEEG=if(ifnull(c.FEXAMFEEG,0) <=0,ifnull(a.FEXAMFEEG,0),ifnull(c.FEXAMFEEG,0)),
		c.FEXAMFEEH=if(ifnull(c.FEXAMFEEH,0) <=0,ifnull(a.FEXAMFEEH,0),ifnull(c.FEXAMFEEH,0)),
		c.FEXAMFEEI=if(ifnull(c.FEXAMFEEI,0) <=0,ifnull(a.FEXAMFEEI,0),ifnull(c.FEXAMFEEI,0)),
		c.FEXAMFEEJ=if(ifnull(c.FEXAMFEEJ,0) <=0,ifnull(a.FEXAMFEEJ,0),ifnull(c.FEXAMFEEJ,0)),
		c.FTOTALFEE=a.FTOTALFEE,
		c.frecptdate = date(now())
		WHERE a.fregno=c.FREGNO
		AND a.APPNO='{$productinfo}' and a.FCOLLCODE='{$collcode}'";

		$result = $conn->query($update_cand_sum); 
			

		$update_cand_appCand = "update canddet c, appcanddet t  
		set c.finserted = t.finserted,
		c.fpresent = t.fpresent
		where c.fdegree = t.fdegree
		and c.fexamno = t.fexamno
		and c.fregno = t.fregno
		and c.fsubcode = t.fsubcode
		and c.fdegree = '{$degree}' and  c.fregno = '{$regno}' and t.APPNO='{$productinfo}' 
		and ifnull(c.fpresent,'') <> 'P'";

		$result = $conn->query($update_cand_appCand); 


		$insert_canddet ="insert into canddet(fdegree,FEXAMNO, FCOLLCODE, FREGNO, FSUBCODE, FINSERTED, 
		FPRESENT, FYEAR, FEXAMTYPE)
		select fdegree, FEXAMNO, FCOLLCODE,FREGNO, FSUBCODE,FINSERTED, FPRESENT, FYEAR,FEXAMTYPE from appcanddet 
		where fregno = '{$regno}' and appno ='{$productinfo}' and CONCAT(fdegree,fexamno,fregno,fsubcode)
		not in(select CONCAT(fdegree,fexamno,fregno,fsubcode) from canddet where  fregno = '{$regno}')";

		$result = $conn->query($insert_canddet);

		$update_studfee = "update studfee s, appstudfee a
		set s.famount = a.famount,
		s.flogdate = a.flogdate
		where s.fdegree = a.fdegree
		and s.fexamno = a.fexamno
		and s.fregno = a.fregno
		and s.ffeecode = a.ffeecode
		and  s.fregno = '{$regno}' and a.appno ='{$productinfo}'";

		$result = $conn->query($update_studfee);
			
		$insert_studfee = "insert into studfee(fdegree,fexamno,fcollcode,fregno,ffeecode,famount,flogdate)
		select fdegree,fexamno,fcollcode,fregno,ffeecode,famount,flogdate from appstudfee where 
		fregno = '{$regno}' and appno ='{$productinfo}' and CONCAT(fdegree,fexamno,fregno,ffeecode) 
		not in(select CONCAT(fdegree,fexamno,fregno,ffeecode) from studfee where  fdegree = '{$degree}' 
		and fregno = '{$regno}')";

		$result = $conn->query($insert_studfee); 

		$statusCode = 1;
		$statusMessage = "Success";

		$jsonLoginArray = array("statusCode" => $statusCode, "statusMessage" => $statusMessage);
		$returnString = json_encode($jsonLoginArray);
		print $returnString;
		exit;

	}

?>