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.147.6.122
<?php
ini_set('max_execution_time', 300);
$main_src=substr($_SERVER['SCRIPT_FILENAME'],0,strlen($_SERVER['SCRIPT_FILENAME'])-7);
//$pdf_writer_class =$main_src."/tarka_pdf/fpdf.php";
$pdf_writer_class =$main_src."/tcpdf/tcpdf.php";
require_once($pdf_writer_class);
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 */
require_once ($pdf_writer_class =$main_src.'/PHPExcel/Classes/PHPExcel.php');
class MYPDF extends TCPDF {
public $aobj_context;
public function setData($aobj_context,$Deggrp,$reportType){
$this->aobj_context = $aobj_context;
$this->Deggrp = $Deggrp;
$this->reportType = $reportType;
$this->univcode = $this->aobj_context->mobj_data["univcode"];
}
public function Header(){
// get the current page break margin
$bMargin = $this->getBreakMargin();
// get current auto-page-break mode
$auto_page_break = $this->AutoPageBreak;
// disable auto-page-break
$this->SetAutoPageBreak(false, 0);
// set bacground image
$this->SetFillColor(248, 248 ,255);
$img_path = $this->aobj_context->main_src."/img/{$this->univcode}_logo.jpg";
if(file_exists($img_path))
$this->Image($img_path,30,6,20,20);
$this->SetFont('Times','B',13);
$this->SetY(5);
$this->Cell(0,4,$this->aobj_context->FUNIVNAME,0,1,'C');
$this->SetFont('Times','',11);
$this->Cell(0,4,$this->aobj_context->s_state,0,1,'C');
$this->SetFont('Times','BU',12);
$this->Ln(1);
$cur_year = date("Y");
$this->Cell(0,5,'QP Indent - '.$this->reportType,'0',1,'C');
$this->SetFont('Times','',12);
$this->Cell(0,6," Degree Group: ".$this->Deggrp,"0",1,"C");
// restore auto-page-break status
$this->SetAutoPageBreak($auto_page_break, $bMargin);
// set the starting point for the page content
}
public function Footer()
{
$this->SetXY(15,-15);
$this->SetFont('helvetica', 'I', 8);
$this->Cell(60, 10,'IP : '.$_SERVER["REMOTE_ADDR"], 0, 0, 'L');
$this->Cell(70, 10,'Date : '.date("d/m/Y H:i:s"), 0, 0, 'C');
$this->Cell(60, 10,'Page ' .$this->getPageNumGroupAlias().'/'.$this->getPageGroupAlias(), 0, 1, 'R');
}
}
class QPIndentReport {
function DefaultConstructor($aobj_context,$Deggrp,$reportType)
{
$this->aobj_context=$aobj_context;
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$this->ip=$_SERVER["REMOTE_ADDR"];
$get_date="select DATE_FORMAT(now(), '%d/%m/%Y') as now_date";
$obj=$this->aobj_context->mobj_db->GetRow($get_date);
$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=$this->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'];
$this->Degree= $Deggrp;
// var_dump($this->Deggrp);
$this->current_date = $obj['now_date'];
$this->pdf= new MYPDF('L');
$this->pdf->setData($aobj_context,$Deggrp,$reportType);
}
function tableHeader($pdf)
{
$pdf->SetFont('Times','B',10);
$pdf->Cell(8,6,"Sl.","LRT",0, "C");
$pdf->Cell(12,6,"QP","LRT",0,"C");
$pdf->Cell(65,6,"Subject Name","LRT",0,"C");
$pdf->Cell(18,6,"Date","LRT",0,"C");
$pdf->Cell(15,6,"Session","LRT",0,"C");
$pdf->Cell(12,6,"QP","LRT",0,"C");
$pdf->Cell(65,6,"Degree","LRT",1,"C");
$pdf->Cell(8,6,"No","LRB",0,"C");
$pdf->Cell(12,6,"Code","LBR",0,"C");
$pdf->Cell(65,6,"","LBR",0,"C");
$pdf->Cell(18,6,"","LBR",0,"C");
$pdf->Cell(15,6,"","LBR",0,"C");
$pdf->Cell(12,6,"Indent","LBR",0,"C");
$pdf->Cell(65,6,"","LBR",1,"C");
$pdf->SetFont('Times','',10);
}
function headerQPWise($pdf){
$pdf->SetFont('Times','B',10);
$pdf->Cell(30,6,"",0,0);
$pdf->Cell(8,6,"Sl.","LRT",0, 'C');
$pdf->Cell(15,6,"Center","LRT",0,"C");
$pdf->Cell(110,6,"Center Name","LRT",0,"C");
$pdf->Cell(15,6,"Total","LRT",1,"C");
$pdf->Cell(30,6,"",0,0);
$pdf->Cell(8,6,"No.","LRB",0,"C");
$pdf->Cell(15,6,"Code","LRB",0,"C"); //w h txt brd pos align
$pdf->Cell(110,6,"","LBR",0,"C");
$pdf->Cell(15,6,"Count","LBR",1,"C");
$pdf->SetFont('Times','',10);
}
function headerDateWise($pdf){
$pdf->SetFont('Times','B',10);
$pdf->Cell(8,6,"Sl.","LRT",0, "C");
$pdf->Cell(20,6,"Date","LRT",0,"C");
$pdf->Cell(16,6,"Session","LRT",0,"C");
$pdf->Cell(10,6,"QP","LRT",0,"C");
$pdf->Cell(80,6,"Subject Name","LRT",0,"C");
$pdf->Cell(125,6,"Degree","LRT",0,"C");
$pdf->Cell(15,6,"QP","LRT",1,"C");
$pdf->Cell(8,6,"No","LRB",0,"C");
$pdf->Cell(20,6,"","LRB",0,"C"); //w h txt brd pos align
$pdf->Cell(16,6,"","LBR",0,"C");
$pdf->Cell(10,6,"Code","LBR",0,"C");
$pdf->Cell(80,6,"","LBR",0,"C");
$pdf->Cell(125,6,"","LBR",0,"C");
$pdf->Cell(15,6,"Count","LBR",1,"C");
$pdf->SetFont('Times','',10);
}
function writeReport($cntrlist)
{
$pdf=$this->pdf;
$pdf->SetMargins(6,30);
$pdf->startPageGroup();
$pdf->AddPage("P");
$orientation = 'P';
$pdf->SetFont('Times','',10);
// $this->tableHeader($pdf);
$old_cntr = '';
$new_cntr = $cntrlist[0]['fcntrcode'];
foreach ($cntrlist as $key => $value)
{
// $value['fcntrname']
$str = explode(',', $value['fdegree']);
$str1 = implode(',',array_slice($str,0,6));
$str2 = implode(',',array_slice($str,6));
$sub1 = substr($value['fsubname'],0,38);
$sub2 = substr($value['fsubname'],38);
if($value['fsession']== 'M1')
$session = "Morning";
else $session = "Afternoon";
// var_dump($date);
$sl_no++;
if($old_cntr !== $new_cntr)
{
if($pdf->getY() > 260)
$pdf->AddPage();
$pdf->SetFont('Times','B',12);
$pdf->Cell(0,12,$value['fcntrcode'].' - '. $value['fcntrname'],0,1, "C");
$this->tableHeader($pdf);
$old_cntr = $value['fcntrcode'];
$sl_no = 1;
}
$new_cntr = $value['fcntrcode'];
if($sub2 || $str2){
$pdf->Cell(8,6,$sl_no,"LRT",0, "C");
$pdf->cell(12,6,$value['fqpcode'],"LRT",0,"L");
$pdf->cell(65,6,$sub1,"LRT",0,"L");
$pdf->cell(18,6,$value['fdoe'],"LRT",0,"R");
$pdf->cell(15,6,$session,"LRT",0,"R");
$pdf->cell(12,6,moneyFormatIndia($value['frounded']),"LRT",0,"R");
$pdf->cell(65,6,$str1,"LRT",1,"L");
if($pdf->getY() > 270){
$pdf->SetFont('Times','B',12);
$pdf->Cell(0,12,$value['fcntrcode'].' - '. $value['fcntrname'],0,1, "C");
$this->tableHeader($pdf);
}
$pdf->Cell(8,6,"","LBR",0);
$pdf->cell(12,6,"","LBR",0,"C");
$pdf->cell(65,6,$sub2,"LBR",0,"L");
$pdf->cell(18,6,"","LBR",0,"R");
$pdf->cell(15,6,"","LBR",0,"R");
$pdf->cell(12,6,"","LBR",0,"R");
$pdf->cell(65,6,$str2,"LBR",1,"L");
if($pdf->getY() > 270)
{
$pdf->SetFont('Times','B',12);
$pdf->Cell(0,12,$value['fcntrcode'].' - '. $value['fcntrname'],0,1, "C");
$this->tableHeader($pdf);
}
}
else
{
$pdf->Cell(8,6,$sl_no,"1",0, "C");
$pdf->cell(12,6,$value['fqpcode'],"1",0,"L");
$pdf->cell(65,6,$sub1,"1",0,"L");
$pdf->cell(18,6,$value['fdoe'],"1",0,"R");
$pdf->cell(15,6,$session,"1",0,"R");
$pdf->cell(12,6,moneyFormatIndia($value['frounded']),"1",0,"R");
$pdf->cell(65,6,$str1,"1",1,"L");
}
if($pdf->getY() > 270)
{
$pdf->SetFont('Times','B',12);
$pdf->Cell(0,12,$value['fcntrcode'].' - '. $value['fcntrname'],0,1, "C");
$this->tableHeader($pdf);
}
}
}
function writeQPReport($qpList){
$pdf=$this->pdf;
$pdf->SetMargins(0,35);
$pdf->startPageGroup();
$pdf->AddPage("P");
$pdf->SetFont('Times','',10);
$this->headerQPWise($pdf);
$sl_no = 0;
foreach ($qpList as $key => $value){
$colname1 = strtolower(substr($value['fcntrname'],0,65));
$colname2 = strtolower(substr($value['fcntrname'],65));
$sl_no++;
if($pdf->getY() > 260)
{
$pdf->AddPage("P");
$this->headerQPWise($pdf);
}
if($colname2)
{
$pdf->Cell(30,6,"",0,0);
$pdf->Cell(8,6,$sl_no,"LRT",0, "C");
$pdf->Cell(15,6,$value['fcntrcode'],"LRT",0,"C");
$pdf->Cell(110,6,ucwords($colname1, '\',. '),"LRT",0,"L");
$pdf->Cell(15,6,moneyFormatIndia($value['fcount']),"LRT",1,"R");
$pdf->Cell(30,6,"",0,0);
$pdf->Cell(8,6,"","LBR",0);
$pdf->Cell(15,6,"","LBR",0,"C");
$pdf->Cell(110,6,$colname2,"LBR",0,"L");
$pdf->Cell(15,6,"","LBR",1,"R");
}else
{
$pdf->Cell(30,6,"",0,0);
$pdf->Cell(8,6,$sl_no,"1",0,"C");
$pdf->Cell(15,6,$value['fcntrcode'],"1",0,"C");
$pdf->Cell(110,6,ucwords($colname1, '\',. '),"1",0,"L");
$pdf->Cell(15,6,moneyFormatIndia($value['fcount']),"1",1,"R");
}
if($pdf->getY() > 260)
{
$pdf->AddPage("P");
$this->headerQPWise($pdf);
}
}
}
function writedoeReport($doelist){
$pdf=$this->pdf;
$pdf->SetMargins(10,35);
$pdf->startPageGroup();
$pdf->AddPage("L");
$pdf->SetFont('Times','',10);
$this->headerDateWise($pdf);
$sl_no = 0;
foreach ($doelist as $key => $value){
if($value['fsession']== 'M1')
$session = "Morning";
else $session = "Afternoon";
$sub = explode(',', $value['fdegree']);
$degstr = implode(', ', $sub);
$sub1 = substr($value['fsubname'],0,40);
$sub2 = substr($value['fsubname'],40);
$sl_no++;
if($sub2)
{
$x = $pdf->GetX();
$y = $pdf->GetY();
$pdf->SetX($x + 134);
$pdf->MultiCell(125,6,$degstr,"LRT","L");
$y1 = $pdf->GetY();
$h = $y1 - $y;
$pdf->SetXY($x,$y);
$pdf->Cell(8,$h,$sl_no,"LRT",0, "C");
$pdf->Cell(20,$h,$value['fdoe'],"LRT",0,"C");
$pdf->Cell(16,$h,$session,"LRT",0,"C");
$pdf->Cell(10,$h,$value['fqpcode'],"LRT",0,"C");
$pdf->Cell(80,$h,$sub1,"LRT",0,"L");
$pdf->SetX($x + 259);
$pdf->Cell(15,$h,moneyFormatIndia($value['fforcoll']),"LRT",1,"R");
if($sub2)
{
$pdf->Cell(8,$h,"","LBR",0);
$pdf->Cell(20,$h,"","LBR",0,"C");
$pdf->Cell(16,$h,"","LBR",0,"C");
$pdf->Cell(10,$h,"","LBR",0,"C");
$pdf->Cell(80,$h,$sub2,"LBR",0,"L");
$pdf->Cell(125,$h,"","LBR",0,"L");
$pdf->Cell(15,$h,"","LBR",1,"R");
}
if($pdf->getY() > 170){
$pdf->AddPage();
$this->headerDateWise($pdf);
}
}
else
{
$x = $pdf->GetX();
$y = $pdf->GetY();
$pdf->SetX($x + 134);
$pdf->MultiCell(125,6,$degstr,1,"L");
$y1 = $pdf->GetY();
$h = $y1 - $y;
$pdf->SetXY($x,$y);
$pdf->Cell(8,$h,$sl_no,"1",0, "C");
$pdf->Cell(20,$h,$value['fdoe'],"1",0,"C");
$pdf->Cell(16,$h,$session,"1",0,"C");
$pdf->Cell(10,$h,$value['fqpcode'],"1",0,"C");
$pdf->Cell(80,$h,$sub1,"1",0,"L");
$pdf->SetX($x + 259);
$pdf->Cell(15,$h,moneyFormatIndia($value['fforcoll']),"1",1,"R");
if($pdf->getY() > 170)
{
$pdf->AddPage();
$this->headerDateWise($pdf);
}
}
if($pdf->getY() > 180){
$this->headerDateWise($pdf);
}
}
}
function SendOutput()
{
ob_end_clean();
$this->pdf->Output("{$this->reportType}_QPIndent{$this->univcode}.pdf","D");
}
}
function getqpIndentReport($aobj_context){
$univcode = $aobj_context->mobj_data["univcode"];
$deggrp = $aobj_context->mobj_data["dgp"];
$reportType = $aobj_context->mobj_data["rt"];
$resetData = $aobj_context->mobj_data["rd"];
$reportFormat = $aobj_context->mobj_data["rf"];
if($resetData)
{
createTable($aobj_context);
}
$class_obj = new QPIndentReport();
$class_obj->univcode = $univcode;
$class_obj->reportType = $reportType;
$class_obj->DefaultConstructor($aobj_context,$deggrp,$reportType);
if($reportType == 'Centrewise Indent'){
$query = "SELECT fcntrcode,fcntrname,fqpcode,fsubname,
DATE_FORMAT(fdoe, '%d/%m/%Y') AS fdoe,fsession,fcnt,fextra,ftotal,frounded,fdegree
FROM tmpqpindsum ORDER BY fcntrcode, fqpcode";
$result = $aobj_context->pobj_db->GetAll($query);
// var_dump($query);
// var_dump($result);
if(count($result) > 0) {
if($reportFormat == 'Excel Format') writeReport($result,$aobj_context);
else {
$class_obj->writeReport($result);
$class_obj->SendOutput();
}
}
}
if($reportType == 'Answer Book Indent'){
$query="SELECT q.fcntrcode, q.fcntrname,SUM(q.frounded) AS fcount
FROM tmpqpindsum q
GROUP BY q.fcntrcode, q.fcntrname
ORDER BY q.fcntrcode, q.fcntrname";
$result = $aobj_context->pobj_db->GetAll($query);
if(count($result) > 0) {
if($reportFormat == 'Excel Format') writeABIReport($result,$aobj_context);
else {
$class_obj->writeQPReport($result);
$class_obj->SendOutput();
}
}
}
if($reportType == 'Total Indent'){
$query = "SELECT DATE_FORMAT(q.fdoe, '%d/%m/%Y') as fdoe , q.fsession, q.fqpcode, q.fsubname, r.fdegree,
q.fforcoll
FROM tmpqpindtot q, tmpqpinddeg r WHERE q.fqpcode = r.fqpcode
GROUP BY q.fdoe, q.fsession, q.fqpcode, q.fsubname
ORDER BY q.fdoe, q.fsession, q.fqpcode";
$result = $aobj_context->pobj_db->GetAll($query);
// var_dump($result);die();
if(count($result) > 0) {
if($reportFormat == 'Excel Format') writedoeReport($result,$aobj_context);
else {
$class_obj->writedoeReport($result);
$class_obj->SendOutput();
}
}
}
}
function writeReport($result,$aobj_context){
$objPHPExcel = new PHPExcel();
$fileName = 'CenterwiseIndent';
// Set document properties
$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);
// Add column headers and make them bold
$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()->freezePane('A2');
$objPHPExcel->getActiveSheet()
->setCellValue('A1', 'Sl. No.')
->setCellValue('B1', 'QP Code')
->setCellValue('C1', 'Center Code')
->setCellValue('D1', 'Center Name')
->setCellValue('E1', 'Subject Name')
->setCellValue('F1', 'Date')
->setCellValue('G1', 'Session')
->setCellValue('H1','Qp Indent')
// ->setCellValue('I1','Degree')
;
$objPHPExcel->getActiveSheet()->getStyle('A1:H1')->applyFromArray($styleArray);
// $objPHPExcel->getActiveSheet()->getColumnDimension('G1')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40);
$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;
if($value['fsession']== 'M1')
$session = "Morning";
else $session = "Afternoon";
$objPHPExcel->getActiveSheet()->setCellValue('A'.$slNo, $slNo-1)->getColumnDimension('A')->setwidth(5);
$objPHPExcel->getActiveSheet()->setCellValue('B'.$slNo, $value['fqpcode'])->getColumnDimension('B')->setwidth(8.43);
$objPHPExcel->getActiveSheet()->setCellValue('C'.$slNo, $value['fcntrcode'])->getColumnDimension('C')->setwidth(8.43);
$objPHPExcel->getActiveSheet()->setCellValue('D'.$slNo, $value['fcntrname'])->getColumnDimension('D')->setwidth(50);
$objPHPExcel->getActiveSheet()->setCellValue('E'.$slNo, $value['fsubname'])->getColumnDimension('E')->setwidth(34);
$objPHPExcel->getActiveSheet()->setCellValue('F'.$slNo, $value['fdoe'])->getColumnDimension('F')->setwidth(12.29);
$objPHPExcel->getActiveSheet()->setCellVAlue('G'.$slNo, $session)->getColumnDimension('G')->setwidth(8.43);
$objPHPExcel->getActiveSheet()->setCellValue('H'.$slNo, $value['frounded'])->getColumnDimension('H')->setwidth(8);
// $objPHPExcel->getActiveSheet()->setCellValue('I'.$slNo, $value['fdegree'])->getColumnDimension('I')->setwidth(45);
// $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setwidth(12);
$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':H'.$slNo)->applyFromArray($styleArray);
$objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(33);
$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':C'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':C'.$slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':I'.$slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':I'.$slNo)->getAlignment()->setWrapText(true);
}
// Set worksheet title
$objPHPExcel->getActiveSheet()->setTitle($fileName);
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
// $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
$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'];
$deggrp = $aobj_context->mobj_data["dgp"];
$reportType = $aobj_context->mobj_data["rt"];
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&H&"-,Bold"&16'.$aobj_context->FUNIVNAME."\n".'&12'.$reportType.' - '.$deggrp);
// $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&H'.$reportType.' - '.$deggrp);
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&RPage &P of &N');
getheaders($objPHPExcel,$fileName);
}
function writedoeReport($result,$aobj_context){
$objPHPExcel = new PHPExcel();
$fileName = 'TotalIndent';
// Set document properties
$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);
// Add column headers and make them bold
$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()->freezePane('A2');
$objPHPExcel->getActiveSheet()
->setCellValue('A1', 'Sl. No.')
->setCellValue('B1', 'Date')
->setCellValue('C1', 'Session')
->setCellValue('D1', 'QP Code')
->setCellValue('E1', 'Subject Name')
->setCellValue('F1','Degree')
->setCellValue('G1','QP Count')
;
$objPHPExcel->getActiveSheet()->getStyle('A1:G1')->applyFromArray($styleArray);
$objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40);
$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);
//Put each record in a new cell
foreach ($result as $key => $value){
$slNo = $key+2;
if($value['fsession']== 'M1')
$session = "Morning";
else $session = "Afternoon";
$objPHPExcel->getActiveSheet()->setCellValue('A'.$slNo, $slNo-1)->getColumnDimension('A')->setwidth(5);
$objPHPExcel->getActiveSheet()->setCellValue('B'.$slNo, $value['fdoe'])->getColumnDimension('B')->setwidth(12.29);
$objPHPExcel->getActiveSheet()->setCellValue('C'.$slNo, $session)->getColumnDimension('C')->setwidth(12);
$objPHPExcel->getActiveSheet()->setCellValue('D'.$slNo, $value['fqpcode'])->getColumnDimension('D')->setwidth(8.43);
$objPHPExcel->getActiveSheet()->setCellVAlue('E'.$slNo, $value['fsubname'])->getColumnDimension('E')->setwidth(34);
$objPHPExcel->getActiveSheet()->setCellValue('F'.$slNo, $value['fdegree'])->getColumnDimension('F')->setwidth(50);
$objPHPExcel->getActiveSheet()->setCellValue('G'.$slNo, $value['fforcoll'])->getColumnDimension('G')->setwidth(8.43);
$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':G'.$slNo)->applyFromArray($styleArray);
$objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(60);
$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('D'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('D'.$slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':G'.$slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('E'.$slNo.':F'.$slNo)->getAlignment()->setWrapText(true);
}
// Set worksheet title and orientation
$objPHPExcel->getActiveSheet()->setTitle($fileName);
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
// $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
$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'];
$deggrp = $aobj_context->mobj_data["dgp"];
$reportType = $aobj_context->mobj_data["rt"];
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&H&"-,Bold"&16'.$aobj_context->FUNIVNAME."\n".'&12'.$reportType.' - '.$deggrp);
// $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&H'.$reportType.' - '.$deggrp);
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&RPage &P of &N');
getheaders($objPHPExcel,$fileName);
}
function writeABIReport($result,$aobj_context){
$objPHPExcel = new PHPExcel();
$fileName = 'AnswerBookIndent';
// Set document properties
$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'),
),
),
);
$objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setSize(12);
$objPHPExcel->getActiveSheet()->freezePane('A2');
$objPHPExcel->getActiveSheet()
->setCellValue('A1', 'Sl. No.')
->setCellValue('B1', 'Center Code')
->setCellValue('C1', 'Center Name')
->setCellValue('D1', 'Total')
;
$objPHPExcel->getActiveSheet()->getStyle('A1:D1')->applyFromArray($styleArray);
$objPHPExcel->getActiveSheet()->getStyle('A1:D1')->applyFromArray($styleArray);
// $objPHPExcel->getActiveSheet()->getColumnDimension('G1')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40);
$objPHPExcel->getActiveSheet()->getStyle('A1:D1')->getAlignment()->setWrapText(true);
$objPHPExcel->getActiveSheet()->getStyle('C'.$slNo)->getAlignment()->setWrapText(true);
$objPHPExcel->getActiveSheet()->getStyle('A1:D1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A1:D1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
//Put each record in a new cell
foreach ($result as $key => $value){
$slNo = $key+2;
$objPHPExcel->getActiveSheet()->setCellValue('A'.$slNo, $slNo-1)->getColumnDimension('A')->setwidth(5);
$objPHPExcel->getActiveSheet()->setCellValue('B'.$slNo, $value['fcntrcode'])->getColumnDimension('B')->setwidth(8);
$objPHPExcel->getActiveSheet()->setCellValue('C'.$slNo, $value['fcntrname'])->getColumnDimension('C')->setwidth(50);
$objPHPExcel->getActiveSheet()->setCellValue('D'.$slNo, $value['fcount'])->getColumnDimension('D')->setwidth(8.43);
$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':D'.$slNo)->applyFromArray($styleArray);
$objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(40);
$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':B'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':B'.$slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':D'.$slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('E'.$slNo.':D'.$slNo)->getAlignment()->setWrapText(true);
}
// Set worksheet title
$objPHPExcel->getActiveSheet()->setTitle($fileName);
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
// $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
$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'];
$deggrp = $aobj_context->mobj_data["dgp"];
$reportType = $aobj_context->mobj_data["rt"];
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&H&"-,Bold"&16'.$aobj_context->FUNIVNAME."\n".'&12'.$reportType.' - '.$deggrp);
// $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&H'.$reportType.' - '.$deggrp);
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&RPage &P of &N');
getheaders($objPHPExcel,$fileName);
}
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 createTable($aobj_context){
$query = "DROP TABLE IF EXISTS qpmaster, tmpqpindsum,tmpqpindtot,tmpqpinddeg";
$result = $aobj_context->pobj_db->Execute($query);
$query = "CREATE TABLE IF NOT EXISTS qpmaster
SELECT DISTINCT fdegree, fexamno, fsubcode, fqpcode, fsubname, fdoe AS fdoe, fsession AS fsession FROM SUBJECT
WHERE IFNULL(fqpcode,'') <> '' AND ftheory = 'T' AND IFNULL(fintass,'') <> 'T'
AND fdegree LIKE 'b%'";
$result = $aobj_context->pobj_db->Execute($query);
$query = "create index qpmaster_inx on qpmaster(fqpcode)";
$result = $aobj_context->pobj_db->Execute($query);
// $query = "CREATE TABLE IF NOT EXISTS tmpqpindsum
// SELECT m.fcntrcode, CONCAT(TRIM(g.fcollname), ', ', g.ftown) AS fcntrname, s.fqpcode,
// s.fsubname, s.fdoe, s.fsession, COUNT(c.fregno) AS fcnt,
// (FLOOR((COUNT(c.fregno) * (10/100)) / 5) * 5) + IF((COUNT(c.fregno) * (10/100)) MOD 5 = 0, 0, 5) AS fextra,
// COUNT(c.fregno) + (FLOOR((COUNT(c.fregno) * (10/100)) / 5) * 5) + IF((COUNT(c.fregno) * (10/100)) MOD 5 = 0, 0, 5) AS ftotal,
// (FLOOR((COUNT(c.fregno) + (FLOOR((COUNT(c.fregno) * (10/100)) / 5) * 5) + IF((COUNT(c.fregno) * (10/100)) MOD 5 = 0, 0, 5)) / 10) * 10) +
// IF((COUNT(c.fregno) + (FLOOR((COUNT(c.fregno) * (10/100)) / 5) * 5) +
// IF((COUNT(c.fregno) * (10/100)) MOD 5 = 0, 0, 5)) MOD 10 = 0, 0, 10) AS frounded,
// GROUP_CONCAT(DISTINCT s.fdegree ORDER BY s.fdegree) AS fdegree
// FROM qpmaster s, canddet c, candsum m, college g
// WHERE s.fdegree = c.fdegree
// AND s.fexamno = c.fexamno
// AND s.fsubcode = c.fsubcode
// AND c.fdegree = m.fdegree AND c.fregno = m.fregno
// AND m.fcntrcode = g.fcollcode
// GROUP BY s.fqpcode, s.fsubname, m.fcntrcode, g.fcollname, g.ftown
// ORDER BY m.fcntrcode, s.fqpcode";
// $result = $aobj_context->pobj_db->Execute($query);
$query = "CREATE TABLE IF NOT EXISTS tmpqpindsum
SELECT m.fexamcodet as fcntrcode, CONCAT(TRIM(g.fcollname), ', ', g.ftown) AS fcntrname, s.fqpcode,
s.fsubname, s.fdoe, s.fsession, COUNT(c.fregno) AS fcnt,
(FLOOR((COUNT(c.fregno) * (10/100)) / 5) * 5) + IF((COUNT(c.fregno) * (10/100)) MOD 5 = 0, 0, 5) AS fextra,
COUNT(c.fregno) + (FLOOR((COUNT(c.fregno) * (10/100)) / 5) * 5) + IF((COUNT(c.fregno) * (10/100)) MOD 5 = 0, 0, 5) AS ftotal,
(FLOOR((COUNT(c.fregno) + (FLOOR((COUNT(c.fregno) * (10/100)) / 5) * 5) + IF((COUNT(c.fregno) * (10/100)) MOD 5 = 0, 0, 5)) / 10) * 10) +
IF((COUNT(c.fregno) + (FLOOR((COUNT(c.fregno) * (10/100)) / 5) * 5) +
IF((COUNT(c.fregno) * (10/100)) MOD 5 = 0, 0, 5)) MOD 10 = 0, 0, 10) AS frounded,
GROUP_CONCAT(DISTINCT s.fdegree ORDER BY s.fdegree) AS fdegree
FROM qpmaster s, canddet c, degcntr m, college g
WHERE s.fdegree = c.fdegree
AND s.fexamno = c.fexamno
AND s.fsubcode = c.fsubcode
AND c.fcollcode = m.fcollcode
AND m.fexamcodet = g.fcollcode
and m.fdeggrp = 'UG' and c.fdegree in(select fdegree from degree where fdeggrp = 'UG')
GROUP BY s.fqpcode, s.fsubname, m.fexamcodet, g.fcollname, g.ftown
ORDER BY m.fexamcodet, s.fqpcode";
$result = $aobj_context->pobj_db->Execute($query);
$query = "CREATE TABLE IF NOT EXISTS tmpqpindtot
SELECT q.fdoe, q.fsession, q.fqpcode, q.fsubname, '' AS fdeg,
SUM(q.frounded) AS fforcoll
FROM tmpqpindsum q
GROUP BY q.fdoe, q.fsession, q.fqpcode, q.fsubname
ORDER BY q.fdoe, q.fsession, q.fqpcode";
$result = $aobj_context->pobj_db->Execute($query);
$query = "CREATE TABLE IF NOT EXISTS tmpqpinddeg
SELECT fqpcode, GROUP_CONCAT(DISTINCT fdegree ORDER BY fdegree) AS fdegree
FROM qpmaster
GROUP BY fqpcode
ORDER BY fqpcode";
$result = $aobj_context->pobj_db->Execute($query);
}
function moneyFormatIndia($num) {
$explrestunits = "" ;
if(strlen($num)>3) {
$lastthree = substr($num, strlen($num)-3, strlen($num));
$restunits = substr($num, 0, strlen($num)-3); // extracts the last three digits
$restunits = (strlen($restunits)%2 == 1)?"0".$restunits:$restunits; // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping.
$expunit = str_split($restunits, 2);
for($i=0; $i<sizeof($expunit); $i++) {
// creates each of the 2's group and adds a comma to the end
if($i==0) {
$explrestunits .= (int)$expunit[$i].","; // if is first value , convert into integer
} else {
$explrestunits .= $expunit[$i].",";
}
}
$thecash = $explrestunits.$lastthree;
} else {
$thecash = $num;
}
return $thecash; // writes the final format where $currency is the currency symbol.
}
?>
|