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.116.47.194
<?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');
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){
$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 . '.xls"');
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 categorywiseresultsheet($aobj_context){
session_start();
$ip=$_SERVER["REMOTE_ADDR"];
$collcode=$_SESSION['collcode'];
$college_code=$_SESSION['collcode'];
$univcode = $aobj_context->mobj_data["univcode"];
$degree = $aobj_context->mobj_data["degree"];
$degexam = $aobj_context->mobj_data["degexam"];
$yearmode = $aobj_context->mobj_data["yearmode"];
$section = $aobj_context->mobj_data["section"];
$deggrp = $aobj_context->mobj_data["deggrp"];
if($section=="All"){
$cnd;
}
else{
$cnd="("."Section"." : ".$section.")";
}
$yearmode = explode("*",$yearmode);
$year = $yearmode[0];
$examtye = $yearmode[1];
$session = $aobj_context->mobj_data["session"];
$get_daliy_present_data= "SELECT DISTINCT fcaste FROM student order by fcaste";
$result = $aobj_context->mobj_db->GetAll($get_daliy_present_data);
$objPHPExcel = new PHPExcel();
$fileName = 'Daily Report';
$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'),
),
),
);
$appArr = ['G', 'J','M','P','S','V','Y','AB','AE','AH','AK',
'AN','AQ','AT','AW','AZ','BC','BF','BI','BL','BO','BR','BU'];
$passArr = ['H', 'K','N','Q','T','W','Z','AC','AF','AI','AL','AO','AR',
'AU','AX','BA','BD','BG','BJ'];
$failArr = ['I', 'L','O','R','U','X','AA','AD','AG','AJ','AM',
'AP','AS','AV','AY','BB','BE','BH','BK'];
$objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setSize(12);
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Sl. No.');
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Degree Code');
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Degree Name');
$objPHPExcel->getActiveSheet()->setCellValue('D1', 'Total');
$objPHPExcel->getActiveSheet()->setCellValue('D2', 'Appeared')->getColumnDimension('D')->setwidth(10);
$objPHPExcel->getActiveSheet()->setCellValue('E2', 'Pass');
$objPHPExcel->getActiveSheet()->setCellValue('F2', 'Fail');
for ($i = 0; $i < count($result); $i++) {
$objPHPExcel->getActiveSheet()->setCellValue($appArr[$i].'1', $result[$i]['fcaste']);
$objPHPExcel->getActiveSheet()->setCellValue($appArr[$i].'2' , 'Appeared');
$objPHPExcel->getActiveSheet()->setCellValue($passArr[$i].'2', 'Pass');
$objPHPExcel->getActiveSheet()->setCellValue($failArr[$i].'2', 'Fail');
$objPHPExcel->getActiveSheet()->mergeCells($appArr[$i].'1:'.$failArr[$i].'1');
}
$objPHPExcel->getActiveSheet()->mergeCells('A1:A2');
$objPHPExcel->getActiveSheet()->mergeCells('B1:B2');
$objPHPExcel->getActiveSheet()->mergeCells('C1:C2');
$objPHPExcel->getActiveSheet()->mergeCells('D1:F1');
$objPHPExcel->getActiveSheet()->getColumnDimension('BJ')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(29);
$objPHPExcel->getActiveSheet()->getStyle('A1:AA1')->getAlignment()->setWrapText(true);
$objPHPExcel->getActiveSheet()->freezePane('A3');
$objPHPExcel->getActiveSheet()->getStyle('A1:'.$failArr[$i].'1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A1:'.$failArr[$i].'1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$j=0;
$newArr = [];
$query = "SELECT DISTINCT CONCAT(r.fdegree) AS degree,concat(r.fdegree,' - ',d.fdescpn) AS descpn, CONCAT(d.fdeggrp,' - ',d.fexamname, ' - ' ,d. fresexamdate) AS examname,
CONCAT(c.fcollcode,' - ',c.fcollname) AS college,s.fcaste ,COUNT(r.fregno) AS Totalcount,
SUM(IF(INSTR(fclass,'fail') > 0,1,0)) AS fail_cnt,
SUM(IF(INSTR(fclass,'fail') <= 0,1,0)) AS pass_cnt FROM
(SELECT DISTINCT fregno,fdegree,fclass,fexamno
FROM resmarks WHERE fexamno = '{$degexam}' AND fdegree IN(SELECT fdegree FROM degree WHERE fdeggrp='$deggrp')
AND fyear = '{$year}' AND fexamtype = '{$examtye}') AS r
INNER JOIN student s ON r.fregno = s.fregno AND r.fdegree = s.fdegree
INNER JOIN degree d ON d.fdegree =r.fdegree AND d.fexamno = r.fexamno
INNER JOIN college c ON s.fcollcode = c.fcollcode WHERE c.fcollcode = '{$collcode}'
GROUP BY r.fdegree";
$lobj_get_data1= $aobj_context->mobj_db->GetAll($query);
foreach($lobj_get_data1 as $val1)
{
$degree = $val1['degree'];
$descpn = $val1['descpn'];
foreach($result as $caste)
{
$query = "SELECT DISTINCT CONCAT(r.fdegree) AS degree,d.fdescpn AS descpn, CONCAT(d.fdeggrp,' - ',d.fexamname, ' - ' ,d. fresexamdate) AS examname,
CONCAT(c.fcollcode,' - ',c.fcollname) AS college,s.fcaste ,COUNT(r.fregno) AS Totalcount,
SUM(IF(INSTR(fclass,'fail') > 0,1,0)) AS fail_cnt,
SUM(IF(INSTR(fclass,'fail') <= 0,1,0)) AS pass_cnt FROM
(SELECT DISTINCT fregno,fdegree,fclass,fexamno
FROM resmarks WHERE fexamno = '{$degexam}' AND fdegree IN(SELECT fdegree FROM degree WHERE fdeggrp='$deggrp')
AND fyear = '{$year}' AND fexamtype = '{$examtye}') AS r
INNER JOIN student s ON r.fregno = s.fregno AND r.fdegree = s.fdegree
INNER JOIN degree d ON d.fdegree =r.fdegree AND d.fexamno = r.fexamno
INNER JOIN college c ON s.fcollcode = c.fcollcode
WHERE c.fcollcode = '{$collcode}' AND fcaste = '{$caste['fcaste']}'
and r.fdegree = '{$degree}'
GROUP BY r.fdegree, r.fexamno,fcaste";
$lobj_get_data= $aobj_context->mobj_db->GetAll($query);
$catcode = $caste['fcaste'];
$i=0;
foreach($lobj_get_data as $key => $data)
{
$newArr[$descpn][$catcode]['degree'] = $data['degree'];
$newArr[$descpn][$catcode]['degreename'] = $data['descpn'];
$newArr[$descpn][$catcode]['examdate'] = $caste['examname'];
$newArr[$descpn][$catcode]['college'] = $caste['college'];
$newArr[$descpn][$catcode]['fcaste'] = $caste['fcaste'];
$newArr[$descpn][$catcode]['Totalcount'] = $data['Totalcount'];
$newArr[$descpn][$catcode]['fail_cnt'] = $data['fail_cnt'];
$newArr[$descpn][$catcode]['pass_cnt'] = $data['pass_cnt'];
}
$i++;
}
}
$i = 3;
$k = 1;
foreach($newArr as $key =>$valye)
{
$slNo = $key +3;
$degreeInfo = explode(' - ', $key);
$degreeCode = isset($degreeInfo[0]) ? $degreeInfo[0] : '';
$degreeName = isset($degreeInfo[1]) ? $degreeInfo[1] : '';
$objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(25);
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i ,$k)->getColumnDimension('A')->setwidth(8);
$objPHPExcel->getActiveSheet()->setCellValue('B' .$i, $degreeCode)->getColumnDimension('B')->setwidth(12);
$objPHPExcel->getActiveSheet()->setCellValue('C' .$i, $degreeName)->getColumnDimension('C')->setwidth(70);
$objPHPExcel->getActiveSheet()->getStyle('A' . $i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('B' . $i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('D' . $i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('E' . $i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('F' . $i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$j=0;
$totalApp = 0;
$totalPass=0;
$totalFail=0;
foreach($result as $catcde)
{
$fcaste = $catcde['fcaste'];
if($valye[$fcaste]['Totalcount'] == ""){
$con1="-";
}else{
$con1=$valye[$fcaste]['Totalcount'];
}
if($valye[$fcaste]['pass_cnt'] == ""){
$con2="-";
}else{
$con2=$valye[$fcaste]['pass_cnt'];
}
if($valye[$fcaste]['fail_cnt'] == ""){
$con3="-";
}else{
$con3=$valye[$fcaste]['fail_cnt'];
}
$totalApp += $valye[$fcaste]['Totalcount'];
$totalPass += $valye[$fcaste]['pass_cnt'];
$totalFail += $valye[$fcaste]['fail_cnt'];
$objPHPExcel->getActiveSheet()->setCellValue($appArr[$j] .$i, $con1)->getColumnDimension($appArr[$j])->setwidth(9);
$objPHPExcel->getActiveSheet()->setCellValue($passArr[$j] .$i,$con2)->getColumnDimension($passArr[$j])->setwidth(8);
$objPHPExcel->getActiveSheet()->setCellValue($failArr[$j] .$i,$con3)->getColumnDimension($failArr[$j])->setwidth(8);
$objPHPExcel->getActiveSheet()->getStyle($appArr[$j] . $i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle($passArr[$j] . $i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle($failArr[$j] . $i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$j++;
}
$objPHPExcel->getActiveSheet()->setCellValue('D' .$i, $totalApp)->getColumnDimension('D')->setwidth(10);
$objPHPExcel->getActiveSheet()->setCellValue('E' .$i, $totalPass)->getColumnDimension('E')->setwidth(8);
$objPHPExcel->getActiveSheet()->setCellValue('F' .$i, $totalFail)->getColumnDimension('F')->setwidth(8);
$slNo++;
$i++;
$k++;
}
$objPHPExcel->getActiveSheet()->setTitle($fileName);
$objPHPExcel->getActiveSheet()->getPageSetup()
->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
getheaders($objPHPExcel, $fileName);
}
?>
|