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.119.50
<?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, 'CSV');
$objWriter->save('php://output');
}
function feepaiddet($aobj_context)
{
$objPHPExcel = new PHPExcel();
$univcode = $aobj_context->mobj_data["univcode"];
$fileName = 'Fee_collected_details';
$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', 'Student Count')
->setCellValue('K1', 'Tab Count')
->setCellValue('L1', 'Paper Count');
$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 s.fdoe as date ,s.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,
COUNT(cd.fhallno) as fcount,
sum(if(ifnull(cd.forder,'2') = '1',1,0)) as tabcnt,
sum(if(ifnull(cd.forder,'2') = '1',0,1)) as pencnt
from canddet cd, masroom mr, subject s ,candsum cs, college c
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 cs.fcntrcode = c.fcollcode
and s.FSUBCODE = cd.FSUBCODE and ifnull(fqpcode,'') <> ''
and ifnull(cd.fpresent,'') = 'P'
and cd.fdegree in(select distinct fdegree from degree where fdeggrp ='{$fdeggrp}')
and s.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 s.fdoe,s.fsession,mr.fcollcode,cd.fhallno,s.fqpcode order by cd.fhallno, s.fqpcode";
$result = $aobj_context->pobj_db->GetAll($query);
// $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"]);
$objPHPExcel->getActiveSheet()
->setCellValue('C' . $i, $value["session"]);
$objPHPExcel->getActiveSheet()
->setCellValue('D' . $i, $value["coll"]);
$objPHPExcel->getActiveSheet()
->setCellValue('E' . $i, $value["name"]);
$objPHPExcel->getActiveSheet()
->setCellValue('F' . $i, $value["qpcode"]);
$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["fcount"]);
$objPHPExcel->getActiveSheet()
->setCellValue('K' . $i, $value["tabcnt"]);
$objPHPExcel->getActiveSheet()
->setCellValue('L' . $i, $value["pencnt"]);
// $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()
->setCellValue('R' . $i, $totamt);
getheaders($objPHPExcel, $fileName);
}
|