| 40 | | if(!class_exists("phpbmsReport")) |
| 41 | | include("report/report_class.php"); |
| 42 | | |
| 43 | | class invoicePDF extends phpbmsReport{ |
| 44 | | |
| 45 | | var $title = "Invoice"; |
| 46 | | var $showShipNameInShipTo = true; |
| 47 | | var $lineitemBoxHeight = 4.25; |
| 48 | | |
| 49 | | /** |
| 50 | | * $count |
| 51 | | * @var int The number of invoice records being displayed |
| 52 | | */ |
| 53 | | var $count; |
| 54 | | |
| 55 | | function invoicePDF($db, $orientation='P', $unit='mm', $format='Letter'){ |
| 56 | | |
| 57 | | $this->db = $db; |
| 58 | | |
| 59 | | if(!class_exists("phpbmsPDFReport")) |
| 60 | | include("report/pdfreport_class.php"); |
| 61 | | |
| 62 | | $this->pdf = new phpbmsPDFReport($db, $orientation, $unit, $format); |
| 63 | | |
| 64 | | $this->initialize(); |
| 65 | | |
| 66 | | }//end method |
| 67 | | |
| 68 | | |
| 69 | | function initialize(){ |
| 70 | | //This function will set column headings, sizes and formatting |
| 71 | | |
| 72 | | $pdf = &$this->pdf; |
| 73 | | |
| 74 | | $topinfo = array(); |
| 75 | | $topinfo[] = new pdfColumn("Order ID", "id", 0.75); |
| 76 | | $topinfo[] = new pdfColumn("Order Date", "orderdate", 1, "date"); |
| 77 | | $topinfo[] = new pdfColumn("Client PO", "ponumber", 1); |
| 78 | | $topinfo[] = new pdfColumn("Processed By", "processedby", 0); |
| 79 | | $topinfo[] = new pdfColumn("Payment Method", "paymentname",2); |
| 80 | | |
| 81 | | $size = 0; |
| 82 | | foreach($topinfo as $column) |
| 83 | | $size += $column->size; |
| 84 | | |
| 85 | | $topinfo[3]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; |
| 86 | | |
| 87 | | $this->topinfo = $topinfo; |
| 88 | | |
| 89 | | |
| 90 | | $lineitems = array(); |
| 91 | | $lineitems[] = new pdfColumn("Product / (Part Number)", "parts", 0); |
| 92 | | $lineitems[] = new pdfColumn("Tax", "taxable", 0.5, "boolean", "C"); |
| 93 | | $lineitems[] = new pdfColumn("Unit Price", "unitprice", 0.75, "currency", "R"); |
| 94 | | $lineitems[] = new pdfColumn("Qty", "quantity", 0.5, "real","R"); |
| 95 | | $lineitems[] = new pdfColumn("Extended", "extended", 0.75, "currency", "R"); |
| 96 | | |
| 97 | | $size = 0; |
| 98 | | foreach($lineitems as $column) |
| 99 | | $size += $column->size; |
| 100 | | |
| 101 | | $lineitems[0]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; |
| 102 | | |
| 103 | | $this->lineitems = $lineitems; |
| 104 | | |
| 105 | | $totalsinfo = array(); |
| 106 | | $totalsinfo[] = new pdfColumn("Discount", "discountamount", 1, "currency", "R"); |
| 107 | | $totalsinfo[] = new pdfColumn("Subtotal", "totaltni", 0, "currency", "R"); |
| 108 | | $totalsinfo[] = new pdfColumn("Tax", "tax", 1, "currency", "R"); |
| 109 | | $totalsinfo[] = new pdfColumn("Shipping", "shipping", 1, "currency", "R"); |
| 110 | | $totalsinfo[] = new pdfColumn("Total", "totalti", 1, "currency", "R"); |
| 111 | | $totalsinfo[] = new pdfColumn("Due", "amountdue", 1, "currency", "R"); |
| 112 | | |
| 113 | | $this->totalsinfo = $totalsinfo; |
| 114 | | |
| 115 | | }//end method |
| 116 | | |
| 117 | | |
| 118 | | function generate($whereclause = NULL, $sortorder = "invoices.id"){ |
| 119 | | |
| 120 | | $pdf = &$this->pdf; |
| 121 | | |
| 122 | | if($whereclause) |
| 123 | | $this->whereclause = $whereclause; |
| 124 | | elseif(!$this->whereclause) |
| 125 | | $this->whereclause = "invoices.id = -400"; |
| 126 | | |
| 127 | | if($sortorder) |
| 128 | | $this->sortorder = $sortorder; |
| 129 | | elseif(!$this->sortorder) |
| 130 | | $this->sortorder = "invoices.id"; |
| 131 | | |
| 132 | | $paymentFields = ""; |
| 133 | | if(ENCRYPT_PAYMENT_FIELDS){ |
| 134 | | |
| 135 | | $paymentFields = " |
| 136 | | ".$this->db->decrypt("`ccnumber`")." AS `ccnumber`, |
| 137 | | ".$this->db->decrypt("`ccverification`")." AS `ccverification`, |
| 138 | | ".$this->db->decrypt("`ccexpiration`")." AS `ccexpiration`, |
| 139 | | ".$this->db->decrypt("`routingnumber`")." AS `routingnumber`, |
| 140 | | ".$this->db->decrypt("`accountnumber`")." AS `accountnumber`, |
| 141 | | "; |
| 142 | | |
| 143 | | }//end if |
| 144 | | |
| 145 | | $querystatement = " |
| 146 | | SELECT |
| 147 | | invoices.*, |
| 148 | | ".$paymentFields." |
| 149 | | |
| 150 | | invoices.totalti - invoices.amountpaid AS amountdue, |
| 151 | | |
| 152 | | clients.firstname, |
| 153 | | clients.lastname, |
| 154 | | clients.company, |
| 155 | | clients.homephone, |
| 156 | | clients.workphone, |
| 157 | | clients.email, |
| 158 | | |
| 159 | | shippingmethods.name AS shippingname, |
| 160 | | |
| 161 | | paymentmethods.name AS paymentname, |
| 162 | | paymentmethods.type AS paymenttype, |
| 163 | | |
| 164 | | tax.name as taxname, |
| 165 | | |
| 166 | | users.firstname AS processorfirst, |
| 167 | | users.lastname AS processorlast |
| 168 | | |
| 169 | | FROM |
| 170 | | invoices INNER JOIN clients ON invoices.clientid = clients.uuid |
| 171 | | INNER JOIN users ON invoices.modifiedby = users.id |
| 172 | | LEFT JOIN shippingmethods ON invoices.shippingmethodid = shippingmethods.uuid |
| 173 | | LEFT JOIN paymentmethods ON invoices.paymentmethodid = paymentmethods.uuid |
| 174 | | LEFT JOIN tax ON invoices.taxareaid = tax.uuid"; |
| 175 | | |
| 176 | | $querystatement = $this->assembleSQL($querystatement); |
| 177 | | $queryresult = $this->db->query($querystatement); |
| 178 | | |
| 179 | | $this->count = $this->db->numRows($queryresult); |
| 180 | | if($this->count == 0){ |
| 181 | | |
| 182 | | $this->_showNoRecords(); |
| 183 | | exit; |
| 184 | | |
| 185 | | }//end if |
| 186 | | |
| 187 | | |
| 188 | | $pdf->hasComapnyHeader = true; |
| 189 | | $pdf->SetMargins(); |
| 190 | | |
| 191 | | //iterate through each invoice record |
| 192 | | while($invoicerecord = $this->db->fetchArray($queryresult)){ |
| 193 | | |
| 194 | | $this->page = 0; |
| 195 | | |
| 196 | | $this->invoicerecord = $invoicerecord; |
| 197 | | |
| 198 | | //adds top info |
| 199 | | $top = $this->_addPage(); |
| 200 | | |
| 201 | | $this->_addLineItems($top); |
| 202 | | |
| 203 | | $pdf->SetXY($pdf->leftmargin, $top["y"] + $this->lineitemBoxHeight + 0.125); |
| 204 | | |
| 205 | | //Print any special/instructions and stuff |
| 206 | | $this->_addNotes(); |
| 207 | | |
| 208 | | //totals |
| 209 | | $this->_addTotals(); |
| 210 | | |
| 211 | | //payment details |
| 212 | | $this->_addPaymentDetails(); |
| 213 | | |
| 214 | | }//end while; |
| 215 | | |
| 216 | | |
| 217 | | }//end method |
| 218 | | |
| 219 | | |
| 220 | | function _addPage(){ |
| 221 | | |
| 222 | | $pdf = &$this->pdf; |
| 223 | | |
| 224 | | |
| 225 | | $pdf->AddPage(); |
| 226 | | $this->page++; |
| 227 | | |
| 228 | | $nextY = $pdf->getY(); |
| 229 | | |
| 230 | | //TITLE |
| 231 | | $title = "Statement"; |
| 232 | | $titleWidth=2.375; |
| 233 | | $titleHeight=.25; |
| 234 | | $pdf->setStyle("title"); |
| 235 | | $pdf->SetXY(-1*($titleWidth+$pdf->rightmargin), $pdf->topmargin); |
| 236 | | $pdf->Cell($titleWidth, $titleHeight,$this->title, $pdf->borderDebug,1,"R"); |
| 237 | | |
| 238 | | $startY = $pdf->GetY() + 0.75; |
| 239 | | |
| 240 | | //page number? |
| 241 | | $pdf->setStyle("normal"); |
| 242 | | $pageNoWidth = 1; |
| 243 | | $pdf->SetFontSize(8); |
| 244 | | $pdf->SetXY(-1*($pageNoWidth + $pdf->rightmargin), $pdf->topmargin + $titleHeight + 0.25); |
| 245 | | $pdf->Cell($pageNoWidth, 0.17, "page: ".$this->page, $pdf->borderDebug,1,"R"); |
| 246 | | |
| 247 | | |
| 248 | | //SOLD TO |
| 249 | | $boxHeight = 1.75; |
| 250 | | $boxWidth = ($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin)/2 -0.0625; |
| 251 | | |
| 252 | | $pdf->setLineWidth(0.02); |
| 253 | | $pdf->Rect($pdf->leftmargin, $startY, $boxWidth, $boxHeight); |
| 254 | | $pdf->setLineWidth(0.01); |
| 255 | | |
| 256 | | $pdf->setStyle("header"); |
| 257 | | $pdf->setY($startY); |
| 258 | | $pdf->Cell($boxWidth, 0.17, "SOLD TO", $pdf->borderDebug, 2, "L", 1); |
| 259 | | $pdf->setStyle("normal"); |
| 260 | | |
| 261 | | //Company Name |
| 262 | | $companyDisplay = ""; |
| 263 | | if($this->invoicerecord["company"]){ |
| 264 | | $companyDisplay .= $this->invoicerecord["company"]; |
| 265 | | if($this->invoicerecord["firstname"]) |
| 266 | | $companyDisplay .= " (".$this->invoicerecord["firstname"]." ".$this->invoicerecord["lastname"].")"; |
| 267 | | } else |
| 268 | | $companyDisplay .= $this->invoicerecord["firstname"]." ".$this->invoicerecord["lastname"]; |
| 269 | | |
| 270 | | $pdf->SetXY($pdf->GetX() + 0.0625, $pdf->GetY() + 0.0625); |
| 271 | | $pdf->SetFont("Arial", "B", 10); |
| 272 | | $pdf->Cell($boxWidth - 0.125, 0.17, $companyDisplay, $pdf->borderDebug, 2, "L"); |
| 273 | | |
| 274 | | $billto = $this->_setBillTo(); |
| 275 | | $pdf->SetFont("Arial", "", 10); |
| 276 | | $pdf->setXY($pdf->GetX(), $pdf->GetY() + 0.0625); |
| 277 | | $pdf->MultiCell($boxWidth - 0.125,.17,$billto, $pdf->borderDebug); |
| 278 | | |
| 279 | | //SHIP TO |
| 280 | | $pdf->setLineWidth(0.02); |
| 281 | | $pdf->Rect($pdf->leftmargin + $boxWidth + 0.125, $startY, $boxWidth, $boxHeight); |
| 282 | | $pdf->setLineWidth(0.01); |
| 283 | | |
| 284 | | $pdf->setStyle("header"); |
| 285 | | $pdf->setXY($pdf->leftmargin + $boxWidth + 0.125, $startY); |
| 286 | | $pdf->Cell($boxWidth, 0.17, "SHIP TO", $pdf->borderDebug, 2, "L", 1); |
| 287 | | $pdf->setStyle("normal"); |
| 288 | | |
| 289 | | $pdf->SetXY($pdf->GetX() + 0.0625, $pdf->GetY() + 0.0625); |
| 290 | | $pdf->SetFont("Arial", "B", 10); |
| 291 | | |
| 292 | | $shipDisplay = (!$this->invoicerecord["shiptosameasbilling"] && $this->invoicerecord["shiptoname"])? $this->invoicerecord["shiptoname"] :$companyDisplay; |
| 293 | | $pdf->Cell($boxWidth - 0.125, 0.17, $shipDisplay, $pdf->borderDebug, 2, "L"); |
| 294 | | |
| 295 | | $shipto = $this->_setShipTo(); |
| 296 | | $pdf->SetFont("Arial", "", 10); |
| 297 | | $pdf->setXY($pdf->GetX(), $pdf->GetY() + 0.0625); |
| 298 | | $pdf->MultiCell($boxWidth - 0.125,.17, $shipto, $pdf->borderDebug); |
| 299 | | |
| 300 | | $pdf->setXY($pdf->leftmargin, $startY + $boxHeight + 0.125); |
| 301 | | |
| 302 | | $this->_topInvoiceInfo(); |
| 303 | | |
| 304 | | //line item headings |
| 305 | | $pdf->setStyle("header"); |
| 306 | | $pdf->SetLineWidth(0.02); |
| 307 | | |
| 308 | | $coords["x"] = $pdf->GetX(); |
| 309 | | $coords["y"] = $pdf->GetY(); |
| 310 | | |
| 311 | | foreach($this->lineitems as $column) |
| 312 | | $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); |
| 313 | | |
| 314 | | return $coords; |
| 315 | | |
| 316 | | }//end method |
| 317 | | |
| 318 | | |
| 319 | | function _setBillTo(){ |
| 320 | | |
| 321 | | $billto = $this->invoicerecord["address1"]; |
| 322 | | |
| 323 | | if($this->invoicerecord["address2"]) |
| 324 | | $billto .= "\n".$this->invoicerecord["address2"]; |
| 325 | | |
| 326 | | $billto .="\n".$this->invoicerecord["city"].", ".$this->invoicerecord["state"]." ".$this->invoicerecord["postalcode"]; |
| 327 | | |
| 328 | | if($this->invoicerecord["country"]) |
| 329 | | $billto .=" ".$this->invoicerecord["country"]; |
| 330 | | |
| 331 | | $phoneemail = ""; |
| 332 | | if($this->invoicerecord["workphone"] || $this->invoicerecord["homephone"]){ |
| 333 | | |
| 334 | | if($this->invoicerecord["workphone"]) |
| 335 | | $phoneemail = $this->invoicerecord["workphone"]." (W)"; |
| 336 | | else |
| 337 | | $phoneemail = $this->invoicerecord["homephone"]." (H)"; |
| 338 | | |
| 339 | | $phoneemail.="\n"; |
| 340 | | |
| 341 | | }//end if |
| 342 | | |
| 343 | | if($this->invoicerecord["email"]) |
| 344 | | $phoneemail .= $this->invoicerecord["email"]; |
| 345 | | |
| 346 | | if($phoneemail) |
| 347 | | $billto .= "\n\n".$phoneemail; |
| 348 | | |
| 349 | | return $billto; |
| 350 | | |
| 351 | | }//end method |
| 352 | | |
| 353 | | |
| 354 | | function _setShipTo(){ |
| 355 | | |
| 356 | | $added = ($this->invoicerecord["shiptosameasbilling"])? "" : "shipto"; |
| 357 | | |
| 358 | | $shipto = ""; |
| 359 | | |
| 360 | | $shipto .= $this->invoicerecord[$added."address1"]; |
| 361 | | |
| 362 | | if($this->invoicerecord[$added."address2"]) |
| 363 | | $shipto .= "\n".$this->invoicerecord[$added."address2"]; |
| 364 | | |
| 365 | | $shipto .="\n".$this->invoicerecord[$added."city"].", ".$this->invoicerecord[$added."state"]." ".$this->invoicerecord[$added."postalcode"]; |
| 366 | | |
| 367 | | if($this->invoicerecord[$added."country"]) |
| 368 | | $shipto .=" ".$this->invoicerecord[$added."country"]; |
| 369 | | |
| 370 | | if($this->showShipNameInShipTo) |
| 371 | | if($this->invoicerecord["shippingname"]) |
| 372 | | $shipto .="\n\nShipping Method:\n".$this->invoicerecord["shippingname"]; |
| 373 | | |
| 374 | | return $shipto; |
| 375 | | |
| 376 | | }//end method |
| 377 | | |
| 378 | | |
| 379 | | function _topInvoiceInfo(){ |
| 380 | | |
| 381 | | $pdf = &$this->pdf; |
| 382 | | |
| 383 | | $pdf->setStyle("header"); |
| 384 | | $pdf->SetLineWidth(0.02); |
| 385 | | |
| 386 | | foreach($this->topinfo as $column) |
| 387 | | $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); |
| 388 | | |
| 389 | | $pdf->Rect($pdf->leftmargin, $pdf->GetY(), ($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin), 0.39); |
| 390 | | |
| 391 | | $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + .2); |
| 392 | | |
| 393 | | |
| 394 | | $this->invoicerecord["processedby"] = $this->invoicerecord["processorfirst"]." ".$this->invoicerecord["processorlast"]; |
| 395 | | $pdf->setStyle("normal"); |
| 396 | | |
| 397 | | foreach($this->topinfo as $column){ |
| 398 | | |
| 399 | | if($column->format != "") |
| 400 | | $value = formatVariable($this->invoicerecord[$column->fieldname], $column->format); |
| 401 | | else |
| 402 | | $value = $this->invoicerecord[$column->fieldname]; |
| 403 | | |
| 404 | | $pdf->Cell($column->size, 0.18, $value, $pdf->borderDebug, 0, $column->align); |
| 405 | | |
| 406 | | }//end foreach |
| 407 | | |
| 408 | | $pdf->SetY($pdf->GetY() + 0.18 + 0.125); |
| 409 | | |
| 410 | | }//end method |
| 411 | | |
| 412 | | |
| 413 | | function _addLineItems($coords){ |
| 414 | | |
| 415 | | $pdf = &$this->pdf; |
| 416 | | |
| 417 | | $lineitemresult = $this->_getLineItems(); |
| 418 | | |
| 419 | | $pdf->setStyle("normal"); |
| 420 | | |
| 421 | | $pdf->SetY($pdf->GetY() + 0.18 + 0.0625); |
| 422 | | |
| 423 | | while($line = $this->db->fetchArray($lineitemresult)){ |
| 424 | | |
| 425 | | |
| 426 | | if($line["partname"] || $line["partnumber"] || $line["extended"]){ |
| 427 | | |
| 428 | | if($pdf->GetY() + 0.17*3 > $coords["y"] + $this->lineitemBoxHeight){ |
| 429 | | |
| 430 | | $pdf->SetLineWidth(0.02); |
| 431 | | $pdf->Rect($coords["x"], $coords["y"], $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $this->lineitemBoxHeight); |
| 432 | | $pdf->SetLineWidth(0.01); |
| 433 | | |
| 434 | | $this->_addPage(); |
| 435 | | |
| 436 | | $pdf->setStyle("normal"); |
| 437 | | |
| 438 | | $pdf->SetY($pdf->GetY() + 0.18 + 0.0625); |
| 439 | | |
| 440 | | }//end if |
| 441 | | |
| 442 | | foreach($this->lineitems as $column){ |
| 443 | | |
| 444 | | $ln = 0; |
| 445 | | |
| 446 | | |
| 447 | | switch($column->fieldname){ |
| 448 | | |
| 449 | | case "parts": |
| 450 | | $pdf->SetFont("Arial", "B", 8); |
| 451 | | $pdf->Write(0.17, $line["partname"]); |
| 452 | | $pdf->setStyle("normal"); |
| 453 | | $pdf->SetX($pdf->leftmargin + $column->size); |
| 454 | | break; |
| 455 | | |
| 456 | | default: |
| 457 | | if($column->format != "") |
| 458 | | $value = formatVariable($line[$column->fieldname], $column->format); |
| 459 | | else |
| 460 | | $value = $line[$column->fieldname]; |
| 461 | | |
| 462 | | if($value == "·") |
| 463 | | $value = " "; |
| 464 | | if($column->fieldname == $this->lineitems[count($this->lineitems)-1]->fieldname) |
| 465 | | $ln = 2; |
| 466 | | |
| 467 | | $pdf->Cell($column->size, 0.17, $value, $pdf->borderDebug, $ln, $column->align); |
| 468 | | break; |
| 469 | | |
| 470 | | }//end switch |
| 471 | | |
| 472 | | }//end foreach |
| 473 | | |
| 474 | | $pdf->SetX($pdf->leftmargin); |
| 475 | | $pdf->Write(0.17, "(".$line["partnumber"].")"); |
| 476 | | $pdf->Ln(); |
| 477 | | |
| 478 | | }//endif |
| 479 | | |
| 480 | | if($line["memo"]){ |
| 481 | | |
| 482 | | $pdf->SetX($pdf->leftmargin + 0.0625); |
| 483 | | $pdf->SetFont("Arial", "I", 8); |
| 484 | | $pdf->MultiCell($this->lineitems[0]->size - 0.0625, 0.16, $line["memo"], $pdf->borderDebug); |
| 485 | | $pdf->setStyle("normal"); |
| 486 | | |
| 487 | | }//end if |
| 488 | | |
| 489 | | $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.0625); |
| 490 | | $pdf->SetLineWidth(0.01); |
| 491 | | $pdf->SetDrawColor(180,180,180); |
| 492 | | $pdf->Line($pdf->leftmargin, $pdf->GetY(), $pdf->paperwidth - $pdf->rightmargin, $pdf->GetY()); |
| 493 | | $pdf->SetDrawColor(0,0,0); |
| 494 | | $pdf->SetLineWidth(0.02); |
| 495 | | $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.0625); |
| 496 | | |
| 497 | | }//end while |
| 498 | | |
| 499 | | $pdf->SetLineWidth(0.02); |
| 500 | | $pdf->Rect($coords["x"], $coords["y"], $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $this->lineitemBoxHeight); |
| 501 | | |
| 502 | | }//end method |
| 503 | | |
| 504 | | |
| 505 | | function _getLineItems(){ |
| 506 | | |
| 507 | | $querystatement = " |
| 508 | | SELECT |
| 509 | | lineitems.*, |
| 510 | | lineitems.quantity * lineitems.unitprice AS extended, |
| 511 | | products.partname, |
| 512 | | products.partnumber |
| 513 | | FROM |
| 514 | | lineitems LEFT JOIN products ON lineitems.productid = products.uuid |
| 515 | | WHERE |
| 516 | | lineitems.invoiceid ='".((int) $this->invoicerecord["id"])."' |
| 517 | | ORDER BY |
| 518 | | displayorder"; |
| 519 | | |
| 520 | | $queryresult = $this->db->query($querystatement); |
| 521 | | |
| 522 | | return $queryresult; |
| 523 | | |
| 524 | | }//end method |
| 525 | | |
| 526 | | |
| 527 | | function _addNotes(){ |
| 528 | | |
| 529 | | $pdf = &$this->pdf; |
| 530 | | |
| 531 | | $height = 1; |
| 532 | | $nextPos = $pdf->GetY() + $height + 0.125; |
| 533 | | |
| 534 | | $pdf->Rect($pdf->GetX(), $pdf->GetY(), $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $height); |
| 535 | | $pdf->setStyle("header"); |
| 536 | | $pdf->Cell($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, 0.18, "Notes/Instructions", 1, 2, "L", 1); |
| 537 | | |
| 538 | | $pdf->setStyle("normal"); |
| 539 | | $pdf->SetXY($pdf->GetX() + .06125, $pdf->GetY() + .06125); |
| 540 | | $pdf->MultiCell($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - 0.125, 0.18, $this->invoicerecord["printedinstructions"]); |
| 541 | | |
| 542 | | $pdf->SetXY($pdf->leftmargin, $nextPos); |
| 543 | | |
| 544 | | }//end method |
| 545 | | |
| 546 | | |
| 547 | | function _addTotals(){ |
| 548 | | |
| 549 | | $pdf = &$this->pdf; |
| 550 | | |
| 551 | | $size = 0; |
| 552 | | foreach($this->totalsinfo as $column) |
| 553 | | switch($column->fieldname){ |
| 554 | | case "shipping": |
| 555 | | case "discountamount": |
| 556 | | if($this->invoicerecord[$column->fieldname]) |
| 557 | | $size += $column->size; |
| 558 | | break; |
| 559 | | default: |
| 560 | | $size += $column->size; |
| 561 | | }//endswitch |
| 562 | | $this->totalsinfo[1]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; |
| 563 | | |
| 564 | | $height = .5; |
| 565 | | $nextPos = $pdf->GetY() + $height + 0.125; |
| 566 | | |
| 567 | | $pdf->Rect($pdf->GetX(), $pdf->GetY(), $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $height); |
| 568 | | |
| 569 | | $pdf->setStyle("header"); |
| 570 | | foreach($this->totalsinfo as $column) |
| 571 | | switch($column->fieldname){ |
| 572 | | case "shipping": |
| 573 | | case "discountamount": |
| 574 | | if($this->invoicerecord[$column->fieldname]) |
| 575 | | $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); |
| 576 | | break; |
| 577 | | default: |
| 578 | | $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); |
| 579 | | }//endswitch |
| 580 | | |
| 581 | | $pdf->setStyle("normal"); |
| 582 | | $pdf->SetFont("Arial", "B", 10); |
| 583 | | $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.18 + 0.0625); |
| 584 | | |
| 585 | | foreach($this->totalsinfo as $column){ |
| 586 | | |
| 587 | | if($column->format != "") |
| 588 | | $value = formatVariable($this->invoicerecord[$column->fieldname], $column->format); |
| 589 | | else |
| 590 | | $value = $this->invoicerecord[$column->fieldname]; |
| 591 | | |
| 592 | | switch($column->fieldname){ |
| 593 | | case "shipping": |
| 594 | | case "discountamount": |
| 595 | | if($this->invoicerecord[$column->fieldname]) |
| 596 | | $pdf->Cell($column->size, 0.18, $value, $pdf->borderDebug, 0, $column->align); |
| 597 | | break; |
| 598 | | default: |
| 599 | | $pdf->Cell($column->size, 0.18, $value, $pdf->borderDebug, 0, $column->align); |
| 600 | | }//endswitch |
| 601 | | }//end foreach |
| 602 | | $this->totalsinfo[1]->size = 0; |
| 603 | | |
| 604 | | $pdf->SetXY($pdf->leftmargin, $nextPos); |
| 605 | | |
| 606 | | }//end method |
| 607 | | |
| 608 | | |
| 609 | | function _addPaymentDetails(){ |
| 610 | | }//end method |
| 611 | | |
| 612 | | |
| 613 | | function output($destination = "screen" , $userinfo = NULL){ |
| 614 | | |
| 615 | | switch($destination){ |
| 616 | | |
| 617 | | case "screen": |
| 618 | | $userinfo = cleanFilename((string)$userinfo); |
| 619 | | $this->pdf->Output($userinfo, 'D'); |
| 620 | | break; |
| 621 | | |
| 622 | | case "email": |
| 623 | | |
| 624 | | if(!$userinfo) |
| 625 | | $userinfo = $_SESSION["userinfo"]; |
| 626 | | |
| 627 | | if(!$userinfo["email"] || !$this->invoicerecord["email"]) |
| 628 | | return false; |
| 629 | | |
| 630 | | $pdf = $this->pdf->Output(NULL, "S"); |
| 631 | | |
| 632 | | $to = $this->invoicerecord["email"]; |
| 633 | | $from = $userinfo["email"]; |
| 634 | | $subject = "Your ".$this->title." from ".COMPANY_NAME; |
| 635 | | $message = "Attached is your ".$this->title." from ".COMPANY_NAME."\n\n" . |
| 636 | | "The attachment requires Adobe Acrobat Reader to view. \n If you do not " . |
| 637 | | "have Acrobat Reader, you can download it at http://www.adobe.com \n\n" . |
| 638 | | COMPANY_NAME."\n". |
| 639 | | COMPANY_ADDRESS."\n".COMPANY_CSZ."\n".COMPANY_PHONE; |
| 640 | | |
| 641 | | $headers = "From: $from"; |
| 642 | | |
| 643 | | $semi_rand = md5( time() ); |
| 644 | | $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; |
| 645 | | |
| 646 | | $headers .= "\nMIME-Version: 1.0\n" . |
| 647 | | "Content-Type: multipart/mixed;\n" . |
| 648 | | " boundary=\"{$mime_boundary}\""; |
| 649 | | |
| 650 | | $message = "This is a multi-part message in MIME format.\n\n" . |
| 651 | | "--{$mime_boundary}\n" . |
| 652 | | "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . |
| 653 | | "Content-Transfer-Encoding: 7bit\n\n" . |
| 654 | | $message . "\n\n"; |
| 655 | | |
| 656 | | $pdf = chunk_split( base64_encode( $pdf ) ); |
| 657 | | |
| 658 | | $message .= "--{$mime_boundary}\n" . |
| 659 | | "Content-Type: {application/pdf};\n" . |
| 660 | | " name=\"".$this->title.$this->invoicerecord["id"].".pdf\"\n" . |
| 661 | | "Content-Disposition: attachment;\n" . |
| 662 | | " filename=\"".$this->title.$this->invoicerecord["id"].".pdf\"\n" . |
| 663 | | "Content-Transfer-Encoding: base64\n\n" . |
| 664 | | $pdf . "\n\n" . |
| 665 | | "--{$mime_boundary}--\n"; |
| 666 | | |
| 667 | | return @ mail($to, $subject, $message, $headers); |
| 668 | | |
| 669 | | break; |
| 670 | | |
| 671 | | }//endswitch |
| 672 | | |
| 673 | | }//end method |
| 674 | | |
| 675 | | }//end class |
| | 40 | if(!class_exists("phpbmsReport")) |
| | 41 | include("../../../report/report_class.php"); |
| | 42 | |
| | 43 | class invoicePDF extends phpbmsReport{ |
| | 44 | |
| | 45 | var $showShipNameInShipTo = true; |
| | 46 | var $lineitemBoxHeight = 4.25; |
| | 47 | var $templateUUID = NULL; |
| | 48 | |
| | 49 | /** |
| | 50 | * $count |
| | 51 | * @var int The number of invoice records being displayed |
| | 52 | */ |
| | 53 | var $count; |
| | 54 | |
| | 55 | |
| | 56 | function invoicePDF($db, $reportUUID, $tabledefUUID, $orientation='P', $unit='mm', $format='Letter'){ |
| | 57 | |
| | 58 | parent::phpbmsReport($db, $reportUUID, $tabledefUUID); |
| | 59 | |
| | 60 | if(!class_exists("phpbmsPDFReport")) |
| | 61 | include("report/pdfreport_class.php"); |
| | 62 | |
| | 63 | $this->pdf = new phpbmsPDFReport($db, $orientation, $unit, $format); |
| | 64 | |
| | 65 | $this->checkForDefaultSettings(); |
| | 66 | $this->initialize(); |
| | 67 | |
| | 68 | }//end method |
| | 69 | |
| | 70 | |
| | 71 | /** |
| | 72 | * function checkForDefaultSettings |
| | 73 | * |
| | 74 | * Checks to make sure loaded report Settings exist and are correct |
| | 75 | */ |
| | 76 | function checkForDefaultSettings(){ |
| | 77 | |
| | 78 | if(!isset($this->settings["reportTitle"])) |
| | 79 | $this->settings["reportTitle"] = "Invoice"; |
| | 80 | |
| | 81 | if(!isset($this->settings["printLogo"])) |
| | 82 | $this->settings["printLogo"] = 1; |
| | 83 | |
| | 84 | if(!isset($this->settings["printCompanyInfo"])) |
| | 85 | $this->settings["printCompanyInfo"] = 1; |
| | 86 | |
| | 87 | if(!isset($this->settings["leftTopBox"])) |
| | 88 | $this->settings["leftTopBox"] = "billto"; |
| | 89 | |
| | 90 | if(!isset($this->settings["leftTopBoxTitle"])) |
| | 91 | $this->settings["leftTopBoxTitle"] = "SOLD TO"; |
| | 92 | |
| | 93 | if(!isset($this->settings["rightTopBox"])) |
| | 94 | $this->settings["rightTopBox"] = "shipto"; |
| | 95 | |
| | 96 | if(!isset($this->settings["rightTopBoxTitle"])) |
| | 97 | $this->settings["rightTopBoxTitle"] = "SHIP TO"; |
| | 98 | |
| | 99 | if(!isset($this->settings["templateFormatting"])) |
| | 100 | $this->settings["templateFormatting"] = 0; |
| | 101 | |
| | 102 | if(!isset($this->settings["templateUUID"])) |
| | 103 | $this->settings["templateUUID"] = ""; |
| | 104 | |
| | 105 | }//end function checkForDefaultSettings |
| | 106 | |
| | 107 | |
| | 108 | function initialize(){ |
| | 109 | //This function will set column headings, sizes and formatting |
| | 110 | |
| | 111 | $pdf = &$this->pdf; |
| | 112 | |
| | 113 | $topinfo = array(); |
| | 114 | $topinfo[] = new pdfColumn("Order ID", "id", 0.75); |
| | 115 | $topinfo[] = new pdfColumn("Order Date", "orderdate", 1, "date"); |
| | 116 | $topinfo[] = new pdfColumn("Client PO", "ponumber", 1); |
| | 117 | $topinfo[] = new pdfColumn("Processed By", "processedby", 0); |
| | 118 | $topinfo[] = new pdfColumn("Payment Method", "paymentname",2); |
| | 119 | |
| | 120 | $size = 0; |
| | 121 | foreach($topinfo as $column) |
| | 122 | $size += $column->size; |
| | 123 | |
| | 124 | $topinfo[3]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; |
| | 125 | |
| | 126 | $this->topinfo = $topinfo; |
| | 127 | |
| | 128 | |
| | 129 | $lineitems = array(); |
| | 130 | $lineitems[] = new pdfColumn("Product / (Part Number)", "parts", 0); |
| | 131 | $lineitems[] = new pdfColumn("Tax", "taxable", 0.5, "boolean", "C"); |
| | 132 | $lineitems[] = new pdfColumn("Unit Price", "unitprice", 0.75, "currency", "R"); |
| | 133 | $lineitems[] = new pdfColumn("Qty", "quantity", 0.5, "real","R"); |
| | 134 | $lineitems[] = new pdfColumn("Extended", "extended", 0.75, "currency", "R"); |
| | 135 | |
| | 136 | $size = 0; |
| | 137 | foreach($lineitems as $column) |
| | 138 | $size += $column->size; |
| | 139 | |
| | 140 | $lineitems[0]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; |
| | 141 | |
| | 142 | $this->lineitems = $lineitems; |
| | 143 | |
| | 144 | $totalsinfo = array(); |
| | 145 | $totalsinfo[] = new pdfColumn("Discount", "discountamount", 1, "currency", "R"); |
| | 146 | $totalsinfo[] = new pdfColumn("Subtotal", "totaltni", 0, "currency", "R"); |
| | 147 | $totalsinfo[] = new pdfColumn("Tax", "tax", 1, "currency", "R"); |
| | 148 | $totalsinfo[] = new pdfColumn("Shipping", "shipping", 1, "currency", "R"); |
| | 149 | $totalsinfo[] = new pdfColumn("Total", "totalti", 1, "currency", "R"); |
| | 150 | $totalsinfo[] = new pdfColumn("Due", "amountdue", 1, "currency", "R"); |
| | 151 | |
| | 152 | $this->totalsinfo = $totalsinfo; |
| | 153 | |
| | 154 | }//end method |
| | 155 | |
| | 156 | |
| | 157 | function generate($whereclause = NULL, $sortorder = "invoices.id"){ |
| | 158 | |
| | 159 | $pdf = &$this->pdf; |
| | 160 | |
| | 161 | if($whereclause) |
| | 162 | $this->whereClause = $whereclause; |
| | 163 | elseif(!$this->whereClause) |
| | 164 | $this->whereClause = "invoices.id = -400"; |
| | 165 | |
| | 166 | if($sortorder) |
| | 167 | $this->sortOrder = $sortorder; |
| | 168 | elseif(!$this->sortOrder) |
| | 169 | $this->sortOrder = "invoices.id"; |
| | 170 | |
| | 171 | $paymentFields = ""; |
| | 172 | if(ENCRYPT_PAYMENT_FIELDS){ |
| | 173 | |
| | 174 | $paymentFields = " |
| | 175 | ".$this->db->decrypt("`ccnumber`")." AS `ccnumber`, |
| | 176 | ".$this->db->decrypt("`ccverification`")." AS `ccverification`, |
| | 177 | ".$this->db->decrypt("`ccexpiration`")." AS `ccexpiration`, |
| | 178 | ".$this->db->decrypt("`routingnumber`")." AS `routingnumber`, |
| | 179 | ".$this->db->decrypt("`accountnumber`")." AS `accountnumber`, |
| | 180 | "; |
| | 181 | |
| | 182 | }//end if |
| | 183 | |
| | 184 | $querystatement = " |
| | 185 | SELECT |
| | 186 | invoices.*, |
| | 187 | ".$paymentFields." |
| | 188 | |
| | 189 | invoices.totalti - invoices.amountpaid AS amountdue, |
| | 190 | |
| | 191 | clients.firstname, |
| | 192 | clients.lastname, |
| | 193 | clients.company, |
| | 194 | clients.homephone, |
| | 195 | clients.workphone, |
| | 196 | clients.email, |
| | 197 | |
| | 198 | shippingmethods.name AS shippingname, |
| | 199 | |
| | 200 | paymentmethods.name AS paymentname, |
| | 201 | paymentmethods.type AS paymenttype, |
| | 202 | |
| | 203 | tax.name as taxname, |
| | 204 | |
| | 205 | users.firstname AS processorfirst, |
| | 206 | users.lastname AS processorlast |
| | 207 | |
| | 208 | FROM |
| | 209 | invoices INNER JOIN clients ON invoices.clientid = clients.uuid |
| | 210 | INNER JOIN users ON invoices.modifiedby = users.id |
| | 211 | LEFT JOIN shippingmethods ON invoices.shippingmethodid = shippingmethods.uuid |
| | 212 | LEFT JOIN paymentmethods ON invoices.paymentmethodid = paymentmethods.uuid |
| | 213 | LEFT JOIN tax ON invoices.taxareaid = tax.uuid"; |
| | 214 | |
| | 215 | $querystatement = $this->assembleSQL($querystatement); |
| | 216 | |
| | 217 | $queryresult = $this->db->query($querystatement); |
| | 218 | |
| | 219 | $this->count = $this->db->numRows($queryresult); |
| | 220 | if($this->count == 0){ |
| | 221 | |
| | 222 | $this->showNoRecords(); |
| | 223 | exit; |
| | 224 | |
| | 225 | }//end if |
| | 226 | |
| | 227 | $pdf->logoInHeader = $this->settings["printLogo"]; |
| | 228 | $pdf->companyInfoInHeader = $this->settings["printCompanyInfo"]; |
| | 229 | |
| | 230 | $pdf->SetMargins(); |
| | 231 | |
| | 232 | //iterate through each invoice record |
| | 233 | while($invoicerecord = $this->db->fetchArray($queryresult)){ |
| | 234 | |
| | 235 | $this->page = 0; |
| | 236 | |
| | 237 | $this->invoicerecord = $invoicerecord; |
| | 238 | |
| | 239 | //adds top info |
| | 240 | $top = $this->_addPage(); |
| | 241 | |
| | 242 | $this->_addLineItems($top); |
| | 243 | |
| | 244 | $pdf->SetXY($pdf->leftmargin, $top["y"] + $this->lineitemBoxHeight + 0.125); |
| | 245 | |
| | 246 | //Print any special/instructions and stuff |
| | 247 | $this->_addNotes(); |
| | 248 | |
| | 249 | //totals |
| | 250 | $this->_addTotals(); |
| | 251 | |
| | 252 | //payment details |
| | 253 | $this->_addPaymentDetails(); |
| | 254 | |
| | 255 | }//end while; |
| | 256 | |
| | 257 | |
| | 258 | }//end method |
| | 259 | |
| | 260 | |
| | 261 | function _addPage(){ |
| | 262 | |
| | 263 | $pdf = &$this->pdf; |
| | 264 | |
| | 265 | $pdf->AddPage(); |
| | 266 | |
| | 267 | if($this->settings["templateUUID"]){ |
| | 268 | |
| | 269 | if(!isset($GLOBALS["pdfDoc"])){ |
| | 270 | |
| | 271 | $querystatement = " |
| | 272 | SELECT |
| | 273 | `file` |
| | 274 | FROM |
| | 275 | `files` |
| | 276 | WHERE |
| | 277 | `uuid` = '".$this->settings["templateUUID"]."'"; |
| | 278 | |
| | 279 | $queryresult = $this->db->query($querystatement); |
| | 280 | |
| | 281 | $therecord = $this->db->fetchArray($queryresult); |
| | 282 | |
| | 283 | $GLOBALS["pdfDoc"] = $therecord["file"]; |
| | 284 | $pdf->setSourceFile("global://pdfDoc"); |
| | 285 | $this->tplIdx = $pdf->importPage(1); |
| | 286 | |
| | 287 | }//endif |
| | 288 | |
| | 289 | $pdf->useTemplate($this->tplIdx); |
| | 290 | |
| | 291 | }//endif |
| | 292 | |
| | 293 | |
| | 294 | $this->page++; |
| | 295 | |
| | 296 | $nextY = $pdf->getY(); |
| | 297 | |
| | 298 | //TITLE |
| | 299 | $title = "Statement"; |
| | 300 | $titleWidth=2.375; |
| | 301 | $titleHeight=.25; |
| | 302 | $pdf->setStyle("title"); |
| | 303 | $pdf->SetXY(-1*($titleWidth+$pdf->rightmargin), $pdf->topmargin); |
| | 304 | $pdf->Cell($titleWidth, $titleHeight, $this->settings["reportTitle"], $pdf->borderDebug,1,"R"); |
| | 305 | |
| | 306 | $startY = $pdf->GetY() + 0.75; |
| | 307 | |
| | 308 | //page number? |
| | 309 | $pdf->setStyle("normal"); |
| | 310 | $pageNoWidth = 1; |
| | 311 | $pdf->SetFontSize(8); |
| | 312 | $pdf->SetXY(-1*($pageNoWidth + $pdf->rightmargin), $pdf->topmargin + $titleHeight + 0.25); |
| | 313 | $pdf->Cell($pageNoWidth, 0.17, "page: ".$this->page, $pdf->borderDebug,1,"R"); |
| | 314 | |
| | 315 | $boxHeight = 1.75; |
| | 316 | $boxWidth = ($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin)/2 -0.0625; |
| | 317 | |
| | 318 | //Left Top Box |
| | 319 | $this->_addTopBox($this->settings["leftTopBox"], $this->settings["leftTopBoxTitle"], $pdf->leftmargin, $startY, $boxWidth, $boxHeight); |
| | 320 | |
| | 321 | //Right Top Box |
| | 322 | $this->_addTopBox($this->settings["rightTopBox"], $this->settings["rightTopBoxTitle"], $pdf->leftmargin + $boxWidth + 0.125, $startY, $boxWidth, $boxHeight); |
| | 323 | |
| | 324 | $pdf->setXY($pdf->leftmargin, $startY + $boxHeight + 0.125); |
| | 325 | |
| | 326 | $this->_topInvoiceInfo(); |
| | 327 | |
| | 328 | |
| | 329 | $coords["x"] = $pdf->GetX(); |
| | 330 | $coords["y"] = $pdf->GetY(); |
| | 331 | |
| | 332 | if(!$this->settings["templateFormatting"]){ |
| | 333 | |
| | 334 | //line item headings |
| | 335 | $pdf->setStyle("header"); |
| | 336 | $pdf->SetLineWidth(0.02); |
| | 337 | |
| | 338 | foreach($this->lineitems as $column) |
| | 339 | $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); |
| | 340 | |
| | 341 | }//endif |
| | 342 | |
| | 343 | return $coords; |
| | 344 | |
| | 345 | }//end method |
| | 346 | |
| | 347 | |
| | 348 | function _addTopBox($areaToPrint, $title, $x, $y, $boxWidth, $boxHeight){ |
| | 349 | |
| | 350 | if($areaToPrint != "noshow"){ |
| | 351 | |
| | 352 | $pdf = &$this->pdf; |
| | 353 | |
| | 354 | if(!$this->settings["templateFormatting"]){ |
| | 355 | |
| | 356 | $pdf->setLineWidth(0.02); |
| | 357 | $pdf->Rect($x, $y, $boxWidth, $boxHeight); |
| | 358 | $pdf->setLineWidth(0.01); |
| | 359 | |
| | 360 | $pdf->setStyle("header"); |
| | 361 | $pdf->setXY($x, $y); |
| | 362 | $pdf->Cell($boxWidth, 0.17, $title, $pdf->borderDebug, 2, "L", 1); |
| | 363 | $pdf->setStyle("normal"); |
| | 364 | |
| | 365 | } else |
| | 366 | $pdf->SetXY($x ,$y + 0.17); |
| | 367 | |
| | 368 | $pdf->setXY($pdf->GetX(), $pdf->GetY() + 0.0625); |
| | 369 | |
| | 370 | switch($areaToPrint){ |
| | 371 | |
| | 372 | case "billto": |
| | 373 | |
| | 374 | $companyDisplay = ""; |
| | 375 | if($this->invoicerecord["company"]){ |
| | 376 | |
| | 377 | $companyDisplay .= $this->invoicerecord["company"]; |
| | 378 | if($this->invoicerecord["firstname"]) |
| | 379 | $companyDisplay .= " (".$this->invoicerecord["firstname"]." ".$this->invoicerecord["lastname"].")"; |
| | 380 | |
| | 381 | } else |
| | 382 | $companyDisplay .= $this->invoicerecord["firstname"]." ".$this->invoicerecord["lastname"]; |
| | 383 | |
| | 384 | $pdf->SetXY($pdf->GetX() + 0.0625, $pdf->GetY() + 0.0625); |
| | 385 | $pdf->SetFont("Arial", "B", 10); |
| | 386 | $pdf->Cell($boxWidth - 0.125, 0.17, $companyDisplay, $pdf->borderDebug, 2, "L"); |
| | 387 | |
| | 388 | $billto = $this->_setBillTo(); |
| | 389 | $pdf->SetFont("Arial", "", 10); |
| | 390 | $pdf->setXY($pdf->GetX(), $pdf->GetY() + 0.0625); |
| | 391 | $pdf->MultiCell($boxWidth - 0.125,.17,$billto, $pdf->borderDebug); |
| | 392 | break; |
| | 393 | |
| | 394 | case "shipto": |
| | 395 | |
| | 396 | $pdf->SetXY($pdf->GetX() + 0.0625, $pdf->GetY() + 0.0625); |
| | 397 | $pdf->SetFont("Arial", "B", 10); |
| | 398 | |
| | 399 | $shipDisplay = (!$this->invoicerecord["shiptosameasbilling"] && $this->invoicerecord["shiptoname"])? $this->invoicerecord["shiptoname"] :$companyDisplay; |
| | 400 | $pdf->Cell($boxWidth - 0.125, 0.17, $shipDisplay, $pdf->borderDebug, 2, "L"); |
| | 401 | |
| | 402 | $shipto = $this->_setShipTo(); |
| | 403 | $pdf->SetFont("Arial", "", 10); |
| | 404 | $pdf->setXY($pdf->GetX(), $pdf->GetY() + 0.0625); |
| | 405 | $pdf->MultiCell($boxWidth - 0.125,.17, $shipto, $pdf->borderDebug); |
| | 406 | break; |
| | 407 | |
| | 408 | case "companyinfo": |
| | 409 | |
| | 410 | $cname = COMPANY_NAME; |
| | 411 | $caddress = COMPANY_ADDRESS."\n".COMPANY_CSZ."\n".COMPANY_PHONE; |
| | 412 | |
| | 413 | $pdf->SetXY($pdf->GetX() + 0.0625, $pdf->GetY() + 0.0625); |
| | 414 | $pdf->SetFont("Arial","B",10); |
| | 415 | $pdf->Cell($boxWidth - 0.125, 0.17, $cname, $pdf->borderDebug, 2, "L"); |
| | 416 | |
| | 417 | //and last, company address |
| | 418 | $pdf->setXY($pdf->GetX(), $pdf->GetY() + 0.0625); |
| | 419 | $pdf->SetFont("Arial", "", 10); |
| | 420 | $pdf->MultiCell($boxWidth - 0.125,.17 , $caddress, $pdf->borderDebug); |
| | 421 | break; |
| | 422 | |
| | 423 | case "invoiceinfo": |
| | 424 | |
| | 425 | $pdf->SetXY($pdf->GetX() + 0.0625, $pdf->GetY() + 0.0625); |
| | 426 | $pdf->SetFont("Arial","B",14); |
| | 427 | $pdf->Cell($boxWidth - 0.125, 0.25, $this->invoicerecord["id"], $pdf->borderDebug, 2, "R"); |
| | 428 | |
| | 429 | |
| | 430 | $details = "payment method\n".$this->invoicerecord["paymentname"]; |
| | 431 | $pdf->setXY($pdf->GetX(), $pdf->GetY() + 0.125); |
| | 432 | $pdf->SetFont("Arial", "", 8); |
| | 433 | $pdf->MultiCell($boxWidth - 0.125,.17, $details, $pdf->borderDebug, "R"); |
| | 434 | |
| | 435 | break; |
| | 436 | |
| | 437 | }//endswitch |
| | 438 | |
| | 439 | }//endif |
| | 440 | |
| | 441 | }//end function _addTopBox |
| | 442 | |
| | 443 | |
| | 444 | function _setBillTo(){ |
| | 445 | |
| | 446 | $billto = $this->invoicerecord["address1"]; |
| | 447 | |
| | 448 | if($this->invoicerecord["address2"]) |
| | 449 | $billto .= "\n".$this->invoicerecord["address2"]; |
| | 450 | |
| | 451 | $billto .="\n".$this->invoicerecord["city"].", ".$this->invoicerecord["state"]." ".$this->invoicerecord["postalcode"]; |
| | 452 | |
| | 453 | if($this->invoicerecord["country"]) |
| | 454 | $billto .=" ".$this->invoicerecord["country"]; |
| | 455 | |
| | 456 | $phoneemail = ""; |
| | 457 | if($this->invoicerecord["workphone"] || $this->invoicerecord["homephone"]){ |
| | 458 | |
| | 459 | if($this->invoicerecord["workphone"]) |
| | 460 | $phoneemail = $this->invoicerecord["workphone"]." (W)"; |
| | 461 | else |
| | 462 | $phoneemail = $this->invoicerecord["homephone"]." (H)"; |
| | 463 | |
| | 464 | $phoneemail.="\n"; |
| | 465 | |
| | 466 | }//end if |
| | 467 | |
| | 468 | if($this->invoicerecord["email"]) |
| | 469 | $phoneemail .= $this->invoicerecord["email"]; |
| | 470 | |
| | 471 | if($phoneemail) |
| | 472 | $billto .= "\n\n".$phoneemail; |
| | 473 | |
| | 474 | return $billto; |
| | 475 | |
| | 476 | }//end method |
| | 477 | |
| | 478 | |
| | 479 | function _setShipTo(){ |
| | 480 | |
| | 481 | $added = ($this->invoicerecord["shiptosameasbilling"])? "" : "shipto"; |
| | 482 | |
| | 483 | $shipto = ""; |
| | 484 | |
| | 485 | $shipto .= $this->invoicerecord[$added."address1"]; |
| | 486 | |
| | 487 | if($this->invoicerecord[$added."address2"]) |
| | 488 | $shipto .= "\n".$this->invoicerecord[$added."address2"]; |
| | 489 | |
| | 490 | $shipto .="\n".$this->invoicerecord[$added."city"].", ".$this->invoicerecord[$added."state"]." ".$this->invoicerecord[$added."postalcode"]; |
| | 491 | |
| | 492 | if($this->invoicerecord[$added."country"]) |
| | 493 | $shipto .=" ".$this->invoicerecord[$added."country"]; |
| | 494 | |
| | 495 | if($this->showShipNameInShipTo) |
| | 496 | if($this->invoicerecord["shippingname"]) |
| | 497 | $shipto .="\n\nShipping Method:\n".$this->invoicerecord["shippingname"]; |
| | 498 | |
| | 499 | return $shipto; |
| | 500 | |
| | 501 | }//end method |
| | 502 | |
| | 503 | |
| | 504 | function _topInvoiceInfo(){ |
| | 505 | |
| | 506 | $pdf = &$this->pdf; |
| | 507 | |
| | 508 | if(!$this->settings["templateFormatting"]){ |
| | 509 | |
| | 510 | $pdf->setStyle("header"); |
| | 511 | $pdf->SetLineWidth(0.02); |
| | 512 | |
| | 513 | foreach($this->topinfo as $column) |
| | 514 | $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); |
| | 515 | |
| | 516 | $pdf->Rect($pdf->leftmargin, $pdf->GetY(), ($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin), 0.39); |
| | 517 | |
| | 518 | }//endif |
| | 519 | |
| | 520 | $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + .2); |
| | 521 | |
| | 522 | |
| | 523 | $this->invoicerecord["processedby"] = $this->invoicerecord["processorfirst"]." ".$this->invoicerecord["processorlast"]; |
| | 524 | $pdf->setStyle("normal"); |
| | 525 | |
| | 526 | foreach($this->topinfo as $column){ |
| | 527 | |
| | 528 | if($column->format != "") |
| | 529 | $value = formatVariable($this->invoicerecord[$column->fieldname], $column->format); |
| | 530 | else |
| | 531 | $value = $this->invoicerecord[$column->fieldname]; |
| | 532 | |
| | 533 | $pdf->Cell($column->size, 0.18, $value, $pdf->borderDebug, 0, $column->align); |
| | 534 | |
| | 535 | }//end foreach |
| | 536 | |
| | 537 | $pdf->SetY($pdf->GetY() + 0.18 + 0.125); |
| | 538 | |
| | 539 | }//end method |
| | 540 | |
| | 541 | |
| | 542 | function _addLineItems($coords){ |
| | 543 | |
| | 544 | $pdf = &$this->pdf; |
| | 545 | |
| | 546 | $lineitemresult = $this->_getLineItems(); |
| | 547 | |
| | 548 | $pdf->setStyle("normal"); |
| | 549 | |
| | 550 | $pdf->SetY($pdf->GetY() + 0.18 + 0.0625); |
| | 551 | |
| | 552 | while($line = $this->db->fetchArray($lineitemresult)){ |
| | 553 | |
| | 554 | |
| | 555 | if($line["partname"] || $line["partnumber"] || $line["extended"]){ |
| | 556 | |
| | 557 | if($pdf->GetY() + 0.17*3 > $coords["y"] + $this->lineitemBoxHeight){ |
| | 558 | |
| | 559 | if(!$this->settings["templateFormatting"]){ |
| | 560 | |
| | 561 | $pdf->SetLineWidth(0.02); |
| | 562 | $pdf->Rect($coords["x"], $coords["y"], $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $this->lineitemBoxHeight); |
| | 563 | $pdf->SetLineWidth(0.01); |
| | 564 | |
| | 565 | }//endif |
| | 566 | |
| | 567 | $this->_addPage(); |
| | 568 | |
| | 569 | $pdf->setStyle("normal"); |
| | 570 | |
| | 571 | $pdf->SetY($pdf->GetY() + 0.18 + 0.0625); |
| | 572 | |
| | 573 | }//end if |
| | 574 | |
| | 575 | foreach($this->lineitems as $column){ |
| | 576 | |
| | 577 | $ln = 0; |
| | 578 | |
| | 579 | |
| | 580 | switch($column->fieldname){ |
| | 581 | |
| | 582 | case "parts": |
| | 583 | $pdf->SetFont("Arial", "B", 8); |
| | 584 | $pdf->Write(0.17, $line["partname"]); |
| | 585 | $pdf->setStyle("normal"); |
| | 586 | $pdf->SetX($pdf->leftmargin + $column->size); |
| | 587 | break; |
| | 588 | |
| | 589 | default: |
| | 590 | if($column->format != "") |
| | 591 | $value = formatVariable($line[$column->fieldname], $column->format); |
| | 592 | else |
| | 593 | $value = $line[$column->fieldname]; |
| | 594 | |
| | 595 | if($value == "·") |
| | 596 | $value = " "; |
| | 597 | if($column->fieldname == $this->lineitems[count($this->lineitems)-1]->fieldname) |
| | 598 | $ln = 2; |
| | 599 | |
| | 600 | $pdf->Cell($column->size, 0.17, $value, $pdf->borderDebug, $ln, $column->align); |
| | 601 | break; |
| | 602 | |
| | 603 | }//end switch |
| | 604 | |
| | 605 | }//end foreach |
| | 606 | |
| | 607 | $pdf->SetX($pdf->leftmargin); |
| | 608 | $pdf->Write(0.17, "(".$line["partnumber"].")"); |
| | 609 | $pdf->Ln(); |
| | 610 | |
| | 611 | }//endif |
| | 612 | |
| | 613 | if($line["memo"]){ |
| | 614 | |
| | 615 | $pdf->SetX($pdf->leftmargin + 0.0625); |
| | 616 | $pdf->SetFont("Arial", "I", 8); |
| | 617 | $pdf->MultiCell($this->lineitems[0]->size - 0.0625, 0.16, $line["memo"], $pdf->borderDebug); |
| | 618 | $pdf->setStyle("normal"); |
| | 619 | |
| | 620 | }//end if |
| | 621 | |
| | 622 | if(!$this->settings["templateFormatting"]){ |
| | 623 | |
| | 624 | $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.0625); |
| | 625 | $pdf->SetLineWidth(0.01); |
| | 626 | $pdf->SetDrawColor(180,180,180); |
| | 627 | $pdf->Line($pdf->leftmargin, $pdf->GetY(), $pdf->paperwidth - $pdf->rightmargin, $pdf->GetY()); |
| | 628 | $pdf->SetDrawColor(0,0,0); |
| | 629 | $pdf->SetLineWidth(0.02); |
| | 630 | |
| | 631 | }//endif |
| | 632 | |
| | 633 | $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.0625); |
| | 634 | |
| | 635 | }//end while |
| | 636 | |
| | 637 | if(!$this->settings["templateFormatting"]){ |
| | 638 | |
| | 639 | $pdf->SetLineWidth(0.02); |
| | 640 | $pdf->Rect($coords["x"], $coords["y"], $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $this->lineitemBoxHeight); |
| | 641 | $pdf->SetLineWidth(0.01); |
| | 642 | |
| | 643 | }//endif |
| | 644 | |
| | 645 | }//end method |
| | 646 | |
| | 647 | |
| | 648 | function _getLineItems(){ |
| | 649 | |
| | 650 | $querystatement = " |
| | 651 | SELECT |
| | 652 | lineitems.*, |
| | 653 | lineitems.quantity * lineitems.unitprice AS extended, |
| | 654 | products.partname, |
| | 655 | products.partnumber |
| | 656 | FROM |
| | 657 | lineitems LEFT JOIN products ON lineitems.productid = products.uuid |
| | 658 | WHERE |
| | 659 | lineitems.invoiceid ='".((int) $this->invoicerecord["id"])."' |
| | 660 | ORDER BY |
| | 661 | displayorder"; |
| | 662 | |
| | 663 | $queryresult = $this->db->query($querystatement); |
| | 664 | |
| | 665 | return $queryresult; |
| | 666 | |
| | 667 | }//end method |
| | 668 | |
| | 669 | |
| | 670 | function _addNotes(){ |
| | 671 | |
| | 672 | $pdf = &$this->pdf; |
| | 673 | |
| | 674 | $height = 1; |
| | 675 | $nextPos = $pdf->GetY() + $height + 0.125; |
| | 676 | |
| | 677 | if(!$this->settings["templateFormatting"]){ |
| | 678 | |
| | 679 | $pdf->Rect($pdf->GetX(), $pdf->GetY(), $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $height); |
| | 680 | $pdf->setStyle("header"); |
| | 681 | $pdf->Cell($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, 0.18, "Notes/Instructions", 1, 2, "L", 1); |
| | 682 | $pdf->setStyle("normal"); |
| | 683 | |
| | 684 | } else |
| | 685 | $pdf->SetY($pdf->GetY() + 0.18); |
| | 686 | |
| | 687 | $pdf->SetXY($pdf->GetX() + .06125, $pdf->GetY() + .06125); |
| | 688 | $pdf->MultiCell($pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - 0.125, 0.18, $this->invoicerecord["printedinstructions"]); |
| | 689 | |
| | 690 | $pdf->SetXY($pdf->leftmargin, $nextPos); |
| | 691 | |
| | 692 | }//end method |
| | 693 | |
| | 694 | |
| | 695 | function _addTotals(){ |
| | 696 | |
| | 697 | $pdf = &$this->pdf; |
| | 698 | |
| | 699 | $size = 0; |
| | 700 | foreach($this->totalsinfo as $column) |
| | 701 | switch($column->fieldname){ |
| | 702 | case "shipping": |
| | 703 | case "discountamount": |
| | 704 | if($this->invoicerecord[$column->fieldname]) |
| | 705 | $size += $column->size; |
| | 706 | break; |
| | 707 | default: |
| | 708 | $size += $column->size; |
| | 709 | }//endswitch |
| | 710 | $this->totalsinfo[1]->size = $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin - $size; |
| | 711 | |
| | 712 | $height = .5; |
| | 713 | $nextPos = $pdf->GetY() + $height + 0.125; |
| | 714 | |
| | 715 | if(!$this->settings["templateFormatting"]){ |
| | 716 | |
| | 717 | $pdf->Rect($pdf->GetX(), $pdf->GetY(), $pdf->paperwidth - $pdf->leftmargin - $pdf->rightmargin, $height); |
| | 718 | |
| | 719 | $pdf->setStyle("header"); |
| | 720 | foreach($this->totalsinfo as $column) |
| | 721 | switch($column->fieldname){ |
| | 722 | |
| | 723 | case "shipping": |
| | 724 | case "discountamount": |
| | 725 | if($this->invoicerecord[$column->fieldname]) |
| | 726 | $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); |
| | 727 | break; |
| | 728 | |
| | 729 | default: |
| | 730 | $pdf->Cell($column->size, 0.18, $column->title, 1, 0, $column->align, 1); |
| | 731 | |
| | 732 | }//endswitch |
| | 733 | |
| | 734 | }//endif |
| | 735 | |
| | 736 | $pdf->setStyle("normal"); |
| | 737 | $pdf->SetFont("Arial", "B", 10); |
| | 738 | $pdf->SetXY($pdf->leftmargin, $pdf->GetY() + 0.18 + 0.0625); |
| | 739 | |
| | 740 | foreach($this->totalsinfo as $column){ |
| | 741 | |
| | 742 | if($column->format != "") |
| | 743 | $value = formatVariable($this->invoicerecord[$column->fieldname], $column->format); |
| | 744 | else |
| | 745 | $value = $this->invoicerecord[$column->fieldname]; |
| | 746 | |
| | 747 | switch($column->fieldname){ |
| | 748 | case "shipping": |
| | 749 | case "discountamount": |
| | 750 | if($this->invoicerecord[$column->fieldname]) |
| | 751 | $pdf->Cell($column->size, 0.18, $value, $pdf->borderDebug, 0, $column->align); |
| | 752 | break; |
| | 753 | default: |
| | 754 | $pdf->Cell($column->size, 0.18, $value, $pdf->borderDebug, 0, $column->align); |
| | 755 | }//endswitch |
| | 756 | }//end foreach |
| | 757 | $this->totalsinfo[1]->size = 0; |
| | 758 | |
| | 759 | $pdf->SetXY($pdf->leftmargin, $nextPos); |
| | 760 | |
| | 761 | }//end method |
| | 762 | |
| | 763 | |
| | 764 | function _addPaymentDetails(){ |
| | 765 | }//end method |
| | 766 | |
| | 767 | |
| | 768 | function output($destination = "screen" , $userinfo = NULL){ |
| | 769 | |
| | 770 | switch($destination){ |
| | 771 | |
| | 772 | case "screen": |
| | 773 | $userinfo = cleanFilename((string)$userinfo); |
| | 774 | $this->pdf->Output($userinfo, 'D'); |
| | 775 | break; |
| | 776 | |
| | 777 | case "email": |
| | 778 | |
| | 779 | if(!$userinfo) |
| | 780 | $userinfo = $_SESSION["userinfo"]; |
| | 781 | |
| | 782 | if(!$userinfo["email"] || !$this->invoicerecord["email"]) |
| | 783 | return false; |
| | 784 | |
| | 785 | $pdf = $this->pdf->Output(NULL, "S"); |
| | 786 | |
| | 787 | $to = $this->invoicerecord["email"]; |
| | 788 | $from = $userinfo["email"]; |
| | 789 | $subject = "Your ".$this->title." from ".COMPANY_NAME; |
| | 790 | $message = "Attached is your ".$this->title." from ".COMPANY_NAME."\n\n" . |
| | 791 | "The attachment requires Adobe Acrobat Reader to view. \n If you do not " . |
| | 792 | "have Acrobat Reader, you can download it at http://www.adobe.com \n\n" . |
| | 793 | COMPANY_NAME."\n". |
| | 794 | COMPANY_ADDRESS."\n".COMPANY_CSZ."\n".COMPANY_PHONE; |
| | 795 | |
| | 796 | $headers = "From: $from"; |
| | 797 | |
| | 798 | $semi_rand = md5( time() ); |
| | 799 | $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; |
| | 800 | |
| | 801 | $headers .= "\nMIME-Version: 1.0\n" . |
| | 802 | "Content-Type: multipart/mixed;\n" . |
| | 803 | " boundary=\"{$mime_boundary}\""; |
| | 804 | |
| | 805 | $message = "This is a multi-part message in MIME format.\n\n" . |
| | 806 | "--{$mime_boundary}\n" . |
| | 807 | "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . |
| | 808 | "Content-Transfer-Encoding: 7bit\n\n" . |
| | 809 | $message . "\n\n"; |
| | 810 | |
| | 811 | $pdf = chunk_split( base64_encode( $pdf ) ); |
| | 812 | |
| | 813 | $message .= "--{$mime_boundary}\n" . |
| | 814 | "Content-Type: {application/pdf};\n" . |
| | 815 | " name=\"".$this->title.$this->invoicerecord["id"].".pdf\"\n" . |
| | 816 | "Content-Disposition: attachment;\n" . |
| | 817 | " filename=\"".$this->title.$this->invoicerecord["id"].".pdf\"\n" . |
| | 818 | "Content-Transfer-Encoding: base64\n\n" . |
| | 819 | $pdf . "\n\n" . |
| | 820 | "--{$mime_boundary}--\n"; |
| | 821 | |
| | 822 | return @ mail($to, $subject, $message, $headers); |
| | 823 | |
| | 824 | break; |
| | 825 | |
| | 826 | }//endswitch |
| | 827 | |
| | 828 | }//end method |
| | 829 | |
| | 830 | |
| | 831 | /** |
| | 832 | * function addingRecordDefaultSettings |
| | 833 | * |
| | 834 | * Creates an array of settings associative arrays for use by the system when |
| | 835 | * a new report record is added that references the file containing this class |
| | 836 | * |
| | 837 | * @retrun array of settings. Each setting should itself be |
| | 838 | * an associative array containing the following |
| | 839 | * name: name of the setting |
| | 840 | * defaultvalue: default value for setting |
| | 841 | * type: (string, int, real, bool) type for value of setting |
| | 842 | * required: (0,1) whether the setting is required or not |
| | 843 | * description: brief description for what this setting is used for. |
| | 844 | */ |
| | 845 | function addingRecordDefaultSettings(){ |
| | 846 | |
| | 847 | $settings[] = array( |
| | 848 | "name"=>"reportTitle", |
| | 849 | "defaultValue"=>"Invoice", |
| | 850 | "type"=>"string", |
| | 851 | "required"=>1, |
| | 852 | "description"=>"Title printed on reports" |
| | 853 | ); |
| | 854 | |
| | 855 | $settings[] = array( |
| | 856 | "name"=>"printLogo", |
| | 857 | "defaultValue"=>1, |
| | 858 | "type"=>"bool", |
| | 859 | "required"=>1, |
| | 860 | "description"=>"Should the logo print (1 = yes, 0 = no)" |
| | 861 | ); |
| | 862 | |
| | 863 | $settings[] = array( |
| | 864 | "name"=>"printCompanyInfo", |
| | 865 | "defaultValue"=>1, |
| | 866 | "type"=>"bool", |
| | 867 | "required"=>1, |
| | 868 | "description"=>"Should the top company information print (1 = yes, 0 = no)" |
| | 869 | ); |
| | 870 | |
| | 871 | $settings[] = array( |
| | 872 | "name"=>"leftTopBox", |
| | 873 | "defaultValue"=>"billto", |
| | 874 | "type"=>"string", |
| | 875 | "required"=>1, |
| | 876 | "description"=>"Contents of Right Top Header Box (can be `billto`, `shipto`, `invoiceinfo`, `companyinfo`, `nowshow` or `blank`)" |
| | 877 | ); |
| | 878 | |
| | 879 | $settings[] = array( |
| | 880 | "name"=>"leftTopBoxTitle", |
| | 881 | "defaultValue"=>"SOLD TO", |
| | 882 | "type"=>"string", |
| | 883 | "required"=>1, |
| | 884 | "description"=>"Title of Left Top Header Box" |
| | 885 | ); |
| | 886 | |
| | 887 | $settings[] = array( |
| | 888 | "name"=>"rightTopBox", |
| | 889 | "defaultValue"=>"shipto", |
| | 890 | "type"=>"string", |
| | 891 | "required"=>1, |
| | 892 | "description"=>"Contents of Right Top Header Box (can be `billto`, `shipto`, `invoiceinfo`, `companyinfo`, `nowshow` or `blank`)" |
| | 893 | ); |
| | 894 | |
| | 895 | $settings[] = array( |
| | 896 | "name"=>"rightTopBoxTitle", |
| | 897 | "defaultValue"=>"SHIP TO", |
| | 898 | "type"=>"string", |
| | 899 | "required"=>1, |
| | 900 | "description"=>"Title of Right Top Header Box" |
| | 901 | ); |
| | 902 | |
| | 903 | $settings[] = array( |
| | 904 | "name"=>"templateFormatting", |
| | 905 | "defaultValue"=>"0", |
| | 906 | "type"=>"bool", |
| | 907 | "required"=>1, |
| | 908 | "description"=>"Should PDF remove lines and dark titles (1 = remove, 0 = keep)" |
| | 909 | ); |
| | 910 | |
| | 911 | $settings[] = array( |
| | 912 | "name"=>"templateUUID", |
| | 913 | "defaultValue"=>"", |
| | 914 | "type"=>"string", |
| | 915 | "required"=>0, |
| | 916 | "description"=>"Optional UUID of file record for PDF to be used as background template" |
| | 917 | ); |
| | 918 | |
| | 919 | return $settings; |
| | 920 | |
| | 921 | }//endfunction addingRecordDefaultSettings |
| | 922 | |
| | 923 | }//end class |