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


Current Path : /var/www/oasis/Report_details/
Upload File :
Current File : /var/www/oasis/Report_details/subWiseFailedStudExcelReport.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 subWiseFailedStudExcelReport($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"];
	
		$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);

	 	$query = "SELECT stu.fcollcode,cl.fcollname,rs.fdegree,dg.fdescpn,rs.fexamno,
				 dg.fexamname,rs.fsubcode,su.fsubname,
				 stu.fname,rs.fregno,rs.fgrade,
				 IF(rs.fgrade = 'F','Failed in SEE',IF(rs.fgrade = 'A','Failed in SEE, Absent in SEE',
				 IF(rs.fgrade = 'N','Failed in IA, Failed in SEE, Not Appearing in SEE',''))) AS remaarks
				 FROM resmarks rs 
				 INNER JOIN subject su ON rs.fsubcode=su.fsubcode 
				 AND rs.fexamno=su.fexamno 
				 AND rs.fdegree=su.fdegree
				 INNER JOIN student stu ON stu.fregno=rs.fregno 
				 INNER JOIN college cl ON stu.fcollcode = cl.fcollcode
				 INNER JOIN degree dg ON dg.fdegree = rs.fdegree
				 AND  dg.fexamno = rs.fexamno
				 WHERE rs.fdegree='{$degree}' AND rs.fexamno='{$degexam}' 
				 AND rs.fgrade IN('A','F','N')
				 AND rs.fyear='{$year}' AND rs.fexamtype='{$examtye}'
				 GROUP BY rs.fdegree,rs.fexamno,rs.fsubcode,rs.fregno";

	  $results =  $aobj_context->mobj_db->GetAll($query);
	
		$objPHPExcel = new PHPExcel();
		
		$fileName = 'failedStudentDetails.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('A7');
	  $objPHPExcel->getActiveSheet()->setCellValue('A5', 'Sl No.');
	  $objPHPExcel->getActiveSheet()->setCellValue('B5', 'Reg. No');
	  $objPHPExcel->getActiveSheet()->setCellValue('C5', 'Name');
	  $objPHPExcel->getActiveSheet()->setCellValue('D5', 'Subject Name');
	  $objPHPExcel->getActiveSheet()->setCellValue('E5', 'Grade');
	  $objPHPExcel->getActiveSheet()->setCellValue('F5', 'Remarks');
	  $objPHPExcel->getActiveSheet()->getStyle('A5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
	  $objPHPExcel->getActiveSheet()->getStyle('B5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
	  $objPHPExcel->getActiveSheet()->getStyle('C5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
	  $objPHPExcel->getActiveSheet()->getStyle('D5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
	  $objPHPExcel->getActiveSheet()->getStyle('E5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
	  $objPHPExcel->getActiveSheet()->getStyle('F5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);

	  $objPHPExcel->getActiveSheet()->mergeCells('A1:F1');
	  $objPHPExcel->getActiveSheet()->mergeCells('A2:F2');
	  $objPHPExcel->getActiveSheet()->mergeCells('A3:F3');
	  $objPHPExcel->getActiveSheet()->mergeCells('A4:F4');
  
	   $objPHPExcel->getActiveSheet()->setCellValue('A1', $res['fcollname']);
	   $objPHPExcel->getActiveSheet()->setCellValue('A2', "Failed Students Report"." - ". $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);

		foreach($results as $key => $value){
		
			$slNo = $key + 6;
			$objPHPExcel->getActiveSheet()->setCellValue('A' . $slNo, $slNo - 5)->getColumnDimension('A')->setwidth(6);
			$objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $value['fregno'])->getColumnDimension('B')->setwidth(20);
			$objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo, $value['fname'])->getColumnDimension('C')->setwidth(35);
		
			$objPHPExcel->getActiveSheet()->setCellValue('D' . $slNo, $value['fsubname'])->getColumnDimension('D')->setwidth(6);
			$objPHPExcel->getActiveSheet()->setCellValue('E'.$slNo, $value['fgrade'])->getColumnDimension('D')->setwidth(10);
			$objPHPExcel->getActiveSheet()->setCellValue('F'.$slNo, $value['remaarks'])->getColumnDimension('D')->setwidth(10);
			$objPHPExcel->getActiveSheet()->setCellValue('G'.$slNo, $value["FCLASS"])->getColumnDimension('D')->setwidth(20);
			
			
			$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('D' . $slNo . ':F' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
			$objPHPExcel->getActiveSheet()->getStyle('D' . $slNo . ':F' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
			$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':F'.$slNo)->applyFromArray($styleArray);
	
		}

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