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


Current Path : /proc/thread-self/root/var/www/html/univadmin_bkp/univadmin/Reports/
Upload File :
Current File : //proc/thread-self/root/var/www/html/univadmin_bkp/univadmin/Reports/examCntrDetQPCSV.php

<?php
ini_set('max_execution_time', 300);
$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');
// 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
    $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 . '.csv"');
    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, 'CSV');
    $objWriter->save('php://output');
}


function examCntrDetQPCSV($aobj_context)
{

    $objPHPExcel = new PHPExcel();
    $univcode=$aobj_context->mobj_data["univcode"];
    $fileName = 'examCntrDetQPCSV'.$univcode;
    $objPHPExcel->getProperties()->setCreator("Me")
    ->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);

    $objPHPExcel->getActiveSheet()->setTitle($fileName);
    $objPHPExcel->getActiveSheet()->getPageSetup()
    ->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);

    $alpha = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 
                'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC',
                'AD', 'AF', 'AE', 'AF', 'AG', 'AH'
            ];

    $objPHPExcel->getActiveSheet()
        ->setCellValue('A1', "fqpcode");
    $objPHPExcel->getActiveSheet()
        ->setCellValue('B1', "fsubname");
    $objPHPExcel->getActiveSheet()
        ->setCellValue('C1', "fdoe");
    $objPHPExcel->getActiveSheet()
        ->setCellValue('D1', "Fee Paid Count");
    $objPHPExcel->getActiveSheet()
        ->setCellValue('E1', "Absent Count");
    $objPHPExcel->getActiveSheet()
        ->setCellValue('F1', "Mal-Practice Count");
    $objPHPExcel->getActiveSheet()
        ->setCellValue('G1', "Total Present Count");

    $qprngfrom = $aobj_context->mobj_data["qpfrm"];
    $qprngto = $aobj_context->mobj_data["qpto"];
    $fdeggrp = $aobj_context->mobj_data["deggrp"];
   

    $query = "SELECT s.fqpcode, fsubname,s.fdoe,
    pcount AS tcount, IFNULL(abcount,0) AS abcount,
    IFNULL(mpcount,0) AS mpcount, (pcount-IFNULL(abcount,0)-IFNULL(mpcount,0)) AS prcount FROM
    (SELECT a.fqpcode,a.fdoe, a.fsubname, COUNT(a.fregno) AS pcount FROM
    (SELECT s.fqpcode, s.fsubname,date_format(s.fdoe, '%d/%m/%Y') as fdoe, cd.fregno
    FROM canddet cd INNER JOIN candsum cs ON cd.fregno = cs.fregno
    AND cd.fdegree = cs.fdegree AND cd.fcollcode = cs.fcollcode
    INNER JOIN subject s ON s.fdegree = cd.fdegree AND s.fexamno = cd.fexamno
    AND s.fsubcode = cd.fsubcode AND IFNULL(s.ftheory, '') = 'T' AND IFNULL(s.fintass,'') = 'F'
    WHERE IFNULL(fpresent,'') = 'P' AND IFNULL(fpassmth,'') = ''  and ifnull(s.fdoe,'0000-00-00') <> '0000-00-00'
    AND s.fqpcode BETWEEN '0' AND 'Z'
    and cd.fdegree in (select distinct fdegree from degree where fdeggrp = 'UG')) a
    GROUP BY a.fqpcode) s 
    LEFT JOIN
    (SELECT a.fcollcode, a.fqpcode, SUM(IF(fabstype = 'QpA', 1, 0))AS abcount, SUM(IF(fabstype = 'QpM', 1, 0))AS mpcount
    FROM absent a
    WHERE a.fregno <> 'nil' AND a.fregno <> '0'
    AND fsession ='AM' AND fcollcode <> ''
    AND a.fqpcode BETWEEN '0' AND 'Z'
    GROUP BY fqpcode) t
    on  s.fqpcode = t.fqpcode
    ORDER BY s.fqpcode";
    
    $result = $aobj_context->pobj_db->GetAll($query);
    
    $i = 2;
    foreach ($result as $key => $value) {

        $objPHPExcel->getActiveSheet()
            ->setCellValue('A'.$i, $value['fqpcode']);
        $objPHPExcel->getActiveSheet()
            ->setCellValue('B'.$i, $value["fsubname"]);
        $objPHPExcel->getActiveSheet()
            ->setCellValue('C'.$i, $value["fdoe"]);
        $objPHPExcel->getActiveSheet()
            ->setCellValue('D'.$i, $value["tcount"]);
        $objPHPExcel->getActiveSheet()
            ->setCellValue('E'.$i, $value["abcount"]);
        $objPHPExcel->getActiveSheet()
            ->setCellValue('F'.$i, $value["mpcount"]);
        $objPHPExcel->getActiveSheet()
            ->setCellValue('G'.$i, $value["prcount"]);
        $i++;
    }

    getheaders($objPHPExcel, $fileName);
}