0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 18.226.88.18


Current Path : /proc/thread-self/root/var/www/html/admission/src/
Upload File :
Current File : //proc/thread-self/root/var/www/html/admission/src/results_new.php

<?php

include 'database.php';

error_reporting(E_ALL);
ini_set('display_errors', 'on');

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

		$univcode = $_SESSION['UNIVCODE'];
		$regno    = $_SESSION['REGNO'];
		
		$res=array();
		$final_arr=array();

		$query = "select concat(d.fexamno,'-',d.fyear,'-',d.fexamtype) as fyear, 
		d.fexamdate, dg.fexamname,date_format(r.fresultdate,'%d/%m/%Y') as fresultdate,r.fregno,
		concat(dg.fdegree,' - ',dg.fdescpn) as degree,concat(c.fcollcode,' - ',c.fcollname,', ',ftown) as college,  
		s.fname as fname
		from degexam d inner join res_fee r on d.fdegree = r.fdegree 
		and d.fexamno = r.fexamno
		and d.fyear = r.fyear
		and d.fexamtype = r.fexamtype
		inner join degree dg on r.fdegree = dg.fdegree	
		and r.fexamno = dg.fexamno
		inner join student s on s.fregno = r.fregno
		inner join college c on s.fcollcode = c.fcollcode
		where r.fregno = '{$regno}'
		order by r.fresultdate desc, r.fexamno";
		$result =mysqli_query($conn,$query);

		$num = mysqli_num_rows($result);

		while($row = mysqli_fetch_assoc($result)){
			$final_arr['year']=$row['fyear'];
			$final_arr['examdate']=$row['fexamdate'];
			$final_arr['examname']=$row['fexamname'];
			$final_arr['resultdate']=$row['fresultdate'];
			$final_arr['regno']=$row['fregno'];
			$final_arr['name']=$row['fname'];
			$final_arr['degree']=$row['degree'];
			$final_arr['college']=$row['college'];
			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;

		echo json_encode($res1); 
		return;
	}else if($_REQUEST['a']== 'getRvAll')
	{

		$univcode = $_SESSION['UNIVCODE'];
		$regno    = $_SESSION['REGNO'];
		
		$res=array();
		$final_arr=array();

		$query = "select concat(d.fexamno,'-',d.fyear,'-',d.fexamtype) as fyear, 
		d.fexamdate, dg.fexamname,date_format(r.fresultdate,'%d/%m/%Y') as fresultdate,r.fregno,
		concat(dg.fdegree,' - ',dg.fdescpn) as degree,
		concat(c.fcollcode,' - ',c.fcollname,', ',ftown) as college, 
		concat(
		
			if(date_format(ifnull(FRVLASTDATE,'00/00/000'),'%d/%m/%Y') = '00/00/0000','',
			concat('RV: ', date_format(FRVLASTDATE,'%d/%m/%Y'))),
			
			if(date_format(ifnull(FXEROXLASTDATE,'00/00/000'),'%d/%m/%Y') = '00/00/0000','',
			concat('<br>PC: ', date_format(FXEROXLASTDATE,'%d/%m/%Y'))),
			
			if(date_format(ifnull(FRTLASTDATE,'00/00/000'),'%d/%m/%Y') = '00/00/0000','',
			concat('<br>RT: ', date_format(FRTLASTDATE,'%d/%m/%Y'))),
			
			if(date_format(ifnull(FCVLASTDATE,'00/00/000'),'%d/%m/%Y') = '00/00/0000','',
			concat('<br>CV: ', date_format(FCVLASTDATE,'%d/%m/%Y')))
			
			) as rvdates,
		s.fname as fname,
		if(
		(
		(r.FRVLASTDATE >=date_format(now(),'%Y-%m-%d')) or
		(r.FRTLASTDATE >=date_format(now(),'%Y-%m-%d')) or 
		(r.FXEROXLASTDATE >=date_format(now(),'%Y-%m-%d')) or 
		(r.FCVLASTDATE >=date_format(now(),'%Y-%m-%d'))
		),1,0) as rvenable
		from degexam d inner join res_fee r on d.fdegree = r.fdegree 
		and d.fexamno = r.fexamno
		and d.fyear = r.fyear
		and d.fexamtype = r.fexamtype
		inner join degree dg on r.fdegree = dg.fdegree	
		and r.fexamno = dg.fexamno
		inner join student s on s.fregno = r.fregno
		inner join college c on s.fcollcode = c.fcollcode
		where r.fregno = '{$regno}'
		order by rvenable desc, r.fexamno";
		$result =mysqli_query($conn,$query);

		$num = mysqli_num_rows($result);

		while($row = mysqli_fetch_assoc($result)){
			$final_arr['year']=$row['fyear'];
			$final_arr['examdate']=$row['fexamdate'];
			$final_arr['examname']=$row['fexamname'];
			$final_arr['resultdate']=$row['fresultdate'];
			$final_arr['regno']=$row['fregno'];
			$final_arr['name']=$row['fname'];
			$final_arr['degree']=$row['degree'];
			$final_arr['college']=$row['college'];
			$final_arr['rvenable']=$row['rvenable'];
			$final_arr['rvdates']=$row['rvdates'];
			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;

		echo json_encode($res1); 
		return;
	}
	else if($_REQUEST['a']== 'getResults'){

		// include 'database.php';

		$univcode = $_SESSION['UNIVCODE'];

		// include("commandb.php");

		$fexamnoarry = $_GET['examno'];
		$examarry = explode("-",$fexamnoarry);	
		$fexamno = $examarry[0];
		$year = $examarry[1];
		$examtype = $examarry[2];
		$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,
		de.fexamdate as FRESEXAMDATE,
		s.FREGNO,s.FNAME,d.FELIGREM01,d.FELIGREM02,ifnull(s.FFATNAME,'') as FFATNAME,
		ifnull(s.FMOTNAME,'') as MOTNAME,ifnull(FNEXTEXAM,'-') as fnextexam 
		from student s inner join college c on c.FCOLLCODE=s.FCOLLCODE 
		inner join degree d on d.FDEGREE=s.FDEGREE 
		inner join degexam de on d.fdegree = de.fdegree and d.fexamno = de.fexamno
		and de.fyear = '{$year}'
		and de.fexamtype = '{$examtype}'
		where s.FREGNO = '{$_SESSION['REGNO']}' and d.fexamno = '{$fexamno}' ";
		
	
		$result1 = $conn->query($qry);
		$result1 = $result1->fetch_assoc();//mysqli_fetch_assoc($result1);
		$fnextexam = $result1['fnextexam'];	
		$FDEGREE = $result1['FDEGREE'];	
	// 	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}'
		and fyear = '{$year}'
		and fexamtype = '{$examtype}'";

		$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 ifnull(fcorrtype,'') as fcorrtype from res_stud 
		where fregno = '{$_SESSION['REGNO']}' and fexamno = '{$fexamno}' and fpaymentstatus = 'success'
		and fcorrtype <> 'RT'
		and FEXAMNO='{$fexamno}'
		and fyear = '{$year}'
		order by FCORRTYPE desc";
		
		$obj_get_rvrtStatus = $conn->query($get_rvrtStatus);
		$obj_get_rvrtStatus = $obj_get_rvrtStatus->fetch_assoc();

		//$obj_get_rvrtStatus = $obj_get_rvrtStatus->fetch_assoc();
		//$rows = mysqli_fetch_assoc($obj_get_rvrtStatus);
		
		
		$rvDesp = '';
		$rtDesp = '';
		$cvDesp = '';
		$vrSlash = 0;
		$vrSlashSymb ='';
		$vrSlash2 = 0;
		$corrtype='';
			if(@count($obj_get_rvrtStatus) >0)
			{
				foreach($obj_get_rvrtStatus as $rvrtVal)
				{
					//var_dump($rvrtVal);
					if($rvrtVal == 'RV')
					{
						$rvDesp = 'Re-valuation';
						$vrSlash =1;
					}
					if($rvrtVal == 'RT')
					{
						if($vrSlash == 1)
						$vrSlashSymb = ' / ';
						$vrSlash2 =1;
						$rtDesp = $vrSlashSymb.'Re-totalling';
					}
					if($rvrtVal == 'CV')
					{	
						if($vrSlash == 1 || $vrSlash2 == 1)
						$vrSlashSymb = ' / ';
						$cvDesp = $vrSlashSymb.'Challenge valuation';
					}
				}
		}

		// }

		// $display = "T";
		$rcrtcvDesp = '';
	//	if(count($obj_get_rvrtStatus)>0)
		//{	
			$get_rvrtFeeStatus="select if(fcorrtype = '','',ifnull(fcorrtype,'')) as fcorrtype from res_fee 
			where fregno = '{$_SESSION['REGNO']}' and fexamno = '{$fexamno}'
			and fyear = '{$year}'
			and fexamtype = '{$examtype}'";
			$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 ='';
					$slashRV = 0;
					$slashRT = 0;
					$slashCV = 0;

					$rvFeeDesp = "";
					$rtFeeDesp = "";
					$cvFeeDesp = "";
					$vrSlashSymb2 = "";

					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';
						//var_dump($rcrtcvDesp);
						$corrtype.="<div style='text-align:center;font-size:18px;width:100%;font-weight:bold;color:green;margin-bottom:10px;'><u>{$rcrtcvDesp}</u></div>";
				}
				else
				{
					//var_dump(count($obj_get_rvrtStatus));
					if(@count($obj_get_rvrtStatus) >0)
					{
						$display = 'F';	
						$rcrtcvDesp = $rvDesp .'  '.$rtDesp.'  '.$cvDesp.' '.'Result pending';
						//var_dump($rcrtcvDesp);
						if(trim($rcrtcvDesp) == 'Result pending')
							$rcrtcvDesp = "";
						$corrtype.="<div style='text-align:center;font-size:18px;width:100%;font-weight:bold;color:red;margin-bottom:10px;'><u>{$rcrtcvDesp}</u></div>";
					}
			
				}
			}
			
	//	}
		//====END====//
		//var_dump($corrtype);

		//===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();

		$revadeg = "SELECT ifnull(fmctype,'') as fmctype,fdeggrp FROM degree where fdegree = '{$FDEGREE}' and fexamno = '{$fexamno}'";
		$resrevadeg=$conn->query($revadeg);
		$revadegdata = $resrevadeg->fetch_assoc();
		$fmctype = $revadegdata['fmctype'];
		$fdeggrp = $revadegdata['fdeggrp'];
		//===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'
			and fyear = '{$year}'
			and fexamtype = '{$examtype}'";
			$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(rm.FTHUE='','-',rm.FTHUE) as FTHUE ,
		if(rm.FPRUE='','-',rm.FPRUE) as FPRUE ,
		if(rm.FTHVV='','-',rm.FTHVV) as FTHVV ,
		if(rm.FPRVV='','-',rm.FPRVV) as FPRVV,
		if(rm.FTHIA='','-',rm.FTHIA) as FTHIA,
		if(rm.FPRIA='','-',rm.FPRIA) as FPRIA,
		if(rm.FTHTOT='','-',rm.FTHTOT) as FTHTOT,
		if(rm.FPRTOT='','-',rm.FPRTOT) as FPRTOT,
		if(rm.FTHPASSMTH='','-',rm.FTHPASSMTH) as FTHPASSMTH,
		if(rm.FPRPASSMTH='','-',rm.FPRPASSMTH) as FPRPASSMTH,
		if(rm.FCREDITS = '','-',rm.FCREDITS) as FCREDITS,
		if(ifnull(rm.FGP,'') = '','-',rm.FGP) as FGP,
		if(ifnull(rm.FCP,'') = '','-',rm.FCP) as FCP,
		if(ifnull(rm.FGRADE,'') = '','-',rm.FGRADE) as FGRADE,
		if(ifnull(rm.FSGPA,'') = '','-',rm.FSGPA) as FSGPA,
		if(ifnull(rm.FCGPA,'') = '','-',rm.FCGPA) as FCGPA,
		rm.FMAXMARKS,rm.FTOTMARKS,rm.FPREVMAX,rm.FPREVTOT,rm.FPERCENT,rm.FCLASS,FMCNUMBER,rm.FYEAR,rm.FEXAMTYPE, rm.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}'
		and rm.fyear = '{$year}'
		and rm.fexamtype = '{$examtype}'
		group by s.FSUBCODE
		order by s.FPRINTORD,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 == '045'){
					//$rem = "Remarks";
					$title1 = ['Sl. No.','Subject Name',
							"Credits",
							"Grade Points",
							"Credit Points",
							'Remarks'];
				}
				else if($univcode == '017'){
					//$rem = "Remarks";
					$title1 = ['Sl. No.','Subject Name','L:T:P',
							"Credits",
							"Grade Points",
							"Credit Points",
							'Remarks'];
				}else if($univcode == '041' || $univcode == '042' || $univcode == '044'){ 
					$title1 = ['Sl. No.','Subject Name',
					"Max. Marks",
							"Sec. Marks",	
							"Credit Hrs",
							"Grade Points",
							"Credit Points",
							'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'){
					if($fdeggrp == 'PHD')
					{
						$title1 = ['Sl. No.','Subject Name',"Th. / Pr.",
						"L:T:P",
						"Credits Hrs",					
						'Grade',
						'Remarks'];
					}else
					{
							$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 == '030'){

					if($fmctype == '21')
					{
						$title1 = ['Sl. No.','Course',
						"Max. Marks",
							"Marks Sec.",
						"No. of <br>Credits",
						"Grade Points",
						"Credit Points",
						'Grade'];

					}else
						$title1 = ['Sl. No.','Course',"Th. / Pr.",
							"No. of <br>Credits",
							"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 == '027'){
					$title1 = ['Sl. No.','Subject Name',
							"Th. / Pr.",
							"Univ Exam",
							'Viva',
							'IA',
							'Total',
							'Credit',
							'Grade Point',
							'Credit Point',
							'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.",
							"Univ Exam",
							"Credit Hrs",
							"Grade Points",
							"Credit Points",
							'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']; 
				
				$FTHPASSMTH1 = trim($v['FTHPASSMTH']);
				$FPRPASSMTH1 = trim($v['FPRPASSMTH']);

				if($FSCHEME == 'CR' && ($univcode == '040' || $univcode == '027'))
				{	
					$FTHPASSMTH = $FGRADE;
					$FPRPASSMTH = $FGRADE;
				}	
				else
				{
					$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'];
				$FCGPA= $v['FCGPA'];
				
				$FSGPA         = $v['FSGPA'];
				

				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(strtolower($FTHPASSMTH1) == strtolower($FPRPASSMTH1))
				{
						$remarks1 = $FTHPASSMTH1; 
				}
				else if(strtolower($FTHPASSMTH1)=="pass" && strtolower($FPRPASSMTH1)=="pass")
				{
						$remarks1 = "Pass"; 
				}
				else if(strtolower($FTHPASSMTH1)=="fail" && strtolower($FPRPASSMTH1)=="fail")
				{
						$remarks1    = "Fail"; 
				}
				else if(strtolower($FTHPASSMTH1)!="-" && strtolower($FPRPASSMTH1)=="-")
				{
						$remarks1  = $FTHPASSMTH1; 
				}
				else if(strtolower($FTHPASSMTH1)=="-" && strtolower($FPRPASSMTH1)!="-")
				{
						$remarks1  = $FPRPASSMTH1; 
				}else
				{

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

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

				}

						//--remarks--//
				$send_data['sl_no'] = $sl_no;
				$send_data['subject'] = $FSUBNAME;
				$send_data['remarks1'] = $remarks1;
				
				if($univcode == '040' && $FSCHEME == 'CR'){
					
					if($FSGPA != '-')
					{
						$send_data['mthprue'] = $mthprue;
						$send_data['uni_exam'] = $FLTP; 
						$send_data['viva_exam'] = $FCREDITS; 
						$send_data['ia_exam'] = $FGP; 
						$send_data['thtot'] = $FCP;
					}else
					{
						$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;
					if($univcode == '027')
					{
						$send_data['FGP'] =$FGP;
						$send_data['FCP'] =$FCP; 
						if($FSCHEME =="CR" )
							$send_data['FGRADE'] =$FCREDITS;
						else	
							$send_data['FGRADE'] =$FGRADE; 
					}	
					$send_data['thtot'] = $total;
				}

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

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

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

				if(($univcode == '041' || $univcode == '042' || $univcode == '001' || $univcode == '044') && $FSCHEME == 'CR' )
					$send_data['fsmaxmarks']= $FSMAXMARKS;
				
				
				if($univcode == '030')
				{	
					if($fmctype == '21')	
					{	
						$send_data['fsmaxmarks']= $FSMAXMARKS;
					}	
					$send_data['fmctype']= $fmctype;
				}else 
					$send_data['fmctype']= "";

			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' || $univcode == '027' || $univcode == '001' || $univcode == '047' ){
				$send_data['FMAXMARKS'] = $FMAXMARKS;
				$send_data['FTOTMARKS'] = $FTOTMARKS;
			}
			if($FSCHEME == 'CR')
			{	
				//var_dump($FSGPA);
			
				if($FCGPA != '0.00'){
					$send_data['FCGPA'] = $FCGPA;
					$send_data['FSGPA'] = $FSGPA;
					if($univcode == '040' && $FSGPA !='-')
					{	
						$send_data['FPERCENT'] = $FSGPA;
						if($fnextexam=="-")
							$send_data['FQPALPERCT'] = $FPERCENT;
					}	
					else if($univcode == '027' && $FPERCENT ==$FSGPA)
					{
						$send_data['FPERCENT'] = round((($FTOTMARKS / $FMAXMARKS)*100),2);
					}else
						$send_data['FPERCENT'] = $FPERCENT;
				}
				else{

					if($univcode == '040' && $FSGPA !='-')
					{	
						$send_data['FPERCENT'] = $FSGPA;
						if($fnextexam=="-")
					  	$send_data['FQPALPERCT'] = $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;
			$send_data['fnextexam'] =$fnextexam;
			array_push($final_data,$send_data);
		}
		//===END Result Det==//
			$res['studDet']=$result1;
			$res['headers'] = $title1;
			$res['body'] = $final_data;
			$res['fdeggrp'] = $fdeggrp;
			$res['corrtype'] = $corrtype;
			$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'];

		$fexamnoarry = $_GET['examno'];
		$examarry = explode("-",$fexamnoarry);	
		$fexamno = $examarry[0];
		$year = $examarry[1];
		$examtype = $examarry[2];

    $query = "select s.FSUBNAME,  rm.fsubcode, rm.fssubname, rm.fmarks, rm.fyear, rm.fexamtype,
	if(s.ftheory = 'T','Th.','Pr.') as thpr
    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}'
	and rm.fyear = '{$year}'
	and rm.fexamtype = '{$examtype}'
	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'];
			$fthpr=$v['thpr'];

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

    }
		$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
		inner join resmarks rm on rm.fregno = r.fregno and rm.fexamno = r.fexamno
		WHERE r.fregno = '{$regno}' 
		and ifnull(r.fdeleted,'') <> 'T'
		order by fexamno desc";
		//var_dump($query,$conn);
		$result =mysqli_query($conn,$query);

	//	$row = mysqli_fetch_assoc($result);
	$num = mysqli_num_rows($result);
	//var_dump($num);	
		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); 	
	}



?>