| 39 | | class 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 | | class pdfColor{ |
| 60 | | |
| 61 | | var $r = 0; |
| 62 | | var $g = 0; |
| 63 | | var $b = 0; |
| 64 | | |
| 65 | | function pdfColor($r = 0,$g = 0,$b = 0){ |
| 66 | | |
| 67 | | $this->r = $r; |
| 68 | | $this->g = $g; |
| 69 | | $this->b = $b; |
| 70 | | |
| 71 | | }//end method |
| 72 | | |
| 73 | | }//end class |
| 74 | | |
| 75 | | |
| 76 | | class pdfFont { |
| 77 | | |
| 78 | | var $family = "Arial"; |
| 79 | | var $style = ""; |
| 80 | | var $size = 8; |
| 81 | | |
| 82 | | function pdfFont($family = "Arial", $style ="", $size = 8){ |
| 83 | | |
| 84 | | $this->family = $family; |
| 85 | | $this->style = $style; |
| 86 | | $this->size = $size; |
| 87 | | |
| 88 | | }//end method |
| 89 | | |
| 90 | | }//end class |
| 91 | | |
| 92 | | |
| 93 | | class pdfStyle{ |
| 94 | | |
| 95 | | var $font = NULL; |
| 96 | | var $textColor = NULL; |
| 97 | | var $backgroundColor = NULL; |
| 98 | | |
| 99 | | function pdfStyle($font = NULL, $textColor = NULL, $backgroundColor = NULL){ |
| 100 | | |
| 101 | | if($font) $this->font = $font; |
| 102 | | if($textColor) $this->textColor = $textColor; |
| 103 | | if($backgroundColor) $this->backgroundColor = $backgroundColor; |
| 104 | | |
| 105 | | }//end method |
| 106 | | |
| 107 | | }//end class |
| 108 | | |
| 109 | | |
| 110 | | if(!class_exists("MEM_IMAGE")){ |
| 111 | | |
| 112 | | include("fpdf/fpdf.php"); |
| 113 | | include("fpdf/mem_image.php"); |
| 114 | | |
| 115 | | }//end if |
| 116 | | |
| 117 | | class phpbmsPDFReport extends MEM_IMAGE { |
| 118 | | |
| 119 | | var $borderDebug = 0; |
| 120 | | |
| 121 | | var $leftmargin = 0.5; |
| 122 | | var $rightmargin = 0.5; |
| 123 | | var $topmargin = 0.75; |
| 124 | | var $paperwidth = 8.5; |
| 125 | | var $paperlength = 11; |
| 126 | | |
| 127 | | var $hasComapnyHeader = false; |
| 128 | | var $companyImageWidth = 1; |
| 129 | | |
| 130 | | var $styles = array(); |
| 131 | | |
| 132 | | |
| 133 | | function phpbmsPDFReport($db, $orientation='P', $unit='mm', $format='Letter'){ |
| 134 | | |
| 135 | | $this->db = $db; |
| 136 | | |
| 137 | | parent::MEM_IMAGE($orientation, $unit, $format); |
| 138 | | |
| 139 | | $this->initStyles(); |
| 140 | | $this->SetLineWidth(0.01); |
| 141 | | |
| 142 | | }//end method |
| 143 | | |
| 144 | | |
| 145 | | function initStyles(){ |
| 146 | | |
| 147 | | //here we set the standard styles |
| 148 | | |
| 149 | | // NORMAL |
| 150 | | $font = new pdfFont("Arial", "", 8); |
| 151 | | $style = new pdfStyle($font); |
| 152 | | |
| 153 | | $this->styles["normal"] = $style; |
| 154 | | |
| 155 | | |
| 156 | | // TITLES |
| 157 | | $font = new pdfFont("Arial", "B", 16); |
| 158 | | $style = new pdfStyle($font); |
| 159 | | |
| 160 | | $this->styles["title"] = $style; |
| 161 | | |
| 162 | | |
| 163 | | // HEADER |
| 164 | | $font = new pdfFont("Arial", "B", 8); |
| 165 | | $bgC = new pdfColor(0,0,0); |
| 166 | | $txtC = new pdfColor(255,255,255); |
| 167 | | $style = new pdfStyle($font, $txtC, $bgC); |
| 168 | | |
| 169 | | $this->styles["header"] = $style; |
| 170 | | |
| 171 | | }//end method |
| 172 | | |
| 173 | | |
| 174 | | function defineStyle($name, $pdfStyleObj){ |
| 175 | | |
| 176 | | if(get_class($pdfStyleObj) != "pdfStyle") |
| 177 | | $error = new appError(1400,"defineStyle Method needs pdfStyle object as parameter 2","PDF Error",true,true,false); |
| 178 | | |
| 179 | | $this->styles[$name] = $pdfStyleObj; |
| 180 | | |
| 181 | | }//end if |
| 182 | | |
| 183 | | |
| 184 | | function setStyle($name){ |
| 185 | | |
| 186 | | if(!isset($this->styles[$name])) |
| 187 | | $name = "normal"; |
| 188 | | |
| 189 | | $newStyle = $this->styles[$name]; |
| 190 | | |
| 191 | | if(isset($newStyle->font)) |
| 192 | | $this->SetFont($newStyle->font->family, $newStyle->font->style, $newStyle->font->size); |
| 193 | | else |
| 194 | | $this->SetFont("Arial", "", 8); |
| 195 | | |
| 196 | | if(isset($newStyle->textColor)) |
| 197 | | $this->SetTextColor($newStyle->textColor->r, $newStyle->textColor->g, $newStyle->textColor->b); |
| 198 | | else |
| 199 | | $this->SetTextColor(0,0,0); |
| 200 | | |
| 201 | | if(isset($newStyle->backgroundColor)) |
| 202 | | $this->SetFillColor($newStyle->backgroundColor->r, $newStyle->backgroundColor->g, $newStyle->backgroundColor->b); |
| 203 | | else |
| 204 | | $this->SetFillColor(255,255,255); |
| 205 | | |
| 206 | | }//end if |
| 207 | | |
| 208 | | |
| 209 | | function SetMargins(){ |
| 210 | | |
| 211 | | parent::SetMargins($this->leftmargin, $this->topmargin, $this->rightmargin); |
| 212 | | |
| 213 | | }//end method |
| 214 | | |
| 215 | | |
| 216 | | function Header(){ |
| 217 | | if($this->hasComapnyHeader){ |
| 218 | | |
| 219 | | $cname = COMPANY_NAME; |
| 220 | | $caddress = COMPANY_ADDRESS."\n".COMPANY_CSZ."\n".COMPANY_PHONE; |
| 221 | | |
| 222 | | $querystatement = " |
| 223 | | SELECT |
| 224 | | `file`, |
| 225 | | UPPER(`type`) AS `type` |
| 226 | | FROM |
| 227 | | files |
| 228 | | WHERE |
| 229 | | id=1"; |
| 230 | | |
| 231 | | $pictureresult = $this->db->query($querystatement); |
| 232 | | |
| 233 | | $thepicture = $this->db->fetchArray($pictureresult); |
| 234 | | |
| 235 | | if($thepicture["type"]=="IMAGE/JPEG"){ |
| 236 | | |
| 237 | | global $image; |
| 238 | | $image = $thepicture["file"]; |
| 239 | | $this->Image('var://image', $this->leftmargin,$this->topmargin, $this->companyImageWidth, 0, "JPEG"); |
| 240 | | |
| 241 | | } elseif($thepicture["type"]=="IMAGE/PNG") |
| 242 | | $this->MemImage($thepicture["file"], $this->leftmargin, $this->topmargin, $this->companyImageWidth); |
| 243 | | |
| 244 | | //company name |
| 245 | | $this->SetXY($this->companyImageWidth + $this->leftmargin, $this->topmargin); |
| 246 | | $this->SetFont("Times","B",12); |
| 247 | | $this->Cell(4, 0.25, $cname, $this->borderDebug, 2, "L"); |
| 248 | | |
| 249 | | //and last, company address |
| 250 | | $this->SetFont("Times","",8); |
| 251 | | $this->MultiCell(4, .125 , $caddress, $this->borderDebug); |
| 252 | | |
| 253 | | }//end if |
| 254 | | |
| 255 | | }//end method |
| 256 | | |
| 257 | | }//end class |
| | 39 | class 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 | |
| | 60 | class 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 | |
| | 77 | class 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 | |
| | 94 | class 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 | |
| | 111 | if(!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 | |
| | 121 | class 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 |