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


Current Path : /var/www/student/cug/src/
Upload File :
Current File : /var/www/student/cug/src/candidate_list12.php

<?php

class candidate_list
{ 
    public $drop_down_arr;
	function __construct($aobj_context)
	{
		session_start();
		$this->aobj_context=$aobj_context;
		$this->g_reg_no=$_SESSION['g_reg_no'];
		$lquery = "select FUNIVCODE from control";
		$restemp = $this->aobj_context->mobj_db->GetRow($lquery);
		$FUNIVCODE=$restemp['FUNIVCODE'];
		$_SESSION['FUNIVCODE']=$FUNIVCODE;
		$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
	}
	
	function dashboardMessageBoard()
	{
		$lquery="select message from message_board
		where current_date() between 
		display_from
		and display_to and college_code='EAF' 
		order by 1 desc ";
		$restemp = $this->aobj_context->mobj_db->GetRow($lquery);	

		$this->mess_data=$restemp['message'];

		if(empty($this->mess_data))
		{
		$this->mess_data="<br><b>All the best.</b><br>
		<br><p justify></p>";
		}
	} 
	
	function DisplayStudentSubjectDetails()
	{
		$this->regno = $this->aobj_context->mobj_data["r"];
		$this->regno = strtoupper($this->regno);
		$this->category = $this->aobj_context->mobj_data["c"];
		$this->li = $this->aobj_context->mobj_data["li"];
		
		$lquery="select FDEGREE,FCOLLCODE,FNAME from student 
		where FREGNO='{$this->regno}' 
		and ifnull(fexamappblk,'') <> 'T' and ifnull(fmp,'') <> 'T'";	 
		$restemp = $this->aobj_context->mobj_db->GetRow($lquery);
		
		$this->college_code=$restemp['FCOLLCODE'];
		$this->degree=$restemp['FDEGREE'];
		$this->student_name=$restemp['FNAME'];
		if(empty($this->college_code))
		{
			$arr['data']='No details found for the student';
			echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
			return false;
		}
		else
		{
			$this->GenerateCandidateDetails();

		}
	}
	
	function SubjectCodeDetails($exam)
	{
		$lquery="select FSUBCODE as id,FSUBNAME,
		FSUBCODE  from degree d inner join subject s on 
		s.FDEGREE=d.FDEGREE  and  d.FEXAMNO=s.FEXAMNO
		where d.FDEGREE='{$this->degree}' and s.FEXAMNO='{$exam}' 
		and ifnull(FSUSPEND,'F')!='T'							 
		group by  FSUBCODE";
		$restemp = $this->aobj_context->mobj_db->GetAll($lquery); 

		$option="<option value='None'>None</option>";
			foreach($restemp as $ak=>$av)
			{
			$code=$av['FSUBCODE'];
			$FSUBNAME=$av['FSUBNAME'];
			$option.="<option value='{$code}'>{$code} {$FSUBNAME}</option>";
			}
			return $option;
	}
	
	function GenerateCandidateDetails()
	{
		session_start();
		$FUNIVCODE=$_SESSION['FUNIVCODE'];
		$exam_appear=array();
		$lquery="SELECT * FROM colldeg WHERE fdegree = '{$this->degree}' AND
		fcollcode = '{$this->college_code}' 
		AND DATE_FORMAT(NOW(),'%Y-%m-%d') 
		BETWEEN DATE_FORMAT(FEXAMAPPSDATE,'%Y-%m-%d') 
		AND DATE_FORMAT(FEXAMAPPEDATE,'%Y-%m-%d')";
		
		$student_exam_details = $this->aobj_context->mobj_db->GetRow($lquery); 
		
		if(!empty($student_exam_details))
		{	
			
			$lquery=" select c.FDEGREE,c.FEXAMNO,c.FCOLLCODE,c.FREGNO,IF(IFNULL(c.FCATEGORY,'')='',s.FCASTE,c.FCATEGORY) AS FCATEGORY,
			if(c.Fgender='',s.Fgender,c.Fgender) as Fgender,c.FAPPEARA,c.FEXAMFEEA,
			c.FAPPEARB,c.FEXAMFEEB,c.FAPPEARC,c.FEXAMFEEC,c.FAPPEARD,c.FEXAMFEED,c.FAPPEARE,
			c.FEXAMFEEE,c.FAPPEARF,c.FEXAMFEEF,c.FAPPEARG,c.FEXAMFEEG,c.FAPPEARH,c.FEXAMFEEH,
			c.FAPPEARI,c.FEXAMFEEI,c.FAPPEARJ,c.FEXAMFEEJ,round(c.FTOTALFEE,2) as FTOTALFEE,
			c.FYEAR,c.FEXAMTYPE,c.FDELETED,FRECPTNO,DATE_FORMAT(FRECPTDATE,'%d/%m/%Y') as FRECPTDATE
			,FREMARKS,
			FRECPTNOA,DATE_FORMAT(FRECPTDATEA,'%d/%m/%Y') AS FRECPTDATEA,
			FRECPTNOB,DATE_FORMAT(FRECPTDATEB,'%d/%m/%Y') AS FRECPTDATEB,
			FRECPTNOC,DATE_FORMAT(FRECPTDATEC,'%d/%m/%Y') AS FRECPTDATEC ,
			FRECPTNOD,DATE_FORMAT(FRECPTDATED,'%d/%m/%Y') AS FRECPTDATED ,
			FRECPTNOE,DATE_FORMAT(FRECPTDATEE,'%d/%m/%Y') AS FRECPTDATEE ,
			FRECPTNOF,DATE_FORMAT(FRECPTDATEF,'%d/%m/%Y') AS FRECPTDATEF ,
			FRECPTNOG,DATE_FORMAT(FRECPTDATEG,'%d/%m/%Y') AS FRECPTDATEG ,
			FRECPTNOH,DATE_FORMAT(FRECPTDATEH,'%d/%m/%Y') AS FRECPTDATEH ,
			FRECPTNOI,DATE_FORMAT(FRECPTDATEI,'%d/%m/%Y') AS FRECPTDATEI ,
			FRECPTNOJ,DATE_FORMAT(FRECPTDATEJ,'%d/%m/%Y') AS FRECPTDATEJ ,
			FFRESHEXAM  
			from candsum c left join student s on s.FDEGREE=c.FDEGREE 
			and s.FREGNO=c.FREGNO
			where c.FDEGREE='{$this->degree}' 
			and c.FCOLLCODE='{$this->college_code}'
			and c.FREGNO='{$this->regno}' 
			and ifnull(s.fexamappblk,'') <> 'T' 
			and ifnull(s.fmp,'') <> 'T'";

			$student_exam_details = $this->aobj_context->mobj_db->GetRow($lquery);

			//var_dump($student_exam_details);
			$e_data="<table style='padding:3px 4px 3px 3px;' class='tr_ventor_row'  width='100%' border='0' cellspacing='0' cellpadding='0'>";
			$e_data.="<th align='left' colspan='10' class='ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper' style='back-ground:yellow;font-size:12px; padding-left:6px; height:24px;'>Exam Details</th>";
			$e_data.="<tr class='ui-state-default ui-jqgrid-hdiv'>";
			$e_data.="<td align='center' style='  font-size:12px;   border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'>A</td>";
			$e_data.="<td align='center' style='font-size:12px; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'>B </td>";
			$e_data.="<td align='center' style='font-size:12px; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'>C </td>";
			$e_data.="<td align='center' style='font-size:12px; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'>D </td>";
			$e_data.="<td align='center' style='font-size:12px; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'>E </td>";
			$e_data.="<td align='center' style='font-size:12px; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'>F</td>";
			$e_data.="<td align='center' style='font-size:12px; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'>G</td>";
			$e_data.="<td align='center' style='font-size:12px; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'>H</td>";
			$e_data.="<td align='center' style='font-size:12px; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'>I</td>";
			$e_data.="<td align='center' style='font-size:12px; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'>J</td>";
			$e_data.="</tr>";	
			$e_data.="<tr  style='   border-bottom:1px solid #C5DBEC;'>";
		}
		else
		{	if($FUNIVCODE != '026')
			{
				if(strlen($this->college_code) >2)
				{
					if(substr($this->college_code,0,1) == 2 || substr($this->college_code,0,1) == 3 || substr($this->college_code,0,2) == 'B1' || substr($this->college_code,0,2) == 'B2')
					{
						$get_student_data= "SELECT S.FDEGREE,S.FREGNO,S.FCOLLCODE,
						ifnull(FPHOTOPATH,'') as photo_path,
						concat(col.FCOLLNAME,',',space(2), col.FTOWN) as CollDetails  ,
						concat(ec.FCOLLNAME,', ',ec.ftown) AS exam_center_name,
						col.FCOLLNAME as FCOLLNAME,
						cs.FCNTRCODE AS FEXAMCNTR,col.FCOLLCODE,
						CONCAT(D.FDESCPN) AS COURSE, D.FEXAMDATE,
						S.FNAME,S.FFATNAME,S.FMOTNAME,S.fstudid,
						DATE_FORMAT(S.FDOB,'%d/%m/%Y') AS FDOB
						FROM student S INNER JOIN degree D ON
						S.FDEGREE=D.FDEGREE AND S.FEXAMNO=D.FEXAMNO
						INNER JOIN college col ON S.FCOLLCODE=col.FCOLLCODE
						inner join candsum cs on S.fdegree = cs.fdegree
						and S.fregno = cs.fregno
						LEFT JOIN college ec ON ec.FCOLLCODE=cs.FCNTRCODE
						inner join colldeg on colldeg.fdegree = cs.fdegree
						and colldeg.fcollcode = cs.fcollcode
						WHERE S.FREGNO ='{$this->regno}' 
						AND S.FDEGREE='{$this->degree}' 
						and cs.FCOLLCODE='{$this->college_code}'
						and cs.frecptdate is not null 
						and ifnull(colldeg.fhtstop,'F') <> 'T'
						and ifnull(S.fexamappblk,'') <> 'T' 
						and ifnull(S.fmp,'') <> 'T' ";					
							
						$lobj_get_student_data = $this->aobj_context->mobj_db->GetAll($get_student_data);
						$this->std_adm_count = count($lobj_get_student_data);
						$reg_photo_path='student_photos/'.$this->college_code.'/'.strtolower($this->degree).'/'.strtoupper($this->regno).'.jpg';
						$url = $this->aobj_context->main_src;
						$url = str_replace('student','oasis/kus',$url);	
						$url_img = trim($url."/".$reg_photo_path);
						//$photoPath=trim($this->aobj_context->main_src."/".$reg_photo_path);
						//var_dump($url_img);
						if(file_exists($url_img))
						{
							$arr['photo_present']='true';
						}
						if($this->std_adm_count == 1)
						{
							$arr['adm_ticket']='true';
						}	
					}
				} 
			}
			
			$arr['data']="<span style='font-weight:bold;font-size:20px;color:red;'>Last date is over for online exam application form</span>";
			echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
			return;	 
		
		}
		
		$fee_td="";
		$FFRESHEXAM=$student_exam_details[FFRESHEXAM];
		
				 
		for($i=65;$i<75;$i++)
		{   
			$html_id="candidate_list_exam_".chr($i)."_details";
			$exam_fee["{$html_id}"]=$student_exam_details['FEXAMFEE'.chr($i)];
			$exam_receipt_no["{$html_id}"]=$student_exam_details['FRECPTNO'.chr($i)];
			$exam_receipt_no_date["{$html_id}"]=is_null($student_exam_details['FRECPTDATE'.chr($i)])?date('d/m/Y'):($student_exam_details['FRECPTDATE'.chr($i)]);
			$border_left=($i==65)?" border-left:1px solid #ccc;":" border-left:0px solid #ccc;";
			if($student_exam_details['FAPPEAR'.chr($i)]=='N')
			{		
				$td_data="NE";
				$id=" id ='cand_entry_".chr($i)."'";
			}	
			else if($student_exam_details['FAPPEAR'.chr($i)]=='P')
			{
				$td_data="Pass";
				$id=" id ='cand_entry_".chr($i)."'";
			}	
			else  if($student_exam_details['FAPPEAR'.chr($i)]=='A' || $student_exam_details['FAPPEAR'.chr($i)]=='E')
			{
				array_push($exam_appear,chr($i));
				$id=" id='cand_entry_".chr($i)."'";
				$td_data="<Input  onclick=showExamNosDiv('{$html_id}'); {$id}  name='radio_common' type='radio'>";
				$id='';
			}
			else  
			{
				$td_data="<font color=red>&nbsp;</font>";
				$id=" id ='cand_entry_".chr($i)."'";
			}
			$e_data.="<td align=center style='padding:2px;  border-bottom:1px solid #ccc; {$border_left}border-right:1px solid #ccc;'  {$id} >{$td_data}</td>";
			$fee_td.="<td align=center style='padding:2px;  border-bottom:1px solid #ccc; {$border_left}border-right:1px solid #ccc; color: #B52DA0;    font-weight: bold; ' id='ssub_fee_".chr($i)."' >&nbsp;</td>";
		}
				 
				 
		$e_data.="</tr>";
		$e_data.="</tr>{$fee_td}</tr>";
		$e_data.="</table>";
				
		$get_total_sub_for_degree="select * from degree where FDEGREE='{$this->degree}'";
		$lobj_get_total_sub_for_degree = $this->aobj_context->mobj_db->GetAll($get_total_sub_for_degree); 
				 
		for($j=0;$j<count($lobj_get_total_sub_for_degree);$j++)
		{
			if($lobj_get_total_sub_for_degree[$j]['FEXAMNO']=='A')
			{ $exam_A_limit=$lobj_get_total_sub_for_degree[$j]['FTOTSUB'];$semister_names['A']=$lobj_get_total_sub_for_degree[$j]['FEXAMNAME'];}
			else if($lobj_get_total_sub_for_degree[$j]['FEXAMNO']=='B')
			{ $exam_B_limit=$lobj_get_total_sub_for_degree[$j]['FTOTSUB'];$semister_names['B']=$lobj_get_total_sub_for_degree[$j]['FEXAMNAME'];}
			else if($lobj_get_total_sub_for_degree[$j]['FEXAMNO']=='C')
			{$exam_C_limit=$lobj_get_total_sub_for_degree[$j]['FTOTSUB'];$semister_names['C']=$lobj_get_total_sub_for_degree[$j]['FEXAMNAME'];}
			else if($lobj_get_total_sub_for_degree[$j]['FEXAMNO']=='D')
			{$exam_D_limit=$lobj_get_total_sub_for_degree[$j]['FTOTSUB'];$semister_names['D']=$lobj_get_total_sub_for_degree[$j]['FEXAMNAME'];}
			else if($lobj_get_total_sub_for_degree[$j]['FEXAMNO']=='E')
			{$exam_E_limit=$lobj_get_total_sub_for_degree[$j]['FTOTSUB'];$semister_names['E']=$lobj_get_total_sub_for_degree[$j]['FEXAMNAME'];}
			else if($lobj_get_total_sub_for_degree[$j]['FEXAMNO']=='F')
			{$exam_F_limit=$lobj_get_total_sub_for_degree[$j]['FTOTSUB'];$semister_names['F']=$lobj_get_total_sub_for_degree[$j]['FEXAMNAME'];}	
			else if($lobj_get_total_sub_for_degree[$j]['FEXAMNO']=='G')
			{$exam_G_limit=$lobj_get_total_sub_for_degree[$j]['FTOTSUB'];$semister_names['G']=$lobj_get_total_sub_for_degree[$j]['FEXAMNAME'];}
			else if($lobj_get_total_sub_for_degree[$j]['FEXAMNO']=='H')
			{$exam_H_limit=$lobj_get_total_sub_for_degree[$j]['FTOTSUB'];$semister_names['H']=$lobj_get_total_sub_for_degree[$j]['FEXAMNAME'];}
			else if($lobj_get_total_sub_for_degree[$j]['FEXAMNO']=='I')
			{$exam_I_limit=$lobj_get_total_sub_for_degree[$j]['FTOTSUB'];$semister_names['I']=$lobj_get_total_sub_for_degree[$j]['FEXAMNAME'];}
			else if($lobj_get_total_sub_for_degree[$j]['FEXAMNO']=='J')
			{$exam_J_limit=$lobj_get_total_sub_for_degree[$j]['FTOTSUB'];$semister_names['J']=$lobj_get_total_sub_for_degree[$j]['FEXAMNAME'];}
		}
		for($i=65;$i<75;$i++)
		{ 
			if(in_array(chr($i),$exam_appear))
			{
				$id='';
				$remaining_count=0;
				$id="\$exam_".chr($i);
				$html_id="candidate_list_exam_".chr($i)."_details";

				$char_name=chr($i);
				$max_limit="\$exam_".$char_name."_limit";
				eval("\$max_limit = \"$max_limit\";");

				$FEXAMNO=chr($i);	
				$id="<table  class='tr_ventor_row' width='100%' border='0' cellspacing='0' cellpadding='0'>";	
				$id.="<th align='left' colspan='10' class='ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper' style='font-size:10px; padding-left:6px; height:20px;'>{$semister_names[$FEXAMNO]}</th>";
				// $id="<table   width='95%' align='center' cellspacing='0' cellpadding='0' border='0' >";
				//$id.=" <tr><td class='act_txtclr' colspan='5' style='background-color:#3D83CC; color:#fff; font-weight:700; width:222px; padding-left:5px; letter-spacing:0.5pt;'>{$semister_names[$FEXAMNO]} </td> </tr>";
				$id.="<tr class='ui-state-default ui-jqgrid-hdiv'>";
				$id.="<td align='center' style='  font-size:12px; border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;font-weight:bold;'>Sub Code</td>";			
				$id.="<td align='center' style='  font-size:12px; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;font-weight:bold;'>QP Code</td>";			
				$id.="<td align='center' style='  font-size:12px; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;font-weight:bold;'>Description</td>";			
				$id.="<td align='center' style='  font-size:12px; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;font-weight:bold;'>Pass Mth<input type=checkbox id='{$html_id}^{$char_name}' onclick='checkAllCandidateSemisterSub(this.id);' ></td>";			
				/* $id.="<tr style='background-image:url(../jqGrid3/themes/tarka/images/grid-blue-hd.gif);border-bottom:1px solid #CBC7B8; color:#000; font-weight:700; padding:3px 6px; letter-spacing:0.5pt;'>";
				$id.="<td  align=center style='padding:2px;  border-bottom:1px solid #ccc; border-left:1px solid #ccc; border-right:1px solid #ccc;width:23px;'>Code</td>";
				$id.="<td align=center  style='padding:2px;   border-bottom:1px solid #ccc;border-left:0px solid #ccc; border-right:1px solid #ccc;width:90px'>Short Name</td>";
				$id.="<td align=center  style='padding:2px;  width:160px; border-bottom:1px solid #ccc;border-left:0px solid #ccc; border-right:1px solid #ccc;'>Description</td>";
				$id.="<td  align=center style='padding:2px;  border-bottom:1px solid #ccc; border-left:0px solid #ccc; border-right:1px solid #ccc;width:80px'>Pass M/Y<input type=checkbox id='{$html_id}^{$char_name}' onclick='checkAllCandidateSemisterSub(this.id);' ></td>";
				*/ $id.="</tr>";
					  
				$lquery="select c.FSUBCODE,s.FSUBNAME,
				ifnull(c.FPASSMTH,'') as FPASSMTH,
				s.FQPCODE AS FSUBSHORT,c.FEXAMTYPE,
				ifnull(c.FPRESENT,'N') as FPRESENT,
				if(c.FINSERTED='','F',c.FINSERTED) as FINSERTED,
				ifnull(c.fthpr,'') as fthpr 
				from canddet c 
				inner join subject s on s.FDEGREE=c.FDEGREE
				and s.fexamno = c.fexamno and s.FSUBCODE=c.FSUBCODE 
				where c.FDEGREE='{$this->degree}' and c.FCOLLCODE='{$this->college_code}' and 
				c.FEXAMNO='{$FEXAMNO}'  and
				c.FREGNO='{$this->regno}' group by c.FSUBCODE order by c.fsubcode,
				s.fqpcode desc limit $max_limit ";
				$lobj_rs = $this->aobj_context->mobj_db->GetAll($lquery); 
				
				$remaining_count=$max_limit-count($lobj_rs);
				$k=0;
				$txt_id=0;
					
				for($m=0;$m<count($lobj_rs);$m++)
				{
					$code_pop_up_field="";
					$FSUBCODE=$lobj_rs[$m]['FSUBCODE']; 
					$FTHPR=$lobj_rs[$m]['fthpr']; 
					$get_theroy_cnt="SELECT COUNT(1) AS t_cnt FROM subject 
					WHERE FDEGREE='{$this->degree}' AND fexamno='{$FEXAMNO}'
					AND FSUBCODE='{$FSUBCODE}' AND IFNULL(ftheory,'') = 'T' 
					AND IFNULL(fintass,'') <> 'T' AND IFNULL(fretain,'') <> 'T'  ";
					$lobj_get_theroy_cnt = $this->aobj_context->mobj_db->GetRow($get_theroy_cnt); 	
					$th_cnt=$lobj_get_theroy_cnt['t_cnt'];

					$get_prc_cnt="SELECT COUNT(1) AS p_cnt FROM subject 
					WHERE FDEGREE='{$this->degree}' AND fexamno='{$FEXAMNO}'
					AND FSUBCODE='{$FSUBCODE}' AND IFNULL(ftheory,'') <> 'T' 
					AND IFNULL(fintass,'') <> 'T' AND IFNULL(fretain,'') <> 'T' ";
					$lobj_get_prc_cnt = $this->aobj_context->mobj_db->GetRow($get_prc_cnt); 	
					$pr_cnt=$lobj_get_prc_cnt['p_cnt'];
					if($th_cnt>1) $th_cnt=max(2,$th_cnt);
					if($pr_cnt>1) $pr_cnt=max(2,$pr_cnt);

					if($FTHPR=='T') $th_cnt=0;
					if($FTHPR=='F') $pr_cnt=0;
					$FSUBSHORT=$lobj_rs[$m]['FSUBSHORT']; 
					$FSUBNAME=$lobj_rs[$m]['FSUBNAME']; 
					if($lobj_rs[$m]['FPASSMTH']=='' or is_null($lobj_rs[$m]['FPASSMTH']))// to display pass M/Y based on the  value
					{
						$FPASSMTH="<input type='checkbox'   onclick='UpdateExamFeeForEachSelectedSubject();' id='exam_{$char_name}_ce_pass_{$txt_id}'> ";	
						$FPASSMTH.="<input type='hidden'   id='exam_{$char_name}_th_cnt_{$txt_id}' value='{$th_cnt}' /> ";	
						$FPASSMTH.="<input type='hidden'   id='exam_{$char_name}_pr_cnt_{$txt_id}' value='{$pr_cnt}' /> ";	
						$FPASSMTH.="<input type='hidden'   id='exam_{$char_name}_fi_{$txt_id}' value='F' /> ";	
						$FPASSMTH_TD="";
						$code_pop_up_field="";					
					}
					else  
					{
						$FPASSMTH=$lobj_rs[$m]['FPASSMTH'];	
						$FPASSMTH_TD=" id='exam_{$char_name}_ce_pass_{$txt_id}' ";
						$code_pop_up_field='readonly=true;';					
					}
					if($lobj_rs[$m]['FINSERTED']=='CT' || $lobj_rs[$m]['FINSERTED']=='ssT')// to display text box for the value if FINSERTED=''T
					{
						$sub_code_input_border=	"";
						$sub_code_input_popup=" onblur='getSubDetails(this.id,{$txt_id});'  onkeydown='return keyboardSubjectAppearingPopup(event,this.id);'";
						$sub_code_input_name="di";
						$input_tab_indx=" tabindex={$txt_id}";
						$read_only=" ";
					}
					else  
					{
						$sub_code_input_border=	" border:none;";
						$sub_code_input_name="update";
						$input_tab_indx=" tabindex=-1";
						$read_only=" readonly";
						if($FUNIVCODE=='016')
						$sub_code_input_popup=	"";	
					}
					if($k%2==0)
					{
						$class='tbl_row';
						$inp_class='tbl_row_input';
					}
					else
					{
						$input_class='tbl_row1'; 
						$inp_class='tbl_row1_input';
					}  
						$id.="<tr>";
						$id.="<td align='center' style='  font-size:12px;   border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'><input {$code_pop_up_field} {$inp_class} type=text style='width:55px;{$sub_code_input_border}' {$read_only} {$sub_code_input_popup} name='{$sub_code_input_name}'   id='exam_{$char_name}_ce_sub_code_{$txt_id}' {$input_tab_indx} value='{$FSUBCODE}'></td>";
						$id.="<td align='center'  style='  font-size:12px;   border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'id='exam_{$char_name}_ce_short_name_{$txt_id}' > {$FSUBSHORT}</td>";
						$id.="<td align='left' id='exam_{$char_name}_ce_desc_{$txt_id}'  style='  font-size:12px;    border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'>   {$FSUBNAME}</td>";
						$id.="<td style='  font-size:12px;    border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;' align='center'  {$FPASSMTH_TD} >{$FPASSMTH} </td>";
						$id.="</tr>";   
						$k++;
						$txt_id++;
				}
				if($remaining_count>0)
				{
					$k=0;
					$subject_options=$this->SubjectCodeDetails($char_name);
					for($j=0;$j<$remaining_count;$j++)
					{
						if($k%2==0)
						{
							$class='tbl_row';
							$inp_class='tbl_row_input';
						}
						else
						{
							$input_class='tbl_row1'; 
							$inp_class='tbl_row1_input';
						}  
						$id.="<tr>";
						$id.="<td align='center'   style=' font-size:12px;   border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'> <select style='width:60px;' tabindex={$txt_id}   onchange =\"getSubjectNamesForSelectedSub({$txt_id},this.value,'{$this->degree}','{$char_name}')\" id='exam_{$char_name}_ce_sub_code_{$txt_id}'>{$subject_options}</select></td>";
						$id.="<td align='center'  style=' font-size:12px;   border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'id='exam_{$char_name}_ce_short_name_{$txt_id}'>&nbsp;</td>";
						$id.="<td align='left'  id='exam_{$char_name}_ce_desc_{$txt_id}'   style=' font-size:12px;   border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'>&nbsp;</td>";
						$pr_th_cnt="<input type='hidden'   id='exam_{$char_name}_th_cnt_{$txt_id}' value='0' /> ";	
						$pr_th_cnt.="<input type='hidden'   id='exam_{$char_name}_pr_cnt_{$txt_id}' value='0' /> ";	
						$pr_th_cnt.="<input type='hidden'   id='exam_{$char_name}_fi_{$txt_id}' value='F' /> ";	
						$id.="<td  style='padding:2px;  font-size:12px;   border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;' align='center'  ><input type='checkbox'  onclick='UpdateExamFeeForEachSelectedSubject();' id='exam_{$char_name}_ce_pass_{$txt_id}' /> {$pr_th_cnt} </td>";
						$id.="</tr>";											 
						$k++;
						$txt_id++;
					}		 
				}
						 
				$total_count_of_each_div[$html_id]=$txt_id;			
				$exam_fee_val=$exam_fee[$html_id];
				$exam_receipt_no_val=$exam_receipt_no[$html_id];
				$exam_receipt_no_date_val=$exam_receipt_no_date[$html_id];
				
				$get_fee_data="SELECT  FHEADCODE,FFEE,
				IF('{$FFRESHEXAM}'='{$char_name}',FFEE,FREPFEE) AS O_FFEE,
				IF('{$FFRESHEXAM}'='{$char_name}',FPRFEE,FREPPRFEE) AS FPRFEE ,FMAXFEE
				FROM admfeestr a
				WHERE FDEGREE='{$this->degree}'
				AND FEXAMNO='{$char_name}'
				AND FCOMBCODE='EXAM' {$cond}
				AND FCATCODE='{$this->category}'
				and FCONSTYPE='{$this->li}' 				
				and IF(IFNULL(FREGRANGE,'') = '', '1=1', 
				1=1 and (INSTR(FREGRANGE,(CONCAT(SUBSTR('{$this->regno}',1,3),'*'))) > 0 
				or INSTR(FREGRANGE,(CONCAT(SUBSTR('{$this->regno}',1,4),'*'))) > 0))
				and IF(IFNULL(FCOLLRANGE,'') = '', '1=1', 
				1=1 and INSTR(FCOLLRANGE,(CONCAT('{$this->college_code}','*'))) <= 0)
				order by FHEADCODE";
				//var_dump($get_fee_data);
				$lobj_get_fee_data = $this->aobj_context->mobj_db->GetAll($get_fee_data); 	
							 
				$fee_cnt=count($lobj_get_fee_data)+1;
				//var_dump($lobj_get_fee_data);
								
				$id.="<tr>";
				$id.="<td colspan='4' style=' border-bottom:1px solid #C5DBEC; border-right:1px solid #C5DBEC; border-left:1px solid #C5DBEC;'>";
				$id.="";  
				$tr="<table id='fee_table_{$char_name}' style='margin:9px;width:50%;'  class='tr_ventor_row'   border='0' cellspacing='0' cellpadding='0' >	 <th align='left' colspan='2' class='ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper' style='font-size:12px; padding-left:6px; height:17px;background:#C48F2D;'>Fee Details</th>";
				$tr.="<tr class='ui-state-default ui-jqgrid-hdiv'>";
				$tr.="<td align='center' style=' font-weight:bold; font-size:12px; border-left:1px solid #C5DBEC; border-top:1px solid #C5DBEC ; border-right:1px solid #C5DBEC;  '>Fee Details</td>";			
				$tr.="<td align='center' style=' font-weight:bold; font-size:12px; border-right:1px solid #C5DBEC; border-top:1px solid #C5DBEC ; border-bottom:1px solid #C5DBEC;'> Amount</td>";			
				$tr.="</tr>";
				$tot=0;
				 
				foreach($lobj_get_fee_data as $ak=>$av)
				{
			      
					$tr.=" <tr class='ui-state-default ui-jqgrid-hdiv'>";
					$h_code=substr($av[FHEADCODE],0,2);	
					$tr.="<td align='left' style='border-top:1px solid #C5DBEC ;border-left:1px solid #C5DBEC; ' id='tfh_{$char_name}_{$h_code}'>{$av[FHEADCODE]}</td>";
					$input_val=$av['FFEE'];	
					$O_FFEE=$av['O_FFEE'];							 
					$tot+=$input_val;							 
					$tr.="<td  align='center'  style='border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;' > <input  type=hidden value='{$av['O_FFEE']}' id='o_fee_{$char_name}_{$h_code}' /> <input  type=hidden value='{$av['FPRFEE']}' id='prfee_{$char_name}_{$h_code}' />  <input  type=hidden value='{$av['FMAXFEE']}' id='minnfee_{$char_name}_{$h_code}' /> <input readonly='true' onblur='CalculateNewwFeeTotals();' style='border:none;text-align:center;;'  type=text value='0' id='nfee_{$char_name}_{$h_code}'></td>";
					$tr.=" </tr>";
				}
				$tr.=" <tr class='ui-state-default ui-jqgrid-hdiv'>";
				$tr.="<td align='center' style='font-weight:bold;border-left:1px solid #C5DBEC ;background:#27E87A; border-top:1px solid #C5DBEC ;border-right:1px solid #C5DBEC;   border-bottom:1px solid #C5DBEC;'> Total </td>";
				$tr.="<td align='center' style=' border-right:1px solid #C5DBEC;border-right:1px solid #C5DBEC;background:#27E87A;   border-bottom:1px solid #C5DBEC;'><input style='text-align:center;border:none;font-weight:bold;background:#27E87A;' readonly=true id='nfee_{$char_name}_total' value=0 /><input type='hidden' id='fresh_exam_{$char_name}' value='{$FFRESHEXAM}' /></td>";
				$tr.=" </tr>";
				$tr.="</table>";
							 
				$id.=$tr ;
				$id.="</td>";
				$id.="</tr>";
			
				$id.="</table>";	
				$arr[$html_id]=$id;  
			}		
		}	
			   
		$student_info="<table width=70% align=center class='result_table_header' id='student_info'>
		<tr style='height:22px;'><td align=center>Reg. No. : {$this->regno}</td></tr>
		<tr style='height:22px;' ><td align=center >Name of the Student : {$this->student_name}</td></tr>
		<tr style='height:22px;' ><td align=center >Category : {$this->category}</td></tr>
		<tr style='height:22px;' ><td align=center >Fee Type : {$this->li}</td></tr>			
		</table>";
		
		$get_data="SELECT  FUNIVCODE FROM control WHERE IFNULL(FUNIVCODE,'')<>'' ";
		$lobj_get_data = $this->aobj_context->mobj_db->GetRow($get_data); 	
		$arr['table_data']=$student_exam_details;
		$arr['student_info']=$student_info;
		$arr['html_data']=$e_data;
		$arr['FUNIVCODE']=$lobj_get_data['FUNIVCODE'];
		$arr['date']=is_null($student_exam_details['FRECPTDATE'])?date('d/m/Y'):$student_exam_details['FRECPTDATE'];

		$arr['total_count_of_each_div']=$total_count_of_each_div;

		$get_data="SELECT payment_type,bank_name FROM acc_mas where ifnull(fsuspend ,'') <> 'T' ";
		$lobj_payment_type= $this->aobj_context->mobj_db->GetAll($get_data); 
		$arr['paymode_type']=$lobj_payment_type;
		
		$photo_path = $this->aobj_context->main_src."/student_photos/".$this->college_code."/".replaceChars(strtolower($this->degree))."/".$reg_no.".jpg";
		$photo_path_real = "student_photos/".$this->college_code."/".replaceChars(strtolower($this->degree))."/".$reg_no.".jpg";

		if(!empty($photo_path) && file_exists($photo_path)) 
		{			
			$arr['photo_path']= $photo_path_real;
		}
		else
		{
			$arr['photo_path']="img/default_photo.jpg";
		}	
					
		if($lobj_get_total_sub_for_degree)	
		echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
		else
		echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
		return;
	}
	
	function GetNextNumber()
	{
		
		$get_prefix_running_number = "select last_number from res_reval_code_generator
		where college_code = '{$this->college_code}' and type='Candidate' ";		
		$lobj_get_prefix_running_number = $this->aobj_context->mobj_db->GetRow($get_prefix_running_number); 

		$query= " Select FEXAMPREFIX from control";
		$result = $this->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
			(
			'{$this->college_code}',
			{$next_number},'Candidate'
			)";
			$lobj_insert_into = $this->aobj_context->mobj_db->Execute($insert_into);
			$last_number = str_pad($next_number,4, "0", STR_PAD_LEFT);		
		}
		return $result[FEXAMPREFIX].$this->college_code.$last_number;	
	}
	
	function UpdateNextNumber()
	{							 
		$update_code_generator = "update res_reval_code_generator set last_number = last_number+1
		where college_code = '{$this->college_code}' and type='Candidate' ";
		$lobj_update_code_generator = $this->aobj_context->mobj_db->Execute($update_code_generator);
	}	
	function InsertEmptyAppCandSumm()
	{
		session_start();
		$FUNIVCODE=$_SESSION['FUNIVCODE'];
		$this->app_number=$this->GetNextNumber($this->aobj_context);
		
		 if($FUNIVCODE=='029')
		{
			$insert=" 
			INSERT INTO  appcandsum 
			(APPNO, FDATE,FPAYMENTYPE,
			FDEGREE,FEXAMNO, FCOLLCODE, FREGNO, 
			FCATEGORY,  FAPPEARA, FEXAMFEEA, 
			FRECPTNOA, 	FRECPTDATEA, FAPPEARB, 
			FEXAMFEEB, 	FRECPTNOB, 	FRECPTDATEB, 
			FAPPEARC, 	FEXAMFEEC, FRECPTNOC, 
			FRECPTDATEC, FAPPEARD, 	FEXAMFEED, 
			FRECPTNOD, 	FRECPTDATED,FAPPEARE, 
			FEXAMFEEE, 	FRECPTNOE, 	FRECPTDATEE, FAPPEARF, 
			FEXAMFEEF, 	FRECPTNOF, 	FRECPTDATEF, 	FAPPEARG, 
			FEXAMFEEG, 	FRECPTNOG, 	FRECPTDATEG, 	FAPPEARH, 
			FEXAMFEEH, 	FRECPTNOH, 	FRECPTDATEH, FAPPEARI, 
			FEXAMFEEI, 	FRECPTNOI,	FRECPTDATEI, 
			FAPPEARJ, FEXAMFEEJ, 	FRECPTNOJ, 
			FRECPTDATEJ, FRECPTNO, FRECPTDATE, 	FTOTALFEE, 
			FREMARKS, 	FYEAR, 	FEXAMTYPE, 	FAPPNO, FCNTRCODE, 	FGENDER,FFRESHEXAM
			)
			SELECT '{$this->app_number}',current_date(),'{$this->payment_type}',
			FDEGREE,FEXAMNO, FCOLLCODE, FREGNO, 
			FCATEGORY,  FAPPEARA, FEXAMFEEA, 
			FRECPTNOA, 	FRECPTDATEA, FAPPEARB, 
			FEXAMFEEB, 	FRECPTNOB, 	FRECPTDATEB, 
			FAPPEARC, 	FEXAMFEEC, FRECPTNOC, 
			FRECPTDATEC, FAPPEARD, 	FEXAMFEED, 
			FRECPTNOD, 	FRECPTDATED,FAPPEARE, 
			FEXAMFEEE, 	FRECPTNOE, 	FRECPTDATEE, FAPPEARF, 
			FEXAMFEEF, 	FRECPTNOF, 	FRECPTDATEF, 	FAPPEARG, 
			FEXAMFEEG, 	FRECPTNOG, 	FRECPTDATEG, 	FAPPEARH, 
			FEXAMFEEH, 	FRECPTNOH, 	FRECPTDATEH, FAPPEARI, 
			FEXAMFEEI, 	FRECPTNOI,	FRECPTDATEI, 
			FAPPEARJ, FEXAMFEEJ, 	FRECPTNOJ, 
			FRECPTDATEJ, FRECPTNO, FRECPTDATE, 	FTOTALFEE, 
			FREMARKS, 	FYEAR, 	FEXAMTYPE, 	FAPPNO, FCNTRCODE, 	FGENDER,FFRESHEXAM
			FROM candsum 	
			where  FDEGREE='{$this->degree}'
			AND FCOLLCODE='{$this->college_code}'
			AND  FREGNO='{$this->reg_no}'
			LIMIT 1"; 
		}	
		else
		{ 
			$insert="INSERT INTO  appcandsum 
					(APPNO, FDATE,FPAYMENTYPE,
					FDEGREE,FEXAMNO, FCOLLCODE, FREGNO, 
					FCATEGORY, 	FSEX, FAPPEARA, FEXAMFEEA, 
					FRECPTNOA, 	FRECPTDATEA, FAPPEARB, 
					FEXAMFEEB, 	FRECPTNOB, 	FRECPTDATEB, 
					FAPPEARC, 	FEXAMFEEC, FRECPTNOC, 
					FRECPTDATEC, FAPPEARD, 	FEXAMFEED, 
					FRECPTNOD, 	FRECPTDATED,FAPPEARE, 
					FEXAMFEEE, 	FRECPTNOE, 	FRECPTDATEE, FAPPEARF, 
					FEXAMFEEF, 	FRECPTNOF, 	FRECPTDATEF, 	FAPPEARG, 
					FEXAMFEEG, 	FRECPTNOG, 	FRECPTDATEG, 	FAPPEARH, 
					FEXAMFEEH, 	FRECPTNOH, 	FRECPTDATEH, FAPPEARI, 
					FEXAMFEEI, 	FRECPTNOI,	FRECPTDATEI, 
					FAPPEARJ, FEXAMFEEJ, 	FRECPTNOJ, 
					FRECPTDATEJ, FRECPTNO, FRECPTDATE, 	FTOTALFEE, 
					FREMARKS, 	FYEAR, 	FEXAMTYPE, 	FAPPNO, FCNTRCODE, 	FGENDER,FFRESHEXAM
					)
					 SELECT '{$this->app_number}',current_date(),'{$this->payment_type}',
					FDEGREE,FEXAMNO, FCOLLCODE, FREGNO, 
					FCATEGORY, 	FSEX, FAPPEARA, FEXAMFEEA, 
					FRECPTNOA, 	FRECPTDATEA, FAPPEARB, 
					FEXAMFEEB, 	FRECPTNOB, 	FRECPTDATEB, 
					FAPPEARC, 	FEXAMFEEC, FRECPTNOC, 
					FRECPTDATEC, FAPPEARD, 	FEXAMFEED, 
					FRECPTNOD, 	FRECPTDATED,FAPPEARE, 
					FEXAMFEEE, 	FRECPTNOE, 	FRECPTDATEE, FAPPEARF, 
					FEXAMFEEF, 	FRECPTNOF, 	FRECPTDATEF, 	FAPPEARG, 
					FEXAMFEEG, 	FRECPTNOG, 	FRECPTDATEG, 	FAPPEARH, 
					FEXAMFEEH, 	FRECPTNOH, 	FRECPTDATEH, FAPPEARI, 
					FEXAMFEEI, 	FRECPTNOI,	FRECPTDATEI, 
					FAPPEARJ, FEXAMFEEJ, 	FRECPTNOJ, 
					FRECPTDATEJ, FRECPTNO, FRECPTDATE, 	FTOTALFEE, 
					FREMARKS, 	FYEAR, 	FEXAMTYPE, 	FAPPNO, FCNTRCODE, 	FGENDER,FFRESHEXAM
					FROM candsum 	
					where  FDEGREE='{$this->degree}'
					AND FCOLLCODE='{$this->college_code}'
					AND  FREGNO='{$this->reg_no}'
					 LIMIT 1";
		}
		
		$lobj_insert = $this->aobj_context->mobj_db->Execute($insert); 
		if($lobj_insert)
		{
			$this->UpdateNextNumber();
			return true;
		}
		else
		{
			return false;
		}
	}
	
	function saveCandidateEntryDetails()
	{
		session_start();
		$FUNIVCODE = $_SESSION['FUNIVCODE'];
		$this->reg_no = $this->aobj_context->mobj_data["reg_no"];
		$this->category = $this->aobj_context->mobj_data["c"];
		$this->li = $this->aobj_context->mobj_data["li"];
		$this->payment_type = $this->aobj_context->mobj_data["payment_type"];
		$name = $this->aobj_context->mobj_data["name"];
		$dob = $this->aobj_context->mobj_data["dob"];
		$fathername = $this->aobj_context->mobj_data["fathername"];
		$mothername = $this->aobj_context->mobj_data["mothername"];
		
		$gender = $this->aobj_context->mobj_data["gender"];
		$category = $this->aobj_context->mobj_data["category"];
		$mobile = $this->aobj_context->mobj_data["mobile"];
		$email = $this->aobj_context->mobj_data["email"];
		
		$curadd1 = $this->aobj_context->mobj_data["curadd1"];
		$curadd2 = $this->aobj_context->mobj_data["curadd2"];
		$curadd3 = $this->aobj_context->mobj_data["curadd3"];
		$curadd4 = $this->aobj_context->mobj_data["curadd4"];
		
		$peradd1 = $this->aobj_context->mobj_data["peradd1"];
		$peradd2 = $this->aobj_context->mobj_data["peradd2"];
		$peradd3 = $this->aobj_context->mobj_data["peradd3"];
		$peradd4 = $this->aobj_context->mobj_data["peradd4"];
		
		$curaddpin = $this->aobj_context->mobj_data["curaddpin"];
		$peraddpin = $this->aobj_context->mobj_data["peraddpin"];
		$adharno = $this->aobj_context->mobj_data["adharno"];
		$fpaymode=$this->payment_type;
		
		$lquery="select date_format(current_date,'%d/%m/%Y') as curr_date,
		FDEGREE,FCOLLCODE,FNAME
		from student where   FREGNO='{$this->reg_no}' ";	 
		$lobj_get_name = $this->aobj_context->mobj_db->GetRow($lquery);

		$this->college_code=$lobj_get_name['FCOLLCODE'];
		$this->degree=$lobj_get_name['FDEGREE'];
		$this->student_name=$lobj_get_name['FNAME'];
		$this->curr_date=$lobj_get_name['curr_date'];

		if(empty($this->college_code))
		{
			$arr['data']='No details found for the student';
			echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
			return;
		}
		if(!$this->InsertEmptyAppCandSumm())
		{
			$arr['data']='Error While Inserting AppCandSum';
			echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
			return;
		}
		
		$total_fee = $this->aobj_context->mobj_data["total_fee"];
		$candidate_list_receipt_no = $this->aobj_context->mobj_data["candidate_list_receipt_no"];
		$candidate_list_remarks = trim($this->aobj_context->mobj_data["candidate_list_remarks"]);
		$candidate_list_date = trim($this->aobj_context->mobj_data["candidate_list_date"]);   
		include_once($this->aobj_context->main_src."/json.php"); 
		$json = new Services_JSON();
		$check_admission_freeze ="select distinct c.FCCLSTATUS, d.fmeyear, d.fmeexamtyp 
		from colldeg c, degree d 
		where c.fdegree = d.fdegree and c.FCOLLCODE='{$this->college_code}' 
		and c.FDEGREE='{$this->degree}'";								
		$lobj_check_admission_freeze = $this->aobj_context->mobj_db->getRow($check_admission_freeze); 

		$lstr_param = stripslashes($this->aobj_context->mobj_data["details"]);
		$mobj_jsondata = $json->decode($lstr_param);
		$sub_arr_data = get_object_vars($mobj_jsondata);
		
		$lstr_sub_fee = stripslashes($this->aobj_context->mobj_data["sub_fee"]);
		$mobj_lstr_sub_fee = $json->decode($lstr_sub_fee);
		$sub_fee_data = get_object_vars($mobj_lstr_sub_fee);
		 	
		for($i=65;$i<75;$i++)
		{
			$exam_data='';
			$char_id=chr($i);
			$exam_data=get_object_vars($sub_arr_data[$char_id]);
			if(!empty($exam_data))
			{		
				for($k=0;$k<count($exam_data);$k++)
				{
					if($exam_data[$k]->sub!='' && $exam_data[$k]->sub!='None'  &&  $exam_data[$k]->smy!=-1)
					{
						$FRESENT=($exam_data[$k]->smy=='1')?"P":"N";
						$insert_canddet_records="insert into appcanddet 
						(APPNO,
						FDEGREE,
						FEXAMNO,
						FCOLLCODE,
						FREGNO,
						FSUBCODE,
						FINSERTED,
						FPRESENT, fyear, fexamtype) values
						(
						'{$this->app_number}',
						'{$this->degree}',
						'{$exam_data[$k]->ex}',
						'{$this->college_code}',
						'{$this->reg_no}',
						'{$exam_data[$k]->sub}',
						'{$exam_data[$k]->fi}',								 
						'{$FRESENT}', '{$lobj_check_admission_freeze['fmeyear']}', '{$lobj_check_admission_freeze['fmeexamtyp']}'	
						)";
						$lobj_insert_canddet_records = $this->aobj_context->mobj_db->Execute($insert_canddet_records);
						 
					}
				}	
							 
			} 
		} 
		if($FUNIVCODE == '016' || $FUNIVCODE == '026')
		{
			$update_appcanddet = "update appcanddet a, canddet b
			set a.fthpr = b.fthpr
			where a.fdegree = b.fdegree
			and a.fexamno = b.fexamno 
			and a.fsubcode = b.fsubcode
			and a.fregno = b.fregno
			and b.fdegree = '{$this->degree}'
			and b.fregno = '{$this->reg_no}'
			and ifnull(b.fthpr,'') <> ''";
	
			$lobj_insert_update_appcanddet = $this->aobj_context->mobj_db->Execute($update_appcanddet);	
		}	
				// to update the exam a/b details
		for($i=65;$i<75;$i++)
		{
			$char_id=chr($i);
			$sub_fee_datas=get_object_vars($sub_fee_data[$char_id]);
			if(!empty($sub_fee_datas))
			{
				$update_records="update appcandsum set  
				FEXAMFEE{$char_id}='{$sub_fee_datas[0]->total_fee}' 

				where  FDEGREE='{$this->degree}' and  FCOLLCODE='{$this->college_code}' 
				and FREGNO='{$this->reg_no}'
				and APPNO='{$this->app_number}'";  
				$lobj_update_records = $this->aobj_context->mobj_db->Execute($update_records);
			} 
		}
		$update_total_fee="update appcandsum set FTOTALFEE={$total_fee},
		FCATEGORY='{$this->category}', 
		FFEETYPE = '{$this->li}',		
		FLOGDATE=now()
		where  FDEGREE='{$this->degree}' and 
		FCOLLCODE='{$this->college_code}' 
		and FREGNO='{$this->reg_no}' 
		and APPNO='{$this->app_number}'	";

		$lobj_update_total_fee = $this->aobj_context->mobj_db->Execute($update_total_fee);
				 // to insert STUDFEE	
		
		$query = "update student set FNAME = '{$name}',FDOB = DATE_FORMAT(str_to_date('{$dob}','%d/%m/%Y'),'%Y-%m-%d'), FFATNAME ='{$fathername}',
				 FMOTNAME = '{$mothername}', FSEX = '{$gender}', FCASTE = '{$category}',FMOBILENO = '{$mobile}',
				 FEMAIL = '{$email}',FPERMADD1 = '{$peradd1}',FPERMADD2 = '{$peradd2}',FPERMADD3 = '{$peradd3}',FPERMADD4 = '{$peradd4}', 
				 FCURRADD1 = '{$curadd1}',FCURRADD2 = '{$curadd2}',FCURRADD3 = '{$curadd3}',
				 FCURRADD4 = '{$curadd4}',FCURRADDPIN = '{$curaddpin}',FPERMADDPIN = '{$peraddpin}',FAADHARNO = '{$adharno}'
				 WHERE FREGNO = '{$this->reg_no}'";
			
		$result = $this->aobj_context->mobj_db->Execute($query);
		 
		$this->insertStudFeeDetails($this->aobj_context);
		if($lobj_update_total_fee and $result) 
		{
			$html="<table border=0 align='center' style='width:100%;font-weight:bold;font-size:16px;line-height:22px;padding:6px;'>";
			$html.="<tr><td align='center' style='color:green;'>Registered Successfully</td></tr>";
			$html.="<tr><td align='center' style='color:green;'>&nbsp;</td></tr>";
			$html.="<tr><td align='center'  style='font-weight:normal;'>Your Application No. : <span style='font-weight:bold'>{$this->app_number}</span></td></tr>";
			$html.="<tr><td align='center' style='font-weight:normal;' >Date : <span style='font-weight:bold'>{$this->curr_date}</span></td></tr>";
			$html.="<tr><td align='center' style='color:green;'>&nbsp;</td></tr>";

			if($fpaymode=="DEBIT/CREDIT/NET BANKING")
			{
			$html.="<tr><td align='center'  > <div class='raval_submit' style='width:193px;float:none;' >
			<span  onclick='MakeOnlinePayment(\"{$this->app_number}\");' style='float:left;margin-left:8px;cursor: pointer; line-height: 19px;font-size:14px;font-weight:bold;'>Make Online Payment</span>
			</div></td></tr>";
			}
			else
			{	$html.="<tr><td align='center'  >Please take a printout and submit to college with documents</td></tr>";
			$html.="<tr><td >&nbsp;</td></tr>";	
			$html.="<tr><td align='center'  > <div class='raval_submit' style='width:241px;float:none;' >
			<span onclick=\"PrintApplicationForm('{$this->payment_type}','{$this->app_number}');\" style='float:left;margin-left:8px;cursor: pointer; line-height: 19px;font-size:14px;font-weight:bold;'>Click here to take a PrintOut</span>
			</div></td></tr>";
			}
			echo $this->aobj_context->mobj_output->ToJSONEnvelope($html,0,"success"); 
			return;
		}
		else
		{
			$arr='Updation failed';
			echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"success"); 
			return;
		}
		 
	} 
	
	function insertStudFeeDetails()
	{
		
		include_once($this->aobj_context->main_src."/json.php"); 
		$json = new Services_JSON();
		$lstr_fee_details = stripslashes($this->aobj_context->mobj_data["new_fee_details"]);

		$mobj_lstr_fee_details = $json->decode($lstr_fee_details);
		$fee_details_data = get_object_vars($mobj_lstr_fee_details);
		  
		for($i=65;$i<75;$i++)
		{
			$char_id=chr($i);
			if(($fee_details_data[$char_id])!=0)
			{ 	
				$insert_arr=get_object_vars($fee_details_data[$char_id]);					
				if(count($insert_arr)>0)
				{
					foreach( $insert_arr as $ak=>$av)
					{
						$FFEECODE=$ak;
						$FAMOUNT=$av;

						$insert_into_student_fee="insert into appstudfee
						(
						APPNO,FDEGREE,FEXAMNO,FCOLLCODE,FREGNO,FFEECODE,FAMOUNT,FLOGDATE
						) VALUES
						(
						'{$this->app_number}',
						'{$this->degree}',
						'{$char_id}',
						'{$this->college_code}',
						'{$this->reg_no}',
						'{$FFEECODE}',
						'{$FAMOUNT}',
						NOW()
						)";
						$lobj_insert_into_student_fee = $this->aobj_context->mobj_db->Execute($insert_into_student_fee);	

					}
				} 
			} 
		} 
	}
	
	function DisplayApplications()
	{
		$reg_no=($this->aobj_context->mobj_data["r"]);	

		$str_reval.="<table style='padding:3px 4px 3px 3px;' class='tr_ventor_row' id='reval_table_data' width='100%' border='0' cellspacing='0' cellpadding='0'>";
		$str_reval.="<tr class='tr_bg1'>";
		$str_reval.="<td align='center' style=' font-size:12px; border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'>Sl No</td>";
		$str_reval.="<td align='center' style=' font-size:12px; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'>Application No</td>";
		$str_reval.="<td align='center' style=' font-size:12px; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'>Amount</td>";
		$str_reval.="<td align='center' style=' font-size:12px; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'>Applied Date</td>";
		$str_reval.="<td align='center' style=' font-size:12px; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'>Payment Type</td>";
		$str_reval.="<td align='center' style=' font-size:12px; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'>Payment Status</td>";
		$str_reval.="<td align='center' style=' font-size:12px; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;'> Print</td>";
		$str_reval.="</tr>";
		
		$get_data="select distinct  APPNO,FTOTALFEE,DATE_FORMAT(FDATE,'%d/%m/%Y') as FAPPDATE ,
		FPAYMENTYPE,FPAYMENTCONFIRM
		from appcandsum
		where FREGNO='{$reg_no}'  ";
		$lobj_get_data = $this->aobj_context->mobj_db->GetAll($get_data);	
		
		$k=0;
		$sl_no=1;
		foreach($lobj_get_data as $ak=>$av)
		{
			$APPNO=$av['APPNO'];
			$FTOTAL=$av['FTOTALFEE'];
			$FAPPDATE=$av['FAPPDATE'];
			$FPAYMENTYPE=$av['FPAYMENTYPE'];
			$FPAYMENTSTATUS=$av['FPAYMENTSTATUS'];
			$FCHALLANNO=$av['FCHALLANNO'];
			$app_status=$av['app_status'];
			$FPAYMENTCONFIRM=$av['FPAYMENTCONFIRM'];
			if($k%2==0)
			$class='tbl_row1';
			else
			$class='tbl_row_alter1';
			$str_reval.="<tr>";		
			$str_reval.="<td class='{$class}' style='text-align:center; border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;' >{$sl_no}</td>";
			$str_reval.="<td class='{$class}' style='border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;text-align:center; ' >&nbsp;{$APPNO}</td>";
			$str_reval.="<td class='{$class}' style='text-align:left; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;text-align:center;  ' >{$FTOTAL}&nbsp;</td>";
			$str_reval.="<td class='{$class}' style='text-align:left; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;text-align:center;  ' >&nbsp;{$FAPPDATE}</td>";
			$str_reval.="<td class='{$class}' style='text-align:left; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;text-align:center;  ' >&nbsp;{$FPAYMENTYPE}</td>";

			if($FPAYMENTCONFIRM=='success')
			$str_reval.="<td class='{$class}' style='text-align:left; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;color:green; ;text-align:center; ' >Received at University for processing</td>";
			else
			{
			if($FPAYMENTYPE=="POSTOFFICE")
			$str_reval.="<td class='{$class}' style='text-align:left; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;color:red; ;text-align:center; '>Payment not made at {$FPAYMENTYPE} </td>";
			else if($FPAYMENTYPE=="DEBIT/CREDIT/NET BANKING")
			$str_reval.="<td class='{$class}' style='text-align:left; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;color:red; ;text-align:center; '>Online Payment Pending</td>";
			else
			$str_reval.="<td class='{$class}' style='text-align:left; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;color:red; ;text-align:center; '>Payment Pending</td>";
			} 

			$div_data="";
			if($FPAYMENTYPE=="DEBIT/CREDIT/NET BANKING")
			{
				if($FPAYMENTCONFIRM=="success")
				{
				$div_data.="<div class='raval_submit' style='margin-right:19px;width:125px;  ' >
				<span  onclick=\"PrintApplicationFormNETBANKING('{$APPNO}');\" style='float:left;margin-left:26px;cursor: pointer; line-height: 19px;font-size:14px;font-weight:bold;'>Print App</span>
				</div>";
				}
				else
				{
				$div_data="<div class='raval_submit' style='margin-right:19px;width:129px;  ;' >
				<span  onclick=\"MakeOnlinePayment('{$APPNO}');\" style='float:left;margin-left:8px;cursor: pointer; line-height: 19px;font-size:14px;font-weight:bold;'>Make Payment</span>
				</div>";
				}
			}
			else if($FPAYMENTYPE=="POSTOFFICE")
			{	 
				$div_data="<div class='raval_submit' style='margin-right:19px;width:129px;  ;' >
				<span  onclick=\"PrintApplicationForm('{$FPAYMENTYPE}','{$APPNO}');\" style='float:left;margin-left:26px;cursor: pointer; line-height: 19px;font-size:14px;font-weight:bold;'>Print App</span>
				</div>";	 
			}
			else
			{
				$div_data="<div class='raval_submit' style='margin-right:19px;width:129px;  ;' >
				<span  onclick=\"PrintApplicationForm('{$FPAYMENTYPE}','{$APPNO}');\" style='float:left;margin-left:8px;cursor: pointer; line-height: 19px;font-size:14px;font-weight:bold;'>Print Challan</span>
				</div>";
			}
			$str_reval.="<td class='{$class}' align='center' style='border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;font-weight:bold;text-align:center;' >{$div_data}</td>";
			$str_reval.="</tr>";
			$sl_no++;
			$k++;
			/* $str_reval.="<td class='{$class}' style='text-align:left; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;text-align:center;  ' >&nbsp;{$FPAYMENTYPE}</td>"; 
			$str_reval.="<td class='{$class}' align='center' style='border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px; font-size:12px;font-weight:bold;text-align:center;' ><div class='raval_submit' style='width:59px; margin: 0 auto;' >
			<span  onclick=\"PrintApplicationForm('{$FPAYMENTYPE}','{$APPNO}');\" style='float:left;margin-left:8px;cursor: pointer; line-height: 19px;font-size:14px;font-weight:bold;'>Print</span>
			</div></td>";
			$str_reval.="</tr>";
			$sl_no++;
			$k++; */
		}	
		
		$str_reval.="</table>";
		$arr['html']=$str_reval;
		echo $this->aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 					
	}
	
}//end of classs

function dashboardMessageBoard($aobj_context)
{
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
	$class_obj=new candidate_list($aobj_context);
	$class_obj->dashboardMessageBoard();	 
}  
function DisplayStudentSubjectDetails($aobj_context)
{
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
	$class_obj=new candidate_list($aobj_context);
	$class_obj->DisplayStudentSubjectDetails();	 
}
function saveCandidateEntryDetails($aobj_context)
{
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
	$class_obj=new candidate_list($aobj_context);
	$class_obj->saveCandidateEntryDetails();	 
} 
function DisplayApplications($aobj_context)
{
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
	$class_obj=new candidate_list($aobj_context);
	$class_obj->DisplayApplications();	 
} 

function validateCandidateRegno($aobj_context)
{
	session_start();
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
	$regno = $aobj_context->mobj_data["r"];
	$category = $aobj_context->mobj_data["c"];
	$li = $aobj_context->mobj_data["li"];
	$_SESSION['regno'] = $regno;
	
	$query="select FDEGREE,FCOLLCODE,FNAME,ifnull(fexamappblk,'') as fexamappblk,ifnull(fmp,'') as fmp  
	from student 
	where FREGNO='{$regno}' ";	 
	$rst = $aobj_context->mobj_db->GetRow($query);
	if($rst)
	{
		
		$college_code=$rst['FCOLLCODE'];
		$degree=$rst['FDEGREE'];
		$student_name=$rst['FNAME'];
		$fexamappblk=$rst['fexamappblk'];
		$fmp=$rst['fmp'];
		if($fexamappblk == 'T'|| $fmp == 'T' )
		{
			$data ='Register number has been bloked';
			echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"Failure");
			return false;
		}	
		else
		{
			$query2=" select * from colldeg where fdegree = '{$degree}' and
			fcollcode = '{$college_code}' 
			and DATE_FORMAT(now(),'%Y-%m-%d') between DATE_FORMAT(FEXAMAPPSDATE,'%Y-%m-%d')
			and DATE_FORMAT(FEXAMAPPEDATE,'%Y-%m-%d')";
			$rst2 = $aobj_context->mobj_db->GetRow($query2); 

			if($rst2)
			{
				$data = 'success';
				echo $aobj_context->mobj_output->ToJSONEnvelope($data,0,"success");
			}
			else
			{
				/* $data ='Last date is over for online exam application form';
				echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"Failure");
				return false; */
				$data = 'success';
				echo $aobj_context->mobj_output->ToJSONEnvelope($data,0,"success");
			}
		}	
	}
	else
	{
		$data ='Not a valid Register no.';
		echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"Failure");
		return false;
	}	
	
}

function personaldetails($aobj_context)
{
	session_start();
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
	$reg_no = $_SESSION['regno'];
	
	$query = "select FNAME,date_format(FDOB,'%d/%m/%Y') as FDOB,FFATNAME,FMOTNAME,FEMAIL,FMOBILENO,
			FCURRADD1,FCURRADD2,FCURRADD3,FCURRADD4,FPERMADD1,FPERMADD2,FPERMADD3,FPERMADD4, 
			FSEX,FCASTE from student where fregno = '{$reg_no}'" ;

	$results = $aobj_context->mobj_db->GetRow($query);
	$query="SELECT FCATEGORY AS internal_code,FCATEGORY AS value FROM category";
	$result1=$aobj_context->mobj_db->GetAll($query);
	$arr['regno'] = $results;
	$arr['category'] = $result1;
	if($results)
	{
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");	
	}
	
	
}
############other functions############
function PopulateCategoryList($aobj_context)
{
	session_start();
	$query = "select FUNIVNAME,FUNIVCODE from control";
	$rst = $aobj_context->mobj_db->GetRow($query); 		
	$_SESSION['FUNIVCODE']=$rst[FUNIVCODE];
	
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
	$get_category_names="select FCATEGORY as internal_code,FCATEGORY as value from category ";
	$get_fconst="SELECT DISTINCT FCONSTYPE as internal_code,FCONSTYPE as value FROM admfeestr ORDER BY 1 DESC ";

	$lobj_get_category_names = $aobj_context->mobj_db->GetAll($get_category_names);
	$lobj_get_fconst = $aobj_context->mobj_db->GetAll($get_fconst);
	$arr['category']=$lobj_get_category_names;
	$arr['FCONSTYPE']=$lobj_get_fconst;
	
	$get_all_message="select message
	from message_board
	where current_date() between 
	display_from
	and display_to and college_code='EAF' 
	order by 1 desc ";
	$lobj_get_all_message = $aobj_context->mobj_db->GetRow($get_all_message);	

	$mess_data=$lobj_get_all_message['message'];

	if(empty($mess_data))
	{
		$mess_data="	<ul class='index_message_ul'> <li>Use Mozilla Firefox for best view</li>
		<li>Enter Register Number, Select Category and the Fee Type to fill the Exam Application Form</li></ul>";
	}
		$arr['mess_data']=$mess_data;
		$arr['FUNIVCODE']=$_SESSION['FUNIVCODE'];
		if($lobj_get_category_names!= 0)	
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
}

function getSubjectNamesForSelectedSub($aobj_context) 
{
	$subject_code = $aobj_context->mobj_data["subject_code"]; 
	$degree_code = $aobj_context->mobj_data["degree_code"]; 	
	$exam = $aobj_context->mobj_data["exam"]; 	
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC); 	
	$get_sub_names="select FSUBCODE as id,FSUBCODE,FSUBNAME,FSUBSHORT ,FMANDATORY 
	from degree d inner join subject s on 
	s.FDEGREE=d.FDEGREE  and  d.FEXAMNO=s.FEXAMNO
	where d.FDEGREE='{$degree_code}' and s.FEXAMNO='{$exam}'  
	and FSUBCODE='{$subject_code}'
	group by  FSUBCODE";
	$lobj_get_sub_names = $aobj_context->mobj_db->getRow($get_sub_names);	
	
	if(count($lobj_get_sub_names)==0 || empty($lobj_get_sub_names))
	{
		echo $aobj_context->mobj_output->ToJSONEnvelope($lobj_get_sub_names,-1,"failure"); 
		return;
	}
	
	else
	{
		$get_theroy_cnt="SELECT COUNT(1) AS t_cnt FROM subject 
		WHERE FDEGREE='{$degree_code}' AND fexamno='{$exam}'
		AND FSUBCODE='{$subject_code}'
		AND IFNULL(ftheory,'')  =  'T' ";
		
		$lobj_get_theroy_cnt = $aobj_context->mobj_db->GetRow($get_theroy_cnt); 	  
		$th_cnt=$lobj_get_theroy_cnt['t_cnt'];

		$get_prc_cnt="SELECT COUNT(1) AS p_cnt FROM subject 
		WHERE FDEGREE='{$degree_code}' AND fexamno='{$exam}'
		AND FSUBCODE='{$subject_code}'
		AND IFNULL(ftheory,'') <> 'T' AND IFNULL(fintass,'') <> 'T' AND IFNULL(fretain,'') <> 'T' ";
		$lobj_get_prc_cnt = $aobj_context->mobj_db->GetRow($get_prc_cnt); 	
		
		$pr_cnt=$lobj_get_prc_cnt['p_cnt'];
		if($th_cnt>1) $th_cnt=max(2,$th_cnt);
		if($pr_cnt>1) $pr_cnt=max(2,$pr_cnt);

		$lobj_get_sub_names['th_cnt']=$th_cnt;		
		$lobj_get_sub_names['pr_cnt']=$pr_cnt;	
		echo $aobj_context->mobj_output->ToJSONEnvelope($lobj_get_sub_names,0,"success"); 
		return;
	}
}


// upload student photo / 28/04/2015
function DiaplayUserSelectedPhoto($aobj_context)
{
	
	$get_last_no="select last_no+1 as lastno from last_no";
	$obj =  $aobj_context->mobj_db->GetRow($get_last_no); 

	$update_last_no="update last_no set last_no=last_no+1";
	$aobj_context->mobj_db->Execute($update_last_no); 
	
	$login_cnt=$obj[lastno];
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC); 

	//session_start();
	 
	 $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."/student_photos/temp";
	if(!file_exists($temp_path))
	{
	 mkdir($temp_path);
	 
	}
	$file_path="/{$login_cnt}_{$file_name}";
 	$temp_path.=$file_path;
	//var_dump($_FILES['student_entry_upload']['name'].'   '.$_FILES['student_entry_upload']['name']);die();
		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;
			 }
			}

	
			$data="sucess";
			echo $aobj_context->mobj_output->ToJSONEnvelope($data,0,"success"); 
				return;	
	
	}
	
	function replaceChars($name)
	{
		$spl_char = array("*","/","~","!","@","#","$","%","^","&",":",";","?","/","\\","_","-","'"," ","");
		$link_name = strtolower(str_replace($spl_char,"_",$name));
		return str_ireplace("__","_",$link_name);
	}	
		
	
	function uploadAdmissionTicketPhoto($aobj_context)
	  {
		session_start();
		$aobj_context=$aobj_context;
		$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
		$regno = $aobj_context->mobj_data["reg_no"];
		$get_other_details="select FDEGREE,FCOLLCODE,FNAME from student where   FREGNO='{$regno}' 
			and ifnull(fmp,'') <> 'T'";	 
		$lobj_get_name = $aobj_context->mobj_db->GetRow($get_other_details);
		$college_code=$lobj_get_name['FCOLLCODE'];
		$degree=$lobj_get_name['FDEGREE'];
		$student_name=$lobj_get_name['FNAME'];
			
			
		$student_entry_photo_path=$aobj_context->mobj_data["student_entry_photo_path"];
		$ext_arr=explode(".",$student_entry_photo_path);
		$app_img=$regno.".".array_pop($ext_arr);
		$src_path=$aobj_context->main_src."/".$student_entry_photo_path;
		$url = $aobj_context->main_src;
		$url = str_replace('student','oasis/kus',$url);	
		$college_path=$url."/student_photos/{$college_code}";
		$folder_path=$url."/student_photos/{$college_code}/".replaceChars(strtolower($degree));
		if(!file_exists($college_path))
		{
			mkdir($college_path);
		} 
		if(!file_exists($folder_path))
		{
			mkdir($folder_path);
		}		
		
		$dest_path =$folder_path.'/'.$app_img;
		copy($src_path,$dest_path);
		
		$data="Photo uploaded successfully";
		echo $aobj_context->mobj_output->ToJSONEnvelope($data,0,"success"); 
		return;	
	
	}
	
	function savestudentdetails($aobj_context)
	{
		session_start();
		$reg_no = $_SESSION['regno'];
		
		$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
		
		$name = $aobj_context->mobj_data["name"];
		$dob = $aobj_context->mobj_data["dob"];
		$fathername = $aobj_context->mobj_data["fathername"];
		$mothername = $aobj_context->mobj_data["mothername"];
		
		$gender = $aobj_context->mobj_data["gender"];
		$category = $aobj_context->mobj_data["category"];
		$mobile = $aobj_context->mobj_data["mobile"];
		$email = $aobj_context->mobj_data["email"];
		
		$curadd1 = $aobj_context->mobj_data["curadd1"];
		$curadd2 = $aobj_context->mobj_data["curadd2"];
		$curadd3 = $aobj_context->mobj_data["curadd3"];
		$curadd4 = $aobj_context->mobj_data["curadd4"];
		
		$peradd1 = $aobj_context->mobj_data["peradd1"];
		$peradd2 = $aobj_context->mobj_data["peradd2"];
		$peradd3 = $aobj_context->mobj_data["peradd3"];
		$peradd4 = $aobj_context->mobj_data["peradd4"];
		
		$query = "update student set FNAME = '{$name}',FDOB = DATE_FORMAT(str_to_date('{$dob}','%d/%m/%Y'),'%Y-%m-%d'), FFATNAME ='{$fathername}',
				 FMOTNAME = '{$mothername}', FSEX = '{$gender}', FCASTE = '{$category}',FMOBILENO = '{$mobile}',
				 FEMAIL = '{$email}',FPERMADD1 = '{$peradd1}',FPERMADD2 = '{$peradd2}',FPERMADD3 = '{$peradd3}',FPERMADD4 = '{$peradd4}', 
				 FCURRADD1 = '{$curadd1}',FCURRADD2 = '{$curadd2}',FCURRADD3 = '{$curadd3}',FCURRADD4 = '{$curadd4}'
				 WHERE FREGNO = '{$reg_no}'";
			
		$result = $aobj_context->mobj_db->Execute($query);
		if($result)
		{
			$data="Successfully Updated";
			echo $aobj_context->mobj_output->ToJSONEnvelope($data,0,"success");
			return;
		}
		else
		{
			$data="Failed to Update";
			echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure");
			return;
		}
	}
	
?>