2011-07-14 09:09:03 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
2011-05-02 12:28:17 +00:00
|
|
|
/**
|
2011-07-14 09:09:03 +00:00
|
|
|
* This class provides invoice PDF rendering capability
|
|
|
|
*
|
2013-03-19 22:35:19 +00:00
|
|
|
* @package Invoice
|
2011-07-14 09:09:03 +00:00
|
|
|
* @category Helpers
|
|
|
|
* @author Deon George
|
2013-03-19 22:35:19 +00:00
|
|
|
* @copyright (c) 2009-2013 Open Source Billing
|
|
|
|
* @license http://dev.osbill.net/license.html
|
2011-05-02 12:28:17 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
define('FPDF_FONTPATH','includes/tcpdf/fonts/');
|
|
|
|
require_once('includes/tcpdf/tcpdf.php');
|
|
|
|
|
2011-07-14 09:09:03 +00:00
|
|
|
abstract class Invoice_TCPDF extends TCPDF {
|
2011-05-02 12:28:17 +00:00
|
|
|
// Our invoice object
|
|
|
|
protected $io;
|
2013-02-12 11:14:59 +00:00
|
|
|
// Our company object
|
|
|
|
protected $co;
|
2011-05-02 12:28:17 +00:00
|
|
|
|
|
|
|
protected $billToCompany = true;
|
|
|
|
protected $itemsSummaryMax = 16;
|
|
|
|
protected $itemsPreviousMax = 5;
|
|
|
|
protected $news = '';
|
|
|
|
protected $pageType = 'blank';
|
|
|
|
protected $show_itemized = true;
|
|
|
|
protected $show_service_range = false;
|
|
|
|
private $invoiceCurrency = '$';
|
|
|
|
private $invoiceDecimals = 2;
|
|
|
|
|
|
|
|
# Store previous invoices due
|
|
|
|
private $itemsPrevious = array();
|
|
|
|
# Stores the invoice items
|
|
|
|
protected $invoice;
|
|
|
|
protected $itemsFull;
|
|
|
|
protected $account;
|
|
|
|
# Iteration of drawing the items on the invoice
|
|
|
|
protected $iteration;
|
|
|
|
# Store the date range, that the invoice covers
|
|
|
|
protected $dateRange;
|
|
|
|
|
|
|
|
public function __construct($io) {
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
$this->io = $io;
|
2013-02-12 11:14:59 +00:00
|
|
|
$this->co = Company::instance();
|
2011-05-02 12:28:17 +00:00
|
|
|
|
|
|
|
// Set up the invoice
|
|
|
|
$this->SetCreator('Open Source Billing');
|
2013-02-12 11:14:59 +00:00
|
|
|
$this->SetAuthor($this->co->name());
|
|
|
|
$this->SetTitle(sprintf('%s Invoice',$this->co->name()));
|
2011-07-14 09:09:03 +00:00
|
|
|
$this->SetSubject(sprintf('Invoice #%06s',$this->io->id()));
|
|
|
|
$this->SetKeywords($this->io->id());
|
2011-05-02 12:28:17 +00:00
|
|
|
$this->SetAutoPageBreak(TRUE,25);
|
|
|
|
$this->SetHeaderMargin(1);
|
|
|
|
$this->SetFooterMargin(10);
|
|
|
|
$this->SetDisplayMode('fullwidth');
|
|
|
|
#$this->setHeaderFont(array('helvetica','',8));
|
|
|
|
$this->setFooterFont(array('helvetica','',8));
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract public function drawCompanyLogo();
|
|
|
|
abstract public function drawCompanyAddress();
|
|
|
|
abstract public function drawInvoiceHeader();
|
|
|
|
abstract public function drawSummaryLineItems();
|
|
|
|
abstract public function drawPaymentMethods();
|
|
|
|
abstract public function drawRemittenceStub();
|
|
|
|
|
|
|
|
public function drawCustom() {}
|
|
|
|
public function drawInvoiceDueNotice() {}
|
|
|
|
public function drawInvoicePaidNotice() {}
|
|
|
|
public function setLateFeeNotice() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a PDF invoice template
|
|
|
|
*/
|
|
|
|
public function getTemplate() {}
|
|
|
|
|
|
|
|
/*
|
|
|
|
public function setItemsFull($items) {
|
|
|
|
$this->itemsFull = $items;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setItemsPrevious($items) {
|
|
|
|
$this->itemsPrevious = $items;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setDateRange($periodStart,$periodEnd) {
|
|
|
|
$this->dateRange = sprintf('%s - %s',date(UNIX_DATE_FORMAT,$periodStart),date(UNIX_DATE_FORMAT,$periodEnd));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setCurrency($currency) {
|
|
|
|
$this->invoiceCurrency = $currency;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setDecimals($decimals) {
|
|
|
|
$this->invoiceDecimals = $decimals;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render an amount into a currency display
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
protected function _currency($num) {
|
|
|
|
global $C_list;
|
|
|
|
|
|
|
|
if ($this->invoiceDecimals>3)
|
|
|
|
return $this->invoiceCurrency.number_format($num,$this->invoiceDecimals);
|
|
|
|
else
|
|
|
|
return $C_list->format_currency_num($num,$this->invoice['actual_billed_currency_id']);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a watermark to the PDF
|
|
|
|
*/
|
|
|
|
public function addWaterMark($text) {
|
|
|
|
$this->SetFont('helvetica','B',50);
|
|
|
|
$this->SetTextColor(203,203,203);
|
|
|
|
$this->Rotate(0);
|
|
|
|
$this->Text(10,50,$text);
|
|
|
|
$this->Rotate(0);
|
|
|
|
$this->SetTextColor(0,0,0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|