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


Current Path : /var/www/oasis/Report_details/
Upload File :
Current File : /var/www/oasis/Report_details/degreewiseMarksEntryStats.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');
// PHPExcel_Shared_Font::setAutoSizeMethod(PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT);
if (PHP_SAPI == 'cli')
    die('This example should only be run from a Web Browser');

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


function getheaders($objPHPExcel, $fileName)
{
    //To Fit To Page while printing
    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);

    // Redirect output to a client’s web browser (Excel5)
    header('Content-Type: application/vnd.ms-excel');
    header('Content-Disposition: attachment;filename='.$fileName);
    header('Cache-Control: max-age=0');
    // If you're serving to IE 9, then the following may be needed
    header('Cache-Control: max-age=1');

    // If you're serving to IE over SSL, then the following may be needed
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
    header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
    header('Pragma: public'); // HTTP/1.0
    ob_clean();
    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
    $objWriter->save('php://output');
    
}


function getDegreeWiseStatsReport($aobj_context){
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
    $subelement = $aobj_context->mobj_data["subelement"];
    $test = $aobj_context->mobj_data["test"];
    $sem = $aobj_context->mobj_data["sem"];
    $degree = $aobj_context->mobj_data["degree"];

    if($degree == "all"){
        $degmCond = "";
         $degaCond = "";
    }else{
        $degmCond = "and m.fdegree='{$degree}'";
        $degaCond = "and a.fdegree='{$degree}'";
    }
    
    $query="select a.fteachcode,m.fteachname, a.fdegree, d.fdescpn,su.fsubname,
            su.fsubshort, count(distinct a.fregno)as count, 
            ifnull(mak.entered, '0')as entered 
            from attendsum a left join (select sum.fteachcode,m.fdegree, m.fexamno, 
            m.fsubcode, m.fregno, 
            sum(case when ifnull(m.ftotal, '-1.0')='-1.0' then 0 else 1 end)as entered 
            from marksint m inner join subdet s on concat(s.fcsubcode, s.fsubcode) = m.fsubcode 
            and s.fdegree = m.fdegree and s.fexamno = m.fexamno 
            inner join attendsum sum on m.fregno = sum.fregno 
            and left(sum.fsubcode, 4) = left(m.fsubcode, 4) 
            and sum.fdegree = m.fdegree
            where m.ftest='{$test}' and s.fsubname='{$subelement}' and m.fexamno='{$sem}' {$degmCond}
            group by m.fdegree,sum.fteachcode,m.fsubcode) mak on mak.fdegree = a.fdegree 
            and mak.fexamno = a.fexamno 
            and a.fteachcode = mak.fteachcode
            and left(mak.fsubcode, 4) = left(a.fsubcode, 4) 
            inner join degree d on d.fdegree = a.fdegree 
            and a.fexamno = d.fexamno  
            inner join masteach m on m.fteachcode = a.fteachcode
            inner join subject su on su.fdegree = a.fdegree and su.fexamno = a.fexamno
            and su.fcsubcode = a.fsubcode
            inner join maxmarksint max on a.fclassid = max.FCLASSID
            where a.fexamno='{$sem}' {$degaCond}
            group by a.fdegree,a.fsubcode, a.fteachcode";
    $result = $aobj_context->mobj_db->GetAll($query);
    
    $fileName = 'Teacher_wise_marks_stats.xls';
    
    $objPHPExcel = new PHPExcel();
    $objPHPExcel->getProperties()->setCreator("Uniclare")
    ->setLastModifiedBy("Me")->setTitle("My Excel Sheet")
    ->setSubject("My Excel Sheet")->setDescription("Excel Sheet")
    ->setKeywords("Excel Sheet")->setCategory("Me");

    // Set active sheet index to the first sheet, so Excel opens this as the first sheet
    $objPHPExcel->setActiveSheetIndex(0);
    
    // Add column headers and make them bold
    $styleArray = array(
        'borders' => array(
            'allborders' => array(
                'style' => PHPExcel_Style_Border::BORDER_THIN,
                'color' => array('argb' => '000000'),
            ),
        ),
    );

    
    $objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setBold(true);
    $objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setSize(12);
    $objPHPExcel->getActiveSheet()->getStyle('A1:I1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
    $objPHPExcel->getActiveSheet()->getStyle('A1:I1')->getFill()->getStartColor()->setRGB('000000');
    $objPHPExcel->getActiveSheet()->getStyle('A1:I1')->getFont()->setColor(new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_WHITE));

    $objPHPExcel->getActiveSheet()->getColumnDimension('A1')->setwidth(30);
    $objPHPExcel->getActiveSheet()->freezePane('A2');

    
    $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Sl. No.')
    ->setCellValue('B1', 'Teacher Code')
    ->setCellValue('C1', 'Teacher Name')
    ->setCellValue('D1', 'Degree')
    ->setCellValue('E1', 'Description')
    ->setCellValue('F1', 'Subject Name')
    ->setCellValue('G1', 'Subshort')
    ->setCellValue('H1', 'Total')
    ->setCellValue('I1', 'Entered');
    $objPHPExcel->getActiveSheet()->getStyle('A1:I1')->applyFromArray($styleArray);
    $objPHPExcel->getActiveSheet()->getColumnDimension('1')->setAutoSize(true);
    $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(30);
    $objPHPExcel->getActiveSheet()->getStyle('A1:I1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
    $objPHPExcel->getActiveSheet()->getStyle('A1:I1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
    foreach ($result as $key => $value) {     
        $slNo = $key + 2;
        $objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(25);
        $objPHPExcel->getActiveSheet()->setCellValue('A' . $slNo, $slNo - 1)->getColumnDimension('A')->setwidth(8);
        $objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $value['fteachcode'])->getColumnDimension('B')->setwidth(15);
        $objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo, $value['fteachname'])->getColumnDimension('C')->setwidth(35);
        $objPHPExcel->getActiveSheet()->setCellValue('D' . $slNo,$value['fdegree'])->getColumnDimension('D')->setwidth(12); 
        $objPHPExcel->getActiveSheet()->setCellValue('E' . $slNo, $value['fdescpn'])->getColumnDimension('E')->setwidth(70);
        $objPHPExcel->getActiveSheet()->setCellValue('F' . $slNo, $value['fsubname'])->getColumnDimension('F')->setwidth(40);
        $objPHPExcel->getActiveSheet()->setCellValue('G' . $slNo, $value['fsubshort'])->getColumnDimension('G')->setwidth(18);
        $objPHPExcel->getActiveSheet()->setCellValue('H' . $slNo, $value['count'])->getColumnDimension('H')->setwidth(12);
        $objPHPExcel->getActiveSheet()->setCellValue('I' . $slNo, $value['entered'] )->getColumnDimension('I')->setwidth(12);
       
        $objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':'.'B'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':'.'B'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::VERTICAL_CENTER); 

        $objPHPExcel->getActiveSheet()->getStyle('D'.$slNo.':'.'D'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle('D'.$slNo.':'.'D'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::VERTICAL_CENTER); 

        $objPHPExcel->getActiveSheet()->getStyle('G'.$slNo.':'.'I'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle('G'.$slNo.':'.'I'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::VERTICAL_CENTER);

        $objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':'.'I'.$slNo)->applyFromArray($styleArray);
        }
        getheaders($objPHPExcel, $fileName);
    }
?>