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


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

<?php

//require_once("/Library/WebServer/Documents/oasis/aws/aws-autoloader.php");
require_once("/var/www/html/aws/aws-autoloader.php");
// require_once("C:/XAMPP/htdocs/aws/aws-autoloader.php");
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;

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

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

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

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

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

	// $aobj_context->main_src = realpath(__DIR__ . '/../..');

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

	// if($final_submit == 'T') {
	// 	if(count($privackd_arr_data) == 0 || count($finaloptdeg_data) == 0
	// 	 ||  count($tot_arr_data) == 0 || count($sub_arr_data) == 0) {
	// 		$arr['message'] = '2. Error in saving admission details. Enter all the details for making final submission.';
	// 		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
	// 		return;
	// 	 } 
	// } 

	//var_dump($privackd_arr_data[0]['qulregno']);
	// var_dump($per_arr_data);
	
	//convert to Associative array
	$rgPerArray = array();
	// $res = true;	
	// if($res) 
	// {
	// 	$arr['message'] = 'Last date is over';
	// 	echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
	// 	return;
	// } 

	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;
	// die();
	// 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;
	// }
	//var_dump($rgPerArray);	
	if(!isset($_SESSION['MOBILE']) || $_SESSION['MOBILE'] == "" ) {
		$arr['message'] = 'Session Sxpired!!! Login and try again.';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
		return;
	}

	$query = "select ifnull(fappno,'') as fappno from entstudadm 
    where fmobileno = '{$_SESSION['MOBILE']}'";

	$result2 = $aobj_context->mobj_db->GetRow($query);
	if(count($result2) > 0) {
		$fappno = $result2['fappno'];
	}
	else {
		$fappno = "";
	}
	
	if($fappno == '')
	{		
		$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; 8073092172
		$fappno = $appno;*/
		
		$insert_qry="insert into entstudadm 
		(FAPPNO, FMOBILENO,
		FNAME,FNATIONAL,
		FGENDER,FDOB,
		FFATNAME,FFATOCC,FMOTNAME,
		FMOTOCC,FCATEGORY,
		FPMREGNO,FINCOME,FBPL,freligion,fmotherton,fsubcaste,
		fincomerdno,fcasterdno,fexservice,fbloodgrp,
		foutstud,fselfsupsch,
		FKARSTUDY,FAADHARNO,FSSLCREGNO,
		FPERMADD1, FPERMADD2,FPERMADD3,
		FPERMDIST,FPERMSTATE,FPERMPIN,
		FCURRADD1,FCURRADD2,FCURRADD3,
		FCURRDIST, FCURRSTATE,FCURRPIN,
		FEMAIL,FKASHMIR,FHK,fhkrdno,
		fhandicap,fsports,fncc,fdefence,
		FJK,FRURAL,FKANNADA,
		FBCUE,FBCUETYPE,
		fpdp,fcof,fcoh,fgah,fkanm,		
		FUNIVSTUD,
		FQDEGREE,FQCOMBCODE,
		FQUNIV,
		FQYEAR,FQMONTH,FQREGNO,
		FQCLASS, FQMAXMARKS,FQSECMARKS,
		FQPERCENTAGE,FLANG1,FLANG1MM,
		FLANG1MS,FLANG2,FLANG2MM,
		FLANG2MS,
		FQCOLLEGE,
		FLANMM,
		FLANMO,
		FPGDEGREE, FPGQDEGREE, 
		FPGUNIVTYPE,FPGUNIV,FPGYEAR,FPGMONTH,FPGREGNO,FPGMAXMARKS,FPGSECMARKS,FOTHEXAM,
		FSPONSOR,FOTHINFO,FTOTFEE,FDOCATTEST, FCREATEDATE,FCREATEUSER, FFINSUB, FRESSTAT,
		fmngetexam, 
    	fmngexamname,
			fmngrank,
			fdocvrfloc,
		fwrkexp,fnss,fchilsuid,fjks,funikar,fscouts,fgardname,fgardocc,fgirlchild,
		fsevenkar,fkashmig,fjkstud,fruralten,fkantem,fsonbcu,fstudbu,finkar,fkarout,
		fbuautclg,fbiopuc,fmathpuc,fsponrcand,fcovid,fstudtype)
		values   
		('{$rgPerArray['fmobileno']}', '{$rgPerArray['fmobileno']}',
		'{$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['fcategory']}', 
		'{$rgPerArray['fpmregno']}', '{$rgPerArray['fincome']}','{$rgPerArray['fbpl']}',
		'{$rgPerArray['freligion']}','{$rgPerArray['fmotherton']}','{$rgPerArray['fsubcaste']}','{$rgPerArray['fincomerdno']}',
		'{$rgPerArray['fcasterdno']}','{$rgPerArray['fexservice']}','{$rgPerArray['fbloodgrp']}',
		'{$rgPerArray['foutstud']}','{$rgPerArray['fselfsupsch']}',
		'{$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['fhkrdno']}',
		'{$rgPerArray['fhandicap']}','{$rgPerArray['fsports']}','{$rgPerArray['fncc']}','{$rgPerArray['fdefence']}',
		'{$rgPerArray['fjk']}','{$rgPerArray['frural']}', '{$rgPerArray['fkannada']}',
		'{$rgPerArray['fbcue']}','{$rgPerArray['fbcuetype']}', 		
		'{$rgPerArray['fpdp']}','{$rgPerArray['fcof']}','{$rgPerArray['fcoh']}',
		'{$rgPerArray['fgah']}','{$rgPerArray['fkanm']}',
		
		'{$rgPerArray['funivstud']}', 
		'{$privackd_arr_data[0]['fdegree']}', '{$privackd_arr_data[0]['fcombcode']}',
		'{$privackd_arr_data[0]['idUnvExam']}',
		'{$rgPerArray['fqyear']}', '{$rgPerArray['fqmonth']}', 
		'{$privackd_arr_data[0]['qulregno']}',
		'{$rgPerArray['fqclass']}', 
		'{$rgPerArray['fqmaxmarks']}',
		'{$rgPerArray['fqsecmarks']}',
		'{$privackd_arr_data[0]['fqpercentage']}',
		 '{$privackd_arr_data[0]['flang1']}','{$rgPerArray['flang1mm']}',
		'{$rgPerArray['flang1ms']}','{$privackd_arr_data[0]['flang2']}', 
		'{$rgPerArray['flang2mm']}',
		'{$rgPerArray['flang2ms']}',

		'{$privackd_arr_data[0]['qulcollname']}',
		'{$privackd_arr_data[0]['flangttlmm']}',
		'{$privackd_arr_data[0]['flangttlms']}',

		'{$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']}',
		'{$rgPerArray['fmngetexam']}',
		'{$rgPerArray['fmngexamname']}',
		'{$rgPerArray['fmngrank']}',
		'{$rgPerArray['fdocloc']}',
		'{$rgPerArray['fwrkexp']}',
		'{$rgPerArray['fnss']}',
		'{$rgPerArray['fchilsuid']}',
		'{$rgPerArray['fjks']}',
		'{$rgPerArray['funikar']}',
		'{$rgPerArray['fscouts']}',
		'{$rgPerArray['fgardname']}','{$rgPerArray['fgardocc']}','{$rgPerArray['fgirlchild']}',
		'{$rgPerArray['fsevenkar']}','{$rgPerArray['fkashmig']}','{$rgPerArray['fjkstud']}',
		'{$rgPerArray['fruralten']}','{$rgPerArray['fkantem']}','{$rgPerArray['fsonbcu']}',
		'{$rgPerArray['fstudbu']}','{$rgPerArray['finkar']}','{$rgPerArray['fkarout']}',
		'{$rgPerArray['fbuautclg']}','{$rgPerArray['fbiopuc']}','{$rgPerArray['fmathpuc']}','{$rgPerArray['fsponrcand']}','{$rgPerArray['fcovid']}','{$rgPerArray['fstudtype']}')";
		//var_dump($insert_qry);die();
		$results = $aobj_context->mobj_db->Execute($insert_qry);
		// var_dump($results,$aobj_context );
		if($results)
		{
			$query = "select internal_code, control.funivcode 
			from entstudadm, 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 entstudadm set fappno = '{$fappno}' 
				where fmobileno = '{$rgPerArray['fmobileno']}' 
				and fappno = '{$rgPerArray['fmobileno']}'";

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


				$query = "INSERT INTO `entstuddoc` (`fappno`, `fdoctype`, `fpath`, `fdeleted`)
				VALUES
				('{$fappno}', '1_AADHAR', NULL, NULL),
				('{$fappno}', '2_SSLC', NULL, NULL),
				('{$fappno}', '3_UG', NULL, NULL),
				('{$fappno}', '4_CASTE', NULL, NULL),
				('{$fappno}', '5_INCOME', NULL, NULL),
				('{$fappno}', '6_HK', NULL, NULL),
				('{$fappno}', '7_SQC', NULL, NULL),
				('{$fappno}', '8_covid', NULL, NULL)";
				$res = $aobj_context->mobj_db->Execute($query);

				foreach($feestr as $k=>$v){
					$ins_query = "insert into entfeedetl(FHEADCODE,FAMOUNT,FAPPNO)
					values('{$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 entstudadm
			where fmobileno = '{$rgPerArray['fmobileno']}'"; 
		$results2 = $aobj_context->mobj_db->GetRow($query);
		$fpaystatus = $results2['fpaystatus'];

		if($fpaystatus == 'success') {
			$final_submit = 'T';
		}
		
		$query = "update entstudadm set
		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']}',
		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']}',
		fscouts = '{$rgPerArray['fscouts']}',
		FRURAL = '{$rgPerArray['frural']}',
		FKANNADA = '{$rgPerArray['fkannada']}',
		FBCUE = '{$rgPerArray['fbcue']}',
		FBCUETYPE = '{$rgPerArray['fbcuetype']}',
		FSPORTS = '{$rgPerArray['fsports']}',
		FCULTURE = '{$rgPerArray['fculture']}',
		FNCC = '{$rgPerArray['fncc']}',
		FNSS = '{$rgPerArray['fnss']}',
		fpdp = '{$rgPerArray['fpdp']}',
		fcof = '{$rgPerArray['fcof']}',
		fcovid = '{$rgPerArray['fcovid']}',
		fcoh = '{$rgPerArray['fcoh']}',
		fgah = '{$rgPerArray['fgah']}',
		fkanm = '{$rgPerArray['fkanm']}',
		funikar = '{$rgPerArray['funikar']}',
		fchilsuid = '{$rgPerArray['fchilsuid']}',
		fjks = '{$rgPerArray['fjks']}',
		FDEFENCE = '{$rgPerArray['fdefence']}',
		FHANDICAP = '{$rgPerArray['fhandicap']}',
		FUNIVSTUD = '{$rgPerArray['funivstud']}',
		FQDEGREE = '{$privackd_arr_data[0]['fdegree']}',
		FQCOMBCODE = '{$privackd_arr_data[0]['fcombcode']}',
		FQUNIV = '{$privackd_arr_data[0]['idUnvExam']}',
		FQYEAR = '{$rgPerArray['fqyear']}',
		FQMONTH = '{$rgPerArray['fqmonth']}',
		FQREGNO = '{$privackd_arr_data[0]['qulregno']}',
		FQCLASS = '{$rgPerArray['fqclass']}',
		FQMAXMARKS = '{$rgPerArray['fqmaxmarks']}',
		FQSECMARKS = '{$rgPerArray['fqsecmarks']}',
		FQPERCENTAGE = '{$privackd_arr_data[0]['fqpercentage']}',
		FLANG1 = '{$privackd_arr_data[0]['flang1']}',
		FLANG1MM = '{$rgPerArray['flang1mm']}',
		FLANG1MS = '{$rgPerArray['flang1ms']}',
		FLANG2 = '{$privackd_arr_data[0]['flang2']}',
		FLANG2MM = '{$rgPerArray['flang2mm']}',
		FLANG2MS = '{$rgPerArray['flang2ms']}',
		FLANMM = '{$privackd_arr_data[0]['flangttlmm']}',
		FLANMO = '{$privackd_arr_data[0]['flangttlms']}',
		FQCOLLEGE = '{$privackd_arr_data[0]['qulcollname']}',
		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']}',
		fmngetexam = '{$rgPerArray['fmngetexam']}', 
		fmngexamname = '{$rgPerArray['fmngexamname']}',
		fmngrank = '{$rgPerArray['fmngrank']}',
		freligion = '{$rgPerArray['freligion']}',
		fmotherton = '{$rgPerArray['fmotherton']}',
		fbloodgrp = '{$rgPerArray['fbloodgrp']}',
		fsubcaste = '{$rgPerArray['fsubcaste']}',
		fincomerdno = '{$rgPerArray['fincomerdno']}',
		fcasterdno = '{$rgPerArray['fcasterdno']}',
		fhkrdno = '{$rgPerArray['fhkrdno']}',
		fexservice = '{$rgPerArray['fexservice']}',
		foutstud = '{$rgPerArray['foutstud']}',
		fselfsupsch = '{$rgPerArray['fselfsupsch']}',
		fdocvrfloc = '{$rgPerArray['fdocloc']}',
		fwrkexp = '{$rgPerArray['fwrkexp']}',
		fgardname = '{$rgPerArray['fgardname']}',
		fgardocc = '{$rgPerArray['fgardocc']}',
		fgirlchild = '{$rgPerArray['fgirlchild']}',
		fsevenkar = '{$rgPerArray['fsevenkar']}',
		fkashmig = '{$rgPerArray['fkashmig']}',
		fjkstud = '{$rgPerArray['fjkstud']}',
		fruralten = '{$rgPerArray['fruralten']}',
		fkantem = '{$rgPerArray['fkantem']}',
		fsonbcu = '{$rgPerArray['fsonbcu']}',
		fstudbu = '{$rgPerArray['fstudbu']}',
		finkar = '{$rgPerArray['finkar']}',
		fkarout = '{$rgPerArray['fkarout']}',
		fbuautclg = '{$rgPerArray['fbuautclg']}',
		fbiopuc = '{$rgPerArray['fbiopuc']}',
		fmathpuc = '{$rgPerArray['fmathpuc']}',
		fsponrcand = '{$rgPerArray['fsponrcand']}',
		fstudtype = '{$rgPerArray['fstudtype']}'
		where fappno = '{$fappno}'";// '84119001027'
		//var_dump($query);
		$results = $aobj_context->mobj_db->Execute($query);

		if($results)
		{
			
			$feestr = $feestr['data'];

			$del_query = "delete from entfeedetl where fappno = '{$fappno}'";
			$results = $aobj_context->mobj_db->Execute($del_query);
			foreach($feestr as $k=>$v){
				$ins_query = "insert into entfeedetl(FHEADCODE,FAMOUNT,FAPPNO)
				values('{$v['feehead']}','{$v['fee']}' ,'{$fappno}')";
				$results = $aobj_context->mobj_db->Execute($ins_query);
			}
		}
	}
	if($results) 
	{
		$s3 = S3Client::factory(
			array(
				'credentials' => array(
					'key' => IAM_KEY,
					'secret' => IAM_SECRET
				),
				'version' => "latest",
				'region'  => 'ap-south-1'
			)
		);
		
		$query = "select funivcode from control";
		$results = $aobj_context->mobj_db->GetRow($query);

		$funivcode = $results['funivcode'];

		$photo_filename = $rgPerArray['photo_path'];
		// var_dump($photo_filename);
		
		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 = $funivcode."/pget_photos/".$photo_filename;
			
			$photo = $funivcode."/pget_photos/".$photo_filename;
			// var_dump($photo);
			if(file_exists($image_path)) 
			{
				try {
					$s3->putObject(['Bucket' => ADMISSION_CERTIFICATES, 'Key' => $photo, 'SourceFile' => $image_path]);
					$update="update entstudadm set FPHOTOPATH='{$photo}' 
						where FAPPNO= '{$fappno}'";
			
					$up_obj=$aobj_context->mobj_db->Execute($update); 
					unlink($image_path);
				}catch(S3Exception $e) {
					$arr['message'] = 'Unable to upload Photo';
					echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
					return;
				}
			}
		}

		$docs = array("1_aadhar", "2_sslc", '3_ug','4_caste', '5_income', '6_hk', '7_sqc','8_covid');

		$query = "INSERT IGNORE INTO `entstuddoc` (`fappno`, `fdoctype`, `fpath`, `fdeleted`)
				VALUES
				('{$fappno}', '1_AADHAR', NULL, NULL),
				('{$fappno}', '2_SSLC', NULL, NULL),
				('{$fappno}', '3_UG', NULL, NULL),
				('{$fappno}', '4_CASTE', NULL, NULL),
				('{$fappno}', '5_INCOME', NULL, NULL),
				('{$fappno}', '6_HK', NULL, NULL),
				('{$fappno}', '7_SQC', NULL, NULL),
				('{$fappno}', '8_covid', NULL, NULL)";
		$res = $aobj_context->mobj_db->Execute($query);

		foreach($docs as $k => $v) {

			$doc = $privackd_arr_data[0][$v];
			// $ug = $privackd_arr_data[0]['ug'];
			// $caste = $privackd_arr_data[0]['caste'];
			// $hk = $privackd_arr_data[0]['hk'];

			if($doc != '' && $doc != NULL)
			{
				$image_path = $aobj_context->main_src."upload/{$doc}";
				$updoc = strtoupper($v);
				$ext = pathinfo($doc, PATHINFO_EXTENSION);
				$doc = $fappno."_".$updoc;
				$doc = $doc.".".$ext;

				$full_file_path = $aobj_context->main_src."pget_photos/".$doc;
				
				$path = $funivcode."/pget_certificates/".$doc;
				// var_dump($path,$image_path);

				if(file_exists($image_path)) {
					try {
						$s3->putObject(['Bucket' => ADMISSION_CERTIFICATES, 'Key' => $path, 'SourceFile' => $image_path]);
						$del_query = "delete from entstuddoc where fappno = '{$fappno}' and fdoctype = '{$updoc}'";
						$up_obj=$aobj_context->mobj_db->Execute($del_query);

						$insert_doc="insert into entstuddoc(fappno,fdoctype,fpath)
						values('{$fappno}','{$updoc}','{$path}')";
						$up_obj=$aobj_context->mobj_db->Execute($insert_doc); 
						unlink($image_path);
					} catch(S3Exception $e){
						$arr['message'] = 'Unable to upload documents';
						echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
						return;
					}
				}
			}
		}
		

		if(count($sub_arr_data) > 0)
		{
			$del_query = "delete from entprevmarks where fappno = '{$fappno}'
			and fcombcode not in ('TOT', 'lan')";
			$res=$aobj_context->mobj_db->Execute($del_query);

			foreach($sub_arr_data as $value)
			{
				$query = "insert into entprevmarks(fappno,fdegree,fcombcode,fsubcode,
				famo,famm,
				fbmo,fbmm,
				fcmo,fcmm,
				fdmo,fdmm,
				femo,femm,
				ffmo,ffmm,
				fsecmarks,fmaxmarks,
				fpercent) values('{$fappno}','{$privackd_arr_data[0]['fdegree']}','{$privackd_arr_data[0]['fcombcode']}',
				'{$value['subcode']}','{$value['subsem1mo']}','{$value['subsem1mm']}',
				'{$value['subsem2mo']}','{$value['subsem2mm']}',
				'{$value['subsem3mo']}','{$value['subsem3mm']}',
				'{$value['subsem4mo']}','{$value['subsem4mm']}',
				'{$value['subsem5mo']}','{$value['subsem5mm']}',
				'{$value['subsem6mo']}','{$value['subsem6mm']}',
				'{$value['subtotalmo']}','{$value['subtotalmm']}','{$value['subpercentagemm']}')";
				
				$res=$aobj_context->mobj_db->Execute($query); 
			}
		}
		if(count($lan_arr_data) > 0)
		{
			$del_query = "delete from entprevmarks where fappno = '{$fappno}'
			and fcombcode = 'lan'";
			$res=$aobj_context->mobj_db->Execute($del_query);

			foreach($lan_arr_data as $value)
			{
				$query = "insert into entprevmarks(fappno,fdegree,fcombcode,fsubcode,
				famo,famm,
				fbmo,fbmm,
				fcmo,fcmm,
				fdmo,fdmm,
				femo,femm,
				ffmo,ffmm,
				fsecmarks,fmaxmarks,
				fpercent) values('{$fappno}','{$privackd_arr_data[0]['fdegree']}','lan',
				'{$value['subcode']}','{$value['lansem1mo']}','{$value['lansem1mm']}',
				'{$value['lansem2mo']}','{$value['lansem2mm']}',
				'{$value['lansem3mo']}','{$value['lansem3mm']}',
				'{$value['lansem4mo']}','{$value['lansem4mm']}',
				'{$value['lansem5mo']}','{$value['lansem5mm']}',
				'{$value['lansem6mo']}','{$value['lansem6mm']}',
				'{$value['lantotalmo']}','{$value['lantotalmm']}','{$value['lanpercentagemm']}')";
				
				$res=$aobj_context->mobj_db->Execute($query); 
			}
		}
		if(count($tot_arr_data) > 0)
		{
			$del_query = "delete from entprevmarks where fappno = '{$fappno}'
			 and fcombcode = 'TOT'";
			$res=$aobj_context->mobj_db->Execute($del_query);

			foreach($tot_arr_data as $value)
			{
				$query = "insert into entprevmarks(fappno,fdegree,fcombcode,fsubcode,
				famo,famm,
				fbmo,fbmm,
				fcmo,fcmm,
				fdmo,fdmm,
				femo,femm,
				ffmo,ffmm,
				fsecmarks,fmaxmarks,
				fpercent) values('{$fappno}','TOT','TOT',
				'ATOT','{$value['totsem1mo']}','{$value['totsem1mm']}',
				'{$value['totsem2mo']}','{$value['totsem2mm']}',
				'{$value['totsem3mo']}','{$value['totsem3mm']}',
				'{$value['totsem4mo']}','{$value['totsem4mm']}',
				'{$value['totsem5mo']}','{$value['totsem5mm']}',
				'{$value['totsem6mo']}','{$value['totsem6mm']}',
				'{$value['tottotalmo']}','{$value['tottotalmm']}','{$value['totpercentagemm']}')";
				
				$res=$aobj_context->mobj_db->Execute($query); 
			}
		}
		if(count($finaloptdeg_data)>0)
		{
			$del_query = "delete from entoptdeg where fappno = '{$fappno}'";
			$res=$aobj_context->mobj_db->Execute($del_query);

			foreach($finaloptdeg_data as $value)
			{
				
				$query = "insert into entoptdeg(fappno,fdegree) values('{$fappno}','{$value['optdeg']}')";
				
				$res=$aobj_context->mobj_db->Execute($query); 
			}	
		}

		$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);

}