phpBMS

root/trunk/phpbms/report/pdfreport_class.php

Revision 703, 8.1 KB (checked in by brieb, 2 years ago)
  • Rearranged payment processing routine to be more flexible. It now needs to save the sales order first
  • Added payment processing template so developers have a guide when putting together their payment scripts
  • It seems their might be some unintentional touching of other files in this commit;
Line 
1<?php
2/*
3 $Rev: 290 $ | $LastChangedBy: brieb $
4 $LastChangedDate: 2007-08-27 18:15:00 -0600 (Mon, 27 Aug 2007) $
5 +-------------------------------------------------------------------------+
6 | Copyright (c) 2004 - 2010, Kreotek LLC                                  |
7 | All rights reserved.                                                    |
8 +-------------------------------------------------------------------------+
9 |                                                                         |
10 | Redistribution and use in source and binary forms, with or without      |
11 | modification, are permitted provided that the following conditions are  |
12 | met:                                                                    |
13 |                                                                         |
14 | - Redistributions of source code must retain the above copyright        |
15 |   notice, this list of conditions and the following disclaimer.         |
16 |                                                                         |
17 | - Redistributions in binary form must reproduce the above copyright     |
18 |   notice, this list of conditions and the following disclaimer in the   |
19 |   documentation and/or other materials provided with the distribution.  |
20 |                                                                         |
21 | - Neither the name of Kreotek LLC nor the names of its contributore may |
22 |   be used to endorse or promote products derived from this software     |
23 |   without specific prior written permission.                            |
24 |                                                                         |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS     |
26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT       |
27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
28 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT      |
29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   |
30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT        |
31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,   |
32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY   |
33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT     |
34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE   |
35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.    |
36 |                                                                         |
37 +-------------------------------------------------------------------------+
38*/
39class pdfColumn{
40
41    var $title;
42    var $fieldname;
43    var $size = 1;
44    var $format;
45    var $align = "L";
46
47    function pdfColumn($title, $fieldname, $size = 1, $format = "", $align = "L"){
48
49        $this->title = $title;
50        $this->fieldname = $fieldname;
51        $this->size = ((real) $size);
52        $this->format = $format;
53        $this->align = $align;
54
55    }//end method
56
57}//end class
58
59
60class pdfColor{
61
62    var $r = 0;
63    var $g = 0;
64    var $b = 0;
65
66    function pdfColor($r = 0,$g = 0,$b = 0){
67
68        $this->r = $r;
69        $this->g = $g;
70        $this->b = $b;
71
72    }//end method
73
74}//end class
75
76
77class pdfFont {
78
79    var $family = "Arial";
80    var $style = "";
81    var $size = 8;
82
83    function pdfFont($family = "Arial", $style ="", $size = 8){
84
85        $this->family = $family;
86        $this->style = $style;
87        $this->size = $size;
88
89    }//end method
90
91}//end class
92
93
94class pdfStyle{
95
96    var $font = NULL;
97    var $textColor = NULL;
98    var $backgroundColor = NULL;
99
100    function pdfStyle($font = NULL, $textColor = NULL, $backgroundColor = NULL){
101
102        if($font) $this->font = $font;
103        if($textColor) $this->textColor = $textColor;
104        if($backgroundColor) $this->backgroundColor = $backgroundColor;
105
106    }//end method
107
108}//end class
109
110
111if(!class_exists("FPDI")){
112
113    require_once("fpdf/fpdf.php");
114    require_once("fpdf/tpl_and_memimage.php");
115    require_once("fpdf/fpdi.php");
116    require_once('fpdf/fpdi_pdf_parser.php');
117
118}//end if
119
120
121class phpbmsPDFReport extends FPDI {
122
123    var $borderDebug = 0;
124
125    var $leftmargin = 0.5;
126    var $rightmargin = 0.5;
127    var $topmargin = 0.75;
128    var $paperwidth = 8.5;
129    var $paperlength = 11;
130
131    var $logoInHeader = false;
132    var $companyInfoInHeader = false;
133
134    var $companyImageWidth = 1;
135
136    var $styles = array();
137
138
139    function phpbmsPDFReport($db, $orientation='P', $unit='mm', $format='Letter'){
140
141            $this->db = $db;
142
143            parent::FPDF_TPL($orientation, $unit, $format);
144
145            $this->initStyles();
146            $this->SetLineWidth(0.01);
147
148    }//end method
149
150
151    function initStyles(){
152
153            //here we set the standard styles
154
155            // NORMAL
156            $font = new pdfFont("Arial", "", 8);
157            $style = new pdfStyle($font);
158
159            $this->styles["normal"] = $style;
160
161
162            // TITLES
163            $font = new pdfFont("Arial", "B", 16);
164            $style = new pdfStyle($font);
165
166            $this->styles["title"] = $style;
167
168
169            // HEADER
170            $font = new pdfFont("Arial", "B", 8);
171            $bgC = new pdfColor(0,0,0);
172            $txtC = new pdfColor(255,255,255);
173            $style = new pdfStyle($font, $txtC, $bgC);
174
175            $this->styles["header"] = $style;
176
177    }//end method
178
179
180    function defineStyle($name, $pdfStyleObj){
181
182            if(get_class($pdfStyleObj) != "pdfStyle")
183                    $error = new appError(1400,"defineStyle Method needs pdfStyle object as parameter 2","PDF Error",true,true,false);
184
185            $this->styles[$name] = $pdfStyleObj;
186
187    }//end if
188
189
190    function setStyle($name){
191
192            if(!isset($this->styles[$name]))
193                    $name = "normal";
194
195            $newStyle = $this->styles[$name];
196
197            if(isset($newStyle->font))
198                    $this->SetFont($newStyle->font->family, $newStyle->font->style, $newStyle->font->size);
199            else
200                    $this->SetFont("Arial", "", 8);
201
202            if(isset($newStyle->textColor))
203                    $this->SetTextColor($newStyle->textColor->r, $newStyle->textColor->g, $newStyle->textColor->b);
204            else
205                    $this->SetTextColor(0,0,0);
206
207            if(isset($newStyle->backgroundColor))
208                    $this->SetFillColor($newStyle->backgroundColor->r, $newStyle->backgroundColor->g, $newStyle->backgroundColor->b);
209            else
210                    $this->SetFillColor(255,255,255);
211
212    }//end if
213
214
215    function SetMargins(){
216
217            parent::SetMargins($this->leftmargin, $this->topmargin, $this->rightmargin);
218
219    }//end method
220
221
222    function Header(){
223
224        if($this->logoInHeader){
225
226            $querystatement = "
227                SELECT
228                    `file`,
229                    UPPER(`type`) AS `type`
230                FROM
231                    files
232                WHERE
233                    id=1";
234
235            $pictureresult = $this->db->query($querystatement);
236
237            $thepicture = $this->db->fetchArray($pictureresult);
238
239            if($thepicture["type"]=="IMAGE/JPEG"){
240
241                global $image;
242                $image = $thepicture["file"];
243                $this->Image('var://image', $this->leftmargin,$this->topmargin, $this->companyImageWidth, 0, "JPEG");
244
245            } elseif($thepicture["type"]=="IMAGE/PNG")
246                $this->MemImage($thepicture["file"], $this->leftmargin, $this->topmargin, $this->companyImageWidth);
247
248        }//end if
249
250        if($this->companyInfoInHeader){
251
252            $cname = COMPANY_NAME;
253            $caddress = COMPANY_ADDRESS."\n".COMPANY_CSZ."\n".COMPANY_PHONE;
254
255            //company name
256            $width = $this->leftmargin;
257            if($this->logoInHeader)
258                $width += $this->companyImageWidth;
259
260            $this->SetXY($width, $this->topmargin);
261            $this->SetFont("Times","B",12);
262            $this->Cell(4, 0.25, $cname, $this->borderDebug, 2, "L");
263
264            //and last, company address
265            $this->SetFont("Times","",8);
266            $this->MultiCell(4, .125 , $caddress, $this->borderDebug);
267
268        }//end if
269
270    }//end method
271
272}//end class
273
274?>
Note: See TracBrowser for help on using the browser.
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.