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


Current Path : /var/www/html/univadmin/Reports/
Upload File :
Current File : /var/www/html/univadmin/Reports/QpSummaryReport.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="QP_Summary.xls"');
    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 getQpSummaryReport($aobj_context)
{
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
    $univcode = $aobj_context->mobj_data['univcode'];
    $exam = $aobj_context->mobj_data['exam'];
    $board = $aobj_context->mobj_data['board'];
    $qpcode = $aobj_context->mobj_data['qpcode'];
    $degree = $aobj_context->mobj_data['degree'];
    $sem = $aobj_context->mobj_data['sem'];
    $teachStatus = $aobj_context->mobj_data['teachStatus'];
    $modStatus = $aobj_context->mobj_data['modStatus'];

    $split = explode("*", $exam);
    $deggrp = $split[0];
    $splitYearAndMode = explode("-", $split[1]);
    $year = $splitYearAndMode[0];
    $type = $splitYearAndMode[1];

    if($board === "All"){
        $boardCond = " ";
    }else{
        $boardCond = "and q.fboard='{$board}'";
    }

    if($qpcode === "All"){
        $qpCond = " ";
    }else{
        $qpcond = "and qd.fqpcode='{$qpcode}'";
    }

    $degreeArr = explode(",", $degree);
    foreach($degreeArr as $key => $val){
        if($val != 'All'){
            $fdegree .= "'".$val."',";
        }
    }
    $degArray = substr_replace($fdegree ,"",-1);

    if($degree === "All"){
        $degCond = " ";
    }else{
        $degCond = "and d.fdegree in ({$degArray})";
    }

    if($sem === "All"){
        $semCond = " ";
    }else{
        $semCond = "and d.fexamno = '{$sem}'";
    }

    if($teachStatus === "uploaded"){
        $teachUpdCond = "and ifnull(qd.fqpfilepath, '') <> ''  
                            and ifnull(fanskeypath, '') <> '' ";
    }else if($teachStatus === "not_uploaded"){
        $teachUpdCond = "and ifnull(qd.fqpfilepath, '') = ''  
                            and ifnull(fanskeypath, '') = ''";
    }else{
        $teachUpdCond = " ";
    }

    if($modStatus === "uploaded"){
        $modstatusCond = "and ifnull(qd.fmodqppath, '') <> ''";
    }else if($modStatus === "not_uploaded"){
        $modstatusCond = "and ifnull(qd.fmodqppath, '') = ''";
    }else{
        $modstatusCond = " ";
    }

    $query = "select group_concat(d.fdegree SEPARATOR ', ') as fdegree,
            group_concat(d.fdescpn SEPARATOR ', ') as fdescpn,
            s.fexamno,
            q.fqpcode,concat(s.fsubname,' - ',s.FSUBSHORT) as fsubname, q.fnoqp,
            group_concat(distinct concat('Set: ',fset,' - ',if(ifnull(fqpfilepath,'') = '','Not Uploaded','Uploaded')) separator ', ')as fstatus,
            group_concat(distinct concat('Set: ',fset,' - ',if(ifnull(fmodqppath,'') = '','Not Uploaded','Uploaded')) separator ', ')as fmodstatus,
            q.fteachcode, m.fteachname, 
            group_concat(distinct concat('Set: ',fset,' - ',if(ifnull(qd.fstatus,'') = '','',qd.fstatus)) separator ', ')as status,
            ifnull(q.fappointdate,'') as fappointdate
            from qpseter q inner join qpseterdet qd on q.fqpcode = qd.fqpcode
            and qd.fteachcode = q.fteachcode
            inner join subject s on q.fqpcode = s.fqpcode
            inner join degree d on s.fdegree = d.fdegree and s.fexamno = d.fexamno
            inner join masteach m on q.fteachcode = m.fteachcode
            WHERE ifnull(q.fappointed,'') = 'T' and d.fdeggrp = '{$deggrp}'
            and qd.fyear='{$year}' and qd.fexamtype='{$type}' {$boardCond} {$qpcond} 
            {$degCond} {$semCond} {$teachUpdCond} {$modstatusCond}
            group by q.fqpcode,q.fteachcode
            order by q.fqpcode,q.fteachcode;";

    $result = $aobj_context->pobj_db->GetAll($query);

    $objPHPExcel = new PHPExcel();
    $fileName = 'QP_Summary';
    $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'),
            ),
        ),
    );

    $count = "";

    $alpha = ['A', 'B', 'C', 'D', 'E', 'F', 'G'];
    if($univcode == '051'){
        $j=4;
        $objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setBold(true);
        $objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setSize(12);
        $objPHPExcel->getActiveSheet()->getColumnDimension('A1')->setwidth(30);
        $objPHPExcel->getActiveSheet()->getColumnDimension('J1')->setwidth(50);
        $objPHPExcel->getActiveSheet()->freezePane('A2');

        
        $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Sl. No.')
        ->setCellValue('B1', 'QP Code')
        ->setCellValue('C1', 'Subject Name')
        ->setCellValue('D1', 'Teaher Code')
        ->setCellValue('E1', 'Teacher Name')
        ->setCellValue('F1', 'Status')
        ->setCellValue('G1', 'QP SET')
        ->setCellValue('H1', 'QP Upload Status')
        ->setCellValue('I1', 'Moderator Status');
        $objPHPExcel->getActiveSheet()->getStyle('A1:I1')->applyFromArray($styleArray);
        $objPHPExcel->getActiveSheet()->getColumnDimension('1')->setAutoSize(true);
        $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40);
        $objPHPExcel->getActiveSheet()->getStyle('A1:I1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle('A1:I1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
        
        $count=rtrim($count,", ");
        
        foreach ($result as $key => $value) {  
        
            $slNo = $key + 2;
            $j=4;
            $objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(30);
            $objPHPExcel->getActiveSheet()->setCellValue('A' . $slNo, $slNo - 1)->getColumnDimension('A')->setwidth(8);
            $objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $value['fqpcode'])->getColumnDimension('B')->setwidth(12);
            $objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo,$value['fsubname'])->getColumnDimension('C')->setwidth(35); 
            $objPHPExcel->getActiveSheet()->setCellValue('D' . $slNo, $value['fteachcode'] )->getColumnDimension('D')->setwidth(15);
            $objPHPExcel->getActiveSheet()->setCellValue('E' . $slNo, $value['fteachname'] )->getColumnDimension('E')->setwidth(30);
            $objPHPExcel->getActiveSheet()->setCellValue('F' . $slNo, $value['status'])->getColumnDimension('F')->setwidth(45);
            $objPHPExcel->getActiveSheet()->setCellValue('G' . $slNo, $value['fnoqp'] )->getColumnDimension('G')->setwidth(8);
            $objPHPExcel->getActiveSheet()->setCellValue('H' . $slNo, $value['fstatus'] )->getColumnDimension('H')->setwidth(45);
            $objPHPExcel->getActiveSheet()->setCellValue('I' . $slNo,$value['fmodstatus'])->getColumnDimension('I')->setwidth(45);

            $objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':'.'I'.$slNo)->applyFromArray($styleArray);
            $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.':'.'C'.$slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
            $objPHPExcel->getActiveSheet()->getStyle('E'.$slNo.':'.'E'.$slNo)->getAlignment()->setVertical(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()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);

            $objPHPExcel->getActiveSheet()->getStyle('F'.$slNo.':'.'I'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); 
            $objPHPExcel->getActiveSheet()->getStyle('F'.$slNo.':'.'I'.$slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
            
        }
    }else{

        $j=4;
        $objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setBold(true);
        $objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setSize(12);
        $objPHPExcel->getActiveSheet()->getColumnDimension('A1')->setwidth(30);
        $objPHPExcel->getActiveSheet()->getColumnDimension('J1')->setwidth(50);
        $objPHPExcel->getActiveSheet()->freezePane('A2');

        
        $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Sl. No.')
        ->setCellValue('B1', 'Degree Code')
        ->setCellValue('C1', 'Degree Name')
        ->setCellValue('D1', 'Sem')
        ->setCellValue('E1', 'QP Code')
        ->setCellValue('F1', 'Subject Name')
        ->setCellValue('G1', 'Teaher Code')
        ->setCellValue('H1', 'Teacher Name')
        ->setCellValue('I1', 'Status')
        ->setCellValue('J1', 'QP SET')
        ->setCellValue('K1', 'QP Upload Status')
        ->setCellValue('L1', 'Moderator Status')
        ->setCellValue('M1', 'Appointed Date');
        $objPHPExcel->getActiveSheet()->getStyle('A1:M1')->applyFromArray($styleArray);
        $objPHPExcel->getActiveSheet()->getColumnDimension('1')->setAutoSize(true);
        $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40);
        $objPHPExcel->getActiveSheet()->getStyle('A1:M1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle('A1:M1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
        
        $count=rtrim($count,", ");
    
        foreach ($result as $key => $value) {  
        
            $slNo = $key + 2;
            $j=4;
            $objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(30);
            $objPHPExcel->getActiveSheet()->setCellValue('A' . $slNo, $slNo - 1)->getColumnDimension('A')->setwidth(8);
            $objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $value['fdegree'])->getColumnDimension('B')->setwidth(12);

            $objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo, $value['fdescpn'])->getColumnDimension('B')->setwidth(30);
            $objPHPExcel->getActiveSheet()->setCellValue('D' . $slNo, $value['fexamno'])->getColumnDimension('B')->setwidth(12);
            $objPHPExcel->getActiveSheet()->setCellValue('E' . $slNo, $value['fqpcode'])->getColumnDimension('B')->setwidth(12);
            
            $objPHPExcel->getActiveSheet()->setCellValue('F' . $slNo,$value['fsubname'])->getColumnDimension('C')->setwidth(35); 
            $objPHPExcel->getActiveSheet()->setCellValue('G' . $slNo, $value['fteachcode'] )->getColumnDimension('D')->setwidth(15);
            $objPHPExcel->getActiveSheet()->setCellValue('H' . $slNo, $value['fteachname'] )->getColumnDimension('E')->setwidth(30);
            $objPHPExcel->getActiveSheet()->setCellValue('I' . $slNo, $value['status'])->getColumnDimension('F')->setwidth(45);
            $objPHPExcel->getActiveSheet()->setCellValue('J' . $slNo, $value['fnoqp'] )->getColumnDimension('G')->setwidth(8);
            $objPHPExcel->getActiveSheet()->setCellValue('K' . $slNo, $value['fstatus'] )->getColumnDimension('H')->setwidth(45);
            $objPHPExcel->getActiveSheet()->setCellValue('L' . $slNo,$value['fmodstatus'])->getColumnDimension('I')->setwidth(45);
            $objPHPExcel->getActiveSheet()->setCellValue('M' . $slNo, $value['fappointdate'] )->getColumnDimension('J')->setwidth(30);

            $objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':'.'M'.$slNo)->applyFromArray($styleArray);
            //$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.':'.'C'.$slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
            $objPHPExcel->getActiveSheet()->getStyle('E'.$slNo.':'.'E'.$slNo)->getAlignment()->setVertical(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()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);

            $objPHPExcel->getActiveSheet()->getStyle('F'.$slNo.':'.'J'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); 
            $objPHPExcel->getActiveSheet()->getStyle('F'.$slNo.':'.'J'.$slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
            
        }
    }

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