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


Current Path : /var/www/html/gcg/pgcet_stop/src/
Upload File :
Current File : /var/www/html/gcg/pgcet_stop/src/saveRerigistration.php

<?php

$app_number = '';

function saveReRigistrationPersonal($aobj_context)
{
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
	$reg_no = $aobj_context->mobj_data["reg_no"];

	include_once($aobj_context->main_src."/json.php"); 
	$json = new Services_JSON();
	
	$lstr_param = stripslashes($aobj_context->mobj_data["personal_info"]);
	$per_arr_data = json_decode($lstr_param, true);
	
	
	$fields = array('slnocnt'=>'FSLNO', 'examno'=> 'FEXAMNO', 'studname'=>'FNAME',
					'fatname' => 'FFATNAME', 'ocupation' => 'FFAT_OCC', 
					'category' => 'FCASTE', 'religion' => 'FRELIGION',
					'gender' => 'FSEX', 'adhar' => 'FAADHARNO',
					'pstate' => 'FPERMSTATE', 'cadd1'=> 'FCURRADD1',
					'cadd2'=> 'FCURRADD2','cadd3'=> 'FCURRADD3',
					'castate' => 'FCURRSTATE', 'landline' => 'FLANDLINE',
					'income' => 'FINCOME', 'sign_path' => 'FSIGNPATH',
					'photo_path' => 'FPHOTOPATH',
					'handicap' => 'FHANDICAP', 'nationality' =>  'FNATIONAL',
					'dob' => 'FDOB', 'cadistrict' => 'FCURRDISTRICT',
					'cpincode' =>'FCURRPINCODE', 'padd1' => 'FPERMADD1',
					'padd2' => 'FPERMADD2','padd3' => 'FPERMADD3',
					'pdistrict' => 'FPERMDISTRICT', 'ppincode' => 'FPERMPINCODE',
					'email' => 'FEMAIL', 'mobile' => 'FMOBILENO');
	$field ='';
	$update ='';
	
	for($i=0; $i<count($per_arr_data); $i++)
	{
		$value = $per_arr_data[$i]['value'];
		if($per_arr_data[$i]['id'] == 'photo_path')
		{
			$photo_filename = $value;
			continue;
		}
		$field = $fields[$per_arr_data[$i]['id']];
		$update .= "$field = '{$value}',";
	}
	
	$update  = rtrim($update,',');
	$query = "update student set {$update} where fregno = '{$reg_no}'";
	//var_dump($query);
	$update_student = $aobj_context->mobj_db->Execute($query);

	if(!strpos($photo_filename, '/'))
	{
		$sql = "select fcollcode,fdegree from student where fregno = '{$reg_no}'";
		$results = $aobj_context->mobj_db->getRow($sql);
		
		$centercode = $results['fcollcode'];
		$degree = $results['fdegree'];
		
		$college_path=$aobj_context->main_src."student_photos/{$centercode}";
		$degree_path=$aobj_context->main_src."student_photos/{$centercode}/".$degree;
		$image_path = $aobj_context->main_src."upload/{$photo_filename}";
		$folder_path=$aobj_context->main_src."student_photos/{$centercode}/".$degree;
		
		if(!file_exists($college_path))
		{
			mkdir($college_path);
		}

		if(!file_exists($degree_path))
		{
			mkdir($degree_path);
		}
		if(!file_exists($sign_folder_path))
		{
			mkdir($sign_folder_path);
		}
		$photo_path = $aobj_context->main_src."upload/{$photo_filename}";

		$filename = explode(".", $photo_filename);
		$ext = strtolower($filename[1]);
		$photo_filename = $reg_no;
		$photo_filename = $photo_filename.".".$ext;

		$full_file_path = $folder_path.'/'.$photo_filename;
		$photo = "student_photos/{$centercode}/".$degree.'/'.$photo_filename;
		
		

		if(copy($image_path,$full_file_path))
		{
			$update="update student set FPHOTOPATH='{$photo}' 
					where fregno = '{$reg_no}' ";
			$up_obj=$aobj_context->mobj_db->Execute($update); 
			unlink($sign_path);
		}
		else
		{
			$update="update student set FPHOTOPATH='{$photo}' 
					where fregno = '{$reg_no}' ";
			$up_obj=$aobj_context->mobj_db->Execute($update);	
		}
	}

	if($update_student) 
	{
		$arr = 'updated';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
		return;
	}
	else
	{
		$arr='Updation failed';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"error"); 
		return;
	}
}

function saveReRigistrationDetails($aobj_context)
{
	session_start();
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
	$reg_no = $aobj_context->mobj_data["reg_no"];
	$category = $aobj_context->mobj_data["cat"];
	$payment_type = $aobj_context->mobj_data["payment_type"];
	$fexamno = $aobj_context->mobj_data['FEXAMNO'];
	$total_fee = $aobj_context->mobj_data["total_fee"];
	
	include_once($aobj_context->main_src."/json.php"); 
	$json = new Services_JSON();
	
	$lstr_param = stripslashes($aobj_context->mobj_data["mand_sub"]);
	//var_dump($lstr_param);
	$mobj_jsondata = $json->decode($lstr_param);
	//var_dump($mobj_jsondata);
	//$sub_arr_data = get_object_vars($mobj_jsondata);
	//var_dump($sub_arr_data);
	$lquery="select date_format(current_date,'%d/%m/%Y') as curr_date,
	FDEGREE,FCOLLCODE,FNAME
	from student where   FREGNO='{$reg_no}'";	 
	$lobj_get_name = $aobj_context->mobj_db->GetRow($lquery);
	$college_code = $lobj_get_name['FCOLLCODE'];
	$degree = $lobj_get_name['FDEGREE'];
	$student_name = $lobj_get_name['FNAME'];
	$curr_date = $lobj_get_name['curr_date'];
	
	$lquery="select FADMTO as last_date
	from collexam where fdegree='{$degree}' and fexamno ='{$fexamno}'";

	$lobj_get_date = $aobj_context->mobj_db->GetRow($lquery);	 
	$last_date = $lobj_get_date['last_date'];

	if(empty($college_code))
	{
		$arr['data']='No details found for the student';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
		return;
	}
	if(!InsertEmptyAppCandSumm($degree, $college_code, $reg_no,$fexamno, $aobj_context, $payment_type))
	{
		
		$arr['data'] = 'Error While Inserting AppCandSum';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
		return;
	}
	global $app_number;
	   
	
	//var_dump($sub_arr_data);die();
	$FPRESENT = 'P';
	//two array optional and mandatory
	//optional finserted = 'T'
	$slno = substr($app_number,-4);
	for($i=1;$i<=count($mobj_jsondata);$i++)
	{				
		$insert_canddet_records = "insert into options 
			(fslno,fappno,fdegree,fexamno,fcollcode,fregno,fsubcode) 
			select distinct '{$slno}','{$app_number}',FDEGREE,'{$fexamno}',FCOLLCODE,
			FREGNO,'{$mobj_jsondata[$i]}' from regcandsum 
			where FDEGREE = '{$degree}' and FREGNO = '{$reg_no}'";
		//var_dump($insert_canddet_records);
		$lobj_insert_canddet_records = $aobj_context->mobj_db->Execute($insert_canddet_records);
	}

	$sql = "select fcombcode from student where FREGNO = '{$reg_no}'";
	$results = $aobj_context->mobj_db->getRow($sql);
	//var_dump($sql);
	$combcode_sub = $results['fcombcode'];
	//var_dump($combcode_sub);
	$query = "select ifnull(fadmfee,0) as fadmfee,ifnull(fadmfine,0) as fadmfine from degree 
			 where fdegree = '{$degree}' and fexamno = '{$fexamno}'";
	$results = $aobj_context->mobj_db->getRow($query);
	
	$totfee = $results['fadmfee'];
	$fadmfine = $results['fadmfine'];	
//var_dump($combcode_sub);

	if(($degree == 'DUBS1' or $degree == 'DUBS') and $fexamno == 'B' and $combcode_sub == '202')
		$totfee = '9355';
	if(($degree == 'DUBS1' or $degree == 'DUBS') and $fexamno == 'B' and $combcode_sub == '201')
		$totfee = '9475';
	
	
	if(($degree == 'DUBS1' or $degree == 'DUBS') and $fexamno == 'C' and $combcode_sub == '202')
		$totfee = '8590';
	if(($degree == 'DUBS1' or $degree == 'DUBS') and $fexamno == 'C' and $combcode_sub == '201')
		$totfee = '8590';

//	var_dump($totfee);	
	$char_id = $fexamno;
	$update_records = "update studadm set  
	ftotfee = '{$totfee}',
	FADMFINE = '{$fadmfine}',
	FPAYMENTTYPE = '{$payment_type}',
	FCREATEDATE = now(),
	FAPPLASTDATE = '{$last_date}'
	where  fdegree='{$degree}' and  fcollcode = '{$college_code}' 
	and fregno = '{$reg_no}'
	and fappno  = '{$app_number}'";  
	$lobj_update_records = $aobj_context->mobj_db->Execute($update_records);

	/* $update_total_fee = "update appcandsum set FTOTALFEE={$total_fee},
	FCATEGORY='{$category}', 
	FFEETYPE = '{$li}',		
	FLOGDATE=now(),
	FAPPLASTDATE = '{$last_date}'
	where  FDEGREE='{$degree}' and 
	FCOLLCODE='{$college_code}' 
	and FREGNO='{$reg_no}' 
	and APPNO='{$app_number}'";
	
	$lobj_update_total_fee = $aobj_context->mobj_db->Execute($update_total_fee); */
					
	$FFEECODE = '01 Registration Fee';
	/* $insert_into_student_fee="insert into appstudfee
	(
	APPNO,FDEGREE,FEXAMNO,FCOLLCODE,FREGNO,FFEECODE,FAMOUNT,FLOGDATE
	) VALUES
	(
	'{$app_number}',
	'{$degree}',
	'{$fexamno}',
	'{$college_code}',
	'{$reg_no}',
	'{$FFEECODE}',
	'{$total_fee}',
	NOW()
	)"; */
	//var_dump($insert_into_student_fee);
	$lobj_insert_into_student_fee = $aobj_context->mobj_db->Execute($insert_into_student_fee);

	if($lobj_insert_canddet_records) 
	{
		$arr['app_no'] = $app_number;
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
		return;
	}
	else
	{
		$arr='Updation failed';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"success"); 
		return;
	}
	 
}

function InsertEmptyAppCandSumm($degree, $college_code, $reg_no,$examno, $aobj_context, $payment_type)
{
	//session_start();
	global $app_number;
	$app_number = GetNextNumber($aobj_context, $college_code);
	
	$slno = substr($app_number,-4);
	
	$insert="INSERT INTO  studadm( 
			FSLNO,fappno,fregno,fdegree,fcollcode,FEXAMNO,FNAME,FFATNAME,FFAT_OCC, 
					FCASTE,FRELIGION,
					FSEX,FAADHARNO,
					FCURRADD1,FCURRADD2,FCURRADD3,FCURSTATE,FCURPINCODE,FLANDLINE,
					FINCOME,FSIGNPATH,FCURDISTRICT,FPHOTOPATH,
					FHANDICAP,FNATIONAL,
					FDOB,FPERSTATE,FPERMADD1,
					FPERMADD2,FPERMADD3,
					FPERDISTRICT,FPERPINCODE,FCENDISTRICT,FBASICQAL,FPREVREGNO,FPREVCOMB,FPREVELECTIVE,FPASSMTHYEAR,FPREVCOLLEGE,
					FEMAIL,FCONTACT_NO,FENGLISH,fcombcode)
			 SELECT '{$slno}','{$app_number}',fregno,fdegree,fcollcode,'{$examno}',fname,
			FFATNAME, FFAT_OCC,FCASTE,FRELIGION,FSEX,FAADHARNO,FCURRADD1,FCURRADD2,FCURRADD3,FCURRSTATE,
			FCURRPINCODE,FLANDLINE,FINCOME,FSIGNPATH,FCURRDISTRICT,FPHOTOPATH,FHANDICAP,FNATIONAL,FDOB,
			FPERMSTATE,FPERMADD1,FPERMADD2,FPERMADD3,FPERMDISTRICT,FPERMPINCODE,FCENDISTRICT,FBASICQAL,FPREVREGNO,FPREVCOMB,FPREVELECTIVE,FPASSMTHYEAR,FPREVCOLLEGE,FEMAIL,FMOBILENO,FENGLISH,fcombcode
			from student where fregno = '{$reg_no}'";
	//var_dump($insert);				
	$lobj_insert = $aobj_context->mobj_db->Execute($insert);
	//var_dump($lobj_insert); 
	if($lobj_insert)
	{
		//$UpdateNextNumber();
		return true;
	}
	else
	{
		return false;
	}
}

//mohan sir app no generation
function GetNextNumber($aobj_context, $college_code)
{	
	$get_prefix_running_number = "select last_number from res_reval_code_generator
	where college_code = '{$college_code}' and type='Candidate' ";		
	$lobj_get_prefix_running_number = $aobj_context->mobj_db->GetRow($get_prefix_running_number); 

	$query= " Select FEXAMPREFIX from control";
	$result = $aobj_context->mobj_db->GetRow($query);

	if(!empty($lobj_get_prefix_running_number['last_number']))
	{			
		$next_number = $lobj_get_prefix_running_number['last_number'];
		$last_number = str_pad($next_number,4, "0", STR_PAD_LEFT);
	}
	else
	{	
		$next_number=0001;			
		$insert_into="insert into res_reval_code_generator(college_code,last_number,type)
		values
		(
		'{$college_code}',
		{$next_number},'Candidate'
		)";
		$lobj_insert_into = $aobj_context->mobj_db->Execute($insert_into);
		$last_number = str_pad($next_number,4, "0", STR_PAD_LEFT);		
	}
	UpdateNextNumber($aobj_context, $college_code);
	return $result['FEXAMPREFIX'].$college_code.$last_number;	
}

function UpdateNextNumber($aobj_context, $college_code)
{							 
	$update_code_generator = "update res_reval_code_generator set last_number = last_number+1
	where college_code = '{$college_code}' and type='Candidate' ";
	$lobj_update_code_generator = $aobj_context->mobj_db->Execute($update_code_generator);
}

?>