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.145.76.12
<?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);
ini_set('max_execution_time', 300);
ini_set('memory_limit', '512M');
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, 'Excel5');
$objWriter->save('php://output');
}
function roomsummarydetail($aobj_context)
{
$styleArray = array(
'borders' => array(
'allborders' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array('argb' => '000000'),
),
),
);
$objPHPExcel = new PHPExcel();
$univcode = $aobj_context->mobj_data["univcode"];
$fileName = 'Room_summary';
$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', 'Sl. No.')
->setCellValue('B1', 'Date')
->setCellValue('C1', 'Session')
->setCellValue('D1', 'Center Code')
->setCellValue('E1', 'Center Name')
->setCellValue('F1', 'Qpcode')
->setCellValue('G1', 'Room Number')
->setCellValue('H1', 'Room Name')
->setCellValue('I1', 'Room Capacity')
->setCellValue('J1', 'SRN')
->setCellValue('K1', 'Examination Type')
->setCellValue('L1', 'Remarks');
$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";
$univcode = $aobj_context->mobj_data["univcode"];
$fdatefrom = $aobj_context->mobj_data["fdatefrom"];
$fdateto = $aobj_context->mobj_data["fdateto"];
$fdeggrp = $aobj_context->mobj_data["fdeggrp"];
//#and fackdate between '{$fdatefrom}' and '{$fdateto}'
$query = "select t.fdoe as date ,t.fsession as session ,mr.fcollcode as coll,c.fcollname as name,
concat(s.FQPCODE,' - ',s.fsubname,'-',fsubshort) as qpcode,mr.froomno as room,
mr.froomname as roomname,mr.fcapacity as cap, cd.fregno as fregno,
(case when cd.forder ='1' then 'TAB' else 'PEN-PAPER' end) as typ
from canddet cd, masroom mr, subject s ,candsum cs, college c, timetable t
where cs.fcntrcode=mr.fcollcode
and mr.froomno = cd.fhallno and cd.fdegree = s.fdegree
and cd.fexamno = s.fexamno
and mr.fcollcode=cs.fcntrcode and cd.fdegree=cs.fdegree and cd.fcollcode=cs.fcollcode and cd.fregno=cs.fregno
and mr.fcollcode = c.fcollcode
and cd.fbatch = t.fbatch
and s.fqpcode = t.fqpcode
and cs.fcntrcode = c.fcollcode
and s.FSUBCODE = cd.FSUBCODE and ifnull(t.fqpcode,'') <> ''
and ifnull(cd.fpresent,'') = 'P' and ifnull(cd.fhallno,'')<>''
and cd.fdegree in(select distinct fdegree from degree where fdeggrp like '%')
and t.fdoe BETWEEN date_format(str_to_date('{$fdatefrom}','%d/%m/%Y'),'%Y-%m-%d')
and date_format(str_to_date('{$fdateto}','%d/%m/%Y'),'%Y-%m-%d')
group by t.fdoe,t.fsession,mr.fcollcode,cd.fhallno,t.fqpcode,cd.fregno
order by t.fdoe,t.fsession,mr.fcollcode,cd.fhallno, t.fqpcode, cd.fregno";
$query = "select t.fdoe as date ,t.fsession as session ,mr.fcollcode as coll,c.fcollname as name,
concat(s.FQPCODE,' - ',s.fsubname,'-',fsubshort) as qpcode,mr.froomno as room,
mr.froomname as roomname,mr.fcapacity as cap, cd.fregno as fregno,
(case when cd.forder ='1' then 'TAB' else 'PEN-PAPER' end) as typ,
if(ifnull(a.fregno,'') = '','Present',if(a.FABSTYPE = 'QpA','Absent','MP Case')) as remarks
from candsum cs inner join masroom mr on cs.fcntrcode=mr.fcollcode
inner join canddet cd on cd.fdegree=cs.fdegree
and cd.fcollcode=cs.fcollcode
and cd.fregno = cs.fregno
inner join college c on cs.fcollcode = c.fcollcode
inner join subject s on cd.fdegree = s.fdegree
and cd.fexamno = s.fexamno
and cd.fsubcode = s.fsubcode
and mr.froomno = cd.fhallno
inner join timetable t on cd.fbatch = t.fbatch
and t.fqpcode = s.fqpcode
and ifnull(t.fqpcode,'') <> ''
left join absent a on a.fregno = cs.fregno and a.fqpcode = t.fqpcode
and a.fqpcode = s.fqpcode and a.fcollcode = cs.fcntrcode
where ifnull(cd.fpresent,'') = 'P' and ifnull(cd.fhallno,'')<>''
and cd.fdegree in(select distinct fdegree from degree where fdeggrp like '%')
and t.fdoe BETWEEN date_format(str_to_date('{$fdatefrom}','%d/%m/%Y'),'%Y-%m-%d')
and date_format(str_to_date('{$fdateto}','%d/%m/%Y'),'%Y-%m-%d')
group by t.fdoe,t.fsession,mr.fcollcode,cd.fhallno,t.fqpcode,cd.fregno
order by t.fdoe,t.fsession,mr.fcollcode,cd.fhallno, t.fqpcode, cd.fregno";
$result = $aobj_context->pobj_db->GetAll($query);
// var_dump($query);
// die();
// var_dump($result);
// die();
// $query = "select a.fdegree as degree ,d.fdescpn as fdescpn,a.fregno as regno ,s.fname as name,
// a.ffreshexam as REGEXAM,
// (case when a.ffeetype='Normal Fee' then 'TAB' else 'PENPAPER' end) as feetype,
// a.fexamfeea as a,a.fexamfeeb as b,a.fexamfeec as c,a.fexamfeed as d,
// a.fexamfeee as e,a.fexamfeef as f,a.fexamfeeg as g,a.fexamfeeh as h,
// a.fexamfeei as i,a.fexamfeej as j,a.ftotalfee as total,a.appno as appno,a.fackdate as ackdate
// from appcandsum a,student s,logisys3_comexam.masuser m,degree d
// where ifnull(a.fackdate,'')<>'' and ifnull(a.fpaymentstatus,'')='success'
// and left(fackdate,10) between date_format(str_to_date('{$fdatefrom}','%d/%m/%Y'),'%Y-%m-%d')
// and date_format(str_to_date('{$fdateto}','%d/%m/%Y'),'%Y-%m-%d')
// and a.fdegree=s.fdegree and a.fregno=s.fregno and m.funivcode='{$univcode}'
// and a.fregno=m.fregno and d.fdeggrp ='{$fdeggrp}' and a.fdegree=d.fdegree and d.fexamno='A'
// order by a.fackdate,a.fdegree,a.fregno";
// var_dump($query);
// var_dump($result);
// die();
$i = 2;
$totamt = 0;
foreach ($result as $key => $value) {
$slNo = $key + 2;
$objPHPExcel->getActiveSheet()
->setCellValue('A' . $slNo, $slNo - 1);
$objPHPExcel->getActiveSheet()
->setCellValue('B' . $i, $value["date"])->getColumnDimension('B')->setwidth(15);
$objPHPExcel->getActiveSheet()
->setCellValue('C' . $i, $value["session"]);
$objPHPExcel->getActiveSheet()
->setCellValue('D' . $i, $value["coll"]);
$objPHPExcel->getActiveSheet()
->setCellValue('E' . $i, $value["name"])->getColumnDimension('E')->setwidth(50);
$objPHPExcel->getActiveSheet()
->setCellValue('F' . $i, $value["qpcode"])->getColumnDimension('F')->setwidth(50);
$objPHPExcel->getActiveSheet()
->setCellValue('G' . $i, $value["room"]);
$objPHPExcel->getActiveSheet()
->setCellValue('H' . $i, $value['roomname']);
$objPHPExcel->getActiveSheet()
->setCellValue('I' . $i, $value["cap"]);
$objPHPExcel->getActiveSheet()
->setCellValue('J' . $i, $value["fregno"]);
$objPHPExcel->getActiveSheet()
->setCellValue('K' . $i, $value["typ"]);
$objPHPExcel->getActiveSheet()
->setCellValue('L' . $i, $value["remarks"]);
// $objPHPExcel->getActiveSheet()
// ->setCellValue('M' . $i, $value["f"]);
// $objPHPExcel->getActiveSheet()
// ->setCellValue('N' . $i, $value["g"]);
// $objPHPExcel->getActiveSheet()
// ->setCellValue('O' . $i, $value['h']);
// $objPHPExcel->getActiveSheet()
// ->setCellValue('P' . $i, $value["i"]);
// $objPHPExcel->getActiveSheet()
// ->setCellValue('Q' . $i, $value["j"]);
// $objPHPExcel->getActiveSheet()
// ->setCellValue('R' . $i, $value["total"]);
// $objPHPExcel->getActiveSheet()
// ->setCellValue('S' . $i, "'".$value["appno"]);
// $objPHPExcel->getActiveSheet()
// ->setCellValue('T' . $i, $value["ackdate"]);
// $totamt=$totamt+$value["total"];
$i++;
}
$objPHPExcel->getActiveSheet()->getStyle('A1:L1')->applyFromArray($styleArray);
// $objPHPExcel->getActiveSheet()->getColumnDimension('G1')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40);
$objPHPExcel->getActiveSheet()->getStyle('A1:L1')->getAlignment()->setWrapText(true);
$objPHPExcel->getActiveSheet()->getStyle('A1:L1')->getAlignment()
->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A1:L1')->getAlignment()
->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A2' . ':L' . $i)->applyFromArray($styleArray);
$objPHPExcel->getActiveSheet()->getStyle('A2'.':L' . $i)->getAlignment()
->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A2'.':L' . $i)->getAlignment()
->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
// $objPHPExcel->getActiveSheet()->getStyle('C2'.':C' . $i)->getAlignment()
// ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
$objPHPExcel->getActiveSheet()->getStyle('E2'.':E' . $i)->getAlignment()
->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
$objPHPExcel->getActiveSheet()->getStyle('F2'.':F' . $i)->getAlignment()
->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
$objPHPExcel->getActiveSheet()
->setCellValue('R' . $i, $totamt);
getheaders($objPHPExcel, $fileName);
}
|