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


Current Path : /proc/thread-self/root/var/www/oasis/Report_details/
Upload File :
Current File : //proc/thread-self/root/var/www/oasis/Report_details/reportAttClassCreate.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
    $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 reportAttClassCreate($aobj_context)
{
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
    $collcode = $_SESSION['collcode'];
    $teachfrom = $aobj_context->mobj_data["teachfrom"];
    $teachto = $aobj_context->mobj_data["teachto"];

    $usertype = $_SESSION['user_type'];
    $usr = $_SESSION['usr'];
	
    $cnd = '';
    
    if(strtolower($usertype) == 'user')
    {
        $cnd = "and a.fteachcode = '{$usr}'";   
    }


    $query = "select concat(a.fteachcode,' - ',m.fteachname) as fteachname, 
    a.fclassname, a.fclassid,a.fteachcode 
    from attclass a inner join masteach m on a.fteachcode = m.fteachcode
    and m.fcollcode = a.fcollcode
    where a.fcollcode = '{$collcode}'
    {$cnd}
    and a.fteachcode between '{$teachfrom}' and '{$teachto}'
    and ifnull(a.fdeleted,'') <> 'T' order by a.fteachcode";

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

    $objPHPExcel = new PHPExcel();
    
    $fileName = 'Classreport';
  
    $objPHPExcel->getProperties()->setCreator("Uniclare")
    ->setLastModifiedBy("Me")->setTitle("My Excel Sheet")
    ->setSubject("My Excel Sheet")->setDescription("Excel Sheet")
    ->setKeywords("Excel Sheet")->setCategory("Me");

    $objPHPExcel->setActiveSheetIndex(0);

    $styleArray = array(
        'borders' => array(
            'allborders' => array(
                'style' => PHPExcel_Style_Border::BORDER_THIN,
                'color' => array('argb' => '000000'),
            ),
        ),
    );

  $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('D1')->setwidth(15);
  $objPHPExcel->getActiveSheet()->freezePane('A2');
  $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Sl. No.');
  $objPHPExcel->getActiveSheet()->setCellValue('B1', 'Teacher Name')  
  ->setCellValue('C1', 'Class Name');
  
    
  $objPHPExcel->getActiveSheet()->getStyle('A1:C1')->applyFromArray($styleArray);
   $objPHPExcel->getActiveSheet()->getColumnDimension('1')->setAutoSize(true);
  $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40);
  $objPHPExcel->getActiveSheet()->getStyle('A1:C1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  $objPHPExcel->getActiveSheet()->getStyle('A1:C1')->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.63);
      $objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $value['fteachname'])->getColumnDimension('B')->setwidth(40);
      $objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo, $value['fclassname'])->getColumnDimension('C')->setwidth(40);
      $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':C'. $slNo)->applyFromArray($styleArray);
      $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':A' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
      $objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(25);
    }
    getheaders($objPHPExcel, $fileName);
}

?>