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


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/teachCsv.php

<?php
ini_set('max_execution_time', 60);
$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 masteach($aobj_context)
{

    $objPHPExcel = new PHPExcel();
    $univcode=$aobj_context->mobj_data["univcode"];
    $fileName = 'MASTEACH'.$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', "Board");
    $objPHPExcel->getActiveSheet()
        ->setCellValue('B1', "College Code");
    $objPHPExcel->getActiveSheet()
        ->setCellValue('C1', "College Name");
    $objPHPExcel->getActiveSheet()
        ->setCellValue('D1', "Teach. Code");
    $objPHPExcel->getActiveSheet()
    ->setCellValue('E1', "Teach. Name");
    $objPHPExcel->getActiveSheet()
    ->setCellValue('F1', "Teach. Email");
    $objPHPExcel->getActiveSheet()
    ->setCellValue('G1', "Teach. Mobile");

    $j = 3;
    $slNo = 1;
    $sum = array();

//    $query = "select mt.fteachcode, fteachname, mt.fmobile, ifnull(fboardcode,'xxx') as fboard1
//		 from masteach mt left join teachsub ts on mt.fteachcode = ts.fteachcode
//		left join masqp mq on ts.fqpcode = mq.fqpcode left join
//		 masboard mb on mq.fboard = mb.fboardcode
//		where mt.fcollcode between '0000' and 'zzzz'
//		and ifnull(fboardcode,'000000') between '0000' and 'zzzz'
//		group by fteachcode
//        order by mt.fcollcode, fboardcode, fteachcode";
    $query = "select  ms.fboard,m.fcollcode,concat(c.fcollname,', ',c.ftown) as college_name,m.fteachcode,m.`FTEACHNAME`,m.femail,m.fmobile
     from masteach m inner join teachsub ts on m.fteachcode = ts.fteachcode
    inner join masqp ms on ts.fqpcode = ms.fqpcode
    inner join college c on m.fcollcode = c.fcollcode
    group by m.fteachcode
    order by ms.fboard,m.fcollcode,m.FTEACHNAME";
    $result = $aobj_context->pobj_db->GetAll($query);
    
    $i = 2;
    foreach ($result as $key => $value) {

        $objPHPExcel->getActiveSheet()
            ->setCellValue('A'.$i, $value['fboard']);
        $objPHPExcel->getActiveSheet()
            ->setCellValue('B'.$i, $value["fcollcode"]);
        $objPHPExcel->getActiveSheet()
            ->setCellValue('C'.$i, $value["college_name"]);
        $objPHPExcel->getActiveSheet()
            ->setCellValue('D'.$i, $value["fteachcode"]);
        $objPHPExcel->getActiveSheet()
        ->setCellValue('E'.$i, $value["FTEACHNAME"]);
        $objPHPExcel->getActiveSheet()
        ->setCellValue('F'.$i, $value["femail"]);
        $objPHPExcel->getActiveSheet()
        ->setCellValue('G'.$i, $value["fmobile"]);
        $i++;
    }

    getheaders($objPHPExcel, $fileName);
}