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


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

<?php

$GLOBALS['main_src']=substr($_SERVER['SCRIPT_FILENAME'],0,strlen($_SERVER['SCRIPT_FILENAME'])-20);
$pdf_writer_class =$GLOBALS['main_src']."/tcpdf/tcpdf.php";
require_once($pdf_writer_class);

class MYPDF extends TCPDF 
{

	public function setData($FUNIVNAME,$s_state,$pdf_logo_path,$FUNIVCODE,$current_date,$folder)
	{
    $this->FUNIVNAME = $FUNIVNAME;
    $this->s_state = $s_state;
    $this->pdf_logo_path = $pdf_logo_path;
    $this->$FUNIVCODE = $FUNIVCODE;
		$this->current_date = $current_date;
		$this->folder = $folder;
	}
	
	public function Header()
	{
    // get the current page break margin
    $bMargin = $this->getBreakMargin();
    // get current auto-page-break mode
    $auto_page_break = $this->AutoPageBreak;
    // disable auto-page-break
    $this->SetAutoPageBreak(false, 0);

    $this->SetFillColor(248, 248 ,255);		
		$img_path = $GLOBALS['main_src']."/img/logo_{$this->folder}.jpg";
		if(file_exists($img_path)) 
			$this->Image($img_path,15,6,20,20);
		$img_path = $GLOBALS['main_src']."/img/logo2.jpg";
	
		if(file_exists($img_path)) 
      $this->Image($img_path,170,6,20,20);
		
		
			$this->SetMargins(10, 20);//l,t,r,true or False

		$this->SetFont('helvetica','B',14);
		$this->Cell(0,4,$this->FUNIVNAME,0,1,'C');
		$this->SetFont('Times','',12);
		$this->Cell(0,4,$this->s_state,0,1,'C');
		
		$cur_year = date("Y");
    $this->SetFont('Times','',10);
    
		$this->SetFont('Times','',12);
		
    $this->SetAutoPageBreak($auto_page_break, $bMargin);
    
  }

	public function Footer() 
	{
		$this->SetMargins(20,45);
		$this->SetY(-15);
		$this->SetFont('helvetica', 'I', 8);
		$this->Cell(40, 10,'IP : '.$_SERVER["REMOTE_ADDR"], 0, 0, 'L');
		$this->Cell(80, 10,'Date : '.date("d-m-Y H:i:s"), 0, 0, 'C');
		$this->Cell(70, 10,'Page ' .$this->getPageNumGroupAlias().'/'.$this->getPageGroupAlias(), 0, 1, 'R');
	}

}

class Results 
{

	public $html='';

	function DefaultConstructor()
	{
		include 'database.php';
		include("commandb.php"); 
		
		$this->ip=$_SERVER["REMOTE_ADDR"];
		$get_date="select DATE_FORMAT(now(), '%d/%m/%Y') as now_date";
		$obj=$conn->query($get_date);
    $obj = $obj->fetch_assoc();

		$get_coll_name="select FUNIVNAME,FUNIVCODE,
		FUNIVADD1 as 'state', pdf_logo_path,
		ifnull(FEXAMAPPREQ,'F') as FEXAMAPPREQ From control where funivcode='{$_SESSION['UNIVCODE']}'";
		$lobj_get_coll_name=$conn->query($get_coll_name);//or die($conn->error)
		$coll_name = $lobj_get_coll_name->fetch_assoc();
		
		$get_univ_shortname ="select ffolder from dbname where funivcode='{$_SESSION['UNIVCODE']}'";
		$ffolder = $conndb->query($get_univ_shortname);//or die($conndb->error)
		$res = $ffolder->fetch_assoc();

		$FUNIVNAME=$coll_name['FUNIVNAME'];
		$s_state=$coll_name['state'];
		$pdf_logo_path=$coll_name['pdf_logo_path'];
		$FUNIVCODE=$coll_name['FUNIVCODE']; 
		$current_date = $obj['now_date'];		
		$folder = $res['ffolder'];
 
		$this->pdf= new MYPDF('L');
		$this->pdf->setData($FUNIVNAME,$s_state,$pdf_logo_path,$FUNIVCODE,$current_date,$folder);
		
  }


	function tableHeader($pdf,$headers,$w)
	{
	
    $pdf->SetFont('Times','B',10);
		$this->html .='<div align="center"><table cellspacing="0" cellpadding="2" border="1" ><tr>';

		foreach($headers as $k =>$item)
		{		
				$this->html .='<th align="center" width = "'.$w[$k].'"><b>'.$item.'</b></th>';	
		}

		$this->html .='</tr>';
		
    $pdf->SetFont('Times','',10);
  }

	function writeReport($detailed)
	{
		$pdf=$this->pdf;
		$univcode = $_SESSION['UNIVCODE'];

    $pdf->startPageGroup();
		
		$data = json_decode($detailed,true);
		
		$studDet = $data['studDet'];

		if(isset($data['footerRemarks']))
			$footerRemarks = $data['footerRemarks'];

		if(isset($data['headers']))
			$headers = $data['headers'];

		$pdf->AddPage('P','A4');
    $pdf->SetFont('Times','B',12);
	
		$pdf->cell(0,6,$studDet['FRESEXAMDATE']." Examination",0,1,"C");
		$pdf->cell(0,6,$studDet['FEXAMNAME'].", ".$studDet['FDEGREE']." - ".$studDet['FDESCPN'],0,1,"C");
		$pdf->cell(0,6,"Reg. No. : ".$studDet['FREGNO'],0,1,"C");
		$pdf->cell(0,6,"Student Name : ".$studDet['FNAME'],0,1,"C");


		//=====Withheld Details======//
		if(isset($data['body']['held_cnt']))
		{
			if ($univcode == "003D" && ($data['body']['fwhrem'] == "EXAM FEE NOT PAID"))
				$this->html .= '<a target = "_blank" rel="noopener noreferrer" style = "color:blue" 
			href="http://logisys.net.in/student/kusdde/index.php?r='.$regno.'">
			clik here to apply</a>';
			else $this->html .= "";

			$this->html .='
				<div align="center">
					<h2>RESULT WITHHELD</h2>
					<h3><b>Withheld Reason : '.$data['body']['fwhrem'].' </b> </h3>
				</div>';
          //=== kusdde Withheld details ===//
          if ($univcode == "003D") {
            $this->html .= '<table border="1" cellspacing="2" cellpadding="0">
            <thead style = "height:40px;background-color: #184F76 !important;color: #fff;">
              <tr class="text-center">
                <th>Sl.No.</td>
                <th>Withheld Reason</td>
                <th>Remarks</td>
              </tr>
            </thead>
            <tr>
              <td align="center" >1</td>
              <td align="left" >Exam Fee Not Paid</td>
              <td align="center" >If Already paid, Send Exam Fee Paid Details to Registrar(Ev) Office.<br>Email id : regexamku@gmail.com</td>
            </tr>
            <tr>
                <td align="center" >2</td>
                <td align="left" >Admission Not Approved By DDE </td>
                <td align="center" >Contact Study Center / College</td>
            </tr>
              
            <tr>
              <td align="center">3</td>
              <td align="left">Combination Not Approved By DDE</td>
              <td align="center">Contact Study Center / College</td>
            </tr>
            <tr>
              <td align="center">4</td>
              <td align="left">IA. (TH) / I.A. (PR) Pending</td>
              <td align="center">Contact Study Center / College</td>
            </tr>
          </table>';
          }
					
					$pdf->Ln(5);
					$pdf->SetFont('Times','',12);
					if ($footerRemarks['FRESULT_REMARKS'] != "") 
					{
						$this->html .= '<hr><div align="left"><p>'.$footerRemarks["FRESULT_REMARKS"].'</p></div>';
					}
					$pdf->writeHTML($this->html, true, false, true, false, '');
					return;
				}
		//=====Withheld Details End======//
				
		// }

		$pdf->Ln(5);		
		//===Res Table===//
		$this->tableHeader($pdf,$headers,$data['width']);
		
		$this->html .='<tbody>';

		foreach($data['body'] as $key => $value) 
		{
		
			$this->html .='<tr align="center">';

			$FTOTMARKS = isset($value["FTOTMARKS"]);
			$FSMAXMARKS = empty($value["fsmaxmarks"]);
			$FPERCENT = $value["FPERCENT"];
			$FSCHEME = $value["FSCHEME"];
			$RESULT = $value["result"];
			$FLTP = isset($value["FLTP"]);
			// $FMAXMARKS = isset($value["FMAXMARKS"]);
			// $FCREDITS = isset($value["FCREDITS"]);
			// $FCP = isset($value["FCP"]);
			// $FGP = isset($value["FGP"]);
			// $FCGPA = isset($value["FCGPA"]);
			$FPREVMAX = $value["FPREVMAX"];
			$ttl_marks = "";
			$viva_exam = "";
			$max_marks = "";	

			if(isset($value["FCGPA"]))
			$FCGPA = $value["FCGPA"];	

			if(isset($value["FSGPA"]))
			$FSGPA = $value["FSGPA"];	

			if ($FSCHEME == "CR" && $univcode == "037") $ttl_marks = "";
			else $ttl_marks = '<td >'.$value["mthprue"].'</td>';

			if ($FSCHEME != "CR" && $univcode == "040") $viva_exam = "";
			else $viva_exam = '<td >'.$value["viva_exam"].'</td>';

			if (isset($value["fsmaxmarks"]))
				$max_marks = '<td >'.$value["fsmaxmarks"].'</td>';			
			else $max_marks = "";

			$this->html .= "<td>".$value['sl_no']."</td>";

			$this->html .='<td align="left">'.$value['subject'].'</td>'.
				$ttl_marks;

			if (isset($value["fsmaxmarks"]))
				$this->html .= '<td >'.$value["fsmaxmarks"].'</td>';

			$this->html .="<td>".$value['uni_exam']."</td>".
				$viva_exam.
				"<td>".$value['ia_exam']."</td> 
				<td>".$value['thtot']."</td>";

			if ($value["FSCHEME"] == "CR") 
			{							
				$PERCENT = $value["FPERCENT"];

				if (isset($value["FCREDITS"]) || isset($value["FGP"]) || isset($value["FCP"])) 
				{
					$this->html .= '<td align="center">'.$value["FCREDITS"].'</td>
					<td align="center">'.$value["FGP"].'</td>
					<td align="center">'.$value["FCP"].'</td>';
				}

			}else 			
				$FPERCENT = $value["FPERCENT"];		

			$this->html .= '<td align="center"><b>'.$value["remarks"].'</b></td>
			</tr>';
		}
		
		$this->html .= '</tbody></table></div>';

		$pdf->writeHTML($this->html, true, false, true, false, '');
		//===Res Table End===//

		//====Footer Details====//
		$pdf->SetFont('helvetica','B',10);
		if ($FSCHEME == "CR") 
		{
			$cgpa = "";
			if ($FCGPA != "-") $cgpa = 'C.G.P.A :'. $FCGPA;
			if ($univcode == "036") $cgpa = "";

			//if acu-034-only sgpa, no result
			if (isset($value["FCREDITS"]) || isset($value["FGP"]) || isset($value["FCP"])) {
				if (isset($value["FMAXMARKS"]) ) 
				{
					if ($univcode == "034")
						$pdf->cell(0,7,"Max. Marks : ".$value["FMAXMARKS"]."   Sec. Marks : ". $value["FTOTMARKS"]."   S.G.P.A : ".$FPERCENT."    " .$cgpa,0,1,"C");
					else if ($univcode == "036")
						$pdf->cell(0,7,"Max. Marks : ".$value["FMAXMARKS"]."   Sec. Marks : ". $value["FTOTMARKS"]."   S.G.P.A : ".$FPERCENT."    " .$cgpa."   Result : ".$RESULT,0,1,"C");
					else if ($univcode == "008")
						$pdf->cell(0,7,"Max. Marks : ".$value["FMAXMARKS"]."   Sec. Marks : ". $value["FTOTMARKS"]."   S.G.P.A : ".$FPERCENT."    " .$cgpa."   Result : ".$RESULT,0,1,"C");
					else
						$pdf->cell(0,7,"Max. Marks : ".$value["FMAXMARKS"]."   Sec. Marks : ". $value["FTOTMARKS"]."   Percentage : ".$FPERCENT."    Result : ".$RESULT,0,1,"C");
				} 
				else if ($RESULT == "Fail, Promoted") {
					//for 039 & 035
					$pdf->cell(0,7,"Max. Marks : ".$value["FMAXMARKS"]."    Sec. Marks : ". $value["FTOTMARKS"]."    S.G.P.A : ".$FPERCENT."    Result : ".$RESULT."   Grade : -",0,1,"C");
				} else 
				{
					$pdf->cell(0,7,"Max. Marks : ".$value["FMAXMARKS"]."    Sec. Marks : ". $value["FTOTMARKS"]."    S.G.P.A : ".$FPERCENT."    Result : Pass     Grade : " .$RESULT,0,1,"C");
				}
			} 
			else if (isset($value["FMAXMARKS"]) ) 
			{
				if ($univcode == "034")
					$pdf->cell(0,7,"Max. Marks : ".$value["FMAXMARKS"]."   Sec. Marks : ". $value["FTOTMARKS"]."   S.G.P.A : ".$FPERCENT."    " .$cgpa,0,1,"C");
				else if ($univcode == "036")
					$pdf->cell(0,7,"Max. Marks : ".$value["FMAXMARKS"]."   Sec. Marks : ". $value["FTOTMARKS"]."   S.G.P.A : ".$FPERCENT."    " .$cgpa."   Result : ".$RESULT,0,1,"C");
				else if ($univcode == "008")
					$pdf->cell(0,7,"Max. Marks : ".$value["FMAXMARKS"]."   Sec. Marks : ". $value["FTOTMARKS"]."   S.G.P.A : ".$FPERCENT."    " .$cgpa."   Result : ".$RESULT,0,1,"C");
				else
					$pdf->cell(0,7,"Max. Marks : ".$value["FMAXMARKS"]."   Sec. Marks : ". $value["FTOTMARKS"]."   Percentage : ".$FPERCENT."    Result : ".$RESULT,0,1,"C");
			} 
			else 
			{
				if ($univcode == "041" || $univcode == "042")
					$pdf->cell(0,7,"S.G.P.A : ".$PERCENT. "     ".$cgpa."   Result : ".$RESULT,0,1,"C");
				else
					$pdf->cell(0,7,"S.G.P.A : ".$PERCENT."     ". $cgpa."   Result : ".$RESULT,0,1,"C");					
			}
		} 
		else 
		{
			if (strtolower($RESULT) == "fail") $color = "red";
			
			$pdf->cell(0,7,"Max. Marks : ".$value["FMAXMARKS"]."   Sec. Marks : ". $value["FTOTMARKS"]."   Percentage : ".$FPERCENT."   Result : ".$RESULT,0,1,"C");

			if ($FPREVMAX != "0000")		
				$pdf->cell(0,7,"Earlier Exams : [Max. Marks: ".$FPREVMAX."   Sec. Marks : ". $FCGPA." ]",0,1,"C");

		}

		if (isset($value["FCREDITS"]) || isset($value["FGP"]) || isset($value["FCP"])) 
		{
			if($univcode != "036" && $univcode != "035" && $univcode != "034")
				$pdf->cell(0,7,"College : ".$studDet['FCOLLCODE']." - ".$studDet['FCOLLNAME'],0,1,"C");

			if ($studDet['FELIGREM01'] != "") 
				$pdf->cell(0,7,"College : ".$studDet['FELIGREM01']."  ".$studDet['FELIGREM02'],0,1,"C");
		} 
		else 
		{
			if ($univcode != "036" && $univcode != "035" && $univcode != "041" && $univcode != "042") 
				$pdf->cell(0,7,"College : ".$studDet['FCOLLCODE']." - ".$studDet['FCOLLNAME'],0,1,"C");

			if ($univcode == "041" || $univcode == "042") 
			{
				$pdf->cell(0,7,"College : ".$studDet['FCOLLCODE']." - ".$studDet['FCOLLNAME'],0,1,"C");

				if ($studDet['FELIGREM01'] != "") 
					$pdf->cell(0,7,$studDet['FELIGREM01']."  ".$studDet['FELIGREM02'],0,1,"C");
			} 
			else 
			{
				if ($studDet['FELIGREM01'] != "") 
					$pdf->Multicell(0,7,$studDet['FELIGREM01']." ".$studDet['FELIGREM02'],0,"C",0,1);//w,h,txt,border,align,fill,1					
			}
		}

		$pdf->SetFont('helvetica','',10);
		
		//=====Footer Remarks=====//
		if ($footerRemarks['FRESULT_REMARKS'] != "") 
		{
			$this->footer = '<hr><div align="left"><p>'.$footerRemarks["FRESULT_REMARKS"].'</p></div>';
		}
		$pdf->writeHTML($this->footer, true, false, true, false, '');
		//======Footer Details End======//

    $pdf->SetFont('Times','BU',12);   
  }

  function SendOutput()
	{
		ob_end_clean();
		$this->pdf->Output("Results.pdf","D");
  }	
}


//==========call to api=========//
include 'database.php';

include("commandb.php");
//=======Request for Print Results=======//
if($_REQUEST['a'] == "printRes")
{
	
  $univcode = $_SESSION['UNIVCODE'];
  
  $fexamno = $_REQUEST['examno']; 

  $qry = "select 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}' ";

	$result1 = $conn->query($qry);
	$result1 = $result1->fetch_assoc();


	//====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']=" 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 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();
		
		$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['dates'] = $dates;
				$res['corrtype'] = $corrtype;
				$res['footerRemarks'] = $remarksDet;

				$class_obj = new Results();
				$class_obj->DefaultConstructor();
				$class_obj->writeReport(json_encode($res,true));
				$class_obj->SendOutput();
				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(FCREDITS = '','-',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,
		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";

		$result = $conn->query($query);
		$title1 = array();
		$send_data = array();
		$final_data = array();
		$marks = "";

		if($row = mysqli_fetch_assoc($result))//$result = $result->fetch_array()
		{
			$FSCHEME = $row['FSCHEME'];
			if($FSCHEME == 'CR')
			{
									
				if($univcode == '023')
				{						
					$title1 = ['Sl. No.','Subject Name',
					"Th / Pr",
					'Univ Exam',
					'Viva',
					'IA',
					'Total',
					"Credit Hrs",
					"Grade Points",
					"Credit Points",
					'Remarks'];//11
					$w = ['20','180','25','40','30','30','40','40','40','40','55'];
				}
				else if($univcode == '017'){
					//$rem = "Remarks";
					$title1 = ['Sl. No.','Subject Name','L:T:P',
					"Total Marks",
							"Credits",
							"Grade Points",
							"Credit Points",
							'Remarks'];//8
					$w = ['20','200','40','40','40','40','40','55'];
				}else if($univcode == '041' || $univcode == '042' || $univcode == '001'){
					$title1 = ['Sl. No.','Subject Name','Th / Pr',
					"Max. Marks",
							"Sec. Marks",	
							"Credit Hrs",
							"Grade Points",
							"Credit Points",
							'Remarks'];//9
						$w = ['20','190','25','39','40','50','58','58','55'];
				}
				else if($univcode == '040'){
					$title1 = ['Sl. No.','Subject Name',"Th_Pr",
					"L:T:P",
							"Credits Hrs",
							"Grade Points",
							"Credit Points",
							'Grade'];//8
					$w = ['20','190','40','40','40','40','40','55'];

				}
				else if($univcode == '034'){
					$title1 = ['Sl. No.','Subject Name',"Th_Pr",
					"Total Marks",
							"Credits Hrs",
							"Grade Points",
							"Credit Points",
							'Grade'];//8
					$w = ['20','190','40','40','40','40','40','55'];

				}
				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'];//11
					$w = ['20','180','25','40','30','30','40','40','40','40','55'];
				}
				else if($univcode == '036'){
					$title1 = ['Sl. No.','Subject Name',
					"Max. Marks",
							"Sec. Marks",	
							"CreditHrs",
							"GradePoints",
							"CreditPoints",
							'Grade'];//8
					$w = ['20','190','40','40','40','40','40','55'];

				}else if($univcode == '038'){
					$title1 = ['Sl. No.','Course Title',"Th Pr",
					"Sem. End Exam",
							"Credits Hrs",
							"Grade Points",
							"Credit Points",
							'Remarks'];//8
					$w = ['20','190','40','40','40','40','40','55'];

				}else if($univcode == '008'){
					$title1 = ['Sl. No.','Subject Name','L:T:P',
					"Total Marks",
							"Credits Hours",
							"Grade Points",
							"Credit Points",
							'Grade'];//8
					$w = ['20','190','40','40','40','40','40','55'];

				}else if($univcode == '037'){
					$title1 = ['Sl. No.','Subject Name',
					"Total Marks",
							"Credits",
							"Grade Points",
							"Credit Points",
							'Grade'];//7
					$w = ['20','190','40','60','40','40','55'];

				}else
				{
					$title1 = ['Sl. No.','Subject Name',
					"Th_Pr",
							"UnivExam",
							"CreditHrs",
							"GradePoints",
							"CreditPoints",
							'Remarks'];//8
					$w = ['20','190','40','40','40','40','40','55'];
				}											
			}else
			{		
				if($univcode == '034'){
					$title1 = ['Sl. No.','Subject Name',
					"Th Pr",
							"Sem. End Exam",	'Viva',
							'IA',
							'Total',
							'Remarks'];//8
							$w = ['20','190','40','40','40','40','40','55'];

				}else if($univcode == '035'){
					$title1 = ['Sl. No.','Subject Name',
					"Th Pr",
							"Sem. End Exam",	'Viva',
							'IA',
							'Total',
							'Remarks'];//8
							$w = ['20','190','40','40','40','40','40','55'];

				}else if($univcode == '040'){
					$title1 = ['Sl.No.','Subject Name',
					"Th / Pr",
					'Univ Exam',
					'IA',
					'Total',
					'Remarks'];//7
					$w = ['20','190','40','60','40','40','55'];
				}else{
					$title1 = ['Sl. No.','Subject Name',
					"Th / Pr",
					'Univ Exam',
					'Viva','IA',
					'Total',
					'Remarks'];//8
					$w = ['35','190','40','60','40','40','40','55'];
				}
			}

			$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']);

				$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}";
					$mthprue  = GetTdData("Th.","Pr.");
					$uni_exam = GetTdData($FTHUE,$FPRUE);
				}
				else if($FTHUE != "-")
				{
					$mthprue  = "Th.";
					$uni_exam = "{$FTHUE}";
					$mthprue  = GetTdData("Th.","");
					$uni_exam = GetTdData($FTHUE,"");
				}
				else
				{
					$mthprue  = "Pr.";
					$uni_exam = "{$FPRUE}";
					$mthprue  = GetTdData("Pr.","");
					$uni_exam = GetTdData($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}";
							$ia_exam=GetTdData($FTHIA,$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;	
					$total=GetTdData($FTHTOT,$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")
				{
						$pass_color = "red;";
						$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
						$remarks = $FTHPASSMTH."<br>".$FPRPASSMTH;

					// 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;
							//$send_data['FCGPA']
					}
				}

				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'){
				$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['FPREVMAX'] = $FPREVMAX; $send_data['FPREVTOT'] = $FPREVTOT;
			$send_data['FSCHEME'] =$FSCHEME;
			array_push($final_data,$send_data);
		}
		$res['studDet']=$result1;
		$res['width'] = $w;
    $res['headers'] = $title1;
    $res['body'] = $final_data;    
    $res['dates'] = $dates;
		$res['corrtype'] = $corrtype;
		$res['footerRemarks'] = $remarksDet;			
		
		$class_obj = new Results();
		$class_obj->DefaultConstructor();
		$class_obj->writeReport(json_encode($res,true));
		$class_obj->SendOutput();

	}

}


function GetTdData1($div1,$div2)
{
	$color1="color:green;";
	$color2="color:green;";
	
	if(trim(strtolower($div1)=="fail"))
		$color1="color:red;";
	if(trim(strtolower($div2)=="fail"))
		$color2="color:red;";
	$html="";
	if(empty($div2))
		$html="<div style=' {$color1}'>{$div1}</div>";
	else
		$html="<div {$color1}'>{$div1}</div><div style='{$color2}'>{$div2}</div>";
	return $html;
	
}

function GetTdData($div1,$div2)
{
	$html="";
	if(empty($div2))
		$html="{$div1}";
	else
		$html="<div >{$div1}</div><div>{$div2}</div>";
	return $html;
}
?>