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 : 18.227.209.89


Current Path : /proc/thread-self/root/var/www/html/phdadm/pgetadm/
Upload File :
Current File : //proc/thread-self/root/var/www/html/phdadm/pgetadm/saveApplication_old_12102019.php

<?php

function saveApplication($aobj_context)
{
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
	$data = $aobj_context->mobj_data["data"];
	include_once($aobj_context->main_src."/json.php"); 
	$json = new Services_JSON();
	//recieve decode json string of personal info
	$lstr_param = stripslashes($aobj_context->mobj_data["data"]);
	$per_arr_data = json_decode($lstr_param, true);
	$feestr = stripslashes($aobj_context->mobj_data["feestr"]);
	$feestr = json_decode($feestr, true);	
	$fappno = stripslashes($aobj_context->mobj_data["fappno"]);
	$final_submit = stripslashes($aobj_context->mobj_data["final"]);
	////recieve decode json string of subject info

	$strSubject = stripslashes($aobj_context->mobj_data["pRgSubjects"]);
	$sub_arr_data = json_decode($strSubject, true);	
	
	// $aobj_context->main_src = realpath(__DIR__ . '/../..');

	$rgMultiMarks = stripslashes($aobj_context->mobj_data["rgMultiMarks"]);
	$MultiMarks_arr_data = json_decode($rgMultiMarks, true);	

	
	$strSubjects = implode("','", $sub_arr_data);
	//convert to Associative array
	$rgPerArray = array();


	for($i=0; $i<count($per_arr_data); $i++)
	{
		$rgPerArray[$per_arr_data[$i]['id']] = $per_arr_data[$i]['value'];

	}
	//For phd admissions assuming examno and college code
	// var_dump($rgPerArray);
	/*$degree  = $rgPerArray['idDegree'];
	$college = $rgPerArray['idCollege'];
	if($degree == '' || $college == '')
	{
		$arr['message'] = '1. Error in saving admission details. Send query through I NEED HELP.';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
		return;
	}*/

/*	$query = "select FCONTACT_NO, fappno from studadm 
	where FCONTACT_NO = '{$rgPerArray['stuMobileno']}'";
	$studresult =  $aobj_context->mobj_db->GetRow($query); 

	if(count($studresult) >0)
		$fappno = $studresult['fappno']; */
	
	// $arr['message'] = 'Last Date is Over. Contact University';
	// echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
	// return;

	if($rgPerArray['fdegree1'] == '' || $rgPerArray['fcategory'] == '') {
		$arr['message'] = 'Error in submitting the application. Enter Degree and category';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
		return;
	}

	if($fappno == '')
	{		
		$get_last_no="select right(concat('0000',ifnull(max(FSLNO),0)+01),4) as app_no 
		from studadm
		WHERE FDEGREE='{$rgPerArray['idDegree']}' and FCOLLCODE = '{$rgPerArray['idCollege']}'";
		$obj =  $aobj_context->mobj_db->GetRow($get_last_no); 
		$sl_no = "0000".$obj['app_no']; 
		$sl_no = substr($sl_no, -4);

		$rgPerArray['cadd1'] = $rgPerArray['cadd1'];
		$rgPerArray['cadd2'] = $rgPerArray['cadd2'];
		$rgPerArray['cadd3'] = $rgPerArray['cadd3'];

		$rgPerArray['padd1'] = $rgPerArray['padd1'];
		$rgPerArray['padd2'] = $rgPerArray['padd2'];
		$rgPerArray['padd3'] = $rgPerArray['padd3'];

		// $query = "select FADMPREFIX from control";
		// $results = $aobj_context->mobj_db->GetRow($query);
		// $FADMPREFIX = $results['FADMPREFIX'];

		/*$query = "select internal_code+1 as FAUTOINCREMENT from studadm 
		order by internal_code desc limit 1";
		$results = $aobj_context->mobj_db->GetRow($query);
		$FAUTOINCREMENT = $results['FAUTOINCREMENT'];

		$appno = $FADMPREFIX.$FAUTOINCREMENT;
		$fappno = $appno;*/
		
		$insert_qry="insert into pgstudadm 
		(FAPPNO, FMOBILENO,
		FDEGREE1,FDEGREE2,FDEGREE3, 
		FDEGREE4,FDEGREE5,FDEGREE6,
		FNAME,FNATIONAL,
		FGENDER,FDOB,
		FFATNAME,FFATOCC,FMOTNAME,
		FMOTOCC, FOGIRL,FCATEGORY,
		FPMREGNO,FINCOME,FBPL,
		FKARSTUDY,FAADHARNO,FSSLCREGNO,
		FPERMADD1, FPERMADD2,FPERMADD3,
		FPERMDIST,FPERMSTATE,FPERMPIN,
		FCURRADD1,FCURRADD2,FCURRADD3,
		FCURRDIST, FCURRSTATE,FCURRPIN,
		FEMAIL,FKASHMIR,FHK,
		FJK,FRURAL,FKANNADA,
		FBCUE,FBCUETYPE,FSPORTS,
		FCULTURE, FNCC,FNSS,
		FDEFENCE,
		FHANDICAP,FQDEGREE,FQUTYPE,
		FQUNIV,
		FQYEAR,FQMONTH,FQREGNO,
		FQCLASS, FQMAXMARKS,FQSECMARKS,
		FQPERCENTAGE,FLANG1,FLANG1MM,
		FLANG1MS,FLANG2,FLANG2MM,
		FLANG2MS,FOPT1,FOPT1MM,
		FOPT1MS,FOPT2,FOPT2MM,
		FOPT2MS,FOPT3,FOPT3MM,
		FOPT3MS,FOPT4,FOPT4MM,FOPT4MS,
		FPUMAT, FPUBIO,FPGDEGREE, FPGQDEGREE, 
		FPGUNIVTYPE,FPGUNIV,FPGYEAR,FPGMONTH,FPGREGNO,FPGMAXMARKS,FPGSECMARKS,FOTHEXAM,
		FSPONSOR,FOTHINFO,FTOTFEE,FDOCATTEST, FCREATEDATE,FCREATEUSER, FFINSUB, FRESSTAT)
		values   
		('{$rgPerArray['fmobileno']}', '{$rgPerArray['fmobileno']}',
		'{$rgPerArray['fdegree1']}','{$rgPerArray['fdegree2']}','{$rgPerArray['fdegree3']}',
		'{$rgPerArray['fdegree4']}','{$rgPerArray['fdegree5']}','{$rgPerArray['fdegree6']}',
		'{$rgPerArray['fname']}','{$rgPerArray['fnational']}',
		'{$rgPerArray['fgender']}', date_format(STR_TO_DATE('{$rgPerArray['fdob']}','%d/%m/%Y'),'%Y-%m-%d'),
		'{$rgPerArray['ffatname']}','{$rgPerArray['ffatocc']}', '{$rgPerArray['fmotname']}',
		'{$rgPerArray['fmotocc']}','{$rgPerArray['fogirl']}', '{$rgPerArray['fcategory']}', 
		'{$rgPerArray['fpmregno']}', '{$rgPerArray['fincome']}','{$rgPerArray['fbpl']}',
		'{$rgPerArray['fkarstudy']}','{$rgPerArray['faadharno']}', '{$rgPerArray['fsslcregno']}', 
		'{$rgPerArray['fpermadd1']}','{$rgPerArray['fpermadd2']}','{$rgPerArray['fpermadd3']}',
		'{$rgPerArray['fpermdist']}', '{$rgPerArray['fpermstate']}', '{$rgPerArray['fpermpin']}',
		'{$rgPerArray['fcurradd1']}', '{$rgPerArray['fcurradd2']}','{$rgPerArray['fcurradd3']}',
		'{$rgPerArray['fcurrdist']}', '{$rgPerArray['fcurrstate']}', '{$rgPerArray['fcurrpin']}',
		'{$rgPerArray['femail']}','{$rgPerArray['fkashmir']}','{$rgPerArray['fhk']}',
		'{$rgPerArray['fjk']}','{$rgPerArray['frural']}', '{$rgPerArray['fkannada']}',
		'{$rgPerArray['fbcue']}','{$rgPerArray['fbcuetype']}', '{$rgPerArray['fsports']}',
		'{$rgPerArray['fculture']}','{$rgPerArray['fncc']}', '{$rgPerArray['fnss']}', 
		'{$rgPerArray['fdefence']}',
		'{$rgPerArray['fhandicap']}', '{$rgPerArray['fqdegree']}', '{$rgPerArray['fqutype']}',
		'{$rgPerArray['fquniv']}',
		'{$rgPerArray['fqyear']}', '{$rgPerArray['fqmonth']}', '{$rgPerArray['fqregno']}',
		'{$rgPerArray['fqclass']}', '{$rgPerArray['fqmaxmarks']}','{$rgPerArray['fqsecmarks']}',
		'{$rgPerArray['fqpercentage']}', '{$rgPerArray['flang1']}','{$rgPerArray['flang1mm']}',
		'{$rgPerArray['flang1ms']}','{$rgPerArray['flang2']}', '{$rgPerArray['flang2mm']}',
		'{$rgPerArray['flang2ms']}', '{$rgPerArray['fopt1']}','{$rgPerArray['fopt1mm']}',
		'{$rgPerArray['fopt1ms']}','{$rgPerArray['fopt2']}', '{$rgPerArray['fopt2mm']}',
		'{$rgPerArray['fopt2ms']}', '{$rgPerArray['fopt3']}', '{$rgPerArray['fopt3mm']}',
		'{$rgPerArray['fopt3ms']}', '{$rgPerArray['fopt4']}',
		'{$rgPerArray['fopt4mm']}','{$rgPerArray['fopt4ms']}', '{$rgPerArray['fpumat']}',
		'{$rgPerArray['fpubio']}',
		'{$rgPerArray['fpgdegree']}', '{$rgPerArray['fpgqdegree']}', '{$rgPerArray['fpgunivtype']}', '{$rgPerArray['fpguniv']}',
		 '{$rgPerArray['fpgyear']}',
		'{$rgPerArray['fpgmonth']}','{$rgPerArray['fpgregno']}', '{$rgPerArray['fpgmaxmarks']}',
		'{$rgPerArray['fpgsecmarks']}', '{$rgPerArray['fothexam']}',
		'{$rgPerArray['fsponsor']}','{$rgPerArray['fothinfo']}','{$rgPerArray['ftotfee']}',
		'{$rgPerArray['fdocattest']}', now(), 'STUDENT', '{$final_submit}', 
		'{$rgPerArray['fresstat']}')";
		// var_dump($results);
		$results = $aobj_context->mobj_db->Execute($insert_qry);
		if($results)
		{
			$query = "select internal_code, control.funivcode 
			from pgstudadm, control 
			where fmobileno = '{$rgPerArray['fmobileno']}' 
			and fappno = '{$rgPerArray['fmobileno']}'"; 
			$results2 = $aobj_context->mobj_db->GetRow($query);
			if(count($results2) > 0)
			{
				$internal_code = $results2['internal_code'];
				$funivcode = substr($results2['funivcode'],1,2);
				
				$fappno = '8'.$funivcode.$internal_code;

				$query = "update pgstudadm set fappno = '{$fappno}' 
				where fmobileno = '{$rgPerArray['fmobileno']}' 
				and fappno = '{$rgPerArray['fmobileno']}'";

				$results3 = $aobj_context->mobj_db->Execute($query);
				$feestr = $feestr['data'];

				foreach($feestr as $k=>$v){
					$ins_query = "insert into admfeedetl(FYEAR,FDEGREE,FEXAMNO,FCOLLCODE,FSLNO,FHEADCODE,FAMOUNT,FAPPNO)
					values('2019','PGCET','A','9997',right($fappno,4),'{$v['feehead']}','{$v['fee']}' ,'{$fappno}')";
					$results = $aobj_context->mobj_db->Execute($ins_query);
				}

			}
			else
			{
				$arr['message'] = '2. Error in saving admission details. Send query through I NEED HELP.';
				echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
				return;
			}

		}
	}
	else
	{

		$query = "select internal_code, ifnull(fpaystatus,'') as  fpaystatus
			from pgstudadm
			where fmobileno = '{$rgPerArray['fmobileno']}'"; 
		$results2 = $aobj_context->mobj_db->GetRow($query);
		$fpaystatus = $results2['fpaystatus'];

		if($fpaystatus == 'success') {
			$final_submit = 'T';
		}
		
		$query = "update pgstudadm set 
		FDEGREE1 = '{$rgPerArray['fdegree1']}',
		FDEGREE2 = '{$rgPerArray['fdegree2']}',
		FDEGREE3 = '{$rgPerArray['fdegree3']}',
		FDEGREE4 = '{$rgPerArray['fdegree4']}',
		FDEGREE5 = '{$rgPerArray['fdegree5']}',
		FDEGREE6 = '{$rgPerArray['fdegree6']}',
		FNAME = '{$rgPerArray['fname']}',
		FNATIONAL = '{$rgPerArray['fnational']}',
		FGENDER = '{$rgPerArray['fgender']}',
		FDOB = date_format(STR_TO_DATE('{$rgPerArray['fdob']}','%d/%m/%Y'),'%Y-%m-%d'),
		FFATNAME = '{$rgPerArray['ffatname']}',
		FFATOCC = '{$rgPerArray['ffatocc']}',
		FMOTNAME = '{$rgPerArray['fmotname']}',
		FMOTOCC = '{$rgPerArray['fmotocc']}',
		FOGIRL = '{$rgPerArray['fogirl']}',
		FCATEGORY = '{$rgPerArray['fcategory']}',
		FPMREGNO = '{$rgPerArray['fpmregno']}',
		FINCOME = '{$rgPerArray['fincome']}',
		FBPL = '{$rgPerArray['fbpl']}',
		FKARSTUDY = '{$rgPerArray['fkarstudy']}',
		FAADHARNO = '{$rgPerArray['faadharno']}',
		FSSLCREGNO = '{$rgPerArray['fsslcregno']}',
		FPERMADD1 = '{$rgPerArray['fpermadd1']}',
		FPERMADD2 = '{$rgPerArray['fpermadd2']}',
		FPERMADD3 = '{$rgPerArray['fpermadd3']}',
		FPERMADD4 = '{$rgPerArray['fpermadd4']}',
		FPERMDIST = '{$rgPerArray['fpermdist']}',
		FPERMSTATE = '{$rgPerArray['fpermstate']}',
		FPERMPIN = '{$rgPerArray['fpermpin']}',
		FCURRADD1 = '{$rgPerArray['fcurradd1']}',
		FCURRADD2 = '{$rgPerArray['fcurradd2']}',
		FCURRADD3 = '{$rgPerArray['fcurradd3']}',
		FCURRADD4 = '{$rgPerArray['fcurradd4']}',
		FCURRDIST = '{$rgPerArray['fcurrdist']}',
		FCURRSTATE = '{$rgPerArray['fcurrstate']}',
		FCURRPIN = '{$rgPerArray['fcurrpin']}',
		FEMAIL = '{$rgPerArray['femail']}',
		FKASHMIR = '{$rgPerArray['fkashmir']}',
		FHK = '{$rgPerArray['fhk']}',
		FJK = '{$rgPerArray['fjk']}',
		FRURAL = '{$rgPerArray['frural']}',
		FKANNADA = '{$rgPerArray['fkannada']}',
		FBCUE = '{$rgPerArray['fbcue']}',
		FBCUETYPE = '{$rgPerArray['fbcuetype']}',
		FSPORTS = '{$rgPerArray['fsports']}',
		FCULTURE = '{$rgPerArray['fculture']}',
		FNCC = '{$rgPerArray['fncc']}',
		FNSS = '{$rgPerArray['fnss']}',
		FDEFENCE = '{$rgPerArray['fdefence']}',
		FHANDICAP = '{$rgPerArray['fhandicap']}',
		FQDEGREE = '{$rgPerArray['fqdegree']}',
		FQUTYPE = '{$rgPerArray['fqutype']}',
		FQUNIV = '{$rgPerArray['fquniv']}',
		FQYEAR = '{$rgPerArray['fqyear']}',
		FQMONTH = '{$rgPerArray['fqmonth']}',
		FQREGNO = '{$rgPerArray['fqregno']}',
		FQCLASS = '{$rgPerArray['fqclass']}',
		FQMAXMARKS = '{$rgPerArray['fqmaxmarks']}',
		FQSECMARKS = '{$rgPerArray['fqsecmarks']}',
		FQPERCENTAGE = '{$rgPerArray['fqpercentage']}',
		FLANG1 = '{$rgPerArray['flang1']}',
		FLANG1MM = '{$rgPerArray['flang1mm']}',
		FLANG1MS = '{$rgPerArray['flang1ms']}',
		FLANG2 = '{$rgPerArray['flang2']}',
		FLANG2MM = '{$rgPerArray['flang2mm']}',
		FLANG2MS = '{$rgPerArray['flang2ms']}',
		FOPT1 = '{$rgPerArray['fopt1']}',
		FOPT1MM = '{$rgPerArray['fopt1mm']}',
		FOPT1MS = '{$rgPerArray['fopt1ms']}',
		FOPT2 = '{$rgPerArray['fopt2']}',
		FOPT2MM = '{$rgPerArray['fopt2mm']}',
		FOPT2MS = '{$rgPerArray['fopt2ms']}',
		FOPT3 = '{$rgPerArray['fopt3']}',
		FOPT3MM = '{$rgPerArray['fopt3mm']}',
		FOPT3MS = '{$rgPerArray['fopt3ms']}',
		FOPT4 = '{$rgPerArray['fopt4']}',
		FOPT4MM = '{$rgPerArray['fopt4mm']}',
		FOPT4MS = '{$rgPerArray['fopt4ms']}',
		FPUMAT = '{$rgPerArray['fpumat']}',
		FPUBIO = '{$rgPerArray['fpubio']}',
		FPGDEGREE = '{$rgPerArray['fpgdegree']}',
		FPGQDEGREE = '{$rgPerArray['fpgqdegree']}',
		FPGUNIVTYPE = '{$rgPerArray['fpgunivtype']}',
		FPGUNIV = '{$rgPerArray['fpguniv']}',
		FPGQCLASS = '{$rgPerArray['fpgqclass']}',
		FPGYEAR = '{$rgPerArray['fpgyear']}',
		FPGMONTH = '{$rgPerArray['fpgmonth']}',
		FPGREGNO = '{$rgPerArray['fpgregno']}',
		FPGMAXMARKS = '{$rgPerArray['fpgmaxmarks']}',
		FPGSECMARKS = '{$rgPerArray['fpgsecmarks']}',
		FOTHEXAM = '{$rgPerArray['fothexam']}',
		FSPONSOR = '{$rgPerArray['fsponsor']}',
		FOTHINFO = '{$rgPerArray['fothinfo']}',
		FTOTFEE = '{$rgPerArray['ftotfee']}',
		FDOCATTEST = '{$rgPerArray['fdocattest']}',
		FFINSUB = '{$final_submit}',
		FRESSTAT = '{$rgPerArray['fresstat']}'
		where fappno = '{$fappno}'";
		
		$results = $aobj_context->mobj_db->Execute($query);

		if($results)
		{
			$query = "select fslno from studadm where fappno = '{$fappno}'";
			$res =  $aobj_context->mobj_db->GetRow($query);

			$feestr = $feestr['data'];

			$del_query = "delete from admfeedetl where fappno = '{$fappno}'";
			$results = $aobj_context->mobj_db->Execute($del_query);
			foreach($feestr as $k=>$v){
				$ins_query = "insert into admfeedetl(FYEAR,FDEGREE,FEXAMNO,FCOLLCODE,FSLNO,FHEADCODE,FAMOUNT,FAPPNO)
				values('2019','PGCET','A','9997',right($fappno,4),'{$v['feehead']}','{$v['fee']}' ,'{$fappno}')";
				$results = $aobj_context->mobj_db->Execute($ins_query);
			}
		}
	}

	if($results) 
	{
		$photo_filename = $rgPerArray['photo_path'];
		
		if($photo_filename != '' && $photo_filename != NULL)
		{
			$image_path = $aobj_context->main_src."upload/{$photo_filename}";
			$ext = pathinfo($photo_filename, PATHINFO_EXTENSION);
			$photo_filename = $fappno;
			$photo_filename = $photo_filename.".".$ext;

			$full_file_path = $aobj_context->main_src."pget_photos/".$photo_filename;

			$photo = "pget_photos/".$photo_filename;
			
			if(copy($image_path,$full_file_path))
			{
				$update="update pgstudadm set FPHOTOPATH='{$photo}' 
						where FAPPNO=  '{$fappno}'";
				$up_obj=$aobj_context->mobj_db->Execute($update); 
				unlink($image_path);
			}
		}

		$data='Your Application is submitted successfully.';
		$arr['message']= $data;
		$arr['app_no'] = $fappno;
		$arr['slno']  = $slnocnt;
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
		return;
	}	
	else
	{
		$arr['message'] = 'Error in submitting the application.';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
		return;
	}

}


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

	$query = "select ifnull(fappno,'') as fappno from studadm 
	where FCONTACT_NO = '{$_SESSION['MOBILE']}' and ffinsub = 'T'";

	$obj =  $aobj_context->mobj_db->GetRow($query); 
	// var_dump($obj);
	$row['appno'] = $obj['fappno'];
	$row['error_code'] = '0';
	if($obj['fappno'] == '')
	{
		$row['error_code'] = '1';
	}
	echo json_encode($row);

}