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


Current Path : /var/www/html/collportal/src/
Upload File :
Current File : //var/www/html/collportal/src/student.php

<?php
	include("sendsmsapi.php");
	require_once("/var/www/html/aws/aws-autoloader.php");
	use Aws\S3\S3Client;
	use Aws\S3\Exception\S3Exception;

	ini_set('display_errors', 1);
			ini_set('display_startup_errors', 1);
			error_reporting(E_ALL);

	class applicationForm
	{
		function __construct($aobj_context)
		{
			session_start();
			$this->aobj_context=$aobj_context;
			$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);	
			$this->aobj_context=$aobj_context;
			$this->ip=$_SERVER["REMOTE_ADDR"];
			$this->login_cnt=$_SESSION['login_cnt'];
		}
		
		function assignParams()
		{
			$this->edit_app_code=trim($this->aobj_context->mobj_data["edit_app_code"]);
			$this->course=trim($this->aobj_context->mobj_data["course"]);
			$this->college=trim($this->aobj_context->mobj_data["college"]);
			$this->candidate_name=trim($this->aobj_context->mobj_data["candidate_name"]);
			$this->dob=trim($this->aobj_context->mobj_data["dob"]);
			$this->paddr1=trim($this->aobj_context->mobj_data["paddr1"]);
			$this->paddr2=trim($this->aobj_context->mobj_data["paddr2"]);
			$this->db=trim($this->aobj_context->mobj_data["db"]);
			//$this->paddr3=trim($this->aobj_context->mobj_data["paddr3"]);
			//$this->paddr4=trim($this->aobj_context->mobj_data["paddr4"]);
			$this->mobile_no=trim($this->aobj_context->mobj_data["mobile_no"]);
			$this->email_id=trim($this->aobj_context->mobj_data["email_id"]);
			$this->amount=trim($this->aobj_context->mobj_data["amount"]);
			$this->paytype=trim($this->aobj_context->mobj_data["paytype"]);
			$this->reg_no=strtoupper(trim($this->aobj_context->mobj_data["reg_no"]));	
			$this->kanname=strtoupper(trim($this->aobj_context->mobj_data["kanname"]));			
			$this->catpath=trim($this->aobj_context->mobj_data["catpath"]);
			$this->scheme=trim($this->aobj_context->mobj_data["scheme"]);
			$this->freccer=trim($this->aobj_context->mobj_data["freccer"]);
			$this->aadhar=trim($this->aobj_context->mobj_data["aadhar"]);
			
			$this->city=trim($this->aobj_context->mobj_data["city"]);
			$this->state=trim($this->aobj_context->mobj_data["state"]);
			$this->pincode=trim($this->aobj_context->mobj_data["pincode"]);
			$this->rctype=trim($this->aobj_context->mobj_data["rctype"]);
			$this->nationality=trim($this->aobj_context->mobj_data["nationality"]);
			$this->fee_arr=trim($this->aobj_context->mobj_data["fee_arr"]);
			$this->univ=trim($this->aobj_context->mobj_data["univ"]);
			$this->catcode=trim($this->aobj_context->mobj_data["catcode"]);
			$this->deg_cert=trim($this->aobj_context->mobj_data["deg_cert"]);
			$this->sem_mks=trim($this->aobj_context->mobj_data["sem_mks"]);
			// var_dump($this->deg_cert,$this->sem_mks);

			$this->paddr3 = '';
			$this->paddr4 = '';
		}
		 
		function SaveDetails()
		{
			
			$this->rctype=trim($this->aobj_context->mobj_data["rctype"]);
			if($this->rctype=="IN ABSENTIA"){
					$this->letterfilepath=trim($this->aobj_context->mobj_data["filepathletter"]);
					$this->thirdName=trim($this->aobj_context->mobj_data["thirdName"]);
					$this->relation=trim($this->aobj_context->mobj_data["relative"]);

					if($this->relation == "father"){
						$cndrelation="Father";
					}else if($this->relation == "mother"){
						$cndrelation="Mother";
					}else if($this->relation == "spouse"){
						$cndrelation="Spouse";
					}else if($this->relation == "other"){
						$cndrelation="Othar";
						$this->other_Relation=trim($this->aobj_context->mobj_data["otherralation"]);
					}
			
					$this->thirdPersonEmail=trim($this->aobj_context->mobj_data["thirdPersonEmail"]);
					$this->thirdPersonMobile=trim($this->aobj_context->mobj_data["thirdPersonMobile"]);
					$this->thirdPersonAddress=trim($this->aobj_context->mobj_data["thirdPersonAddress"]);
					$this->thirdPersonIDP=trim($this->aobj_context->mobj_data["idproof"]);
					if($this->thirdPersonIDP=="aadhar"){
						$cndidproof="Aadhar";
						$this->idno=trim($this->aobj_context->mobj_data["aadharno"]);
					}else if($this->thirdPersonIDP=="driving"){
						$cndidproof="Driving";
						$this->idno=trim($this->aobj_context->mobj_data["drivingliecence"]);
					}else if($this->thirdPersonIDP=="voter"){
						$cndidproof="Voter";
						$this->idno=trim($this->aobj_context->mobj_data["voterproof"]);
					}else if ($this->thirdPersonIDP=="other"){
						$cndidproof="Other";
						$this->otherproof=trim($this->aobj_context->mobj_data["otherproof"]);
						$this->idno=trim($this->aobj_context->mobj_data["otherproofnumber"]);
					}
					$this->filepathextproof=trim($this->aobj_context->mobj_data["filepathextproof"]);

			}else if($this->rctype=="by Post"){
                $this->houseno=trim($this->aobj_context->mobj_data["byposthouseno"]);
				$this->streetname=trim($this->aobj_context->mobj_data["bypoststreetname"]);
				$this->area=trim($this->aobj_context->mobj_data["bypostarea"]);
				$this->landmark=trim($this->aobj_context->mobj_data["bypostlandmark"]);
				$this->counties=trim($this->aobj_context->mobj_data["counties"]);   
				if($this->counties=="india"){
					$state=trim($this->aobj_context->mobj_data["indiasState"]);
				}else if($this->counties=="other"){
					$othercounty=trim($this->aobj_context->mobj_data["otherthanall"]);
					$state=trim($this->aobj_context->mobj_data["otherthanstate"]);
				}else{
					$state=trim($this->aobj_context->mobj_data["otherthanstate"]);
				}
				$this->dist=trim($this->aobj_context->mobj_data["postdist"]);
				$this->pincode=trim($this->aobj_context->mobj_data["bypostpincode"]); 
			}
			
			// var_dump($this->counties,$state,$othercounty);die();
			
			$query = "select funivcode from control";
			$results = $this->aobj_context->mobj_db->GetRow($query);
			$this->funivcode = $results['funivcode'];

			$check_dup="select c.funivcode as fcunivcode,dc.* from dctran dc, control c
			where dc.FREGNO='{$this->reg_no}' 
			and dc.funivcode = '{$this->univ}'";

		
		
			$obj_check_dup=$this->aobj_context->mobj_db->GetRow($check_dup);	
			
		
			if(strtoupper($obj_check_dup['FPAYSTATUS']) == 'SUCCESS')
			{
				$data = "Convocation Fee Paid. Go to Reprint Acknowledgement";
				echo $this->aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure"); 
				return;	
			}

			if($obj_check_dup)
			{
				$app_no = $obj_check_dup['FAPPNO'];
				
				$db=trim($this->aobj_context->mobj_data["db"]);
				

				include_once("/json.php");	
				$json = new Services_JSON();

				$mobj_jsondata = json_decode($this->fee_arr);

				if($db!="sikkim"){
				$upd = "update dctran set 
				FNAME = '{$this->candidate_name}', 
				FDOB = date_format(str_to_date('{$this->dob}','%Y-%m-%d'),'%Y-%m-%d'), 
				FMOBILE = '{$this->mobile_no}',
				FEMAIL = '{$this->email_id}',
				FPAYTYPE = '{$this->paytype}',
				FREGDATE = now(),
				FREGIP = '{$this->ip}',
				FPOSTADDR1 = '{$this->paddr1}',
				FPOSTADDR2 = '{$this->paddr2}',
				FCITY = '{$this->city}',
				FKANNAME = '$this->kanname',
				FSTATE = '{$this->state}',
				FPINCODE = '{$this->pincode}',
				FRCTYPE = '{$this->rctype}',
				FNATIONAL = '{$this->nationality}',
				FAADHAR = '{$this->aadhar}',
				FCATCODE = '{$this->catcode}'
			
				where fregno = '{$this->reg_no}'
				and fappno = '{$app_no}'";
				}else{
					$upd = "update dctran set 
				FNAME = '{$this->candidate_name}', 
				FMOBILE = '{$this->mobile_no}',
				FEMAIL = '{$this->email_id}',
				FPAYTYPE = '{$this->paytype}',
				FREGDATE = now(),
				FREGIP = '{$this->ip}',
				FPOSTADDR1 = '{$this->paddr1}',
				FPOSTADDR2 = '{$this->paddr2}',
				FCITY = '{$this->city}',
				FSTATE = '{$this->state}',
				FPINCODE = '{$this->pincode}',
				FRCTYPE = '{$this->rctype}',
			    FTNAME='{$this->thirdName}',
				FTUPLOADLETTER='{$this->letterfilepath}',
				FTRELATION='{$cndrelation}',
				FTOTHERRELATION='{$this->other_Relation}',
				FTEMAIL='{$this->thirdPersonEmail}',
				FTMOBILE='{$this->thirdPersonMobile}',
				FTADDRESS='{$this->thirdPersonAddress}',
				FTIDPROOF='{$cndidproof}',
				FTOTHERIDPROOF='{$this->otherproof}',
				FTIDNUMBER='{$this->idno}',
				FTIDPATH='{$this->filepathextproof}',
				FPHOUSE='{$this->houseno}',
				FPSTREET='{$this->streetname}',
				FPAREA='{$this->area}',
				FPLANDMARKS='{$this->landmark}',
				FPCOUNTRY='{$this->counties}',
				FPOTHERCOUNTRY='{$othercounty}',
				FPSTATE='{$state}',
				FPDIST='{$this->dist}',
				FPPINCODE='{$this->pincode}'				
				where fregno = '{$this->reg_no}'
				and fappno = '{$app_no}'";
				}
			
				$upd = $this->aobj_context->mobj_db->Execute($upd);
		
				for($k=0;$k<count($mobj_jsondata);$k++)
				{	
					if($mobj_jsondata[$k]->headcode != 'Total Amount')
					{
						$query  = "INSERT INTO `studcnvfee` (`fappno`, `fregno`, `fheadcode`, `famount`, `fcreateddate`)
						VALUES
						('{$app_no}', '$this->reg_no', '{$mobj_jsondata[$k]->headcode}', '{$mobj_jsondata[$k]->fee}', now()) 
						ON DUPLICATE KEY UPDATE fheadcode = '{$mobj_jsondata[$k]->headcode}',
						fheadcode = '{$mobj_jsondata[$k]->headcode}',
						famount = '{$mobj_jsondata[$k]->fee}',
						fcreateddate = now()";
					
						$this->aobj_context->mobj_db->Execute($query);
					}else
					{
						$query="update dctran set FAMOUNT = '{$mobj_jsondata[$k]->fee}'
						where FAPPNO='{$app_no}'";
						$this->aobj_context->mobj_db->Execute($query);

					}
					
				}

					$folder_path=$this->aobj_context->main_src.'/'.$this->db."/student_photos";
					// var_dump($folder_path);
					$file_name=basename($_FILES['student_entry_upload']['name']);
					$path_arr=pathinfo($_FILES['student_entry_upload']['name']);
					$file_ext=$path_arr['extension'];
					$full_file_path= $folder_path.'/'.$this->reg_no.".".$file_ext;;
					$image_path="student_photos/".$this->reg_no.".".$file_ext;;
					// var_dump($_FILES);
					
					$s3 = S3Client::factory(
						array(
							'credentials' => array(
								'key' => IAM_KEY,
								'secret' => IAM_SECRET
							),
							'version' => "latest",
							'region'  => 'ap-south-1'
						)
					);

					if($this->db == 'vskub'){
					$doc_names = ['deg_cert', 'sem_mks'];

					for($i=0;$i<count($doc_names);$i++)
					{
						if($doc_names[$i] == 'deg_cert'){
							$GCCERT = $this->deg_cert;
							$TAB = 'FDEGCERTPATH';
						}elseif($doc_names[$i] == 'sem_mks'){
							$GCCERT = $this->sem_mks;
							$TAB = 'FALLSEMCERT';
						}
						
						if($GCCERT == '')
							continue;

						$GCCERT_PATH = $this->aobj_context->main_src.$this->db.'/uploads/'.$GCCERT;
						$filename = explode(".", $GCCERT_PATH);
						$ext = strtolower($filename[1]);


						$GCCERT_FILENAME = $doc_names[$i];
						
						$GCCERT_FILENAME = $GCCERT_FILENAME.".".$ext;
						// var_dump($GCCERT_PATH);
						// die();

						$GCCERT_FILENAME_FILENAME = $cert_path."/".$GCCERT_FILENAME;
						$GCCERT = $this->funivcode."/certificates/{$this->reg_no}/".$GCCERT_FILENAME;
						$GCCERT_upd = "/certificates/{$this->reg_no}/".$GCCERT_FILENAME;
						// var_dump($GCCERT, $GCCERT_PATH);
						// die();
						// var_dump()
						if(file_exists($GCCERT_PATH)) {
							try {								
								$s3->putObject(['Bucket' => CNV_STUDENT_PHOTOS_BUCKET, 'Key' => $GCCERT, 'SourceFile' => $GCCERT_PATH]);								
									$update="update dctran set {$TAB} ='{$GCCERT}' 
									where fappno=  {$app_no} ";
									$up_obj=$this->aobj_context->mobj_db->Execute($update); 
								
									unlink($GCCERT_PATH);
							}	catch(S3Exception $e){
								// var_dump($e);
								$arr['message'] = 'Unable to upload documents';
								echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
								return;
							}
						}
						
					}
				}

					if(isset($_FILES['student_entry_upload']['name']) && $_FILES['student_entry_upload']['name'] != '')         
					{ 
						//var_dump("Outside: ".$full_file_path);

						if(move_uploaded_file($_FILES['student_entry_upload']['tmp_name'],$full_file_path))
						{
							//var_dump($full_file_path);
							try {
								$res = $s3->putObject(['Bucket' => CNV_STUDENT_PHOTOS_BUCKET, 'Key' => $this->funivcode."/".$image_path, 'SourceFile' => $full_file_path]);
								$photo_path=$image_path; 
								unlink($image_path);
							}catch(S3Exception $e) {
								$arr['message'] = 'Unable to upload Photo';
								echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
								return;
							}

							$update="update dctran set FPHOTOPATH='{$image_path}' 
							where fappno=  {$app_no} ";
							$up_obj=$this->aobj_context->mobj_db->Execute($update); 
							$arr['app_no']=$app_no;
							echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
							
						}
						else
						{
							$data="Error While Moving the Image";
							echo $this->aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure"); 
							return;
						}
					}else
					{

						$query = "select ifnull(FPHOTOPATH,'') as FPHOTOPATH 
						from dctran where fappno = '{$app_no}'";
						$res=$this->aobj_context->mobj_db->GetRow($query); 
						
						if($res['FPHOTOPATH'] == '')
						{
							$arr['message'] = 'Unable to upload Photo';
							echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
							return;

						}else
						{
							$arr['app_no']=$app_no;
							echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
						}	
					}

				

			}else
			{
				// if($this->amount == 0)
				// 	$this->paytype = 'POSTOFFICE';
				
				if($this->univ!="018"){
				$insert_qry=" insert into dctran(FAPPNO,FREGNO,FNAME,FDOB,FMOBILE,FEMAIL,FAMOUNT,FPAYTYPE,FREGDATE,FREGIP,FRECCER,FPOSTADDR1,FPOSTADDR2,FCITY,FSTATE,FPINCODE,FRCTYPE,FNATIONAL,FAADHAR,FUNIVCODE,FCATCODE,FKANNAME)
							values('{$this->reg_no}','{$this->reg_no}','{$this->candidate_name}',date_format(str_to_date('{$this->dob}','%Y-%m-%d'),'%Y-%m-%d'),'{$this->mobile_no}','{$this->email_id}',
							'{$this->amount}','{$this->paytype}',now(),'{$this->ip}','{$this->freccer}','{$this->paddr1}','{$this->paddr2}','{$this->city}','{$this->state}','{$this->pincode}','{$this->rctype}','{$this->nationality}','{$this->aadhar}','{$this->univ}','{$this->catcode}','{$this->kanname}') ";
				}else{
				$insert_qry=" insert into dctran(FAPPNO,FREGNO,FNAME,FMOBILE,FEMAIL,FAMOUNT,
							FPAYTYPE,FREGDATE,FPOSTADDR1,FPOSTADDR2,FCITY,FSTATE,FPINCODE,FRCTYPE,FUNIVCODE)
							values('{$this->reg_no}','{$this->reg_no}','{$this->candidate_name}', '{$this->mobile_no}','{$this->email_id}',
							'{$this->amount}','{$this->paytype}',now(),'{$this->paddr1}','{$this->paddr2}','{$this->city}','{$this->state}','{$this->pincode}',
							'{$this->rctype}','{$this->univ}')";
				}
					
				$insert_obj=$this->aobj_context->mobj_db->Execute($insert_qry);	
			
				// '{$this->ip}','{$this->freccer}','{$this->nationality}','{$this->aadhar}','{$this->catcode}','{$this->kanname}'

				$error=mysql_error();
				$this->last_inserted_id = $this->aobj_context->mobj_db->Insert_ID();
				
				if($this->last_inserted_id)
				{
					
					$this->UpdateApplicationUniqueNo();
					
				}
				else
				{
					$data="Error While Inserting ".$error ;;
					echo $this->aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure"); 
					return;
				}
			}
		}
		
		function UpdateApplicationUniqueNo()
		{
			$db=trim($this->aobj_context->mobj_data["db"]);
			
			
			include_once("/json.php");	
			$json = new Services_JSON();

			$mobj_jsondata = json_decode($this->fee_arr);

			$query="SELECT fdcappno+1 as FLASTNO,FCVPREFIX FROM control";
			$objrst =  $this->aobj_context->mobj_db->GetRow($query); 
			
			$this->prefix=$objrst['FCVPREFIX'];
			$this->app_no=$this->prefix.$objrst['FLASTNO'];
			
			$update_last_no="update control set fdcappno=fdcappno+1";
			$this->aobj_context->mobj_db->Execute($update_last_no); 
			
			$update_app_no="update dctran set FAPPNO='{$this->app_no}'
					where FAUTONO={$this->last_inserted_id}";
			$this->aobj_context->mobj_db->Execute($update_app_no);
			
			for($k=0;$k<count($mobj_jsondata);$k++)
			{	
				if($mobj_jsondata[$k]->headcode != 'Total Amount')
				{
					$query  = "INSERT INTO `studcnvfee` (`fappno`, `fregno`, `fheadcode`, `famount`, `fcreateddate`)
					VALUES
					('{$this->app_no}', '{$this->reg_no}', '{$mobj_jsondata[$k]->headcode}', '{$mobj_jsondata[$k]->fee}', now()) 
					ON DUPLICATE KEY UPDATE fheadcode = '{$mobj_jsondata[$k]->headcode}',
					fheadcode = '{$mobj_jsondata[$k]->headcode}',
					famount = '{$mobj_jsondata[$k]->fee}',
					fcreateddate = now()";
					//var_dump($query);
					$this->aobj_context->mobj_db->Execute($query);
				}else
				{
					$query="update dctran set FAMOUNT = '{$mobj_jsondata[$k]->fee}'
					where FAPPNO='{$this->app_no}'";
					$this->aobj_context->mobj_db->Execute($query);
				}	
			}

			$this->SendAppNoUser($this->mobile_no,$this->email_id,$this->app_no,$db);	
			
			//include_once($this->aobj_context->main_src."/JSON.php"); 
			//$json = new Services_JSON();
			$college_path=$this->aobj_context->main_src.'/'.$this->db."/student_photos/{$this->college}";
			$folder_path=$this->aobj_context->main_src.'/'.$this->db."/student_photos";
			$file_name=basename($_FILES['student_entry_upload']['name']);
			$path_arr=pathinfo($_FILES['student_entry_upload']['name']);
			$file_ext=$path_arr['extension'];
			$full_file_path= $folder_path.'/'.$this->reg_no.".".$file_ext;;
			$image_path="student_photos/".$this->reg_no.".".$file_ext;;
			  
			$s3 = S3Client::factory(
				array(
					'credentials' => array(
						'key' => IAM_KEY,
						'secret' => IAM_SECRET
					),
					'version' => "latest",
					'region'  => 'ap-south-1'
				)
			);

			if($this->db == 'vskub'){
				$doc_names = ['deg_cert', 'sem_mks'];

				for($i=0;$i<count($doc_names);$i++)
				{
					if($doc_names[$i] == 'deg_cert'){
						$GCCERT = $this->deg_cert;
						$TAB = 'FDEGCERTPATH';
					}elseif($doc_names[$i] == 'sem_mks'){
						$GCCERT = $this->sem_mks;
						$TAB = 'FALLSEMCERT';
					}
					
					if($GCCERT == '')
						continue;

					$GCCERT_PATH = $this->aobj_context->main_src.$this->db.'/uploads/'.$GCCERT;
					$filename = explode(".", $GCCERT_PATH);
					$ext = strtolower($filename[1]);


					$GCCERT_FILENAME = $doc_names[$i];
					
					$GCCERT_FILENAME = $GCCERT_FILENAME.".".$ext;
					// var_dump($GCCERT_PATH);
					// die();

					$GCCERT_FILENAME_FILENAME = $cert_path."/".$GCCERT_FILENAME;
					$GCCERT = $this->funivcode."/certificates/{$this->reg_no}/".$GCCERT_FILENAME;
					$GCCERT_upd = "/certificates/{$this->reg_no}/".$GCCERT_FILENAME;
					// var_dump($GCCERT, $GCCERT_PATH);
					// die();
					// var_dump()
					if(file_exists($GCCERT_PATH)) {
						try {								
							$s3->putObject(['Bucket' => CNV_STUDENT_PHOTOS_BUCKET, 'Key' => $GCCERT, 'SourceFile' => $GCCERT_PATH]);								
								$update="update dctran set {$TAB} ='{$GCCERT}' 
								where fappno=  {$this->app_no} ";
								$up_obj=$this->aobj_context->mobj_db->Execute($update); 
								// var_dump($update);
							
								unlink($GCCERT_PATH);
						}	catch(S3Exception $e){
							// var_dump($e);
							$arr['message'] = 'Unable to upload documents';
							echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
							return;
						}
					}
					
				}
			}


			if(isset($_FILES['student_entry_upload']['name']) && $_FILES['student_entry_upload']['name'] != '')         
			{ 
				//var_dump("Outside: ".$full_file_path);

				if(move_uploaded_file($_FILES['student_entry_upload']['tmp_name'],$full_file_path))
				{
					
					try {
						$res = $s3->putObject(['Bucket' => CNV_STUDENT_PHOTOS_BUCKET, 'Key' => $this->funivcode."/".$image_path, 'SourceFile' => $full_file_path]);
						$photo_path=$image_path; 
						
							
							
						unlink($image_path);
					}catch(S3Exception $e) {
						$arr['message'] = 'Unable to upload Photo';
						echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
						return;
					}

					$update="update dctran set FPHOTOPATH='{$image_path}' 
					where FAUTONO=  '{$this->last_inserted_id}' ";
					$up_obj=$this->aobj_context->mobj_db->Execute($update); 


					$query = "select ifnull(FPHOTOPATH,'') as FPHOTOPATH 
					from dctran where fappno = '{$this->app_no}'";
					$res=$this->aobj_context->mobj_db->GetRow($query); 
					
					if($res['FPHOTOPATH'] == '')
					{
						$arr['message'] = 'Unable to upload Photo';
						echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
						return;

					}else
					{
						$arr['app_no']=$this->app_no;
						echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
					}	
					
				}
				else
				{
					$data="Error While Moving the Image";
					echo $this->aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure"); 
					return;
				}
			}
			// $arr['app_no']=$this->app_no;
			// echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
		}	
		 
		function GetApplicationDetails()
		{
			$this->app_no=trim($this->aobj_context->mobj_data["app_no"]);
			$get_data=" select internal_code, app_no, pget_val, subject, candidate_name, 
			mother_name, father_name, spouse_name, 
			date_format(dob,'%d/%m/%Y') as dob, sex, 
			s.pob, pob_others, 
			nationality,
			s.college ,
			college_others, 
			s.univ ,univ_others, cncl_reg_no, 
			cncl_reg_name, date_format(rotary,'%d/%m/%Y') as rotary, marks, 
			u_pg, phq, religion, 
			s.category, category_others, 
			caste, sub_caste, dd_amt, dd_no, date_format(dd_date,'%d/%m/%Y') as dd_date,
			dd_bank, address, pin,IFNULL(debared,'No') as debared, email, phone, 
			mobile, in_service_status,  
			s.dept , '' as dept_others, plc_of_working, 
			date_format(date_of_entry,'%d/%m/%Y') as date_of_entry, prob_period, date_format(prob_date,'%d/%m/%Y') as  prob_date,
			doing_pg, pg_degree_course, 
			date_format(pg_degree_date,'%d/%m/%Y') as pg_degree_date, 
			pg_diploma_course, date_format(pg_diploma_date,'%d/%m/%Y') as pg_diploma_date, 
			speciality, enq_pending, suspension, absence, remarks, photo_path, 
			created_date, f_max_marksa, f_sec_marksa, 
			f_no_attaa, f_max_marksb, f_sec_marksb, 
			f_no_attbb, f_max_marksc, f_sec_marksc, 
			f_no_attcc, f_max_marksd, f_sec_marksd, 
			f_no_attdd, f_tot_max_marks, f_tot_sec_marks ,ip_address,created_date 
			from 
			dcstud s						 
			where app_no={$this->app_no}";
						//echo $get_data;die();
			$lobj_get_data=$this->aobj_context->mobj_db->GetRow($get_data); 
			$data="Error While Moving the Image";
			echo $this->aobj_context->mobj_output->ToJSONEnvelope($lobj_get_data,0,"Success"); 
			return;
		}
	 
	
	function GetCMSDropDownMenuValues()
	{
		$db=trim($this->aobj_context->mobj_data["db"]);
		$query="SELECT fcnvno AS int_code,fcnvname AS val FROM mascnvfee 
		where ifnull(fdeleted,'') <> 'T' order by fcnvno asc ";
		$rst=$this->aobj_context->mobj_db->GetAll($query);
		$arr['convtype'] = $rst;

		$query2="SELECT FCATEGORY AS int_code,FDESCPN AS val FROM category 
		where ifnull(fdeleted,'') <> 'T' order by FCATEGORY asc ";
		$rst2=$this->aobj_context->mobj_db->GetAll($query2);
		$arr['category'] = $rst2;

		$get_data="SELECT payment_type AS int_code,bank_name AS val FROM acc_mas 
		where ifnull(fsuspend,'') <> 'T'";
		$up_obj=$this->aobj_context->mobj_db->GetAll($get_data);
		$arr['acctype'] = $up_obj;

		$get_data="SELECT funivcode AS int_code,fdescpn AS val 
		FROM dcuniv where ifnull(fdeleted,'') <> 'T'";
		$up_obj=$this->aobj_context->mobj_db->GetAll($get_data);
		$arr['univdata'] = $up_obj;
		$arr['db'] = $db;

		echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
		return;		
	}
	
	function GetCMSAmountValue()
	{
		$degree=trim($this->aobj_context->mobj_data["degree"]);
		$nationality=trim($this->aobj_context->mobj_data["nationality"]);
		$qry="SELECT FAMOUNT FROM masfee
		WHERE FDEGREE='{$degree}' AND FNATIONAL='{$nationality}'";
		$up_obj=$this->aobj_context->mobj_db->GetRow($qry);
	 
		$amt=$up_obj['FAMOUNT'];
		$amt=empty($amt)?0:$amt;
		$arr['amount']=$amt;
		
		$sub_arr=$this->GetSubjectDetails($degree);
		$doc_arr=$this->GetStudentDocumentsTable($degree,$nationality);
		$arr['subjects'] = $sub_arr;
		$arr['doc_arr'] = $doc_arr;
		echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
	}
	
	function ValidatePaymentApplicationData()
	{
		$p_appno=trim($this->aobj_context->mobj_data["p_appno"]);
		$p_dob=trim($this->aobj_context->mobj_data["p_dob"]);
		$p_reg_no=trim($this->aobj_context->mobj_data["p_reg_no"]);
	 

		$query = "select FUNIVCODE from control";
		$res=$this->aobj_context->mobj_db->GetRow($query);
		$FUNIVCODE = $res['FUNIVCODE'];

		$qry="SELECT  FAPPNO,ifnull(FPAYSTATUS,'') PAYSTATUS from dctran
		WHERE FDOB='{$p_dob}' AND FAPPNO='{$p_appno}' AND FREGNO='{$p_reg_no}'";
		$up_obj=$this->aobj_context->mobj_db->GetRow($qry);
	 
		$FAPPNO = $up_obj['FAPPNO'];
		if(empty($FAPPNO))
		{	
			$error_msg = 'Invalid Inputs Entered';
			echo $this->aobj_context->mobj_output->ToJSONEnvelope($error_msg,-1,"failure");
			return;
		}	
		else if($up_obj['PAYSTATUS'] == 'success')
		{
			$error_msg = 'Payment already made for the given application no.';
			echo $this->aobj_context->mobj_output->ToJSONEnvelope($error_msg,-1,"failure");
			return;
		}	
		else
		{
			$arr['app_no'] = $FAPPNO;
			$arr['UNIVCODE'] = $FUNIVCODE;
			echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
			return;
		}	
	}	
	
	function ValidatePrintCertificateApplicationData()
	{
		$appno =trim($this->aobj_context->mobj_data["appno"]);
		$dob=trim($this->aobj_context->mobj_data["dob"]);
		$regno=trim($this->aobj_context->mobj_data["regno"]);
		$db=trim($this->aobj_context->mobj_data["db"]);

		$query = "SELECT fcollcode,fdegree,fregno from dcstud where FREGNO='{$regno}'";
		$res=$this->aobj_context->mobj_db->GetRow($query);
		$FCOLLCODE = $res['fcollcode'];
		$FDEGREE = $res['fdegree'];
	 
		if($db!="sikkim"){
			$qry = "SELECT  FAPPNO,FPAYTYPE, ifnull(FPAYSTATUS,'') as FPAYSTATUS 
			from dctran
			WHERE FREGNO='{$regno}' and FAPPNO ='{$appno}'";		
			
		}else{
			$qry="SELECT FAPPNO,FPAYTYPE, ifnull(FPAYSTATUS,'') as FPAYSTATUS 
			from dctran WHERE  FREGNO='{$regno}' and FAPPNO ='{$appno}'";
		}
		$up_obj=$this->aobj_context->mobj_db->GetRow($qry);
		

		$FAPPNO=$up_obj['FAPPNO'];
		$FPAYTYPE = $up_obj['FPAYTYPE'];
		$FPAYSTATUS = $up_obj['FPAYSTATUS'];
		if($FPAYSTATUS != 'success')
		{
			$query = "select count(*) as cnt from collexam where 
			fdegree = '{$FDEGREE}'
			and fcollcode = '{$FCOLLCODE}'
			and  DATE_FORMAT(NOW(),'%Y-%m-%d') 
			BETWEEN DATE_FORMAT(FCNVFROM,'%Y-%m-%d') 
			AND DATE_FORMAT(FCNVTO,'%Y-%m-%d')";
			
			$resuls = $this->aobj_context->mobj_db->GetRow($query);
			
			if($resuls['cnt'] == '0')
			{
				$data="Date are not enabled";
				echo $this->aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure");
				return;
			}

			// $query = "select ifnull(fdissable,'F') as fdissable From dcstud where fregno = '{$regno}'";
			// $res1 = $aobj_context->mobj_db->GetRow($query);
			// $fdissable = $res1['fdissable'];

			if($fdissable == 'T')
			{
				$data="Date are not enabled";
				echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure");
				return;
			}
		}

		if(empty($FAPPNO))
		{	
			$error_msg = 'invalid credentials';
			echo $this->aobj_context->mobj_output->ToJSONEnvelope($error_msg,-1,"failure");
		}	
		else
		{
			$arr['app_no']=$FAPPNO;
			$arr['paytype']=$FPAYTYPE;
			$arr['paystatus']=$FPAYSTATUS;
			echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
		}
			
	}	
	
	function GetSubjectDetails($degree)
	{
		$get_sub="SELECT FQUALSUB FROM massub
					WHERE FDEGREE='{$degree}'";	
		 $up_get_sub=$this->aobj_context->mobj_db->GetAll($get_sub);			
		$i=0;
		$sl=1;
		$html="";
		foreach($up_get_sub	 as $ak=>$av)
		{
			$FQUALSUB=$av['FQUALSUB'];
			$html.="<tr>";
		 
			$html.="<td style='width:300px' id='sub_td_{$i}'>{$FQUALSUB}</td>";
			$html.="<td><input style='width:200px' type='text' id='sub_max_{$i}' placeholder='{$FQUALSUB} Marks' maxlength=10 class='form-control'></td>";
			$html.="<td><input style='width:200px' type='text' id='sub_sec_{$i}' placeholder='{$FQUALSUB} Secured' maxlength=10 class='form-control'></td>";
			$html.="</tr>";
			$i++;
			$sl++;
		}
		return $html;
	}
	
	function GetpaymentLinkForAppNo()
	{
		$app_no=trim($this->aobj_context->mobj_data["app_no"]);
		$db=trim($this->aobj_context->mobj_data["db"]);
		
		$get_details="SELECT dctran.FAPPNO as FAPPNO,dctran.FREGNO,college.FCOLLNAME,degree.FDESCPN,date_format(dctran.FDOB,'%d/%m/%Y') as FDOB,dctran.FAMOUNT,
		dctran.FNAME,dctran.FMOBILE,dctran.FEMAIL,dctran.FREGDATE,dctran.FPAYTYPE,control.funivcode  
		FROM dctran,dcstud,degree,college,control
		WHERE dcstud.FREGNO = dctran.FREGNO and college.FCOLLCODE = dcstud.FCOLLCODE
		and degree.FDEGREE = dcstud.FDEGREE and FAPPNO='{$app_no}' ";
		$objget_details=$this->aobj_context->mobj_db->GetRow($get_details);
	
		$FDATE=$objget_details['FREGDATE'];	 
		$FREGNO=$objget_details['FREGNO'];	
		$FCOLLCODE=$objget_details['FCOLLNAME'];	 
		$FDEGREE=$objget_details['FDESCPN'];	
		$FNAME=$objget_details['FNAME'];	
		$FDOB=$objget_details['FDOB'];	 
		$FAMOUNT=$objget_details['FAMOUNT'];	 
		$FMOBILENO=$objget_details['FMOBILE'];	 
		$FEMAIL=$objget_details['FEMAIL'];
		$FPAYTYPE=$objget_details['FPAYTYPE'];
		$funivcode=$objget_details['funivcode'];	
		if($db == 'sikkim')
		{
			$html='	<h3 class="col-md-offset-1" style="color:green;"><br>Your Application No. is : '.$app_no.' <br> Keep this number for future correspondence with University.</h3> 
			<div class="row">
			<div class="col-md-6 col-sm-12">
			</div>
			</div></div>';
		}else
		{
			$html='	<h3 class="col-md-offset-1" style="color:green;"> Successfully Applied(Fee Pending) !!. <br>Your Application No. is : '.$app_no.' <br> Keep this number for future correspondence with University.</h3> <div class="row">
			<div class="col-md-6 col-sm-12">

			<div class="portlet yellow box">
				<div class="portlet-title">
					<div class="caption">
						<i class="fa fa-cogs"></i>Application Details
					</div>
					 
				</div>
				<div class="portlet-body">
					<div class="row static-info">
						<div class="col-md-5 name">
							 Application no. :
						</div>
						<div class="col-md-7 value">
							 '.	$app_no.'
							 
						</div>
					</div>
					<div class="row static-info">
						<div class="col-md-5 name">
							 Application Date &amp; Time:
						</div>
						<div class="col-md-7 value">
							'.$FDATE.'
						</div>
					</div>
					<div class="row static-info">
						<div class="col-md-5 name">
							 Registration no. :
						</div>
						<div class="col-md-7 value">
							'.$FREGNO.'
						</div>
					</div>
					<div class="row static-info">
						<div class="col-md-5 name">
							 College:
						</div>
						<div class="col-md-7 value">
							'.$FCOLLCODE.'
						</div>
					</div>
					<div class="row static-info">
						<div class="col-md-5 name">
							Degree:
						</div>
						<div class="col-md-7 value">
							'.$FDEGREE.'
						</div>
					</div>
					<div class="row static-info">
						<div class="col-md-5 name">
							 Candidate Name:
						</div>
						<div class="col-md-7 value">
								'.$FNAME.'
						</div>
					</div>
					<div class="row static-info">
						<div class="col-md-5 name">
							Amount:
						</div>
						<div class="col-md-7 value">
								<i style="color:red;" class="fa fa-rupee"></i> '.$FAMOUNT.'
						</div>
					</div>
					<div class="row static-info">
						<div class="col-md-5 name">
							 Mobile:
						</div>
						<div class="col-md-7 value">
							'.$FMOBILENO.'
						</div>
					</div>
					<div class="row static-info">
						<div class="col-md-5 name">
							 Email id:
						</div>
						<div class="col-md-7 value">
							'.$FEMAIL.'
						</div>
					</div>
				</div>
			</div>
			</div></div>';
		}
		
			if($FPAYTYPE == 'Other Banks')	
			{	
				$html.='<div class="form-actions fluid">
				<div class="row">
				<div class="col-md-12">
				<div class="col-md-offset-3 col-md-4">
				<button class="btn green" onclick=\'CMS.MakeOnlinePayment("'.$app_no.'","'.$funivcode.'");\' type="button"><i class="fa fa-rupee"></i> Make Online Payment</button>
				<button class="btn red" onclick="home();" type="button"  ><i class="fa fa-times"></i> Pay Later</button>
				</div>
				</div>
				</div>
				</div>';
			}
			else
			{
				$html.='<div class="form-actions fluid">
				<div class="row">
				<div class="col-md-12">
				<div class="col-md-offset-3 col-md-4">
				<button class="btn green" onclick=\'CMS.PrintPOSTCertifcate("'.$app_no.'");\' type="button"><i class="fa fa-rupee"></i> Print Application</button>
				<button class="btn red" onclick="home();" type="button"  ><i class="fa fa-times"></i>Back</button>
				</div>
				</div>
				</div>
				</div>';
			}		
		echo $this->aobj_context->mobj_output->ToJSONEnvelope($html,0,"success"); 
		return;
	}
	function recurseRmdir($dir) {
		  $files = array_diff(scandir($dir), array('.','..'));
		 
		  foreach ($files as $file) {
			(is_dir("$dir/$file")) ? recurseRmdir("$dir/$file") : unlink("$dir/$file");
		  }
		  return rmdir($dir);
		}

	function GetStudentDocumentsTable($degree,$nationality)
	{
	     
		 $delete="delete from studoc where 
							login_cnt='{$this->login_cnt}'
							and app_no is null
							";	
				$lobj_delete= $this->aobj_context->mobj_db->Execute($delete);	
		$dir_path=$this->aobj_context->main_src."/certificates/{$this->login_cnt}/";
		if($this->login_cnt>0)
		{
		$this->recurseRmdir($dir_path);
		 rmdir($dir_path);
		}
		$get_document_data="select internal_code as int_code, FCERTDESC as doc_type ,
		ifnull(FFILENAME,REPLACE(REPLACE(FCERTDESC,' ','_'),'+','_')) as FFILENAME from masdoc
		WHERE FDEGREE='{$degree}' and FNATIONAL like '%{$nationality}%'";
		  							
		$lobj_get_document_data= $this->aobj_context->mobj_db->GetAll($get_document_data);
		
	    $this->html="";
		$this->html.='	<form    id="form_module_image_upload" enctype="multipart/form-data" method="POST"> 
		<!-- MY TASK BEGIN CONDENSED TABLE PORTLET-->
		<div class="span11"><div class="portlet box blue">
		<div class="portlet-title">
		<i class="fa fa-cogs"></i> UPLOAD CERTIFICATES								

		</div>
		<div class="portlet-body">
		<div class="scroller" data-height="380px">
		<table id="upload_table" class="table table-bordered table-hover" cellpadding="0" cellspacing="0">
		<thead>
		<tr>											
		<th>#</th>																		
		<th><i class="icon-briefcase"></i>&nbsp;Document Type</th>																		
		<th>File Type</th>											
		<th>Attachment</th>	</tr>
		</thead>
		<tbody>';
		$sl=1;
		foreach($lobj_get_document_data as $mk=>$mv)
		{
		    $int_code=$mv['int_code'];
		    $doc_type=$mv['doc_type'];
		    $attachment_path=$mv['attachment_path'];
		    $FFILENAME=$mv['FFILENAME'];
		    $file_name=$mv['file_name'];
			$file_type_id="ed_{$int_code}";
			$doc_file_path=$attachment_path;
				if(!empty($attachment_path))
				$selected=" <span class='label label-success' id='uploded_{$int_code}'>Yes</span> ";
				else
				$selected=" <span class='label label-warning' id='uploded_{$int_code}'>No</span>";
				 
			 
			$this->html.='<tr>						
						<td style="width:30px">'.$sl.'</td>						
						<td id="doc_upload_'.$int_code.'" style="width:300px">'.$doc_type.'</td>						
						<td style="width:300px"><div style="float:left;"><input type="file" name='.$file_type_id.' id='.$file_type_id.' /></div><div style="float:left;"><a class="btn btn-sm blue" href="#" onclick=CMS.UploadEmployeeDocuments("'.$int_code.'","'.$FFILENAME.'")><i class="fa fa-upload"></i>&nbsp;Upload</a></div></td>';	
			if(!empty($attachment_path))
			{
				$this->html.='<td style="width:100px"><a style="color:#AB45F9; padding-right:5px;" href="'.$doc_file_path.'" target="_blank">'.$file_name.'</a><span style="cursor:pointer;" class="label label-danger" onclick=CMS.DeleteEmployeeDocuments("'.$int_code.'")>Delete</span></td>';
			}
			else
			{
				$this->html.='<td style="width:100px" id="attach_td_'.$int_code.'">&nbsp;</td>';
			}
		 
			
			$this->html.='</tr>';	$sl++;	
		}
		$this->html.='</tbody></table>
						</div>
					</div>
					</div>
					</div>
					</form>
					<!-- END CONDENSED TABLE PORTLET-->';
		return $this->html;							
	} 
	
	function UploadEmployeeDocuments()
	{		 

		$temp_path = $this->aobj_context->main_src."/certificates/{$this->login_cnt}";
		
		if(!file_exists($temp_path))
		{
			mkdir($temp_path);
		}
		$file_name = replaceChars(basename($_FILES['categoryatt']['name']));
		$file_path = "/{$file_name}";
		$temp_path.=$file_path;
		
		if(isset($file_name) && $file_name != '')         
		{ 		
			$path_arr=pathinfo($_FILES['categoryatt']['name']);
			$file_ext=$path_arr['extension'];
			$root_file_name=$dir_path."/".$file_name;	
			$attachement_path="certificates/{$this->login_cnt}/{$file_name}";
			
			if(move_uploaded_file($_FILES['categoryatt']['tmp_name'],$temp_path))
			{
				$arr['path']=$attachement_path;								
				$arr['file_name']=$file_name;	
				echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");	
				return; 
			}
			else
			{
					$data="Moving {$file_name} to emp_doc_attchments failed";						
					echo $this->aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure");	
					return;
			}
		} 
		else
		{
			$data="File is empty, not moved";						
			echo $this->aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure");	
			return;
		}
	}

	function UploadEmployeeDocumentsTAB()
	{ 
		
		$db =trim($this->aobj_context->mobj_data["db"]);
		$temp_path = $this->aobj_context->main_src.$db."/uploads/";
		$file_name_param=trim($this->aobj_context->mobj_data["file_name"]);
		$fregno=trim($this->aobj_context->mobj_data["fregno"]);
		
		
		// var_dump($file_name_param);
		
		// if(!file_exists($temp_path))
		// {			
		// 	mkdir($temp_path);
		// 	chmod($temp_path, 777);
		// }
		// var_dump($_GET['file_name']);
		// die();
		$file_name = replaceChars(basename($_FILES[$_GET['file_name']]['name']));
		$file_path = $fregno.'_'.$file_name_param;
		$temp_path.=$file_path;
		// var_dump($temp_path);
		// die();
		// var_dump($db);

		
		if(isset($file_name) && $file_name != '')         
		{ 		
			$path_arr=pathinfo($_FILES[$_GET['file_name']]['name']);
			$file_ext=$path_arr['extension'];
			$root_file_name=$dir_path."/".$file_name;	
			$attachement_path="uploads/".$file_path.'.'.$file_ext;

			$temp_path = $temp_path.'.'.$file_ext;
			// var_dump($_FILES[$_GET['file_name']]['tmp_name'],$temp_path.'.'.$file_ext);
			// die();

			
			if(move_uploaded_file($_FILES[$_GET['file_name']]['tmp_name'],$temp_path))
			{
				$arr['path']=$attachement_path;								
				$arr['file_name']=$file_path.'.'.$file_ext;
				$arr['file_name_param'] = $file_name_param;
				echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");	
				return; 
			}
			else
			{
					$data="Moving {$file_name} to emp_doc_attchments failed";						
					echo $this->aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure");	
					return;
			}
		} 
		else
		{
			$data="File is empty, not moved";						
			echo $this->aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure");	
			return;
		}
	}
	//http://myvaluefirst.com/smpp/
	function SendAppNoUser($mobile_no,$s_email_id,$appno,$db)
	{		
		//require_once("cManualMailer.php");
		require_once("sendGridMail.php");
		$message="<html>";
		$message.="<body>";
		$message.="<style>";		
		$message.=".mail_tbl td{text-align:left; padding:2px; font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif;}";	
		$message.="</style>";
		$message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>Dear Candidate,</p></br>";
		if($db == 'sikkim')
			$message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>Your Application no for the 6th Convocation is: ".$appno."</p></br>";
		else 
			$message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>Your Application no. : ".$appno."</p></br>";	
			
		$message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>Your Registration shall be incomplete in case you have not made the Payment.</p>";			
		
		$message.="</br>";	
		$message.="</br>";	
		
		if($db == 'sikkim')
			$message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>Sikkim University</p>";			


		$message.="</br>";			
		$message.="</body>";
		$message.="</html>";
		if($db == 'bcu')
			$subject="BCUUNI - Application no";	 
		else if($db == 'sikkim')	
			$subject="SU - Application no";	 
		$data='true';
		//$data= send_manual_mail($s_email_id,$subject,$message,$replay_to=null,$cc=null,$bcc=null);
		$data= sendGridMail($s_email_id,$subject,$message,$replay_to=null,$cc=null,$bcc=null);
		//SMS OTP
		// $username = 'log01';
		// $password = 'log01124';
		// $from = 'KUVUNI';
		// $to = $mobile_no;
		// $text ="Application no. : ".$appno.". Registration is incomplete until payment is maid.";
		// $category = '';
		// $smsresp = sendsmaapi($username,$password,$from,$to,$text,$category);	

	}
	
	function SendMailOtPToUser()
	{
		$mobile_no=trim($this->aobj_context->mobj_data["s_mobile_no"]);
		$s_email_id=$this->aobj_context->mobj_data['s_email_id'];
		
		$query = "select funivcode,ffolder from control";
		$results = $this->aobj_context->mobj_db->GetRow($query);
		$this->funivcode = $results['funivcode'];
		$ffolder = $results['ffolder'];

		//require_once("cManualMailer.php");
		include("sendsmsapiv1.php");
		date_default_timezone_set('Asia/Kolkata');
		$time =  date("h:i A");
		//require_once("sendGridMail.php");
		//$otp = generateRandomString();

		$otp = rand(100000, 900000); //strtoupper(substr(sha1(rand()), 0, 4));
		
		$smsotp = "From $ffolder: Dear Student, OTP for Registration is $otp. sent at {$time} - Uniclare";

		$sms = new SMS($this->funivcode, 'RGOTP');
		$sms->sendIndvidualSms($mobile_no, $smsotp, '900', 'CVPOR');

		$message="<html>";
		$message.="<body>";
		$message.="<style>";		
		$message.=".mail_tbl td{text-align:left; padding:2px; font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif;}";	
		$message.="</style>";
		$message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>Dear Candidate,</p></br>";
		$message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>You recently registered for Convocation Certificate. To complete your registration, please confirm your account.</p></br>";
		$message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>You may be asked to enter this confirmation code : {$otp}</p>";			
		$message.="</br>";			
		$message.="</body>";
		$message.="</html>";
		$subject="BCUUNI - Action required: Confirm your Registration";	 
		$data='true';
		
		//$results = json_decode($data,true);

		if($data)
		{
			echo $this->aobj_context->mobj_output->ToJSONEnvelope($otp,0,"success"); 
		}
		else
		{
			echo $this->aobj_context->mobj_output->ToJSONEnvelope($data,-1,"success"); 
		}	
	}

	function Getapplicationstatusdetails()
	{
		$appno =trim($this->aobj_context->mobj_data["appno"]);
		$regno =trim($this->aobj_context->mobj_data["regno"]);
		$dob =trim($this->aobj_context->mobj_data["dob"]);
		$db =trim($this->aobj_context->mobj_data["db"]);
		
		if($db!="sikkim"){
			$get_qry="SELECT distinct s.*,DATE_FORMAT(s.FDOB,'%d/%m/%Y') as dob, 
			if(ifnull(s.FPAYSTATUS,'')='','Pending',s.FPAYSTATUS) as FPAYSTATUS,c.FCOLLNAME,d.FDESCPN,
			st.FCERTNO, st.FCERTDATE
			FROM dctran s, dcstud st,college c, degree d 
			WHERE st.FREGNO = s.FREGNO and st.FCOLLCODE = c.FCOLLCODE and st.FDEGREE = d.FDEGREE 
			and IFNULL(s.FAPPNO,'')!='' and s.FAPPNO='{$appno}' and s.FREGNO='{$regno}' 
			and DATE_FORMAT(s.FDOB,'%d/%m/%Y') = '{$dob}'
			GROUP BY s.FAPPNO ORDER BY s.FAPPNO";
		}else{
			$get_qry="SELECT distinct s.*, 
			if(ifnull(s.FPAYSTATUS,'')='','Pending',s.FPAYSTATUS) as FPAYSTATUS,
			c.FCOLLNAME,d.FDESCPN, st.FCERTNO, st.FCERTDATE FROM dctran s, 
			dcstud st,college c, degree d WHERE st.FREGNO = s.FREGNO and 
			st.FCOLLCODE = c.FCOLLCODE and st.FDEGREE = d.FDEGREE
			 and IFNULL(s.FAPPNO,'')!='' and s.FAPPNO='{$appno}' 
			 and s.FREGNO='{$regno}'  GROUP BY s.FAPPNO ORDER BY s.FAPPNO";
		}
		$this->aobj_context->mobj_db->execute("SET @@session.group_concat_max_len=10000");
		$up_obj=$this->aobj_context->mobj_db->GetRow($get_qry);	
		
		if($up_obj)
		{	
			$html = "<div class='portlet-body form' style='margin-left:10px;'>
			<div class='row'><div class='col-md-10'> <div class='portlet box green'>
			<div class='portlet-title'>
			<div class='caption'>
			<i class='fa fa-picture'></i>Application Details
			</div>
			</div>	 
			</div>
			<!-- BEGIN FORM-->
			<form  class='form-horizontal' id='form_module_details_upload' enctype='multipart/form-data' method='POST'> 
			<div class='col-md-8'>

			<input type='hidden' name= 'MAX_FILE_SIZE' value='10000000000' /> 


			<div class='form-body' >
			<h3 class='form-section'>Payment Information</h3>
			<div class='form-group' >
			<label class='col-md-3 control-label'  style='text-align:left;font-size:18px;font-weight: bold;'>Application no.</label>
			<label class='col-md-5 control-label' style='text-align:left;font-size:18px;'>
			{$up_obj['FAPPNO']}									
			</label>
			</div>	
			<div class='form-group'>
			<label class='col-md-3 control-label'  style='text-align:left;font-weight: bold;'>Register no.</label>
			<label class='col-md-5 control-label' style='text-align:left;'>
			{$up_obj['FREGNO']}
			</label>
			</div>	
			<div class='form-group'>
			<label class='col-md-3 control-label'  style='text-align:left; font-weight: bold;'>College</label>
			<label class='col-md-5 control-label' style='text-align:left;'>
			{$up_obj['FCOLLNAME']}
			</label>
			</div>	
			<div class='form-group'>
			<label class='col-md-3 control-label'  style='text-align:left; font-weight: bold;'>Degree</label>
			<label class='col-md-5 control-label' style='text-align:left;'>
			{$up_obj['FDESCPN']}									
			</label>
			</div>	
			
			<div class='form-group'>
			<label class='col-md-3 control-label'  style='text-align:left; font-weight: bold;'>Candidate name</label>
			<label class='col-md-5 control-label' style='text-align:left;'>
			{$up_obj['FNAME']}	
			</label>
			</div>	";
			if($db != "sikkim"){
			$html.="
			<div class='form-group'>
			<label class='col-md-3 control-label'  style='text-align:left; font-weight: bold;'>DOB</label>
			<label class='col-md-5 control-label' style='text-align:left;'>
			{$up_obj['dob']}
			</label>						
			</div>";
		}	
		$html.="
			</div>

			</div>	
			<div class='col-md-4'>
			<div class='form-group'>
			<img id='student_entry_photo' style='width:148px;z-index:1;height:187px; width:148px'  src='{$up_obj[FPHOTOPATH]}' class='img-responsive' >
			</div>
			</div>		
			</form> 
			</div>
			<div class='form-body' style='clear:both;margin-left:20px;'>
			<h3 class='form-section'>Personnel Information</h3>

			<!--/row-->
			<div class='row'>

			<!--/span-->
			<div class='col-md-3'>
			<div class='form-group'>
			<label style='font-weight: bold;'>Mobile No. : </label><br>
			{$up_obj['FMOBILE']}
			</div>
			</div>
			<div class='col-md-3'>
			<div class='form-group'>
			<label style='font-weight: bold;'>Email Id. : </label><br>
			{$up_obj['FEMAIL']}												
			</div>
			</div>
			<!--/span-->
			</div>
			</div>		
			<div class='form-body' style='clear:both;margin-left:20px;'>
			<h3 class='form-section'>Payment Information</h3>
			<div class='row'>
			<div class='col-md-3'>
			<div class='form-group'>
			<label style='font-weight: bold;'>Payment Type. : </label><br>
			{$up_obj['FPAYTYPE']}
			</div>
			</div>
			<div class='col-md-3'>
			<div class='form-group'>
			<label style='font-weight: bold;'>Payment Status. : </label><br>
			{$up_obj['FPAYSTATUS']}												
			</div>
			</div>
			</div>";

			"<div class='form-body' style='clear:both;'>
			<h3 class='form-section'>Convocation certificate Information</h3>			
			<div class='row'>
			<div class='col-md-3'>
			<div class='form-group'>
			<label style='font-weight: bold;'>Certificate no. : </label><br>
			{$up_obj['FCERTNO']}
			</div>
			</div>
			<div class='col-md-3'>
			<div class='form-group'>
			<label style='font-weight: bold;'>Certificate Print Date. : </label><br>
			{$up_obj['FCERTDATE']}														
			</div>
			</div>
			</div>	
			<span> <b>Note : </b>Certificate will be dispatched to College / Study Center within 30 days from the date of Printing.</span>
			<div class='col-md-12'>
			<div class='col-md-offset-3 col-md-4'>
			<br><br>
			<button class='btn red' onclick='home();' type='button'  ><i class='fa fa-times'></i>Back</button>
			</div>
			</div>
			
			</div></div>";	
			
		$arr['html']=$html;
		echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,0,"Success"); 
		return;
	}
	else
	{
		$error_msg = 'invalid credentials';
		echo $this->aobj_context->mobj_output->ToJSONEnvelope($error_msg,-1,"failure"); 
		return;
	}	
	}	
}

function GetpaymentLinkForAppNo($aobj_context)
{ 
	$obj=new applicationForm($aobj_context);
	$obj->GetpaymentLinkForAppNo();
}

function ValidatePaymentApplicationData($aobj_context)
{ 
	$obj=new applicationForm($aobj_context);
	$obj->ValidatePaymentApplicationData();
}

function ValidatePrintCertificateApplicationData($aobj_context)
{ 
$obj=new applicationForm($aobj_context);
$obj->ValidatePrintCertificateApplicationData();
}
function GetCMSDropDownMenuValues($aobj_context)
{ 
	$obj=new applicationForm($aobj_context);
	$obj->GetCMSDropDownMenuValues();
}

function UploadEmployeeDocuments($aobj_context)
{ 
	$obj=new applicationForm($aobj_context);
	$obj->UploadEmployeeDocuments();
}
function UploadEmployeeDocumentsTAB($aobj_context)
{ 
	$obj=new applicationForm($aobj_context);
	$obj->UploadEmployeeDocumentsTAB();
}

function HandleUserInputFiles($aobj_context)
{ 
	$obj=new applicationForm($aobj_context);
	$obj->HandleUserInputFiles();
}

function GetCMSAmountValue($aobj_context)
{ 
	$obj=new applicationForm($aobj_context);
	$obj->GetCMSAmountValue();
}

function SendMailOtPToUser($aobj_context)
{ 
	$obj=new applicationForm($aobj_context);
	$obj->SendMailOtPToUser();
}

function SaveCertificateDetails($aobj_context)
{ 
	$obj=new applicationForm($aobj_context);
	$obj->assignParams();
	
	if($obj->edit_app_code==0)
	{
	$obj->SaveDetails();
	}
	else
	{
	$obj->UpdateAuditTrial();
	$obj->UpdateDetails();
	}
}

function Getapplicationstatusdetails($aobj_context)
{
	$obj=new applicationForm($aobj_context);
	$obj->Getapplicationstatusdetails();
}

 

function DiaplayUserSelectedPhoto($aobj_context)
{
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC); 
	session_start();
	$logincnt = $_SESSION['login_cnt'];
	$db =trim($aobj_context->mobj_data["db"]);
	
	$folder_path = $aobj_context->main_src.'/'.$db."/student_photos/";
	$file_name = replaceChars(basename($_FILES['student_entry_upload']['name']));
	
	$path_arr = pathinfo($_FILES['student_entry_upload']['name']);
	
	$file_ext = $path_arr['extension'];
	
	$temp_path = $aobj_context->main_src.'/'.$db."/student_photos/temp";
	

	if(!file_exists($temp_path))
	{
		mkdir($temp_path);
	}
	$file_path = "/{$logincnt}_{$file_name}";
	
	
 	$temp_path.=$file_path;
	 
		
	if(isset($_FILES['student_entry_upload']['name']) && $_FILES['student_entry_upload']['name'] != '')         
	{ 
		$size = ($_FILES['student_entry_upload']['size']/1024);
		if($size>1024)
		{
			$data = "Please Upload the Photo of size less than 1 MB";
			echo $aobj_context->mobj_output->ToJSONEnvelope($data,-2,"success"); 
			return;
		}
		if(move_uploaded_file($_FILES['student_entry_upload']['tmp_name'],$temp_path))
		{
			$data = "student_photos/temp/{$file_path}";
			
			echo $aobj_context->mobj_output->ToJSONEnvelope($data,0,"success"); 
			return;
		}
	}
	echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure"); 
	return;	
}

function Getstudentdetails($aobj_context)
{
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC); 
	session_start();
	$regno = $aobj_context->mobj_data["regno"];
	$dob = $aobj_context->mobj_data["birthData"];
	$univ = $aobj_context->mobj_data["univ"];
	$db = $aobj_context->mobj_data["db"];


	$qry = "select ifnull(s.fregno,'') as fregno, ifnull(s.FDEGREE,'')as fdegree, ifnull(d.FDESCPN,'')as fdescpn, ifnull(s.FCOLLCODE,'')as FCOLLCODE,
	ifnull(concat(c.FCOLLNAME,', ', c.FTOWN),'') as FCOLLNAME, ifnull(s.FNAME,'') as fname,
	 ifnull('{$univ}','') as funivcode, 
	 ifnull(s.FMAXMARKSA,'-') as FMAXMARKSA, ifnull(s.FMARKSA,'-') as FMARKSA,
	 ifnull(s.FMAXMARKSB,'-') as FMAXMARKSB, ifnull(s.FMARKSB,'-') as FMARKSB,
	 ifnull(s.FMAXMARKSC,'-') as FMAXMARKSC, ifnull(s.FMARKSC,'-') as FMARKSC, 
	 ifnull(s.FMAXMARKSD,'-') as FMAXMARKSD, ifnull(s.FMARKSD,'-') as FMARKSD,
	 ifnull(s.FMAXMARKSE,'-') as FMAXMARKSE, ifnull(s.FMARKSE,'-') as FMARKSE,
	 ifnull(s.FMAXMARKSF,'-') as FMAXMARKSF, ifnull(s.FMARKSF,'-') as FMARKSF,
	 ifnull(s.FMAXMARKSG,'-') as FMAXMARKSG, ifnull(s.FMARKSG,'-') as FMARKSG,
	 ifnull(s.FMAXMARKSH,'-') as FMAXMARKSH, ifnull(s.FMARKSH,'-') as FMARKSH,
	 ifnull(s.FMAXMARKSI,'-') as FMAXMARKSI ,ifnull(s.FMARKSI,'-') as FMARKSI,
	 ifnull(s.FMAXMARKSJ,'-') as FMAXMARKSJ, ifnull(s.FMARKSJ,'-') as FMARKSJ
	from dcstud s inner join college c on c.FCOLLCODE=s.FCOLLCODE 
	inner join degree d on d.FDEGREE=s.FDEGREE
	and d.fexamno = 'A'
	INNER JOIN student sd ON s.fregno=sd.fregno AND s.fdegree=sd.fdegree
    where s.FREGNO = '{$regno}' and sd.fdob='{$dob}'";


    $res = $aobj_context->mobj_db->GetRow($qry);
	
	if($res){
		// $arr=$res;
		// echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");;
		// return;
	}else{
		if($db == 'sikkim')
		{
			$data="Data not available - pls contact su.certificates@cus.ac.in for further queries";
		}else 
		{
			$data="Data not available. Contact Help Desk ";
		}
		
        echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure");
        return;
	}

	$FDEGREE = $res['FDEGREE'];
	$FCOLLCODE = $res['FCOLLCODE'];


	$query = "select count(*) as cnt from collexam where 
	fdegree = '{$FDEGREE}'
	and fcollcode = '{$FCOLLCODE}'
	and  DATE_FORMAT(NOW(),'%Y-%m-%d') 
	BETWEEN DATE_FORMAT(FCNVFROM,'%Y-%m-%d') 
	AND DATE_FORMAT(FCNVTO,'%Y-%m-%d')";
	// var_dump($query);die();
	$resuls = $aobj_context->mobj_db->GetRow($query);
	

	// if($resuls['cnt'] == '0')
	// {
	// 	$data="Date are not enabled";
    //     echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure");
    //     return;
	// }

	$query = "select ifnull(fdissable,'F') as fdissable From dcstud where fregno = '{$regno}'";
	
	$res1 = $aobj_context->mobj_db->GetRow($query);
	$fdissable = $res1['fdissable'];

	// if($fdissable == 'T')
	// {
	// 	$data="Date are not enabled";
    //     echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure");
    //     return;
	// }
    

	$check_dup="select c.funivcode as fcunivcode, date_format(dc.fdob,'%d/%m/%Y') as dob,dc.* from dctran dc, control c
			where dc.FREGNO='{$regno}' 
			and dc.funivcode = '{$univ}'";
			// var_dump($check_dup);die();
	$obj_check_dup=$aobj_context->mobj_db->GetRow($check_dup);	

	if(strtoupper($obj_check_dup['FPAYSTATUS']) == 'SUCCESS')
	{

		if($db == 'sikkim')
		{
			$data="Application already submitted please Make Payment/Reprint the Application";
		}else
		{
			$data="Convocation Fee Paid. Go to Reprint Acknowledgement";
		}
		
		echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure"); 
		return;
	} 
	
	
	$query = "select distinct dcstud.FREGNO,
	ifnull(dcstud.FCERTNO,'') as FCERTNO, dcstud.FNAME,  concat(college.FCOLLNAME,', ',college.FTOWN) as FCOLLNAME, 
	degree.FDESCPN,ifnull(dcstud.FCASTE,'') as FCASTE,FCNVNAME,
	 if(FMAXMARKSA <= 0,'-',ifnull(FMAXMARKSA,'-')) as FMAXMARKSA, 
	 if(FMARKSA <= 0,'-',ifnull(FMARKSA,'-')) as FMARKSA,

	 if(FMAXMARKSB <= 0,'-',ifnull(FMAXMARKSB,'-')) as FMAXMARKSB, 
	 if(FMARKSB <= 0,'-',ifnull(FMARKSB,'-')) as FMARKSB,

	 if(FMAXMARKSC <= 0,'-',ifnull(FMAXMARKSC,'-')) as FMAXMARKSC, 
	 if(FMARKSC <= 0,'-',ifnull(FMARKSC,'-')) as FMARKSC,

	 if(FMAXMARKSD <= 0,'-',ifnull(FMAXMARKSD,'-')) as FMAXMARKSD, 
	 if(FMARKSD <= 0,'-',ifnull(FMARKSD,'-')) as FMARKSD,

	 if(FMAXMARKSE <= 0,'-',ifnull(FMAXMARKSE,'-')) as FMAXMARKSE, 
	 if(FMARKSE <= 0,'-',ifnull(FMARKSE,'-')) as FMARKSE,

	 if(FMAXMARKSF <= 0,'-',ifnull(FMAXMARKSF,'-')) as FMAXMARKSF, 
	 if(FMARKSF <= 0,'-',ifnull(FMARKSF,'-')) as FMARKSF,

	 if(FMAXMARKSG <= 0,'-',ifnull(FMAXMARKSG,'-')) as FMAXMARKSG, 
	 if(FMARKSG <= 0,'-',ifnull(FMARKSG,'-')) as FMARKSG,

	 if(FMAXMARKSH <= 0,'-',ifnull(FMAXMARKSH,'-')) as FMAXMARKSH, 
	 if(FMARKSH <= 0,'-',ifnull(FMARKSH,'-')) as FMARKSH,

	 if(FMAXMARKSI <= 0,'-',ifnull(FMAXMARKSI,'-')) as FMAXMARKSI, 
	 if(FMARKSI <= 0,'-',ifnull(FMARKSI,'-')) as FMARKSI,

	 if(FMAXMARKSJ <= 0,'-',ifnull(FMAXMARKSJ,'-')) as FMAXMARKSJ, 
	 if(FMARKSJ <= 0,'-',ifnull(FMARKSJ,'-')) as FMARKSJ,
	 ifnull(FCLASS,'-') as FCLASS,
	 ifnull(FCEXAM,'-') as FCEXAM,
	 ifnull(FKANNAME,'') as FKANNAME,
	 ifnull(dcstud.frollno,'') as frollno,
	 ifnull(dcstud.fthesis,'-') as fthesis,
	if(FMAXMARKSA = '0', 'T',ifnull(flateral,'F')) as lat,
	ifnull(degree.fdcmsg,'F') as fdcmsg
	from dcstud, college, degree, dcuniv, mascnvfee 
	where dcstud.FCOLLCODE = college.FCOLLCODE 
	and dcstud.FDEGREE = degree.FDEGREE 
	and dcuniv.funivcode = dcstud.funivcode
	and mascnvfee.FCNVNO = dcstud.FCNVNO
	and dcstud.FREGNO='{$regno}'
	and dcstud.funivcode = '{$univ}'";

	$rst = $aobj_context->mobj_db->GetRow($query);
	if($rst)
	{
		if($rst['FCERTNO'] !='')
		{
			$error_msg = "Convocation Certificate already printed";
			echo $aobj_context->mobj_output->ToJSONEnvelope($error_msg,-1,"failure"); 
			return;
		}
		else
		{	
			$arr['mdata'] = $rst;
			$arr['tdata'] = $obj_check_dup;
			$arr['db'] = $db;
			echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
			return;
		}	
			
	}		
	else
	{	
		$error_msg = 'Not a valid Register no, Please check once again or <br><b>Contact Help desk</b>';
		echo $aobj_context->mobj_output->ToJSONEnvelope($error_msg,-1,"failure");
		return;	
	}				
}

function replaceChars($name)
{
	$spl_char = array("*","/","~","!","@","#","$","%","^","&",":",";","?","/","\\","_","-","'"," ","");
	$link_name = strtolower(str_replace($spl_char,"_",$name));
	return str_ireplace("__","_",$link_name);
}


function generateRandomString($length = 8)
{
    return substr(sha1(rand()), 0, $length);
}

function Getcnvcategoryfee($aobj_context)
{
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC); 
	session_start();
	$regno = $aobj_context->mobj_data["regno"];
	$catcode = $aobj_context->mobj_data["catcode"];

	
	$query = " select if('{$catcode}' ='SCST',(mascnvfee.FSCSTFEE - ifnull(dcstud.fprevpaid,0)),(mascnvfee.FFEE - ifnull(dcstud.fprevpaid,0))) as Fee
	from mascnvfee,dcstud 
	where mascnvfee.FCNVNO = dcstud.FCNVNO and dcstud.FREGNO = '{$regno}'";
	$rst = $aobj_context->mobj_db->GetRow($query);
	$arr['fee'] = $rst[Fee]; 
	echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
	return;
}

function loadConvoFee($aobj_context)
{
	$regno = $aobj_context->mobj_data["regno"];
	$catcode = $aobj_context->mobj_data["catcode"];
	$rctype = $aobj_context->mobj_data["rctype"];
	$nationality = $aobj_context->mobj_data["nationality"];
	$db = $aobj_context->mobj_data["db"];

	
	$query = "select FDEGREE,FCOLLCODE,FCASTE,FCNVNO,fdeggrp from 
	dcstud where fregno = '{$regno}'";
	$result = $aobj_context->mobj_db->GetRow($query);
	

	$fdeggrp = strtoupper($result['fdeggrp']);
	$FCNVNO = $result['FCNVNO'];
	
	if($db == "sikkim"){
	$qry="select fheadcode,ffee as fee
	from admfeestr	
	where fdegree = '{$fdeggrp}'
	and fcombcode = 'convo'
	and fcatcode = 'GM'
	and fseattype = '{$rctype}'
	and fconstype = '{$FCNVNO}'";

	// $qry="select fheadcode,ffee as fee
	// from admfeestr	
	// where fdegree = '{$fdeggrp}'
	// and fcombcode = 'convo'
	// and fcatcode = 'GM'
	// and fseattype = '{$rctype}'
	// and fconstype = '{$FCNVNO}
	// and DATE_FORMAT(NOW(),'%Y-%m-%d') 
	// BETWEEN DATE_FORMAT(fadmfeesdate,'%Y-%m-%d') 
	// AND DATE_FORMAT(fadmfeeedate,'%Y-%m-%d')'";
	
	}else{
	$qry = "select fheadcode,if('{$nationality}' = 'FOREIGNER',fmaxfee,ffee) as fee
	from admfeestr	
	where fdegree = '{$fdeggrp}'
	and fcombcode = 'convo'
	and fcatcode = '{$catcode}'
	and fseattype = '{$rctype}'
	and fconstype = '{$FCNVNO}'
	 and DATE_FORMAT(NOW(),'%Y-%m-%d') 
	BETWEEN DATE_FORMAT(fadmfeesdate,'%Y-%m-%d') 
	AND DATE_FORMAT(fadmfeeedate,'%Y-%m-%d')";
	}
	// if($db == 'sikkim')
		// var_dump($qry);die();
	$res = $aobj_context->mobj_db->GetAll($qry);
	
	if($res)
	{
		$arr['fee'] = $res;
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
		return;
	}else
	{
		$arr['msg']='Convocation Fee Not Defined';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
		return;
	}


}

function viewGoldMedal($aobj_context)
{
	$regno = $aobj_context->mobj_data["regno"];
	$db = $aobj_context->mobj_data["db"];
	
	$query = "select * from dctran where fregno = '{$regno}'
	and ifnull(fgold,'') = 'T'";
	$result = $aobj_context->mobj_db->GetRow($query);

	if($result)
	{
		$arr = 'success';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
		return;
	}else
	{
		$arr = 'No Data Found';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
		return;
	}


}

function saveGoldMedal($aobj_context)
{
	$regno = $aobj_context->mobj_data["regno"];
	$vname1 = $aobj_context->mobj_data["vname1"];
	$vname2 = $aobj_context->mobj_data["vname2"];
	$vrelation1 = $aobj_context->mobj_data["vrelation1"];
	$vrelation2 = $aobj_context->mobj_data["vrelation2"];
	$vemail1 = $aobj_context->mobj_data["vemail1"];
	$vemail2 = $aobj_context->mobj_data["vemail2"];
	$vmob1 = $aobj_context->mobj_data["vmob1"];
	$vmob2 = $aobj_context->mobj_data["vmob2"];
	$db = $aobj_context->mobj_data["db"];

	$query = "select fregno,fappno from dctran where fregno = '{$regno}'
	and ifnull(fgold,'') = 'T'
	and ifnull(fpaystatus,'') = 'success'
	and frctype = 'IN PERSON'";
	$res = $aobj_context->mobj_db->GetRow($query);

	$query = "update dctran set fvname1 = '{$vname1}',
	fvname2 = '{$vname2}',
	fvrelation1 = '{$vrelation1}',
	fvrelation2 = '{$vrelation2}',
	fvemail1 = '{$vemail1}',
	fvemail2 = '{$vemail2}',
	fvmob1 = '{$vmob1}',
	fvmob2 = '{$vmob2}'
	where fregno = '{$regno}'
	and ifnull(fgold,'') = 'T'
	and ifnull(fpaystatus,'') = 'success'
	and frctype = 'IN PERSON'";
	$result = $aobj_context->mobj_db->Execute($query);

	if($result)
	{
		$arr['msg'] = 'Updated Successfully';
		$arr['appno'] = $res['fappno'];
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
		return;
	}else
	{
		$arr = 'No Data Found';
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
		return;
	}


}
?>