Advertisement
Guest User

WHMCS invoicepdf.tpl mods to save PDF files

a guest
Dec 5th, 2013
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.48 KB | None | 0 0
  1. <?php
  2.  
  3. if ($status == 'Paid' || file_exists('/home/whmcs/invoices/' . (int)$invoiceid . '.pdf')) {
  4.     if (get_class($pdf) != 'PDFDecorator') {
  5.         class PDFDecorator {
  6.             protected $_instance;
  7.             public $_invoiceid = 0, $_multi_invoice = 0;
  8.  
  9.             public function __construct($instance) {
  10.                 $this->_instance = $instance;
  11.             }
  12.             public function __get($prop) {
  13.                 return $this->_instance->$prop;
  14.             }
  15.             public function __set($prop, $val) {
  16.                 return $this->_instance->$prop = $val;
  17.             }
  18.             public function __call($method, $args) {
  19.                 return call_user_func_array(array($this->_instance, $method), $args);
  20.             }
  21.             public function Output($name = 'doc.pdf', $dest = 'I') {
  22.                 if (!$this->_multi_invoice && $dest == 'S') {
  23.                     if (!file_exists('/home/whmcs/invoices/' . $this->_invoiceid . '.pdf'))
  24.                         $this->_instance->Output('/home/whmcs/invoices/' . $this->_invoiceid . '.pdf', 'F');
  25.                     return file_get_contents('/home/whmcs/invoices/' . $this->_invoiceid . '.pdf');
  26.                 }
  27.                 return $this->_instance->Output($name, $dest);
  28.             }
  29.         }
  30.         $pdf = new PDFDecorator($pdf);
  31.     }
  32.     if ($pdf->_invoiceid)
  33.         $pdf->_multi_invoice = 1;
  34.     else
  35.         $pdf->_invoiceid = (int)$invoiceid;
  36. }
  37.  
  38. /* rest of invoicepdf.tpl */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement