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.138.137.114
<?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 valuatorExcelReport($aobj_context)
{
$univcode = $aobj_context->mobj_data["univcode"];
$teachfrom = $aobj_context->mobj_data["techfrom"];
$teachto = $aobj_context->mobj_data["teachto"];
$collfrom = $aobj_context->mobj_data["collfrom"];
$collto = $aobj_context->mobj_data["collto"];
$fboard = $aobj_context->mobj_data["board"];
$type = $aobj_context->mobj_data["type"];
$college = $aobj_context->mobj_data["college"];
$tcode = $aobj_context->mobj_data["tcode"];
$user = $aobj_context->mobj_data["user"];
$college_arr = (explode(",",$college));
foreach ($college_arr as $key => $value) {
$col.= "'".$value."',";
}
$teach = (explode(",",$tcode));
foreach ($teach as $key => $value) {
$tea.= "'".$value."',";
}
$teah_arr=substr_replace($tea ,"",-1);
if($teah_arr == "'all'"){
$tcnd = " m.fteachcode BETWEEN '000' and 'zzz' ";
}else{
$tcnd = " m.fteachcode in ({$teah_arr}) ";
}
$col_ar=substr_replace($col ,"",-1);
if($col_ar == "'all'"){
$collcond = "";
}else{
$collcond = "and m.fcollcode IN ($col_ar)";
}
if($fboard == 'All'){
$cnd4 = "";
}else{
$cnd4 = "AND m.fboard = '{$fboard}'";
}
$user = json_decode($user,true);
if($user['fcurtype'] == '400')
{
$cnd = "and ms.fboard = '{$user['fdegree']}'";
$cnd3 = "and s.fboard = '{$user['fdegree']}'";
}else
{
$cnd = "";
$cnd3 = "";
}
$cnd2="";
if($type == 'All')
{
$cnd2 = "";
}else if($type == 'nval')
{
$cnd2 = "and ifnull(v.fvalcode,'') = ''";
}else if($type == 'val')
{
$cnd2 = "and ifnull(v.fvalcode,'') <> ''";
}
$query1 = "SELECT m.fcollcode, m.fboard,mb.fboardname, m.fteachcode, m.fteachname,m.fgender,m.fscale,m.fmobile,m.femail, CONCAT(c.fcollname,', ', c.ftown) AS fcollname,
IF(IFNULL(v.fvalcode,'') = '','F','T') AS fvalstatus
FROM masteach m INNER JOIN college c ON m.fcollcode = c.fcollcode
LEFT JOIN teachsub ts ON ts.fteachcode = m.fteachcode
LEFT JOIN masqp s ON ts.fqpcode = s.fqpcode
INNER JOIN masboard mb ON mb.fboardcode = m.fboard
LEFT JOIN
(SELECT DISTINCT m.fvalcode FROM mastabu m
INNER JOIN masqp ms ON m.fqpcode = ms.fqpcode {$cnd}
UNION
SELECT DISTINCT m.frevcode FROM mastabu m
INNER JOIN masqp ms ON m.fqpcode = ms.fqpcode {$cnd}
) v ON v.fvalcode = m.fteachcode
WHERE
$tcnd $collcond
{$cnd2} {$cnd3}
{$cnd4}
GROUP BY m.fteachcode
ORDER BY m.fteachname, m.fscale";
$result = $aobj_context->pobj_db->GetAll($query1);
$objPHPExcel = new PHPExcel();
$fileName = 'valuatorReport';
$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', 'College Code')
->setCellValue('C1', 'College Name')
->setCellValue('D1', 'Board')
->setCellValue('E1', 'Board Name')
->setCellValue('F1', 'Teacher Code')
->setCellValue('G1', 'Teacher Name')
->setCellValue('H1', 'Gender')
->setCellValue('I1', 'Scale')
->setCellValue('J1', 'Contact No.')
->setCellValue('K1', 'Email ID');
$objPHPExcel->getActiveSheet()->getStyle('A1:K1')->applyFromArray($styleArray);
$objPHPExcel->getActiveSheet()->getColumnDimension('1')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40);
$objPHPExcel->getActiveSheet()->getStyle('A1:K1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A1:K1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
foreach ($result as $key => $value) {
$slNo = $key + 2;
$objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(25);
$objPHPExcel->getActiveSheet()->setCellValue('A' . $slNo, $slNo - 1)->getColumnDimension('A')->setwidth(6.63);
$objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $value['fcollcode'])->getColumnDimension('B')->setwidth(13);
$objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo, $value['fcollname'])->getColumnDimension('C')->setwidth(50);
$objPHPExcel->getActiveSheet()->setCellValue('D' . $slNo, $value['fboard'])->getColumnDimension('D')->setwidth(10);
$objPHPExcel->getActiveSheet()->setCellValue('E' . $slNo, $value['fboardname'])->getColumnDimension('E')->setwidth(25);
$objPHPExcel->getActiveSheet()->setCellValue('F' . $slNo, $value['fteachcode'])->getColumnDimension('F')->setwidth(13);
$objPHPExcel->getActiveSheet()->setCellValue('G' . $slNo, $value['fteachname'])->getColumnDimension('G')->setwidth(25);
$objPHPExcel->getActiveSheet()->setCellValue('H' . $slNo, $value['fgender'])->getColumnDimension('H')->setwidth(10);
$objPHPExcel->getActiveSheet()->setCellValue('I' . $slNo, $value['fscale'])->getColumnDimension('I')->setwidth(10);
$objPHPExcel->getActiveSheet()->setCellValue('J' . $slNo, $value['fmobile'])->getColumnDimension('J')->setwidth(13);
$objPHPExcel->getActiveSheet()->setCellValue('K' . $slNo, $value['femail'])->getColumnDimension('K')->setwidth(30);
$objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':K'. $slNo)->applyFromArray($styleArray);
$objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':B' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('D' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('F' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('H' . $slNo . ':J' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
}
getheaders($objPHPExcel, $fileName);
}
?>
|