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


Current Path : /var/www/html/univadmin/Reports/
Upload File :
Current File : /var/www/html/univadmin/Reports/teach_report.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');
// 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 . '.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 teacher_report($aobj_context)
{
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

    $univcode = $aobj_context->mobj_data["univcode"];
    $fileName = "Teacher Report";
    $collDet = $aobj_context->mobj_data["coll"];
    $boardDet = $aobj_context->mobj_data["board"];
    $teachDet = $aobj_context->mobj_data["teachcode"];
    $fcurcollcode = $aobj_context->mobj_data["fcurcollcode"];
    $fcurtype = $aobj_context->mobj_data["fcurtype"];

    $colldet_arr= (explode(",",$collDet));
    $boarddet_arr= (explode(",",$boardDet));
    $teachdet_arr= (explode(",",$teachDet));

    
    foreach($colldet_arr as $key => $val){ 
        $coll .= "'".$val."',";
    }
    
    $coll_arr = substr_replace($coll ,"",-1);

    if($fcurtype !== '500' && $fcurtype !== '501'){
        if($coll_arr === "'All'"){
            $con = "c.fcollcode <> ''";
        }else{
          $con = "c.fcollcode in ($coll_arr)";
        }
    }else{
        $con = "c.fcollcode = '$fcurcollcode'";
    }
    

    foreach($boarddet_arr as $key => $val){
        $board .= "'".$val."',";
    }

    $board_arr = substr_replace($board ,"",-1);

    if($board_arr === "'All'"){
        $con1 = "";
    }else{
      $con1 = "and m.fboard in ($board_arr)";
    }

    foreach($teachdet_arr as $key => $val){
        $teach .= "'".$val."',";
    }

    $teach_arr = substr_replace($teach ,"",-1);

    if($teach_arr === "'All'"){
        $con2 = "and m.fteachcode <> ''";
    }else{
      $con2 = "and m.fteachcode in ($teach_arr)";
    }

    $query = "select distinct ifnull(m.fteachcode, '') as fteachcode ,
    ifnull(m.fteachname, '')as fteachname, ifnull(fqual, '') as fqual, 
    ifnull(fscale, '')as fscale, ifnull(fmobile, '')as fmobile, 
    ifnull(femail, '') as femail, ifnull(fgender, '') as fgender, 
    ifnull(fdob, '') as fdob
    from masteach m 
    inner join colldeg c on m.fcollcode = c.fcollcode
    where $con
    $con1
    $con2";
    
    // var_dump($query);die();
    $result = $aobj_context->pobj_db->GetAll($query);

    $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'),
            ),
        ),
    );
    if($univcode == "021"){

        $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.')
            ->setCellValue('B1', 'Teach Code')
            ->setCellValue('C1', 'Teacher Name')
            ->setCellValue('D1', 'Date Of Birth')
            ->setCellValue('E1', 'Gender')
            ->setCellValue('F1', 'Email')
            ->setCellValue('G1', 'Mobile No');
        
        $objPHPExcel->getActiveSheet()->getStyle('A1:G1')->applyFromArray($styleArray);
            
        $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(29);
        $objPHPExcel->getActiveSheet()->getStyle('A1:G1')->getAlignment()->setWrapText(true);
        $objPHPExcel->getActiveSheet()->getStyle('A1:G1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle('A1:G1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
    
        foreach ($result as $key => $value) {
        $slNo = $key + 2;
        
        $objPHPExcel->getActiveSheet()->setCellValue('A' . $slNo, $slNo - 1)->getColumnDimension('A')->setwidth(6.5);
        $objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $value['fteachcode'])->getColumnDimension('B')->setwidth(15);
        $objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo, $value['fteachname'])->getColumnDimension('C')->setwidth(30);
        $objPHPExcel->getActiveSheet()->setCellValue('D' . $slNo, $value['fdob'])->getColumnDimension('D')->setwidth(15);
        $objPHPExcel->getActiveSheet()->setCellValue('E' . $slNo, $value['fgender'])->getColumnDimension('E')->setwidth(10);
        $objPHPExcel->getActiveSheet()->setCellValue('F' . $slNo, $value['femail'])->getColumnDimension('F')->setwidth(30);
        $objPHPExcel->getActiveSheet()->setCellValue('G' . $slNo, $value['fmobile'])->getColumnDimension('G')->setwidth(20);
        
        $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':G'. $slNo)->applyFromArray($styleArray);
        $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo.':B'. $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle('E' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle('G' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        
            }
    }else{
        $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.')
            ->setCellValue('B1', 'Teach Code')
            ->setCellValue('C1', 'Teacher Name')
            ->setCellValue('D1', 'Date Of Birth')
            ->setCellValue('E1', 'Gender')
            ->setCellValue('F1', 'Qualification')
            ->setCellValue('G1', 'Scale')
            ->setCellValue('H1', 'Email')
            ->setCellValue('I1', 'Mobile No');
        
        $objPHPExcel->getActiveSheet()->getStyle('A1:I1')->applyFromArray($styleArray);
            
        $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(29);
        $objPHPExcel->getActiveSheet()->getStyle('A1:I1')->getAlignment()->setWrapText(true);
        $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()->setCellValue('A' . $slNo, $slNo - 1)->getColumnDimension('A')->setwidth(6.5);
        $objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $value['fteachcode'])->getColumnDimension('B')->setwidth(15);
        $objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo, $value['fteachname'])->getColumnDimension('C')->setwidth(30);
        $objPHPExcel->getActiveSheet()->setCellValue('D' . $slNo, $value['fdob'])->getColumnDimension('D')->setwidth(15);
        $objPHPExcel->getActiveSheet()->setCellValue('E' . $slNo, $value['fgender'])->getColumnDimension('E')->setwidth(10);
        $objPHPExcel->getActiveSheet()->setCellValue('F' . $slNo, $value['fqual'])->getColumnDimension('F')->setwidth(20);
        $objPHPExcel->getActiveSheet()->setCellValue('G' . $slNo, $value['fscale'])->getColumnDimension('G')->setwidth(13);
        $objPHPExcel->getActiveSheet()->setCellValue('H' . $slNo, $value['femail'])->getColumnDimension('H')->setwidth(30);
        $objPHPExcel->getActiveSheet()->setCellValue('I' . $slNo, $value['fmobile'])->getColumnDimension('I')->setwidth(20);
        
        $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':G'. $slNo)->applyFromArray($styleArray);
        $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo.':B'. $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle('E' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle('G' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        
            }
    }
    $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->pobj_db->GetRow($get_coll_name);


    $aobj_context->FUNIVNAME = $lobj_get_coll_name['FUNIVNAME'];
    $aobj_context->s_state = $lobj_get_coll_name['state'];
    $aobj_context->pdf_logo_path = $lobj_get_coll_name['pdf_logo_path'];
    $aobj_context->FUNIVCODE = $lobj_get_coll_name['FUNIVCODE'];    
// die();

// $objPHPExcel->getActiveSheet()->getHeaderFooter()->addImage($aobj_context->main_src.'img/'.$aobj_context->FUNIVCODE.'_logo.jpg', PHPExcel_Worksheet_HeaderFooter::IMAGE_HEADER_LEFT);
    $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&H&"-,Bold"&16' . $aobj_context->FUNIVNAME . "\n" . '&12');
    $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&H'.$colteach);

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

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