consolidated PDF classes to one class

added show_pdf.php
This commit is contained in:
Michael Clemens 2009-05-12 00:51:21 +00:00
parent 19d46e48b4
commit d7f826c831
4 changed files with 221 additions and 205 deletions

View File

@ -84,7 +84,6 @@ header("Pragma: no-cache");
// ** Include generic code and external libraries ** //
include ($config["library_path"] . "/adodb5/adodb.inc.php");
//include_once($config["include_path"] . "/functions.php");
include_once($config["include_path"] . "/tsmmonitor.php");
include_once($config["include_path"] . "/polld.php");

View File

@ -1,5 +1,5 @@
function genPDF() {
window.open( "includes/pdf.php", "myWindow", "status = 1, fullscreen=yes,scrollbars=yes" )
window.open( "includes/show_pdf.php", "myWindow", "status = 1, fullscreen=yes,scrollbars=yes" )
}
function show_confirm($url, $id, $action)

View File

@ -35,13 +35,15 @@ require('global.php');
define('FPDF_FONTPATH','font/');
/**
*
* Class PDF_MySQL_Table
* Class PDF
*
*/
class PDF_MySQL_Table extends FPDF
class PDF extends FPDF
{
var $ProcessingTable=false;
var $aCols=array();
@ -59,8 +61,22 @@ var $ColorIndex;
function Header()
{
//Print the table header if necessary
if($this->ProcessingTable)
$this->TableHeader();
if($this->ProcessingTable) $this->TableHeader();
$configarray = $_SESSION["configarray"];
$queryarray = $configarray["queryarray"];
$qq = $_SESSION["GETVars"]["qq"];
$server = $_SESSION["GETVars"]["server"];
$label = $queryarray[$qq]["label"];
$snapshotdate = $_SESSION['timemachine']['time'];
if ($snapshotdate != "") {
$snapshotdate = " (".strftime("%Y/%m/%d %H:%m", $snapshotdate).")";
}
//Title
$this->SetFont('Arial','',12);
$this->Cell(0,6,$server.": ".$label.$snapshotdate,0,1,'C');
$this->Ln(10);
//Ensure table header is output
parent::Header();
}
@ -211,54 +227,4 @@ function Table($query,$prop=array(),$dbresult)
}
/**
*
* Class PDF
*
*/
class PDF extends PDF_MySQL_Table
{
/**
* Header - class header
*
*/
function Header()
{
$configarray = $_SESSION["configarray"];
$queryarray = $configarray["queryarray"];
$qq = $_SESSION["GETVars"]["qq"];
$server = $_SESSION["GETVars"]["server"];
$label = $queryarray[$qq]["label"];
$snapshotdate = $_SESSION['timemachine']['time'];
if ($snapshotdate != "") {
$snapshotdate = " (".strftime("%Y/%m/%d %H:%m", $snapshotdate).")";
}
//Title
$this->SetFont('Arial','',12);
$this->Cell(0,6,$server.": ".$label.$snapshotdate,0,1,'C');
$this->Ln(10);
//Ensure table header is output
parent::Header();
}
}
$pdf=new PDF();
$pdf->Open();
$pdf->AddPage();
//First table: put all columns automatically
$prop=array('HeaderColor'=>array(180,180,180),
'color1'=>array(255,255,255),
'color2'=>array(230,230,230),
'padding'=>2);
//$pdf->Table('select * from res_'.$_SESSION["GETVars"]["qq"].'_'.$_SESSION["GETVars"]["server"],$prop);
$res = $tsmmonitor->fetchArrayDB($_SESSION["lastsql"], $tsmmonitor->conn);
//var_dump($res);
$pdf->Table($_SESSION["lastsql"],$prop,$res);
$pdf->Output();
?>

51
includes/show_pdf.php Normal file
View File

@ -0,0 +1,51 @@
<?php
/**
************************************************************************
This file is part of TSM Monitor.
TSM Monitor is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TSM Monitor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TSM Monitor. If not, see <http://www.gnu.org/licenses/>.
************************************************************************
**/
/**
*
* showpdf.php, TSM Monitor
*
* used for PDF popup window, calls class PDF
*
* @author Michael Clemens
* @package tsmmonitor
*/
require('global.php');
require('pdf.php');
define('FPDF_FONTPATH','font/');
$pdf=new PDF();
$pdf->Open();
$pdf->AddPage();
//First table: put all columns automatically
$prop=array('HeaderColor'=>array(180,180,180),
'color1'=>array(255,255,255),
'color2'=>array(230,230,230),
'padding'=>2);
$res = $tsmmonitor->fetchArrayDB($_SESSION["lastsql"], $tsmmonitor->conn);
$pdf->Table($_SESSION["lastsql"],$prop,$res);
$pdf->Output();
?>