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


Current Path : /var/www/html/phdadm/pgetadm/
Upload File :
Current File : /var/www/html/phdadm/pgetadm/option-entry.php

<?php

function getOptionEntryDet($aobj_context) 
{
	session_start();
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

	$query_pgadmdate = "select * from collexam where fcollcode = 'pget'
    and fdegree = 'opent'
    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'] = "Last Date to modify option-entry is over";
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-2,"Failure"); 
      return;
	}

	$query2 = "select ifnull(fappno,'') as fappno,
	ifnull(ffinsub,'F') as ffinsub,ifnull(fpaystatus,'F') as fpaystatus 
	from entstudadm 
	where fmobileno = '{$_SESSION['MOBILE']}'";
	$qry2 =  $aobj_context->mobj_db->GetAll($query2);
	if(count($qry2) == 0) {
		$arr['msg'] = 'Option Entry not available.';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
		return;
	}

	if($qry2[0]['fpaystatus'] == 'success')
	{
		$arr['msg'] = "After Payment not allowed modify option-entry";
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-2,"Failure"); 
		return;
	}

	$query = "select fentoptround from control";
	$res1 =  $aobj_context->mobj_db->GetRow($query);
	if($res1['fentoptround'] == 'OR') {
		$fappno = $qry2[0]['fappno'];
		$ffinsub = $qry2[0]['ffinsub'];
		$fpaystatus = $qry2[0]['fpaystatus'];

		$query1 = "select x.fdegree, concat(fdescpn) as degree, 
		concat(fcollname) as college, x.fcollcode
		from entcolldeg x inner join entdeg y on x.fdegree = y.fdegree
		inner join entcoll z on x.fcollcode = z.fcollcode
		inner join entoptdeg deg on deg.fdegree = x.fdegree 
		where deg.fappno ='{$fappno}'
		order by x.fdegree, z.forder,x.fcollcode";
		//var_dump($query1);
		$obj =  $aobj_context->mobj_db->GetAll($query1);
		
		$query3 = "select * from entoptions 
		where fappno = '{$fappno}' and fentoptround = '{$res1['fentoptround']}' 
		order by fpriority";
		  $result2 = $aobj_context->mobj_db->GetAll($query3);
		  //var_dump($query3);
		if(count($obj) > 0) {
	
			$res['fappno'] = $fappno;
			$res['fround'] = $res1['fentoptround'];
			$res['optent'] = $obj;
			$res['priority'] = $result2;
			$res['ffinsub'] = $ffinsub;
			$res['fpaystatus'] = $fpaystatus;
			echo $aobj_context->mobj_output->ToJSONEnvelope($res,0,"success"); 
			return;
		}
		else {
			$arr['msg'] = 'Error in fetching option entry details.';
			echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
			return;
		}
	} else {

		$fappno = $qry2[0]['fappno'];
		$ffinsub = $qry2[0]['ffinsub'];
		$fpaystatus = $qry2[0]['fpaystatus'];

		$query3 = "select ifnull(fchoice,'-') as fchoice, ifnull(fseatstatus,'-') as fseatstatus  
		from entseatallot st, control c
		where c.fentround = st.fallotround
		and fappno = '{$fappno}'";
		$res = $aobj_context->mobj_db->GetRow($query3);

		if($res['fchoice'] == '-')
		{
			$arr['msg'] = 'Kindly choose your willingness in Seat Allotment to make changes in Options entry. 
			Options entry will be enabled only if choice is selected. Call Help Desk for clarifications.';
			echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
			return;
		}

		if($res['fseatstatus'] == 'Confirmed')
		{
			$arr['msg'] = 'You have already made the payment for the confirmed seat.
			Options entry will not be allowed. Call Help Desk for clarifications.';
			echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
			return;
		}

		//var_dump($query2);
		$query1 = "select x.fdegree, concat(fdescpn) as degree, 
		concat(fcollname) as college, x.fcollcode
		from entcolldeg x inner join entdeg y on x.fdegree = y.fdegree
		inner join entcoll z on x.fcollcode = z.fcollcode
		inner join entoptdeg deg on deg.fdegree = x.fdegree 
		where deg.fappno ='{$fappno}'
		order by x.fdegree,  z.forder, x.fcollcode";
		//var_dump($query1);
		$obj =  $aobj_context->mobj_db->GetAll($query1);
		
		$query3 = "select op.fdegree,op.fcollcode,op.fpriority,
		if(ifnull(st.fdegree,'') = '',op.fpriority,'99') as ffreze 
		from entoptions op 
		left outer join entseatallot st on 
		op.fappno = st.fappno 
		and op.fdegree = st.fdegree 
		and op.fcollcode = st.fcollcode
		and ifnull(st.fallotround,'0') <> '0'
		where op.fappno = '{$fappno}'
		order by fpriority";
		$result2 = $aobj_context->mobj_db->GetAll($query3);
		//var_dump($query3);
		if(count($obj) > 0) {

			$res['fappno'] = $fappno;
			$res['optent'] = $obj;
			$res['priority'] = $result2;
			$res['ffinsub'] = $ffinsub;
			$res['fpaystatus'] = $fpaystatus;
			echo $aobj_context->mobj_output->ToJSONEnvelope($res,0,"success"); 
		}
		else {
			$arr['msg'] = 'Error in fetching option entry details.';
			echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
		}
		return;
	}

}

function saveOptionEntryDet($aobj_context) 
{
	session_start();
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
	$data = json_decode($aobj_context->mobj_data['options'], true);

	// $res = true;
	// if($res) {
	// 	$arr['msg'] = 'Last date is over';
	// 	echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
	// 	return;
	//  } 
	$query_pgadmdate = "select * from collexam where fcollcode = 'pget'
    and fdegree = 'opent'
    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'] = "Last Date to modify option-entry is over";
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-2,"Failure"); 
      return;
    }

	$query = "select fappno from entstudadm where fmobileno = '{$_SESSION['MOBILE']}'";
	$obj =  $aobj_context->mobj_db->GetRow($query); 
	$appno = $obj['fappno'];

	if($appno == "") {
		$arr['msg'] = 'Application Payment Not done';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
		return;
	}

	$query = "select fentoptround from control";
	$res1 =  $aobj_context->mobj_db->GetRow($query);

	if($res1['fentoptround'] == 'OR') {

		$values = "";
		foreach($data as $value) {
			$values .= "('{$appno}', '{$value['degree']}', '{$value['college']}', '{$value['priority']}', '{$res1['fentoptround']}'),";
		}

		$values = rtrim($values, ',');
		$delete = "delete from entoptions where fappno = '{$appno}' and fentoptround = '{$res1['fentoptround']}'";

		$res =  $aobj_context->mobj_db->Execute($delete); 

		$insert = "insert into entoptions(fappno, fdegree, fcollcode, fpriority, fentoptround) 
		values  $values ";
		$res =  $aobj_context->mobj_db->Execute($insert); 
		// var_dump($insert);
		if($res) {
			$arr['msg'] = "Preferences saved successfully.";
			echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
		}
		else {
			$arr['msg'] = 'Error While saving preferences.';
			echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 	
		}

	}
	else {
		$query3 = "select ifnull(fchoice,'-') as fchoice, ifnull(fseatstatus,'-') as fseatstatus  
		from entseatallot st, control c
		where c.fentround = st.fallotround
		and fappno = '{$appno}'";
		$res1 = $aobj_context->mobj_db->GetRow($query3);

		if($res1['fchoice'] == '-')
		{
			$arr['msg'] = 'Kindly choose your willingness in Seat Allotment to make changes in Options entry. 
			Options entry will be enabled only if choice is selected. Call Help Desk for clarifications.';
			echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
			return;
		}

		if($res1['fseatstatus'] == 'Confirmed')
		{
			$arr['msg'] = 'You have already made the payment for the confirmed seat.
			Options entry will not be allowed. Call Help Desk for clarifications.';
			echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
			return;
		}

		$values = "";
		foreach($data as $value) {
			$values .= "('{$appno}', '{$value['degree']}', '{$value['college']}', '{$value['priority']}', '1'),";
		}

		$values = rtrim($values, ',');
		$delete = "delete from entoptions where fappno = '{$appno}' and fround = '1'";

		$res =  $aobj_context->mobj_db->Execute($delete); 

		$insert = "insert into entoptions(fappno, fdegree, fcollcode, fpriority, fround) 
		values  $values ";
		$res =  $aobj_context->mobj_db->Execute($insert); 

		if($res) {
			$arr['msg'] = "Preferences saved successfully.";
			echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
		}
		else {
			$arr['msg'] = 'Error While saving preferences.';
			echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 	
		}

	}

}

function UpdateSSSforStudent($aobj_context) {
	session_start();
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);	
	$fappno = $aobj_context->mobj_data['fappno'];
	$response = $aobj_context->mobj_data['response'];

	$query = "update entstudadm set fselfsupsch = '{$response}' where fappno = '{$fappno}'";

	$res =  $aobj_context->mobj_db->Execute($query); 

	if($res) {
		$arr['msg'] = "Updated successfully.";
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
	}
	else {
		$arr['msg'] = 'Error While updating.';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 	
	}

}