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


Current Path : /var/www/html/studentportal_wait/src/
Upload File :
Current File : /var/www/html/studentportal_wait/src/results.php

<?php


	
// include 'database.php';


// include("commandb.php");

// //session_start();
// $UNIVCODE  = $_SESSION['UNIVCODE'];

// /*$query = "INSERT INTO menulog(funivcode,fdate,fresults)
// VALUES('{$UNIVCODE}',date_format(now(),'%Y-%m-%d'),1)
// ON DUPLICATE KEY UPDATE fresults = if(ifnull(fresults,'') = '', 1,fresults+1)";
// $results = mysqli_query($conndb,$query);*/

// $strUserLogQuery = "insert into userlog 
// (funivcode, fregno, fmobileno, fipadd, FREASONCODE, FDESCPN)
// values ('{$_SESSION['UNIVCODE']}', '{$_SESSION['REGNO']}', 
// '{$_SESSION['MOBILE']}', '{$_SERVER['REMOTE_ADDR']}', 
// 'REMN', 'REMN - {$_SESSION['REGNO']} Viewed Results')";
// $result = mysqli_query($conndb,$strUserLogQuery);

// $id = $_POST['id'];
// $reg_no = $_SESSION['REGNO'];
// $folder = $_SESSION['FOLDER'];

// /*$sql = "SELECT re.fexamno,dg.fexamname FROM res_fee re
// inner join degree dg on re.fdegree = dg.fdegree and re.fexamno = dg.fexamno
// where re.fregno = '{$reg_no}' order by fexamno"; */

// $query = "select fregno, fdegree, fcaste, 
// if(fenroll='', fregno, ifnull(fenroll,fregno))  as enroll 
// from student where fregno = '{$reg_no}'"; 
// $result = mysqli_query($conn,$query);
// while ($studentrow = $result->fetch_assoc()) 
// {
// 	$fcaste = $studentrow['fcaste'];
// 	$fenroll = $studentrow['enroll'];
	
// }

// if($_SESSION['UNIVCODE'] == '023')
// 	$cnd = " re.fregno in(select distinct fregno from student 
// 	where (fregno = '{$reg_no}' or ifnull(fenroll,'') = '{$fenroll}'))";
// else
// 	$cnd = "re.fregno = '{$reg_no}' ";

// $sql = "SELECT re.fexamno,dg.fexamname,re.fregno,re.fdegree FROM res_fee re
// 	inner join degree dg on re.fdegree = dg.fdegree and re.fexamno = dg.fexamno
// 	where {$cnd}
// 	order by fexamno";

// $result = mysqli_query($conn,$sql);
// $i=0;

// while ($row1 = $result->fetch_assoc()) 
// {
// 	$row[$i] = $row1;
// 	$i++;
// }
// //var_dump(count($array));

// if(mysqli_num_rows($result) > 0)
// {
// 	//$row['sem'] = $array;
// 	//$row['fregno'] = $reg_no;
// 	$row['folder'] = $folder;
// 	$row['resdet'] = $row;
// 	$row['fcaste'] = $fcaste;
// 	$row['UNIVCODE'] = $_SESSION['UNIVCODE'];
// 	$row['status'] = 'success';
// 	mysqli_close($conn);
// 	mysqli_close($conndb);
// 	echo json_encode($row);
// }
// else
// {
// 	$data = array("status"=>"failure");
// 	mysqli_close($conn);
// 	mysqli_close($conndb);
// 	echo json_encode($data);
// }


	if($_REQUEST['a']== 'getResults'){

		include 'database.php';

		$univcode = $_SESSION['UNIVCODE'];

		include("commandb.php");

		$fexamno = $_GET['examno'];
		$res = array();

		//===Get Basic Student Details===//
		$qry = "select s.fregno,s.FDEGREE,d.FDESCPN, s.FEXAMNO,d.FEXAMNAME,s.FCOLLCODE,concat(c.FCOLLNAME,', ', c.FTOWN) as FCOLLNAME,d.FRESEXAMDATE,
		s.FREGNO,s.FNAME,d.FELIGREM01,d.FELIGREM02,ifnull(s.FFATNAME,'') as FFATNAME,
		ifnull(s.FMOTNAME,'') as MOTNAME 
		from student s inner join college c on c.FCOLLCODE=s.FCOLLCODE inner join degree d on d.FDEGREE=s.FDEGREE 
		where s.FREGNO = '{$_SESSION['REGNO']}' and d.fexamno = '{$fexamno}' ";
		// var_dump($qry);
	
		$result1 = $conn->query($qry);
		$result1 = $result1->fetch_assoc();//mysqli_fetch_assoc($result1);
	// var_dump($result1);	
	// 	die();
		//====Get the dates for Reval n etc ====//
		$get_result_date="select FCOLLCODE,
		DATE_FORMAT(FRESULTDATE,'%d/%m/%Y') as FRESULTDATE,
		DATE_FORMAT(IFNULL(FRVLASTDATE,'0000-00-00'),'%d/%m/%Y') as FRVLASTDATE,
		DATE_FORMAT(IFNULL(FRTLASTDATE,'0000-00-00'),'%d/%m/%Y') as FRTLASTDATE,
		DATE_FORMAT(IFNULL(FXEROXLASTDATE,'0000-00-00'),'%d/%m/%Y') as FXEROXLASTDATE,
		DATE_FORMAT(IFNULL(FCVLASTDATE,'0000-00-00'),'%d/%m/%Y') as FCVLASTDATE,
		DATE_FORMAT(IFNULL(FRILASTDATE,'0000-00-00'),'%d/%m/%Y') as FRILASTDATE,
		ifnull(fdeleted,'') as fdeleted
		from res_fee
		where FREGNO='{$_SESSION['REGNO']}'
		and FEXAMNO='{$fexamno}'";

		$result_dates=$conn->query($get_result_date);
		$result_dates = $result_dates->fetch_assoc();

		$_SESSION['g_FCOLLCODE']=$result_dates['FCOLLCODE'];
		$FRESULTDATE=$result_dates['FRESULTDATE'];		
		$FRVLASTDATE=$result_dates['FRVLASTDATE'];		
		$FRTLASTDATE=$result_dates['FRTLASTDATE'];		
		$FCVLASTDATE=$result_dates['FCVLASTDATE'];		
		$FXEROXLASTDATE=$result_dates['FXEROXLASTDATE'];	
		$dates['accDate'] = $FRESULTDATE;
		$dates['scroll_txt']=" ";

		if($FRVLASTDATE!="00/00/0000" || $FRTLASTDATE!="00/00/0000" || $FXEROXLASTDATE!="00/00/0000" || $FCVLASTDATE!="00/00/0000"){
			$dates['scroll_txt'] .="Last Date for";
		}

		if($FRVLASTDATE!="00/00/0000")
		{
			$dates['scroll_txt'].=" RV : <b>{$FRVLASTDATE}</b> &nbsp;&nbsp;";
		}
		if($FRTLASTDATE!="00/00/0000")
		{
		$dates['scroll_txt'].=" RT : <b>{$FRTLASTDATE}</b> &nbsp;&nbsp; ";
		}if($FXEROXLASTDATE!="00/00/0000")
		{
		$dates['scroll_txt'].=" Photo Copy : <b>{$FXEROXLASTDATE}</b> &nbsp;&nbsp;";
		}if($FCVLASTDATE!="00/00/0000")
		{
		$dates['scroll_txt'].=" CV : <b>{$FCVLASTDATE}</b> &nbsp;&nbsp;";
		}
		// if($scroll_txt = " Last Date for ")
		// 	$scroll_txt = "";			
		
		//==if fee paid and result announced==//
		$get_rvrtStatus="select fcorrtype from res_stud 
		where fregno = '{$_SESSION['REGNO']}' and fexamno = '{$fexamno}' and fpaymentstatus = 'success'";
		$obj_get_rvrtStatus=$conn->query($get_rvrtStatus);
		// $obj_get_rvrtStatus = $obj_get_rvrtStatus->fetch_assoc();
		// var_dump($obj_get_rvrtStatus);
		
		$rvDesp = '';
		$rtDesp = '';
		$cvDesp = '';
		$vrSlash = 0;
		$vrSlashSymb ='';
		$vrSlash2 = 0;
		$corrtype='';

			foreach($obj_get_rvrtStatus as $rvrtVal)
			{
				
				if($rvrtVal['fcorrtype'] == 'RV')
				{
					$rvDesp = 'Re-valuation';
					$vrSlash =1;
				}
				if($rvrtVal['fcorrtype'] == 'RT')
				{
					if($vrSlash == 1)
					$vrSlashSymb = ' / ';
					$vrSlash2 =1;
					$rtDesp = $vrSlashSymb.'Re-totalling';
				}
				 if($rvrtVal['fcorrtype'] == 'CV')
				{	
					if($vrSlash == 1 || $vrSlash2 == 1)
					$vrSlashSymb = ' / ';
					$cvDesp = $vrSlashSymb.'Challenge valuation';
				}
			}
		// }

		// $display = "T";
		$rcrtcvDesp = '';
		if($obj_get_rvrtStatus = $obj_get_rvrtStatus->fetch_assoc())
		{	
			$get_rvrtFeeStatus="select ifnull(fcorrtype,'') as fcorrtype from res_fee 
			where fregno = '{$_SESSION['REGNO']}' and fexamno = '{$fexamno}'";
			$obj_get_rvrtFeeStatus=$conn->query($get_rvrtFeeStatus);
			$obj_get_rvrtFeeStatus = $obj_get_rvrtFeeStatus->fetch_assoc();

			$rvrtArray = (explode(",",$obj_get_rvrtFeeStatus['fcorrtype']));
			if($obj_get_rvrtFeeStatus)
			{
			if($obj_get_rvrtFeeStatus['fcorrtype'] != '')
			{
				$vrSlash =0;
				$vrSlashSymb ='';
				foreach($rvrtArray as $rvrtArrayVal)
				{
					if($rvrtArrayVal == 'RV')
					{
						$rvFeeDesp = 'Re-valuation';
						$slashRV =1;
					}
					if($rvrtArrayVal == 'RT')
					{
						$rtFeeDesp = 'Re-totalling';
						$slashRT =1;
					}
					if($rvrtArrayVal == 'CV')
					{
						$cvFeeDesp = $vrSlashSymb.'Challenge valuation';
						$slashCV =1;
					}
					if($rvrtArrayVal == 'RI')
					{
						$cvFeeDesp = $vrSlashSymb.'Result Improvement';
						$slashCV =1;
					}
					
				}
					if($slashRV == 1 && $slashRT == 1)
						$vrSlashSymb = ' / ';
					if($slashRT == 1 && $slashCV == 1)
						$vrSlashSymb2 = ' / ';
					if($slashRV == 1 && $slashCV == 1)
						$vrSlashSymb2 = ' / ';	
						
					$rcrtcvDesp = $rvFeeDesp .'  '.$vrSlashSymb.$rtFeeDesp.'  '.$vrSlashSymb2.$cvFeeDesp.' '.'Result';
					$corrtype.="<div style='text-align:center;font-size:18px;width:100%;font-weight:bold;color:green;margin-bottom:10px;'><u>{$rcrtcvDesp}</u></div>";
			}
			else
			{
				$display = 'F';	
				$rcrtcvDesp = $rvDesp .'  '.$rtDesp.'  '.$cvDesp.' '.'Result pending';
				$corrtype.="<div style='text-align:center;font-size:18px;width:100%;font-weight:bold;color:red;margin-bottom:10px;'><u>{$rcrtcvDesp}</u></div>";
		
			}
			}
			
		}
		//====END====//

		//===Get the Note (remarks) to display at the footer====//
		$get_remarks="SELECT FRESULT_REMARKS, FUNIVCODE FROM control";
		$remarksDet=$conn->query($get_remarks);
		$remarksDet = $remarksDet->fetch_assoc();

		//===END====//
		
		//====Get Withheld Details===//
		if($univcode == '003D' || $univcode == '041' || $univcode == '042'){			
						//for withhelds

			$get_data="select  count(1) as held_cnt, if(ifnull(fmcnumber,'')='','',concat(fmcnumber)) as fwhrem						 
			from resmarks rm					 
			where FREGNO='{$_SESSION['REGNO']}' and 
			rm.FEXAMNO='{$fexamno}' and FCLASS='WITHHELD'";
			$rest=mysqli_query($conn,$get_data);
			$count =  mysqli_num_rows($rest);

			$data = mysqli_fetch_assoc($rest);
			$held_cnt = $data['held_cnt'];
			if($held_cnt != 0)
			{
				$res['studDet']=$result1;
				$res['univcode'] = $_SESSION['UNIVCODE'];
				$res['body'] = $data;
				$res['error_code'] = 0;
				$res['dates'] = $dates;
				$res['corrtype'] = $corrtype;
				$res['footerRemarks'] = $remarksDet;
				$res['error_code'] = 0;
				echo json_encode($res); 
				return;
			}
		}
		// else{
		
			//=====Get Results Details to display=====//
		$query = "select if(FSUBSIDARY = 'T',concat(s.FSUBNAME,' **'),s.FSUBNAME) as FSUBNAME,if(ifnull(s.FLTP,'') = '','',s.FLTP) as FLTP,
		sum(s.FSMAXMARKS) as FSMAXMARKS,
		if(FTHUE='','-',FTHUE) as FTHUE ,
		if(FPRUE='','-',FPRUE) as FPRUE ,
		if(FTHVV='','-',FTHVV) as FTHVV ,
		if(FPRVV='','-',FPRVV) as FPRVV,
		if(FTHIA='','-',FTHIA) as FTHIA,
		if(FPRIA='','-',FPRIA) as FPRIA,
		if(FTHTOT='','-',FTHTOT) as FTHTOT,
		if(FPRTOT='','-',FPRTOT) as FPRTOT,
		if(FTHPASSMTH='','-',FTHPASSMTH) as FTHPASSMTH,
		if(FPRPASSMTH='','-',FPRPASSMTH) as FPRPASSMTH,
		if(rm.FCREDITS = '','-',rm.FCREDITS) as FCREDITS,
		if(ifnull(FGP,'') = '','-',FGP) as FGP,
		if(ifnull(FCP,'') = '','-',FCP) as FCP,
		if(ifnull(FGRADE,'') = '','-',FGRADE) as FGRADE,
		if(ifnull(FSGPA,'') = '','-',FSGPA) as FSGPA,
		if(ifnull(FCGPA,'') = '','-',FCGPA) as FCGPA,
		rm.FMAXMARKS,FTOTMARKS,FPREVMAX,FPREVTOT,FPERCENT,FCLASS,FMCNUMBER,FYEAR,FEXAMTYPE, FSCHEME
		from resmarks rm
		inner join subject s on s.FDEGREE=rm.FDEGREE
		and s.FEXAMNO=rm.FEXAMNO and s.FSUBCODE=rm.FSUBCODE 
		where rm.FREGNO='{$_SESSION['REGNO']}' and rm.fexamno='{$fexamno}'
		group by s.FSUBCODE";
		// var_dump($query);
		$result = $conn->query($query);

		$title1 = array();
		$send_data = array();
		$final_data = array();
		$marks = "";
		if($row = mysqli_fetch_assoc($result))
		{
			$FSCHEME = $row['FSCHEME'];

			if($FSCHEME == 'CR')
			{
			//$w      = array('5','50','5','8','8','8','8','10');
									
				if($univcode == '023')
				{						
					$title1 = ['Sl. No.','Subject Name',
					"Th Pr",
					'Univ.Exam',
					'Viva',
					'IA',
					'Total',
					"Credit Hrs",
					"Grade Points",
					"Credit Points",
					'Remarks'];
				}
				else if($univcode == '017'){
					//$rem = "Remarks";
					$title1 = ['Sl. No.','Subject Name','L:T:P',
					"Total Marks",
							"Credits",
							"Grade Points",
							"Credit Points",
							'Remarks'];
				}else if($univcode == '041' || $univcode == '042'){
					$title1 = ['Sl. No.','Subject Name','Th Pr',
					"Max. Marks",
							"Sec. Marks",	
							"CreditHrs",
							"GradePoints",
							"CreditPoints",
							'Remarks'];
				}else if($univcode == '001'){
					$title1 = ['Sl. No.','Subject Name','Th Pr',
					"Max. Marks",
							"Sec. Marks",	
							"Credit Hrs",
							"Grade Points",
							"Credit Points",
							'Remarks'];
				}
				else if($univcode == '040'){
					$title1 = ['Sl. No.','Subject Name',"Th_Pr",
					"L:T:P",
							"Credits Hrs",
							"Grade Points",
							"Credit Points",
							'Grade'];
				}
				else if($univcode == '034'){
					$title1 = ['Sl. No.','Subject Name',"Th_Pr",
					"Total Marks",
							"Credits Hrs",
							"Grade Points",
							"Credit Points",
							'Grade'];
				}
				else if($univcode == '039' || $univcode == '035'){
					$title1 = ['Sl. No.','Subject Name',
					"Th Pr",
							"Sem. End Exam",	'Viva',
							'IA',
							'Total',
							"Credit Hrs",
							"Grade Points",
							"Credit Points",
							'Remarks'];
				}
				else if($univcode == '036'){
					$title1 = ['Sl. No.','Subject Name',
					"Max. Marks",
							"Sec. Marks",	
							"Credit Hours",
							"Grade Point",
							"Credit Point",
							'Grade'];
				}else if($univcode == '038'){
					$title1 = ['Sl. No.','Course Title',"Th Pr",
					"Sem. End Exam",
							"Credits Hrs",
							"Grade Points",
							"Credit Points",
							'Remarks'];
				}else if($univcode == '008'){
					$title1 = ['Sl. No.','Subject Name','L:T:P',
					"Total Marks",
							"Credit Hours",
							"Grade Point",
							"Credit Point",
							'Grade'];
				}else if($univcode == '037'){
					$title1 = ['Sl. No.','Subject Name',
					"Total Marks",
							"Credits",
							"Grade Points",
							"Credit Points",
							'Grade'];
				}else if($univcode == '032'){//PG
					$title1 = ['Sl. No.','Subject Name','Th Pr',
					"Total Marks",
							"Credit Hours",
							"Grade Point",
							"Credit Point",
							'Grade'];
				}
				else
				{
					$title1 = ['Sl. No.','Subject Name',
					"Th_Pr",
							"UnivExam",
							"CreditHrs",
							"GradePoints",
							"CreditPoints",
							'Remarks'];
				}	
						
				$w = ['5','50','5','8','8','8','8','8','8','8','10'];
					
			}else
			{		
				if($univcode == '034' || $univcode == '033' || $univcode == '032'){
					$title1 = ['Sl. No.','Subject Name',
					"Th Pr",
							"Sem. End Exam",	'Viva',
							'IA',
							'Total',
							'Remarks'];
				}else if($univcode == '035'){
					$title1 = ['Sl. No.','Subject Name',
					"Th Pr",
							"Sem. End Exam",	'Viva',
							'IA',
							'Total',
							'Remarks'];
				}else if($univcode == '040'){
					$title1 = ['Sl.No.','Subject Name',
					"Th_Pr",
					'Univ Exam',
					'IA',
					'Total',
					'Remarks'];
				}else if($univcode == '003' || $univcode == '008' ){
					$title1 = ['Sl.No.','Subject Name',
					"Th Pr",
					'Univ Exam',
					'Viva','IA',
					'Total',
					'Remarks'];
				}
				else{
					$title1 = ['Sl.No.','Subject Name',
					"Th_Pr",
					'Univ Exam',
					'Viva','IA',
					'Total',
					'Remarks'];
					$w = ['5','50','5','8','8','8','8','10'];
				}
			}

			$FMAXMARKS = $row['FMAXMARKS'];
			$FTOTMARKS = $row['FTOTMARKS'];
			$FPREVMAX  = $row['FPREVMAX'];
			$FPREVTOT  = $row['FPREVTOT'];
			$FPERCENT  = $row['FPERCENT'];
			$FCLASS    = $row['FCLASS'];
			$FMCNUMBER = $row['FMCNUMBER'];
			$FYEAR     = $row['FYEAR'];
			$FEXAMTYPE = $row['FEXAMTYPE'];	
			$FSCHEME   = $row['FSCHEME'];	
			
			$sl_no=0;
			foreach($result as $k=>$v)
			{
				
				$sl_no++;
				$FSUBNAME   = $v['FSUBNAME'];
				$FSMAXMARKS = $v['FSMAXMARKS']; 
				$FLTP       = $v['FLTP'];
				$FTHUE      = $v['FTHUE'];
				$FPRUE      = $v['FPRUE'];
				$FTHVV      = $v['FTHVV'];
				$FPRVV      = $v['FPRVV'];
				$FTHIA      = $v['FTHIA'];
				$FPRIA      = $v['FPRIA'];
				$FTHTOT     = $v['FTHTOT'];
				$FPRTOT     = $v['FPRTOT'];
				$FGRADE     = $v['FGRADE']; 
				$FTHPASSMTH = trim($v['FTHPASSMTH']);
				$FPRPASSMTH = trim($v['FPRPASSMTH']);

				// $FTHPASSMTH = preg_replace("/[^A-Za-z0-9+-]/","",$FTHPASSMTH); 
				// $FPRPASSMTH = preg_replace("/[^A-Za-z0-9+-]/","",$FPRPASSMTH); 
				// var_dump($FLTP);
				// $FEXAMNO       = $v['FEXAMNO'];
				// $FEXAMNAME     = $v['FEXAMNAME'];
				// $FRESULTDATE   = $v['FRESULTDATE'];
				// $FRESULTSCHEME = $v['FRESULTSCHEME'];
				$FCREDITS      = $v['FCREDITS'];
				$FGP           = $v['FGP'];
				$FCP           = $v['FCP'];
				$FSGPA         = $v['FSGPA'];
				$FCGPA         = $v['FCGPA'];

				if($FTHUE != "-" && $FPRUE != "-")
				{
					$mthprue  = "Th.</br> Pr.";
					$uni_exam = "{$FTHUE} </br>{$FPRUE}";
				}
				else if($FTHUE != "-")
				{
					$mthprue  = "Th.";
					$uni_exam = "{$FTHUE}";
				}
				else
				{
					$mthprue  = "Pr.";
					$uni_exam = "{$FPRUE}";
				}
					
				if($univcode=='018')
				{
						$mthprue = "-";
				}

						#########viva$########
				if($FTHVV!="-" && $FPRVV!="-")
				{					
					if(empty($FPRVV))
							$viva_exam = $FTHVV;
					else
							$viva_exam = $FPRVV;
				}
				else if($FTHVV!="-")
				{
						$viva_exam = $FTHVV;
				}
				else
				{
						$viva_exam = $FPRVV; 
				}
						#########IA########
				if($FTHIA!="-" && $FPRIA!="-")
				{
					if(empty($FPRIA))
							$ia_exam = $FTHIA;
					else
							$ia_exam = $FPRIA;
							$ia_exam = "{$FTHIA} </br>{$FPRIA}";

				}
				else if($FTHIA != "-")
				{
						$ia_exam = $FTHIA;
				}
				else
				{
						$ia_exam = $FPRIA;  
				}
							#########TOTAl########
				if($FTHTOT!="-" && $FPRTOT!="-")
				{
						if(empty($FPRTOT))
								$total = $FTHTOT;
						else
								$total = $FPRTOT;
					$total = "{$FTHTOT} </br>{$FPRTOT}";					
				}
				else if($FTHTOT != "-")
				{
						$total= $FTHTOT;
				}else
				{
						$total= $FPRTOT; 
				}
							#########Remarks########
				if($univcode == '018')
				{
						$FPRPASSMTH="";
				}
				if(strtolower($FTHPASSMTH) == strtolower($FPRPASSMTH))
				{
						$remarks = $FTHPASSMTH; 
				}
				else if(strtolower($FTHPASSMTH)=="pass" && strtolower($FPRPASSMTH)=="pass")
				{
						$remarks = "Pass"; 
				}
				else if(strtolower($FTHPASSMTH)=="fail" && strtolower($FPRPASSMTH)=="fail")
				{
						$remarks    = "Fail"; 
				}
				else if(strtolower($FTHPASSMTH)!="-" && strtolower($FPRPASSMTH)=="-")
				{
						$remarks  = $FTHPASSMTH; 
				}
				else if(strtolower($FTHPASSMTH)=="-" && strtolower($FPRPASSMTH)!="-")
				{
						$remarks  = $FPRPASSMTH; 
				}else
				{

					if(empty($FPRPASSMTH))
						$remarks = $FTHPASSMTH;
					else{
						if(strtolower($FTHPASSMTH) == 'fail')
							$thfailStatus = "<span style='color:red'>{$FTHPASSMTH}</span>";
						else 
							$thfailStatus = "<span style='color:green'>{$FTHPASSMTH}</span>";
						
						if(strtolower($FPRPASSMTH) == 'fail')
							$prpassStatus = "<span style='color:red'>{$FPRPASSMTH}</span>";
						else
							$prpassStatus = "<span style='color:green'>{$FPRPASSMTH}</span>";

						$remarks = $thfailStatus."<br>".$prpassStatus;
					}

					// if(empty($FPRPASSMTH))
					// 		$remarks = $FTHPASSMTH;
					// else
					// 		$remarks = $FPRPASSMTH;
					// return $remarks;
				}
						//--remarks--//
				$send_data['sl_no'] = $sl_no;
				$send_data['subject'] = $FSUBNAME;
				
				if($univcode == '040' && $FSCHEME == 'CR'){
					$send_data['mthprue'] = $mthprue;
					$send_data['uni_exam'] = $FLTP; 
					$send_data['viva_exam'] = $viva_exam; 
					$send_data['ia_exam'] = $ia_exam; 
					$send_data['thtot'] = $total;
				}else if($univcode == "037" && $FSCHEME!="CR"){
					$send_data['mthprue'] = $mthprue;
					$send_data['uni_exam'] = $uni_exam; 
					$send_data['viva_exam'] = $viva_exam; 
					$send_data['ia_exam'] = $ia_exam; 
					$send_data['thtot'] = $total;
				}else
				{
					$send_data['mthprue'] = $mthprue;
					$send_data['uni_exam'] = $uni_exam; 
					$send_data['viva_exam'] = $viva_exam; 
					$send_data['ia_exam'] = $ia_exam; 
					$send_data['thtot'] = $total;
				}

				if($univcode == '035' || $univcode == '039' || $univcode == '023')
				{	
					if($FSCHEME == 'CR')
					{	
							$send_data['FCREDITS'] =$FCREDITS;
							$send_data['FGP'] =$FGP;
							$send_data['FCP'] =$FCP;
							if($univcode == '039')
								$send_data['FSGPA'] =$FSGPA;
					}
				}

				if(($univcode == '017' || $univcode == '008' )&& $FSCHEME == 'CR' ){
					$send_data['mthprue']= $FLTP;
				}				

				if($univcode == '036' && $FSCHEME == 'CR' ){
					$send_data['mthprue']= $FSMAXMARKS;
				}		

				if(($univcode == '041' || $univcode == '042' || $univcode == '001') && $FSCHEME == 'CR' )
					$send_data['fsmaxmarks']= $FSMAXMARKS;

			if(($univcode == '035' || $univcode == '039' || $univcode == '023') && $FSCHEME == 'CR')
			{	
				if($FCLASS == 'Fail, Promoted')
					$result =$FCLASS;//grade
				else
					$result = $FCLASS;
			}else
				$result = $FCLASS;
								
			$send_data['result'] = $result;
			$send_data['remarks'] = $remarks;
			if($FSCHEME != 'CR' || ($univcode == '035' || $univcode == '039' || $univcode == '023')){
				$send_data['FMAXMARKS'] = $FMAXMARKS;
				$send_data['FTOTMARKS'] = $FTOTMARKS;
			}
			if($FSCHEME == 'CR' && $univcode == '033' || $univcode == '008' || $univcode == '034' || $univcode == '036' || $univcode == '032'){
				$send_data['FMAXMARKS'] = $FMAXMARKS;
				$send_data['FTOTMARKS'] = $FTOTMARKS;
			}
			if($FSCHEME == 'CR')
			{	
				if($FCGPA != '0.00'){
					$send_data['FCGPA'] = $FCGPA;
					$send_data['FSGPA'] = $FSGPA;
					$send_data['FPERCENT'] = $FPERCENT;
				}
				else{
					$send_data['FPERCENT'] = $FPERCENT;
				}
			}else
				$send_data['FPERCENT'] = $FPERCENT;

			if($FCGPA == '-' && $FPREVTOT !="0000")
				$send_data['FCGPA'] = $FPREVTOT;
			if($FPREVMAX != "0000" && !empty($FPREVMAX))
				$send_data['FCGPA'] = $FPREVTOT;$send_data['FPREVMAX'] = $FPREVMAX;

			$send_data['FSCHEME'] =$FSCHEME;
			array_push($final_data,$send_data);
		}
		//===END Result Det==//
			$res['studDet']=$result1;
			$res['headers'] = $title1;
			$res['body'] = $final_data;
			$res['error_code'] = 0;
			$res['dates'] = $dates;
			$res['corrtype'] = $corrtype;
			$res['footerRemarks'] = $remarksDet;
			$res['univcode'] = $_SESSION['UNIVCODE'];	

			echo json_encode($res); 
			return;
		}
	else
		{
			$res['error_code'] = 1;
			$res['status'] = 'Failure';
			echo json_encode($res);
			return;
		}
	// }
	}
	else if($_REQUEST['a']== 'getResDet'){
		include 'database.php';

		$univcode = $_SESSION['UNIVCODE'];

		include("commandb.php");
		$fexamno = $_GET['examno'];

    $query = "select s.FSUBNAME,  rm.fsubcode, rm.fssubname, rm.fmarks, rm.fyear, rm.fexamtype
    from resmarksdet rm left join subject s on s.FDEGREE = rm.fdegree
    and s.FEXAMNO = rm.fexamno and s.FCSUBCODE = rm.fsubcode
    where fregno = '{$_SESSION['REGNO']}' and rm.fexamno = '{$fexamno}'
		order by s.fsubcode, s.fssubcode";
		// var_dump($query);
		$result =$conn->query($query);
		$row= mysqli_fetch_assoc($result);
		// var_dump($result);
    if(empty($result))
    {
			$res['error_code'] = 1;
			$res['status'] = 'Failure';
			echo json_encode($res);
			return;	
    }
    $final_arr=array();

    foreach($result as $k=>$v)
    {			
			$FSUBNAME=$v['FSUBNAME'];
			$fssubname=$v['fssubname'];
			$fmarks=$v['fmarks'];
			$fsubcode=$v['fsubcode'];

			$final_arr[$FSUBNAME][$fsubcode]['s']=$fssubname;
			$final_arr[$FSUBNAME][$fsubcode]['m']=$fmarks;

    }
		$res['error_code']=0;
		$res['data']=$final_arr;
    echo json_encode($res); 
	}
	else if ($_REQUEST['a']=='getExamno'){
		include 'database.php';

		$univcode = $_SESSION['UNIVCODE'];

		include "commandb.php";
		$regno = $_SESSION['REGNO'];
		$res=array();
		$final_arr=array();
		$query = "SELECT DISTINCT d.fexamno,d.fexamname FROM res_fee r
		inner join degree d on d.fexamno = r.fexamno and d.fdegree=r.fdegree
		WHERE fregno = '{$regno}' order by fexamno desc";
		// var_dump($query,$conn);
		$result =mysqli_query($conn,$query);

	//	$row = mysqli_fetch_assoc($result);
	$num = mysqli_num_rows($result);

		while($row = mysqli_fetch_assoc($result)){
			$final_arr['fexamno']=$row['fexamno'];
			$final_arr['fexamname']=$row['fexamname'];
				array_push($res,$final_arr);
		}

		if(empty($result))
    {
			$res['error_code'] = 1;
			$res['status'] = 'Failure';
			echo json_encode($res);
			return;	
    }
		$res1['error_code']=0;
		$res1['data']=$res;

		
		// $res['data']=$row;
		echo json_encode($res1); 	
	}

	// include 'database.php';
	// include("commandb.php");

	// session_start();
	// $UNIVCODE  = $_SESSION['UNIVCODE'];

	// /*$query = "INSERT INTO menulog(funivcode,fdate,fresults)
	// VALUES('{$UNIVCODE}',date_format(now(),'%Y-%m-%d'),1)
	// ON DUPLICATE KEY UPDATE fresults = if(ifnull(fresults,'') = '', 1,fresults+1)";
	// $results = mysqli_query($conndb,$query);
	
	// $strUserLogQuery = "insert into userlog 
	// (funivcode, fregno, fmobileno, fipadd, FREASONCODE, FDESCPN)
	// values ('{$_SESSION['UNIVCODE']}', '{$_SESSION['REGNO']}', 
	// '{$_SESSION['MOBILE']}', '{$_SERVER['REMOTE_ADDR']}', 
	// 'REMN', 'REMN - {$_SESSION['REGNO']} Viewed Results')";
	// $result = mysqli_query($conndb,$strUserLogQuery);*/

	// $id = $_POST['id'];
	// $reg_no = $_SESSION['REGNO'];
	// $folder = $_SESSION['FOLDER'];
	
	// /*$sql = "SELECT re.fexamno,dg.fexamname FROM res_fee re
	// inner join degree dg on re.fdegree = dg.fdegree and re.fexamno = dg.fexamno
	// where re.fregno = '{$reg_no}' order by fexamno"; */

	// $query = "select fregno, fdegree, fcaste, 
	// if(fenroll='', fregno, ifnull(fenroll,fregno))  as enroll 
	// from student where fregno = '{$reg_no}'"; 
	// $result = mysqli_query($conn,$query);
	// while ($studentrow = $result->fetch_assoc()) 
	// {
	// 	$fcaste = $studentrow['fcaste'];
	// 	$fenroll = $studentrow['enroll'];
		
	// }

	// if($_SESSION['UNIVCODE'] == '023')
	// 	$cnd = " re.fregno in(select distinct fregno from student 
	// 	where (fregno = '{$reg_no}' or ifnull(fenroll,'') = '{$fenroll}'))";
	// else
	// 	$cnd = "re.fregno = '{$reg_no}' ";

	// $sql = "SELECT re.fexamno,dg.fexamname,re.fregno,re.fdegree FROM res_fee re
	// 	inner join degree dg on re.fdegree = dg.fdegree and re.fexamno = dg.fexamno
	// 	where {$cnd}
	// 	order by fexamno";

	// $result = mysqli_query($conn,$sql);
	// $i=0;

	// while ($row1 = $result->fetch_assoc()) 
	// {
	// 	$row[$i] = $row1;
	// 	$i++;
	// }
	// //var_dump(count($array));

	// if(mysqli_num_rows($result) > 0)
	// {
	// 	//$row['sem'] = $array;
	// 	//$row['fregno'] = $reg_no;
	// 	$row['folder'] = $folder;
	// 	$row['resdet'] = $row;
	// 	$row['fcaste'] = $fcaste;
	// 	$row['UNIVCODE'] = $_SESSION['UNIVCODE'];
	// 	$row['status'] = 'success';
	// 	mysqli_close($conn);
	// 	mysqli_close($conndb);
	// 	echo json_encode($row);
	// }
	// else
	// {
	// 	$data = array("status"=>"failure");
	// 	mysqli_close($conn);
	// 	mysqli_close($conndb);
	// 	echo json_encode($data);
	// }


?>