Changes to AgileBill
This commit is contained in:
621
modules/invoice/PDF/pdf_invoice_itemised-fpdf.inc.php
Normal file
621
modules/invoice/PDF/pdf_invoice_itemised-fpdf.inc.php
Normal file
@@ -0,0 +1,621 @@
|
||||
<?php
|
||||
/**
|
||||
* Graytech Hosting - Highly detailed PDF invoice
|
||||
*/
|
||||
require_once PATH_MODULES.'invoice/invoice_base_fpdf.inc.php';
|
||||
|
||||
class pdf_invoice_overview extends pdf_invoice_base {
|
||||
var $v, $i, $y;
|
||||
|
||||
# Current line being printed
|
||||
private $sum_y = 0;
|
||||
|
||||
/**
|
||||
* Draw the logo
|
||||
*/
|
||||
public function drawCompanyLogo() {
|
||||
$x = 9; $y = 7;
|
||||
$size = 25;
|
||||
$logo = sprintf('%s/%s',PATH_THEMES.DEFAULT_THEME,'invoice/invoice-logo.png');
|
||||
|
||||
if (is_file($logo))
|
||||
$this->Image($logo,$x,$y,$size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the Company Address
|
||||
*/
|
||||
public function drawCompanyAddress($inv) {
|
||||
global $C_translate;
|
||||
|
||||
# Add the company address next to the logo
|
||||
$x = 40; $y = 9;
|
||||
|
||||
$this->SetFont('arial','B',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$inv->print['site']['NAME']); $y += 4;
|
||||
|
||||
$this->SetFont('arial','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$inv->print['site']['TAXID']); $y += 6;
|
||||
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$inv->print['site']['ADDRESS']); $y += 4;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%s, %s %s',$inv->print['site']['CITY'],$inv->print['site']['STATE'],$inv->print['site']['ZIP'])); $y += 4;
|
||||
|
||||
$y += 2;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Phone:'); $this->SetXY($x+16,$y); $this->Cell(0,0,$inv->print['site']['PHONE']); $y += 4;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Fax:'); $this->SetXY($x+16,$y); $this->Cell(0,0,$inv->print['site']['FAX']); $y += 4;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Web:'); $this->SetXY($x+16,$y); $this->Cell(0,0,$inv->print['site']['URL']); $y += 4;
|
||||
}
|
||||
|
||||
public function drawRemittenceStub($inv) {
|
||||
global $C_translate;
|
||||
|
||||
# Draw the remittance line
|
||||
$this->Line(9,195,200,195);
|
||||
|
||||
$x = 18; $y = 200;
|
||||
|
||||
$this->SetFont('arial','B',13);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_payment_remit','setup_invoice')); $y +=5;
|
||||
|
||||
$this->SetFont('arial','',8);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_return1','setup_invoice')); $y +=3;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_return2','setup_invoice').' '.$inv->print['site']['NAME']);
|
||||
|
||||
# Due Date
|
||||
$x = 110; $y = 200;
|
||||
$this->SetFont('arial','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_bill_date','setup_invoice'));
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,date(UNIX_DATE_FORMAT,$inv->print['invoice']['date_orig']),0,0,'R');
|
||||
|
||||
# Account ID
|
||||
$y = 205;
|
||||
$this->SetFont('arial','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_account_number','setup_invoice'));
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%06s',$inv->print['account']['id']),0,0,'R');
|
||||
|
||||
# Invoice number
|
||||
$y = 210;
|
||||
$this->SetFont('arial','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number','setup_invoice'));
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%06s',$inv->getInvoiceNum()),0,0,'R');
|
||||
|
||||
# Company Address
|
||||
$y = 216;
|
||||
$this->SetFont('arial','',10);
|
||||
$this->SetXY(18,$y); $this->Cell(0,0,$inv->print['site']['NAME']); $y += 4;
|
||||
$this->SetXY(18,$y); $this->Cell(0,0,$inv->print['site']['ADDRESS']); $y += 4;
|
||||
$this->SetXY(18,$y); $this->Cell(0,0,sprintf('%s, %s %s',$inv->print['site']['CITY'],$inv->print['site']['STATE'],$inv->print['site']['ZIP'])); $y += 4;
|
||||
|
||||
# Previous Due
|
||||
$y = 215;
|
||||
$this->SetFont('arial','',9);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Previous Due');
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$this->_currency($inv->getPreviousBalance()),0,0,'R');
|
||||
|
||||
$y = 219;
|
||||
$this->SetFont('arial','',9);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_amount_due_by','setup_invoice').' '.date(UNIX_DATE_FORMAT,$inv->print['invoice']['due_date']));
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$this->_currency($inv->print['invoice']['total_amt']-$inv->print['invoice']['billed_amt']),0,0,'R');
|
||||
|
||||
# Total Due
|
||||
$y = 224;
|
||||
$this->SetFont('arial','B',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Total Due');
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$this->_currency($inv->getPreviousBalance()+$inv->print['invoice']['total_amt']-$inv->print['invoice']['billed_amt']),0,0,'R');
|
||||
|
||||
# Draw the Customers Address
|
||||
$x = 25; $y = 248;
|
||||
|
||||
$this->SetFont('arial','B',12);
|
||||
|
||||
if ($this->billToCompany && ! empty($inv->print['account']['company']))
|
||||
$name = $inv->print['account']['company'];
|
||||
else
|
||||
$name = sprintf('%s %s',$inv->print['account']['first_name'],$inv->print['account']['last_name']);
|
||||
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,html_entity_decode($name,ENT_NOQUOTES)); $y += 5;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%s %s ',$inv->print['account']['address1'],$inv->print['account']['address2'])); $y += 5;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%s, %s %s',$inv->print['account']['city'],$inv->print['account']['state'],$inv->print['account']['zip'])); $y += 5;
|
||||
}
|
||||
|
||||
public function drawInvoiceHeader($inv) {
|
||||
global $C_translate;
|
||||
|
||||
$x = 125; $y = 10;
|
||||
|
||||
# Draw a box.
|
||||
$this->SetFillColor(245);
|
||||
$this->SetXY($x-1,$y-3); $this->Cell(0,35+($inv->print['invoice']['billed_amt'] ? 5 : 0),'',1,0,'',1);
|
||||
|
||||
# Draw a box around the invoice due date and amount due.
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'TAX INVOICE');
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%06s',$inv->getInvoiceNum()),0,0,'R');
|
||||
|
||||
# Invoice number at top of page.
|
||||
$y += 7;
|
||||
$this->SetFont('arial','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_bill_date','setup_invoice')); $y += 5;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_amount_due_by','setup_invoice'));
|
||||
$this->SetFont('arial','B',11);
|
||||
|
||||
$y -= 5;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,date(UNIX_DATE_FORMAT,$inv->print['invoice']['date_orig']),0,0,'R'); $y += 5;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,date(UNIX_DATE_FORMAT,$inv->print['invoice']['due_date']),0,0,'R');
|
||||
|
||||
$y += 5;
|
||||
$this->SetFont('arial','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Previous Due');
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->getPreviousBalance()),0,0,'R');
|
||||
|
||||
$y += 5;
|
||||
$this->SetFont('arial','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_current_charges','setup_invoice'));
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->print['invoice']['total_amt']),0,0,'R');
|
||||
|
||||
if ($inv->print['invoice']['billed_amt']) {
|
||||
$y += 5;
|
||||
$this->SetFont('arial','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Payments Received');
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->print['invoice']['billed_amt']),0,0,'R');
|
||||
}
|
||||
|
||||
$y += 5;
|
||||
$this->SetFont('arial','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Total Payable');
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->getPreviousBalance()+$inv->print['invoice']['total_amt']-$inv->print['invoice']['billed_amt']),0,0,'R');
|
||||
}
|
||||
|
||||
#@todo Limit the size of the news to 6 lines
|
||||
public function drawNews($news) {
|
||||
global $C_translate;
|
||||
|
||||
if (! $news)
|
||||
return;
|
||||
|
||||
$x = 9; $y = 170;
|
||||
|
||||
# Draw a box.
|
||||
$this->SetFillColor(243);
|
||||
$this->SetXY($x-1,$y-3); $this->Cell(0,20,'',1,0,'',1);
|
||||
|
||||
$this->SetFont('arial','',8);
|
||||
$this->SetXY($x,$y); $this->MultiCell(0,3,str_replace('\n',"\n",$news),0,'L',0);
|
||||
}
|
||||
|
||||
#@todo make this list dynamic
|
||||
public function drawPaymentMethods($inv) {
|
||||
$x = 110; $y = 242;
|
||||
|
||||
# Draw a box.
|
||||
$this->SetFillColor(235);
|
||||
$this->SetXY($x-1,$y-3); $this->Cell(0,32,'',1,0,'',1);
|
||||
|
||||
$this->SetFont('arial','B',8);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'This invoice can also be paid by:'); $y += 4;
|
||||
|
||||
# Direct Debit
|
||||
$logo = sprintf('%s/%s',PATH_THEMES.DEFAULT_THEME,'invoice/invoice-payment-dd.png');
|
||||
$this->Image($logo,$x+1,$y,8);
|
||||
$this->SetFont('arial','B',8);
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'Direct Credit to our Bank Account'); $y += 3;
|
||||
$this->SetFont('arial','',8);
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'BSB:'); $y += 3;
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'ACCOUNT:'); $y += 3;
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'REF:'); $y += 3;
|
||||
|
||||
$y -= 9;
|
||||
$this->SetFont('arial','B',8);
|
||||
$this->SetXY($x+30,$y); $this->Cell(0,0,'633-000'); $y += 3;
|
||||
$this->SetXY($x+30,$y); $this->Cell(0,0,'120 440 821'); $y += 3;
|
||||
$this->SetXY($x+30,$y); $this->Cell(0,0,$inv->getInvoiceID()); $y += 3;
|
||||
|
||||
# Direct Debit
|
||||
$y += 3;
|
||||
$logo = sprintf('%s/%s',PATH_THEMES.DEFAULT_THEME,'invoice/invoice-payment-dd.png');
|
||||
$this->Image($logo,$x+1,$y,8);
|
||||
$this->SetFont('arial','B',8);
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'Direct Debit'); $y += 3;
|
||||
$this->SetFont('arial','',8);
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'Please visit '.$inv->print['site']['URL']); $y += 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw previous invoices due
|
||||
*/
|
||||
public function drawSummaryInvoicesDue($items) {
|
||||
$x = 125; $y = $this->sum_y ? $this->sum_y : 50;
|
||||
|
||||
# Calculate the box size
|
||||
$box = count($items) < $this->itemsPreviousMax ? count($items) : $this->itemsPreviousMax;
|
||||
|
||||
# Draw a box.
|
||||
$this->SetFillColor(245);
|
||||
$this->SetXY($x-1,$y-3); $this->Cell(0,5*(1+$box)+1,'',1,0,'',1);
|
||||
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Previous Invoices due'); $y += 5;
|
||||
|
||||
$this->SetFont('arial','',11);
|
||||
$i = 0;
|
||||
$sum_total = 0;
|
||||
foreach ($items as $line) {
|
||||
if (++$i < $this->itemsPreviousMax) {
|
||||
$this->SetXY($x,$y);
|
||||
$this->Cell(0,0,sprintf('%s #%06s',date(UNIX_DATE_FORMAT,$line['date_orig']),$line['id']));
|
||||
$this->Cell(0,0,$this->_currency($line['total_amt']-$line['billed_amt']),0,0,'R'); $y += 5;
|
||||
|
||||
} else {
|
||||
$sum_total += $line['total_amt']-$line['billed_amt'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($sum_total) {
|
||||
$this->SetXY($x,$y);
|
||||
$this->SetFont('arial','I',11);
|
||||
$this->Cell(0,0,'Other invoices');
|
||||
$this->SetFont('arial','',11);
|
||||
$this->Cell(0,0,$this->_currency($sum_total),0,0,'R'); $y += 5;
|
||||
}
|
||||
|
||||
$this->sum_y = $y+5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before begining to loop the invoice_item table. Used to set initial values.
|
||||
*/
|
||||
public function drawLineItems_pre($iteration) {
|
||||
$this->iteration = $iteration;
|
||||
if ($iteration>1)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called once per line item to add to the PDF invoice. This function serves to
|
||||
* direct each iteration to a different function which handles a specific piece
|
||||
* of the PDF building puzzle.
|
||||
*/
|
||||
public function drawLineItems($db,$line,$invnum) {
|
||||
switch($this->iteration) {
|
||||
case 0:
|
||||
$this->drawLineItems_0($db,$line,$invnum);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$this->drawLineItems_1($db,$line,$invnum);
|
||||
break;
|
||||
|
||||
default:
|
||||
echo 'Unknown PDF iteration encountered. Halting.';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the non-VoIP related items for iteration 0.
|
||||
*/
|
||||
private function drawLineItems_0($db,$line,$invnum) {
|
||||
global $C_translate;
|
||||
|
||||
if ($line['price_type'] == 0 && $line['item_type']==5)
|
||||
return;
|
||||
|
||||
$x = 10; $y = 5;
|
||||
if ($this->i == 0 || $this->i%51 == 0) {
|
||||
$this->AddPage();
|
||||
|
||||
$this->SetFont('arial','B',12);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_itemized_charges','setup_invoice'));
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_page','setup_invoice').$this->PageNo(),0,0,'R');
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number_small','setup_invoice').$invnum,0,0,'C');
|
||||
|
||||
# Draw table headers
|
||||
$y += 10;
|
||||
$this->SetFont('arial','B',8);
|
||||
$this->SetXY($x,$y);
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_item_description','setup_invoice'));
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_item_quantity','setup_invoice'));
|
||||
$this->SetX($x+160);
|
||||
$this->Cell(10,0,$C_translate->translate('pdf_item_cost','setup_invoice'),0,0,'R');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_item_amount','setup_invoice'),0,0,'R');
|
||||
$this->Line($x,$y+2,200,$y+2);
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
}
|
||||
|
||||
$this->SetFont('arial','',8);
|
||||
$this->SetX($x);
|
||||
$this->Cell(0,0,$line['name']);
|
||||
|
||||
if (isset($line['price_base'])) {
|
||||
$this->SetX($x+160);
|
||||
$this->Cell(10,0,$this->_currency($line['price_base']),0,0,'R');
|
||||
}
|
||||
|
||||
if (isset($line['qty'])) {
|
||||
$this->SetX($x+130);
|
||||
$this->Cell(10,0,$line['qty'],0,0,'R');
|
||||
}
|
||||
|
||||
$this->SetX($x+130);
|
||||
$this->Cell(0,0,$this->_currency($line['total_amt']),0,0,'R');
|
||||
|
||||
if ($this->show_service_range && $line['daterange']) {
|
||||
$this->SetFont('arial','I',7);
|
||||
$y += 3;
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'Service Period');
|
||||
$this->SetFont('arial','',7);
|
||||
$this->SetXY($x+40,$y); $this->Cell(0,0,$line['daterange']);
|
||||
}
|
||||
|
||||
if ($line['domain']) {
|
||||
$this->SetFont('arial','I',7);
|
||||
$y += 3;
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'Domain');
|
||||
$this->SetFont('arial','',7);
|
||||
$this->SetXY($x+40,$y); $this->Cell(0,0,$line['domain']);
|
||||
}
|
||||
|
||||
if ($line['attr']) {
|
||||
$showchars = 20;
|
||||
foreach (explode("\n",$line['attr']) as $attr) {
|
||||
list($field,$value) = explode('==',$attr);
|
||||
|
||||
$this->SetFont('arial','I',7);
|
||||
$this->y += 3;
|
||||
$this->SetXY(20,$this->y); $this->Cell(0,0,strlen($field) > $showchars ? substr($field,0,$showchars-2).'...' : $field);
|
||||
$this->SetFont('arial','',7);
|
||||
$this->SetXY(50,$this->y); $this->Cell(0,0,$value);
|
||||
}
|
||||
}
|
||||
|
||||
$this->y += 5;
|
||||
$this->SetY($this->y);
|
||||
$this->i++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the Item Detail for Iteration 1.
|
||||
*/
|
||||
private function drawLineItems_1($db,$line,$invnum) {
|
||||
global $C_translate;
|
||||
|
||||
if ($this->show_itemized != 1) return;
|
||||
if ($line['price_type'] != 0 || $line['item_type'] != 5)
|
||||
return;
|
||||
|
||||
$x = 10; $y = 5;
|
||||
if ($this->i == 0 || $this->i%51 == 0) {
|
||||
$this->AddPage();
|
||||
|
||||
$this->SetFont('arial','B',12);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_itemized_calls','setup_invoice'));
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_page','setup_invoice').$this->PageNo(),0,0,'R');
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number_small','setup_invoice').$invnum,0,0,'C');
|
||||
|
||||
# Draw table headers
|
||||
$this->SetFont('arial','B',8);
|
||||
$this->SetXY($x,$y);
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_item_from','setup_invoice'));
|
||||
$this->SetX(69);
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_item_to','setup_invoice'));
|
||||
$this->SetX(119);
|
||||
$this->Cell(0,0,'Date & Time');
|
||||
$this->SetX(160);
|
||||
$this->Cell(10,0,'Seconds' /*$C_translate->translate('pdf_item_min','setup_invoice')*/,0,0,'R');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_item_amount','setup_invoice'),0,0,'R');
|
||||
$this->Line($x,$y+4,200,$y+4);
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
}
|
||||
|
||||
if ($line['price_type'] != 0) {
|
||||
$this->SetFont('arial','I',6);
|
||||
} else {
|
||||
$this->SetFont('arial','',6);
|
||||
}
|
||||
|
||||
$val = $line['name'];
|
||||
if (strlen($line['attr'])) {
|
||||
$val = "";
|
||||
$atrs = preg_split("/\r\n/", str_replace('\r\n',"\r\n",$line['attr']));
|
||||
foreach ($atrs as $a) {
|
||||
$parts = preg_split("/==/", $a);
|
||||
switch ($parts[0]) {
|
||||
case "Destination":
|
||||
$this->SetX(69);
|
||||
$this->Cell(0,0,$parts[1]);
|
||||
$cc = ""; $npa = ""; $nxx = ""; $e164 = "";
|
||||
if ($this->v->e164($parts[1], $e164, $cc, $npa, $nxx)) {
|
||||
$this->SetX(89);
|
||||
$this->Cell(0,0,substr($this->v->where_is($db, $cc, $npa, $nxx), 0, 20));
|
||||
}
|
||||
break;
|
||||
case "Source":
|
||||
$this->SetX(9);
|
||||
$this->Cell(0,0,$parts[1]);
|
||||
$cc = ""; $npa = ""; $nxx = ""; $e164 = "";
|
||||
if ($this->v->e164($parts[1], $e164, $cc, $npa, $nxx)) {
|
||||
$this->SetX(29);
|
||||
$this->Cell(0,0,substr($this->v->where_is($db, $cc, $npa, $nxx), 0, 20));
|
||||
}
|
||||
break;
|
||||
case "parent_service_id":
|
||||
$sql = sqlSelect($db,"service","prod_attr","id=::".$parts[1]."::");
|
||||
$rstmp = $db->Execute($sql);
|
||||
$atrs2 = split("\r\n", $rstmp->fields['prod_attr']);
|
||||
foreach ($atrs2 as $a2) {
|
||||
$parts2 = split("==", $a2);
|
||||
switch ($parts2[0]) {
|
||||
case "station":
|
||||
case "ported":
|
||||
$val = $line['name']." for ".$parts2[1];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "station":
|
||||
case "ported":
|
||||
$val = $line['name']." for ".$parts[1];
|
||||
break;
|
||||
case "date_orig":
|
||||
$this->SetX(119);
|
||||
$this->Cell(0,0,date(UNIX_DATE_FORMAT." H:i:s",$parts[1]));
|
||||
break;
|
||||
case "voip_cdr_id":
|
||||
$sql = "SELECT billsec, amount FROM ".AGILE_DB_PREFIX."voip_cdr WHERE site_id=".DEFAULT_SITE." AND id=".$parts[1];
|
||||
$row = $db->GetRow($sql);
|
||||
$this->SetX(160);
|
||||
$this->Cell(10,0,$row[0],0,0,'R');
|
||||
$this->SetX(160);
|
||||
$this->Cell(0,0,$this->_currency($row[1]),0,0,'R');
|
||||
$val = "";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->SetX(9);
|
||||
$this->Cell(0,0, $val);
|
||||
if ($line['price_type'] == 0) {
|
||||
$this->SetX(160);
|
||||
//$this->Cell(10,0, $line['qty']." M",0,0,'R');
|
||||
} else {
|
||||
$q = $line['qty'];
|
||||
if(empty($q)) $q = 1;
|
||||
$this->SetX(160);
|
||||
$this->Cell(10,0, $line['qty'],0,0,'R');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0, $this->_currency($line['amount']), 0,0,'R');
|
||||
}
|
||||
$this->y += 5;
|
||||
$this->SetY($this->y);
|
||||
$this->i++;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will draw the Summary Box, with the summary of the items
|
||||
* on the invoice.
|
||||
*/
|
||||
public function drawSummaryLineItems($inv) {
|
||||
global $C_translate;
|
||||
|
||||
if (! $this->show_itemized)
|
||||
return;
|
||||
|
||||
$items = $inv->summarizeLineItems($inv->print['invoiceitems']);
|
||||
|
||||
# Calculate the box size
|
||||
$box = count($items) < $this->itemsSummaryMax ? count($items) : $this->itemsSummaryMax;
|
||||
|
||||
$x = 10; $y = $this->sum_y ? $this->sum_y : 55;
|
||||
|
||||
# Draw a box.
|
||||
$this->SetFillColor(245);
|
||||
$this->SetXY($x-1,$y-3); $this->Cell(0,5*(1+1+1+5+$box)+1,'',1,0,'',1);
|
||||
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_cur_charge_summary','setup_invoice')); $y += 5;
|
||||
|
||||
$this->SetY($y);
|
||||
$this->SetFont('arial','',9);
|
||||
|
||||
$i=0;
|
||||
if (is_array($items)) {
|
||||
foreach($items as $line) {
|
||||
$this->SetX($x);
|
||||
|
||||
$q = $line['quantity'];
|
||||
if (empty($q))
|
||||
$q = 1;
|
||||
|
||||
$this->Cell(0,0,$q);
|
||||
$this->SetX($x+8);
|
||||
$this->Cell(0,0,sprintf('%s (%s)',$line['summaryname'],$this->_currency($line['price_base'])));
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$this->_currency($line['price_base']*$line['quantity']),0,0,'R');
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
$i++;
|
||||
if ($i > $this->itemsSummaryMax) {
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetX($x);
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_summary','setup_invoice'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
# Calculate our rounding error
|
||||
$subtotal = 0;
|
||||
foreach($items as $line)
|
||||
$subtotal += $line['price_base']*$line['quantity'];
|
||||
|
||||
$subtotal = round($subtotal,2);
|
||||
|
||||
if (round($inv->print['invoice']['total_amt']-$inv->print['invoice']['tax_amt'],2) != $subtotal) {
|
||||
$this->SetFont('arial','',9);
|
||||
$this->SetX($x);
|
||||
$this->Cell(0,0,'Rounding');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$this->_currency($inv->print['invoice']['total_amt']-$inv->print['invoice']['tax_amt']-$subtotal),0,0,'R');
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
}
|
||||
|
||||
# @todo Draw discounts
|
||||
# Sub total and tax.
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
$this->SetFont('arial','B',9);
|
||||
$this->SetX($x+8);
|
||||
$this->Cell(0,0,'Sub Total');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$this->_currency($inv->print['invoice']['total_amt']-$inv->print['invoice']['tax_amt']),0,0,'R');
|
||||
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
$this->SetX($x+8);
|
||||
$this->Cell(0,0,'Taxes');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$this->_currency($inv->print['invoice']['tax_amt']),0,0,'R');
|
||||
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
$this->SetX($x+8);
|
||||
$this->Cell(0,0,'Total Charges');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$this->_currency($inv->print['invoice']['total_amt']),0,0,'R');
|
||||
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
$this->SetX($x+8);
|
||||
$this->Cell(0,0,'Payments Received');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$this->_currency($inv->print['invoice']['billed_amt']),0,0,'R');
|
||||
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
$this->SetX($x+8);
|
||||
$this->Cell(0,0,'Balance Due');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$this->_currency($inv->print['invoice']['total_amt']-$inv->print['invoice']['billed_amt']),0,0,'R');
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
638
modules/invoice/PDF/pdf_invoice_itemised-fpdi.inc.php
Normal file
638
modules/invoice/PDF/pdf_invoice_itemised-fpdi.inc.php
Normal file
@@ -0,0 +1,638 @@
|
||||
<?php
|
||||
/**
|
||||
* Graytech Hosting - Highly detailed PDF invoice
|
||||
*/
|
||||
require_once PATH_MODULES.'invoice/invoice_base_fpdi.inc.php';
|
||||
|
||||
class pdf_invoice_overview extends pdf_invoice_base {
|
||||
var $v, $i, $y;
|
||||
|
||||
# Current line being printed
|
||||
private $sum_y = 0;
|
||||
|
||||
/**
|
||||
* Draw the logo
|
||||
*/
|
||||
public function drawCompanyLogo() {
|
||||
$x = 9; $y = 7;
|
||||
$size = 25;
|
||||
$logo = sprintf('%s/%s',PATH_THEMES.DEFAULT_THEME,'invoice/invoice-logo.png');
|
||||
|
||||
if (is_file($logo))
|
||||
$this->Image($logo,$x,$y,$size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the Company Address
|
||||
*/
|
||||
public function drawCompanyAddress($inv) {
|
||||
global $C_translate;
|
||||
|
||||
# Add the company address next to the logo
|
||||
$x = 40; $y = 9;
|
||||
|
||||
$this->SetFont('arial','B',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$inv->print['site']['NAME']); $y += 4;
|
||||
|
||||
$this->SetFont('arial','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$inv->print['site']['TAXID']); $y += 6;
|
||||
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$inv->print['site']['ADDRESS']); $y += 4;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%s, %s %s',$inv->print['site']['CITY'],$inv->print['site']['STATE'],$inv->print['site']['ZIP'])); $y += 4;
|
||||
|
||||
$y += 2;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Phone:'); $this->SetXY($x+16,$y); $this->Cell(0,0,$inv->print['site']['PHONE']); $y += 4;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Fax:'); $this->SetXY($x+16,$y); $this->Cell(0,0,$inv->print['site']['FAX']); $y += 4;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Web:'); $this->SetXY($x+16,$y); $this->Cell(0,0,$inv->print['site']['URL']); $y += 4;
|
||||
}
|
||||
|
||||
public function drawRemittenceStub($inv) {
|
||||
global $C_translate;
|
||||
|
||||
# Draw the remittance line
|
||||
$this->Line(9,195,200,195);
|
||||
|
||||
$x = 18; $y = 200;
|
||||
|
||||
$this->SetFont('arial','B',13);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_payment_remit','setup_invoice')); $y +=5;
|
||||
|
||||
$this->SetFont('arial','',8);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_return1','setup_invoice')); $y +=3;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_return2','setup_invoice').' '.$inv->print['site']['NAME']);
|
||||
|
||||
# Due Date
|
||||
$x = 110; $y = 200;
|
||||
$this->SetFont('arial','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_bill_date','setup_invoice'));
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,date(UNIX_DATE_FORMAT,$inv->print['invoice']['date_orig']),0,0,'R');
|
||||
|
||||
# Account ID
|
||||
$y = 205;
|
||||
$this->SetFont('arial','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_account_number','setup_invoice'));
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%06s',$inv->print['account']['id']),0,0,'R');
|
||||
|
||||
# Invoice number
|
||||
$y = 210;
|
||||
$this->SetFont('arial','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number','setup_invoice'));
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%06s',$inv->getInvoiceNum()),0,0,'R');
|
||||
|
||||
# Company Address
|
||||
$y = 216;
|
||||
$this->SetFont('arial','',10);
|
||||
$this->SetXY(18,$y); $this->Cell(0,0,$inv->print['site']['NAME']); $y += 4;
|
||||
$this->SetXY(18,$y); $this->Cell(0,0,$inv->print['site']['ADDRESS']); $y += 4;
|
||||
$this->SetXY(18,$y); $this->Cell(0,0,sprintf('%s, %s %s',$inv->print['site']['CITY'],$inv->print['site']['STATE'],$inv->print['site']['ZIP'])); $y += 4;
|
||||
|
||||
# Previous Due
|
||||
$y = 215;
|
||||
$this->SetFont('arial','',9);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Previous Due');
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$this->_currency($inv->getPreviousBalance()),0,0,'R');
|
||||
|
||||
$y = 219;
|
||||
$this->SetFont('arial','',9);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_amount_due_by','setup_invoice').' '.date(UNIX_DATE_FORMAT,$inv->print['invoice']['due_date']));
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$this->_currency($inv->print['invoice']['total_amt']-$inv->print['invoice']['billed_amt']),0,0,'R');
|
||||
|
||||
# Total Due
|
||||
$y = 224;
|
||||
$this->SetFont('arial','B',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Total Due');
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$this->_currency($inv->getPreviousBalance()+$inv->print['invoice']['total_amt']-$inv->print['invoice']['billed_amt']),0,0,'R');
|
||||
|
||||
# Draw the Customers Address
|
||||
$x = 25; $y = 248;
|
||||
|
||||
$this->SetFont('arial','B',12);
|
||||
|
||||
if ($this->billToCompany && ! empty($inv->print['account']['company']))
|
||||
$name = $inv->print['account']['company'];
|
||||
else
|
||||
$name = sprintf('%s %s',$inv->print['account']['first_name'],$inv->print['account']['last_name']);
|
||||
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,html_entity_decode($name,ENT_NOQUOTES)); $y += 5;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%s %s ',$inv->print['account']['address1'],$inv->print['account']['address2'])); $y += 5;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%s, %s %s',$inv->print['account']['city'],$inv->print['account']['state'],$inv->print['account']['zip'])); $y += 5;
|
||||
}
|
||||
|
||||
public function drawInvoiceHeader($inv) {
|
||||
global $C_translate;
|
||||
|
||||
$x = 125; $y = 10;
|
||||
|
||||
# Draw a box.
|
||||
$this->SetFillColor(245);
|
||||
$this->SetXY($x-1,$y-3); $this->Cell(0,35+($inv->print['invoice']['billed_amt'] ? 5 : 0),'',1,0,'',1);
|
||||
|
||||
# Draw a box around the invoice due date and amount due.
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'TAX INVOICE');
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%06s',$inv->getInvoiceNum()),0,0,'R');
|
||||
|
||||
# Invoice number at top of page.
|
||||
$y += 7;
|
||||
$this->SetFont('arial','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_bill_date','setup_invoice')); $y += 5;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_amount_due_by','setup_invoice'));
|
||||
$this->SetFont('arial','B',11);
|
||||
|
||||
$y -= 5;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,date(UNIX_DATE_FORMAT,$inv->print['invoice']['date_orig']),0,0,'R'); $y += 5;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,date(UNIX_DATE_FORMAT,$inv->print['invoice']['due_date']),0,0,'R');
|
||||
|
||||
$y += 5;
|
||||
$this->SetFont('arial','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Previous Due');
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->getPreviousBalance()),0,0,'R');
|
||||
|
||||
$y += 5;
|
||||
$this->SetFont('arial','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_current_charges','setup_invoice'));
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->print['invoice']['total_amt']),0,0,'R');
|
||||
|
||||
if ($inv->print['invoice']['billed_amt']) {
|
||||
$y += 5;
|
||||
$this->SetFont('arial','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Payments Received');
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->print['invoice']['billed_amt']),0,0,'R');
|
||||
}
|
||||
|
||||
$y += 5;
|
||||
$this->SetFont('arial','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Total Payable');
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->getPreviousBalance()+$inv->print['invoice']['total_amt']-$inv->print['invoice']['billed_amt']),0,0,'R');
|
||||
}
|
||||
|
||||
#@todo Limit the size of the news to 6 lines
|
||||
public function drawNews($news) {
|
||||
global $C_translate;
|
||||
|
||||
if (! $news)
|
||||
return;
|
||||
|
||||
$x = 9; $y = 170;
|
||||
|
||||
# Draw a box.
|
||||
$this->SetFillColor(243);
|
||||
$this->SetXY($x-1,$y-3); $this->Cell(0,20,'',1,0,'',1);
|
||||
|
||||
$this->SetFont('arial','',8);
|
||||
$this->SetXY($x,$y); $this->MultiCell(0,3,str_replace('\n',"\n",$news),0,'L',0);
|
||||
}
|
||||
|
||||
#@todo make this list dynamic
|
||||
public function drawPaymentMethods($inv) {
|
||||
$x = 110; $y = 242;
|
||||
|
||||
# Draw a box.
|
||||
$this->SetFillColor(235);
|
||||
$this->SetXY($x-1,$y-3); $this->Cell(0,32,'',1,0,'',1);
|
||||
|
||||
$this->SetFont('arial','B',8);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'This invoice can also be paid by:'); $y += 4;
|
||||
|
||||
# Direct Debit
|
||||
$logo = sprintf('%s/%s',PATH_THEMES.DEFAULT_THEME,'invoice/invoice-payment-dd.png');
|
||||
$this->Image($logo,$x+1,$y,8);
|
||||
$this->SetFont('arial','B',8);
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'Direct Credit to our Bank Account'); $y += 3;
|
||||
$this->SetFont('arial','',8);
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'BSB:'); $y += 3;
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'ACCOUNT:'); $y += 3;
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'REF:'); $y += 3;
|
||||
|
||||
$y -= 9;
|
||||
$this->SetFont('arial','B',8);
|
||||
$this->SetXY($x+30,$y); $this->Cell(0,0,'633-000'); $y += 3;
|
||||
$this->SetXY($x+30,$y); $this->Cell(0,0,'120 440 821'); $y += 3;
|
||||
$this->SetXY($x+30,$y); $this->Cell(0,0,$inv->getInvoiceID()); $y += 3;
|
||||
|
||||
# Direct Debit
|
||||
$y += 3;
|
||||
$logo = sprintf('%s/%s',PATH_THEMES.DEFAULT_THEME,'invoice/invoice-payment-dd.png');
|
||||
$this->Image($logo,$x+1,$y,8);
|
||||
$this->SetFont('arial','B',8);
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'Direct Debit'); $y += 3;
|
||||
$this->SetFont('arial','',8);
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'Please visit '.$inv->print['site']['URL']); $y += 3;
|
||||
|
||||
# $r1 = $this->w - 40;
|
||||
# $r2 = $r1 + 30;
|
||||
# $y1 = 8;
|
||||
# $y2 = $y1 ;
|
||||
# $mid = $y1 + ($y2 / 2);
|
||||
# $this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 2.5, 'F');
|
||||
|
||||
# $this->addWaterMark('hello');
|
||||
# # Pay Pal
|
||||
# $y += 3;
|
||||
# $logo = sprintf('%s/%s',PATH_THEMES.DEFAULT_THEME,'invoice/invoice-payment-pp.png');
|
||||
# $this->Image($logo,$x+1,$y,8);
|
||||
# $this->SetFont('arial','B',8);
|
||||
# $this->SetXY($x+10,$y); $this->Cell(0,0,'Pay Pal'); $y += 3;
|
||||
# $this->SetFont('arial','',8);
|
||||
# $this->SetXY($x+10,$y); $this->Cell(0,0,'Please visit '.$inv->print['site']['URL']); $y += 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw previous invoices due
|
||||
*/
|
||||
public function drawSummaryInvoicesDue($items) {
|
||||
$x = 125; $y = $this->sum_y ? $this->sum_y : 50;
|
||||
|
||||
# Calculate the box size
|
||||
$box = count($items) < $this->itemsPreviousMax ? count($items) : $this->itemsPreviousMax;
|
||||
|
||||
# Draw a box.
|
||||
$this->SetFillColor(245);
|
||||
$this->SetXY($x-1,$y-3); $this->Cell(0,5*(1+$box)+1,'',1,0,'',1);
|
||||
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Previous Invoices due'); $y += 5;
|
||||
|
||||
$this->SetFont('arial','',11);
|
||||
$i = 0;
|
||||
$sum_total = 0;
|
||||
foreach ($items as $line) {
|
||||
if (++$i < $this->itemsPreviousMax) {
|
||||
$this->SetXY($x,$y);
|
||||
$this->Cell(0,0,sprintf('%s #%06s',date(UNIX_DATE_FORMAT,$line['date_orig']),$line['id']));
|
||||
$this->Cell(0,0,$this->_currency($line['total_amt']-$line['billed_amt']),0,0,'R'); $y += 5;
|
||||
|
||||
} else {
|
||||
$sum_total += $line['total_amt']-$line['billed_amt'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($sum_total) {
|
||||
$this->SetXY($x,$y);
|
||||
$this->SetFont('arial','I',11);
|
||||
$this->Cell(0,0,'Other invoices');
|
||||
$this->SetFont('arial','',11);
|
||||
$this->Cell(0,0,$this->_currency($sum_total),0,0,'R'); $y += 5;
|
||||
}
|
||||
|
||||
$this->sum_y = $y+5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before begining to loop the invoice_item table. Used to set initial values.
|
||||
*/
|
||||
public function drawLineItems_pre($iteration) {
|
||||
$this->iteration = $iteration;
|
||||
if ($iteration>1)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called once per line item to add to the PDF invoice. This function serves to
|
||||
* direct each iteration to a different function which handles a specific piece
|
||||
* of the PDF building puzzle.
|
||||
*/
|
||||
public function drawLineItems($db,$line,$invnum) {
|
||||
switch($this->iteration) {
|
||||
case 0:
|
||||
$this->drawLineItems_0($db,$line,$invnum);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$this->drawLineItems_1($db,$line,$invnum);
|
||||
break;
|
||||
|
||||
default:
|
||||
echo 'Unknown PDF iteration encountered. Halting.';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the non-VoIP related items for iteration 0.
|
||||
*/
|
||||
private function drawLineItems_0($db,$line,$invnum) {
|
||||
global $C_translate;
|
||||
|
||||
if ($line['price_type'] == 0 && $line['item_type']==5)
|
||||
return;
|
||||
|
||||
$x = 10; $y = 5;
|
||||
if ($this->i == 0 || $this->i%51 == 0) {
|
||||
$this->AddPage();
|
||||
|
||||
$this->SetFont('arial','B',12);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_itemized_charges','setup_invoice'));
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_page','setup_invoice').$this->PageNo(),0,0,'R');
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number_small','setup_invoice').$invnum,0,0,'C');
|
||||
|
||||
# Draw table headers
|
||||
$y += 10;
|
||||
$this->SetFont('arial','B',8);
|
||||
$this->SetXY($x,$y);
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_item_description','setup_invoice'));
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_item_quantity','setup_invoice'));
|
||||
$this->SetX($x+160);
|
||||
$this->Cell(10,0,$C_translate->translate('pdf_item_cost','setup_invoice'),0,0,'R');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_item_amount','setup_invoice'),0,0,'R');
|
||||
$this->Line($x,$y+2,200,$y+2);
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
}
|
||||
|
||||
$this->SetFont('arial','',8);
|
||||
$this->SetX($x);
|
||||
$this->Cell(0,0,$line['name']);
|
||||
|
||||
if (isset($line['price_base'])) {
|
||||
$this->SetX($x+160);
|
||||
$this->Cell(10,0,$this->_currency($line['price_base']),0,0,'R');
|
||||
}
|
||||
|
||||
if (isset($line['qty'])) {
|
||||
$this->SetX($x+130);
|
||||
$this->Cell(10,0,$line['qty'],0,0,'R');
|
||||
}
|
||||
|
||||
$this->SetX($x+130);
|
||||
$this->Cell(0,0,$this->_currency($line['total_amt']),0,0,'R');
|
||||
|
||||
if ($this->show_service_range && $line['daterange']) {
|
||||
$this->SetFont('arial','I',7);
|
||||
$y += 3;
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'Service Period');
|
||||
$this->SetFont('arial','',7);
|
||||
$this->SetXY($x+40,$y); $this->Cell(0,0,$line['daterange']);
|
||||
}
|
||||
|
||||
if ($line['domain']) {
|
||||
$this->SetFont('arial','I',7);
|
||||
$y += 3;
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'Domain');
|
||||
$this->SetFont('arial','',7);
|
||||
$this->SetXY($x+40,$y); $this->Cell(0,0,$line['domain']);
|
||||
}
|
||||
|
||||
if ($line['attr']) {
|
||||
$showchars = 20;
|
||||
foreach (explode("\n",$line['attr']) as $attr) {
|
||||
list($field,$value) = explode('==',$attr);
|
||||
|
||||
$this->SetFont('arial','I',7);
|
||||
$this->y += 3;
|
||||
$this->SetXY(20,$this->y); $this->Cell(0,0,strlen($field) > $showchars ? substr($field,0,$showchars-2).'...' : $field);
|
||||
$this->SetFont('arial','',7);
|
||||
$this->SetXY(50,$this->y); $this->Cell(0,0,$value);
|
||||
}
|
||||
}
|
||||
|
||||
$this->y += 5;
|
||||
$this->SetY($this->y);
|
||||
$this->i++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the Item Detail for Iteration 1.
|
||||
*/
|
||||
private function drawLineItems_1($db,$line,$invnum) {
|
||||
global $C_translate;
|
||||
|
||||
if ($this->show_itemized != 1) return;
|
||||
if ($line['price_type'] != 0 || $line['item_type'] != 5)
|
||||
return;
|
||||
|
||||
$x = 10; $y = 5;
|
||||
if ($this->i == 0 || $this->i%51 == 0) {
|
||||
$this->AddPage();
|
||||
|
||||
$this->SetFont('arial','B',12);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_itemized_calls','setup_invoice'));
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_page','setup_invoice').$this->PageNo(),0,0,'R');
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number_small','setup_invoice').$invnum,0,0,'C');
|
||||
|
||||
# Draw table headers
|
||||
$this->SetFont('arial','B',8);
|
||||
$this->SetXY($x,$y);
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_item_from','setup_invoice'));
|
||||
$this->SetX(69);
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_item_to','setup_invoice'));
|
||||
$this->SetX(119);
|
||||
$this->Cell(0,0,'Date & Time');
|
||||
$this->SetX(160);
|
||||
$this->Cell(10,0,'Seconds' /*$C_translate->translate('pdf_item_min','setup_invoice')*/,0,0,'R');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_item_amount','setup_invoice'),0,0,'R');
|
||||
$this->Line($x,$y+4,200,$y+4);
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
}
|
||||
|
||||
if ($line['price_type'] != 0) {
|
||||
$this->SetFont('arial','I',6);
|
||||
} else {
|
||||
$this->SetFont('arial','',6);
|
||||
}
|
||||
|
||||
$val = $line['name'];
|
||||
if (strlen($line['attr'])) {
|
||||
$val = "";
|
||||
$atrs = preg_split("/\r\n/", str_replace('\r\n',"\r\n",$line['attr']));
|
||||
foreach ($atrs as $a) {
|
||||
$parts = preg_split("/==/", $a);
|
||||
switch ($parts[0]) {
|
||||
case "Destination":
|
||||
$this->SetX(69);
|
||||
$this->Cell(0,0,$parts[1]);
|
||||
$cc = ""; $npa = ""; $nxx = ""; $e164 = "";
|
||||
if ($this->v->e164($parts[1], $e164, $cc, $npa, $nxx)) {
|
||||
$this->SetX(89);
|
||||
$this->Cell(0,0,substr($this->v->where_is($db, $cc, $npa, $nxx), 0, 20));
|
||||
}
|
||||
break;
|
||||
case "Source":
|
||||
$this->SetX(9);
|
||||
$this->Cell(0,0,$parts[1]);
|
||||
$cc = ""; $npa = ""; $nxx = ""; $e164 = "";
|
||||
if ($this->v->e164($parts[1], $e164, $cc, $npa, $nxx)) {
|
||||
$this->SetX(29);
|
||||
$this->Cell(0,0,substr($this->v->where_is($db, $cc, $npa, $nxx), 0, 20));
|
||||
}
|
||||
break;
|
||||
case "parent_service_id":
|
||||
$sql = sqlSelect($db,"service","prod_attr","id=::".$parts[1]."::");
|
||||
$rstmp = $db->Execute($sql);
|
||||
$atrs2 = split("\r\n", $rstmp->fields['prod_attr']);
|
||||
foreach ($atrs2 as $a2) {
|
||||
$parts2 = split("==", $a2);
|
||||
switch ($parts2[0]) {
|
||||
case "station":
|
||||
case "ported":
|
||||
$val = $line['name']." for ".$parts2[1];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "station":
|
||||
case "ported":
|
||||
$val = $line['name']." for ".$parts[1];
|
||||
break;
|
||||
case "date_orig":
|
||||
$this->SetX(119);
|
||||
$this->Cell(0,0,date(UNIX_DATE_FORMAT." H:i:s",$parts[1]));
|
||||
break;
|
||||
case "voip_cdr_id":
|
||||
$sql = "SELECT billsec, amount FROM ".AGILE_DB_PREFIX."voip_cdr WHERE site_id=".DEFAULT_SITE." AND id=".$parts[1];
|
||||
$row = $db->GetRow($sql);
|
||||
$this->SetX(160);
|
||||
$this->Cell(10,0,$row[0],0,0,'R');
|
||||
$this->SetX(160);
|
||||
$this->Cell(0,0,$this->_currency($row[1]),0,0,'R');
|
||||
$val = "";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->SetX(9);
|
||||
$this->Cell(0,0, $val);
|
||||
if ($line['price_type'] == 0) {
|
||||
$this->SetX(160);
|
||||
//$this->Cell(10,0, $line['qty']." M",0,0,'R');
|
||||
} else {
|
||||
$q = $line['qty'];
|
||||
if(empty($q)) $q = 1;
|
||||
$this->SetX(160);
|
||||
$this->Cell(10,0, $line['qty'],0,0,'R');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0, $this->_currency($line['amount']), 0,0,'R');
|
||||
}
|
||||
$this->y += 5;
|
||||
$this->SetY($this->y);
|
||||
$this->i++;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will draw the Summary Box, with the summary of the items
|
||||
* on the invoice.
|
||||
*/
|
||||
public function drawSummaryLineItems($inv) {
|
||||
global $C_translate;
|
||||
|
||||
if (! $this->show_itemized)
|
||||
return;
|
||||
|
||||
$items = $inv->summarizeLineItems($inv->print['invoiceitems']);
|
||||
|
||||
# Calculate the box size
|
||||
$box = count($items) < $this->itemsSummaryMax ? count($items) : $this->itemsSummaryMax;
|
||||
|
||||
$x = 10; $y = $this->sum_y ? $this->sum_y : 55;
|
||||
|
||||
# Draw a box.
|
||||
$this->SetFillColor(245);
|
||||
$this->SetXY($x-1,$y-3); $this->Cell(0,5*(1+1+1+5+$box)+1,'',1,0,'',1);
|
||||
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_cur_charge_summary','setup_invoice')); $y += 5;
|
||||
|
||||
$this->SetY($y);
|
||||
$this->SetFont('arial','',9);
|
||||
|
||||
$i=0;
|
||||
if (is_array($items)) {
|
||||
foreach($items as $line) {
|
||||
$this->SetX($x);
|
||||
|
||||
$q = $line['quantity'];
|
||||
if (empty($q))
|
||||
$q = 1;
|
||||
|
||||
$this->Cell(0,0,$q);
|
||||
$this->SetX($x+8);
|
||||
$this->Cell(0,0,sprintf('%s (%s)',$line['summaryname'],$this->_currency($line['price_base'])));
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$this->_currency($line['price_base']*$line['quantity']),0,0,'R');
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
$i++;
|
||||
if ($i > $this->itemsSummaryMax) {
|
||||
$this->SetFont('arial','B',11);
|
||||
$this->SetX($x);
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_summary','setup_invoice'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
# Calculate our rounding error
|
||||
$subtotal = 0;
|
||||
foreach($items as $line)
|
||||
$subtotal += $line['price_base']*$line['quantity'];
|
||||
|
||||
$subtotal = round($subtotal,2);
|
||||
|
||||
if (round($inv->print['invoice']['total_amt']-$inv->print['invoice']['tax_amt'],2) != $subtotal) {
|
||||
$this->SetFont('arial','',9);
|
||||
$this->SetX($x);
|
||||
$this->Cell(0,0,'Rounding');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$this->_currency($inv->print['invoice']['total_amt']-$inv->print['invoice']['tax_amt']-$subtotal),0,0,'R');
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
}
|
||||
|
||||
# @todo Draw discounts
|
||||
# Sub total and tax.
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
$this->SetFont('arial','B',9);
|
||||
$this->SetX($x+8);
|
||||
$this->Cell(0,0,'Sub Total');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$this->_currency($inv->print['invoice']['total_amt']-$inv->print['invoice']['tax_amt']),0,0,'R');
|
||||
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
$this->SetX($x+8);
|
||||
$this->Cell(0,0,'Taxes');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$this->_currency($inv->print['invoice']['tax_amt']),0,0,'R');
|
||||
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
$this->SetX($x+8);
|
||||
$this->Cell(0,0,'Total Charges');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$this->_currency($inv->print['invoice']['total_amt']),0,0,'R');
|
||||
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
$this->SetX($x+8);
|
||||
$this->Cell(0,0,'Payments Received');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$this->_currency($inv->print['invoice']['billed_amt']),0,0,'R');
|
||||
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
$this->SetX($x+8);
|
||||
$this->Cell(0,0,'Balance Due');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$this->_currency($inv->print['invoice']['total_amt']-$inv->print['invoice']['billed_amt']),0,0,'R');
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
624
modules/invoice/PDF/pdf_invoice_itemised-tcpdf.inc.php
Normal file
624
modules/invoice/PDF/pdf_invoice_itemised-tcpdf.inc.php
Normal file
@@ -0,0 +1,624 @@
|
||||
<?php
|
||||
/**
|
||||
* Graytech Hosting - Highly detailed PDF invoice
|
||||
*/
|
||||
require_once PATH_MODULES.'invoice/invoice_base_tcpdf.inc.php';
|
||||
|
||||
class pdf_invoice_overview extends pdf_invoice_base {
|
||||
var $v, $i, $y;
|
||||
|
||||
# Current line being printed
|
||||
public $sum_y = 0;
|
||||
|
||||
/**
|
||||
* Draw the logo
|
||||
*/
|
||||
public function drawCompanyLogo() {
|
||||
$x = 9; $y = 7;
|
||||
$size = 25;
|
||||
$logo = sprintf('%s/%s',PATH_THEMES.DEFAULT_THEME,'invoice/invoice-logo.png');
|
||||
|
||||
if (is_file($logo))
|
||||
$this->Image($logo,$x,$y,$size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the Company Address
|
||||
*/
|
||||
public function drawCompanyAddress($inv) {
|
||||
global $C_translate;
|
||||
|
||||
# Add the company address next to the logo
|
||||
$x = 40; $y = 7;
|
||||
|
||||
$this->SetFont('helvetica','B',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$inv->print['site']['NAME']); $y += 4;
|
||||
|
||||
$this->SetFont('helvetica','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$inv->print['site']['TAXID']); $y += 6;
|
||||
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$inv->print['site']['ADDRESS']); $y += 4;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%s, %s %s',$inv->print['site']['CITY'],$inv->print['site']['STATE'],$inv->print['site']['ZIP'])); $y += 4;
|
||||
|
||||
$y += 2;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Phone:'); $this->SetXY($x+16,$y); $this->Cell(0,0,$inv->print['site']['PHONE']); $y += 4;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Fax:'); $this->SetXY($x+16,$y); $this->Cell(0,0,$inv->print['site']['FAX']); $y += 4;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Web:'); $this->SetXY($x+16,$y); $this->addHtmlLink($inv->print['site']['URL'],$inv->print['site']['URL']); $y += 4;
|
||||
}
|
||||
|
||||
public function drawRemittenceStub($inv) {
|
||||
global $C_translate;
|
||||
|
||||
# Draw the remittance line
|
||||
$this->Line(9,195,200,195);
|
||||
|
||||
$x = 18; $y = 200;
|
||||
|
||||
$this->SetFont('helvetica','B',13);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_payment_remit','setup_invoice')); $y +=5;
|
||||
|
||||
$this->SetFont('helvetica','',8);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_return1','setup_invoice')); $y +=3;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_return2','setup_invoice').' '.$inv->print['site']['NAME']);
|
||||
|
||||
# Due Date
|
||||
$x = 110; $y = 200;
|
||||
$this->SetFont('helvetica','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_bill_date','setup_invoice'));
|
||||
$this->SetFont('helvetica','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,date(UNIX_DATE_FORMAT,$inv->print['invoice']['date_orig']),0,0,'R');
|
||||
|
||||
# Account ID
|
||||
$y = 205;
|
||||
$this->SetFont('helvetica','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_account_number','setup_invoice'));
|
||||
$this->SetFont('helvetica','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%06s',$inv->print['account']['id']),0,0,'R');
|
||||
|
||||
# Invoice number
|
||||
$y = 210;
|
||||
$this->SetFont('helvetica','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number','setup_invoice'));
|
||||
$this->SetFont('helvetica','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%06s',$inv->getInvoiceNum()),0,0,'R');
|
||||
|
||||
# Company Address
|
||||
$y = 216;
|
||||
$this->SetFont('helvetica','',10);
|
||||
$this->SetXY(18,$y); $this->Cell(0,0,$inv->print['site']['NAME']); $y += 4;
|
||||
$this->SetXY(18,$y); $this->Cell(0,0,$inv->print['site']['ADDRESS']); $y += 4;
|
||||
$this->SetXY(18,$y); $this->Cell(0,0,sprintf('%s, %s %s',$inv->print['site']['CITY'],$inv->print['site']['STATE'],$inv->print['site']['ZIP'])); $y += 4;
|
||||
|
||||
# Previous Due
|
||||
$y = 215;
|
||||
$this->SetFont('helvetica','',9);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Previous Due');
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$this->_currency($inv->getPreviousBalance()),0,0,'R');
|
||||
|
||||
$y = 219;
|
||||
$this->SetFont('helvetica','',9);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_amount_due_by','setup_invoice').' '.date(UNIX_DATE_FORMAT,$inv->print['invoice']['due_date']));
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$this->_currency($inv->print['invoice']['total_amt']-$inv->print['invoice']['billed_amt']),0,0,'R');
|
||||
|
||||
# Total Due
|
||||
$y = 224;
|
||||
$this->SetFont('helvetica','B',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Total Due');
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$this->_currency($inv->getPreviousBalance()+$inv->print['invoice']['total_amt']-$inv->print['invoice']['billed_amt']),0,0,'R');
|
||||
|
||||
# Draw the Customers Address
|
||||
$x = 25; $y = 248;
|
||||
|
||||
$this->SetFont('helvetica','B',12);
|
||||
|
||||
if ($this->billToCompany && ! empty($inv->print['account']['company']))
|
||||
$name = $inv->print['account']['company'];
|
||||
else
|
||||
$name = sprintf('%s %s',$inv->print['account']['first_name'],$inv->print['account']['last_name']);
|
||||
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,html_entity_decode($name,ENT_NOQUOTES)); $y += 5;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%s %s ',$inv->print['account']['address1'],$inv->print['account']['address2'])); $y += 5;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%s, %s %s',$inv->print['account']['city'],$inv->print['account']['state'],$inv->print['account']['zip'])); $y += 5;
|
||||
}
|
||||
|
||||
public function drawInvoiceHeader($inv) {
|
||||
global $C_translate;
|
||||
|
||||
$x = 125; $y = 10;
|
||||
|
||||
# Draw a box.
|
||||
$this->SetFillColor(245);
|
||||
$this->SetXY($x-1,$y-1); $this->Cell(0,35+($inv->print['invoice']['billed_amt'] ? 5 : 0),'',1,0,'',1);
|
||||
|
||||
# Draw a box around the invoice due date and amount due.
|
||||
$this->SetFont('helvetica','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'TAX INVOICE');
|
||||
$this->SetFont('helvetica','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%06s',$inv->getInvoiceNum()),0,0,'R');
|
||||
|
||||
# Invoice number at top of page.
|
||||
$y += 7;
|
||||
$this->SetFont('helvetica','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_bill_date','setup_invoice')); $y += 5;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_amount_due_by','setup_invoice'));
|
||||
|
||||
$y -= 5;
|
||||
$this->SetFont('helvetica','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,date(UNIX_DATE_FORMAT,$inv->print['invoice']['date_orig']),0,0,'R'); $y += 5;
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,date(UNIX_DATE_FORMAT,$inv->print['invoice']['due_date']),0,0,'R');
|
||||
|
||||
$y += 5;
|
||||
$this->SetFont('helvetica','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Previous Due');
|
||||
$this->SetFont('helvetica','B',11);
|
||||
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->getPreviousBalance()),0,0,'R');
|
||||
|
||||
$y += 5;
|
||||
$this->SetFont('helvetica','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_current_charges','setup_invoice'));
|
||||
$this->SetFont('helvetica','B',11);
|
||||
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->print['invoice']['total_amt']),0,0,'R');
|
||||
|
||||
if ($inv->print['invoice']['billed_amt']) {
|
||||
$y += 5;
|
||||
$this->SetFont('helvetica','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Payments Received');
|
||||
$this->SetFont('helvetica','B',11);
|
||||
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->print['invoice']['billed_amt']),0,0,'R');
|
||||
}
|
||||
|
||||
$y += 5;
|
||||
$this->SetFont('helvetica','',10);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Total Payable');
|
||||
$this->SetFont('helvetica','B',11);
|
||||
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->getPreviousBalance()+$inv->print['invoice']['total_amt']-$inv->print['invoice']['billed_amt']),0,0,'R');
|
||||
}
|
||||
|
||||
#@todo Limit the size of the news to 6 lines
|
||||
public function drawNews($news) {
|
||||
global $C_translate;
|
||||
|
||||
if (! $news)
|
||||
return;
|
||||
|
||||
$x = 9; $y = 170;
|
||||
|
||||
# Draw a box.
|
||||
$this->SetFillColor(243);
|
||||
$this->SetXY($x-1,$y-1); $this->Cell(0,20,'',1,0,'',1);
|
||||
|
||||
$this->SetFont('helvetica','',8);
|
||||
$this->SetXY($x,$y); $this->MultiCell(0,3,str_replace('\n',"\n",$news),0,'L',0);
|
||||
}
|
||||
|
||||
#@todo make this list dynamic
|
||||
public function drawPaymentMethods($inv) {
|
||||
$x = 110; $y = 242;
|
||||
|
||||
# Draw a box.
|
||||
$this->SetFillColor(235);
|
||||
$this->SetXY($x-1,$y-2); $this->Cell(0,32,'',1,0,'',1);
|
||||
|
||||
$this->SetFont('helvetica','B',8);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'This invoice can also be paid by:'); $y += 4;
|
||||
|
||||
# Direct Debit
|
||||
$logo = sprintf('%s/%s',PATH_THEMES.DEFAULT_THEME,'invoice/invoice-payment-dd.png');
|
||||
$this->Image($logo,$x+1,$y,8);
|
||||
$this->SetFont('helvetica','B',8);
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'Direct Credit to our Bank Account'); $y += 3;
|
||||
$this->SetFont('helvetica','',8);
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'BSB:'); $y += 3;
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'ACCOUNT:'); $y += 3;
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'REF:'); $y += 3;
|
||||
|
||||
$y -= 9;
|
||||
$this->SetFont('helvetica','B',8);
|
||||
$this->SetXY($x+30,$y); $this->Cell(0,0,'633-000'); $y += 3;
|
||||
$this->SetXY($x+30,$y); $this->Cell(0,0,'120 440 821'); $y += 3;
|
||||
$this->SetXY($x+30,$y); $this->Cell(0,0,$inv->getInvoiceID()); $y += 3;
|
||||
|
||||
# Direct Debit
|
||||
$y += 3;
|
||||
$logo = sprintf('%s/%s',PATH_THEMES.DEFAULT_THEME,'invoice/invoice-payment-dd.png');
|
||||
$this->Image($logo,$x+1,$y,8);
|
||||
$this->SetFont('helvetica','B',8);
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'Direct Debit'); $y += 3;
|
||||
$this->SetFont('helvetica','',8);
|
||||
$this->SetXY($x+10,$y); $this->Cell(0,0,'Please visit '); $this->SetXY($x+30,$y); $this->addHtmlLink($inv->print['site']['URL'].'?_page=invoice:user_view&id='.$inv->getInvoiceNum(),$inv->print['site']['URL']); $y += 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw previous invoices due
|
||||
*/
|
||||
public function drawSummaryInvoicesDue($items) {
|
||||
$x = 125; $y = $this->sum_y ? $this->sum_y : 50;
|
||||
|
||||
# Calculate the box size
|
||||
$box = count($items) < $this->itemsPreviousMax ? count($items) : $this->itemsPreviousMax;
|
||||
|
||||
# Draw a box.
|
||||
$this->SetFillColor(245);
|
||||
$this->SetXY($x-1,$y-1); $this->Cell(0,5*(1+$box)+1,'',1,0,'',1);
|
||||
|
||||
$this->SetFont('helvetica','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,'Previous Invoices due'); $y += 5;
|
||||
|
||||
$this->SetFont('helvetica','',11);
|
||||
$i = 0;
|
||||
$sum_total = 0;
|
||||
foreach ($items as $line) {
|
||||
if (++$i < $this->itemsPreviousMax) {
|
||||
$this->SetXY($x,$y);
|
||||
$this->Cell(0,0,sprintf('%s #%06s',date(UNIX_DATE_FORMAT,$line['date_orig']),$line['id']));
|
||||
$this->Cell(0,0,$this->_currency($line['total_amt']-$line['billed_amt']),0,0,'R'); $y += 5;
|
||||
|
||||
} else {
|
||||
$sum_total += $line['total_amt']-$line['billed_amt'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($sum_total) {
|
||||
$this->SetXY($x,$y);
|
||||
$this->SetFont('helvetica','I',11);
|
||||
$this->Cell(0,0,'Other invoices');
|
||||
$this->SetFont('helvetica','',11);
|
||||
$this->Cell(0,0,$this->_currency($sum_total),0,0,'R'); $y += 5;
|
||||
}
|
||||
|
||||
$this->sum_y = $y+5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before begining to loop the invoice_item table. Used to set initial values.
|
||||
*/
|
||||
public function drawLineItems_pre($iteration) {
|
||||
$this->iteration = $iteration;
|
||||
if ($iteration>1)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called once per line item to add to the PDF invoice. This function serves to
|
||||
* direct each iteration to a different function which handles a specific piece
|
||||
* of the PDF building puzzle.
|
||||
*/
|
||||
public function drawLineItems($db,$line,$invnum) {
|
||||
switch($this->iteration) {
|
||||
case 0:
|
||||
$this->drawLineItems_0($db,$line,$invnum);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$this->drawLineItems_1($db,$line,$invnum);
|
||||
break;
|
||||
|
||||
default:
|
||||
echo 'Unknown PDF iteration encountered. Halting.';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the non-VoIP related items for iteration 0.
|
||||
* @todo need to make sure that this pages well, when there are many items (with many sub details).
|
||||
* @tood Need to replicate this to the other fpdf files
|
||||
*/
|
||||
private function drawLineItems_0($db,$line,$invnum) {
|
||||
global $C_translate;
|
||||
|
||||
if ($line['price_type'] == 0 && $line['item_type']==5)
|
||||
return;
|
||||
|
||||
$x = 10;
|
||||
if ($this->i == 0 || $this->i%51 == 0) {
|
||||
$this->y = 5;
|
||||
$this->AddPage();
|
||||
|
||||
$this->SetFont('helvetica','B',12);
|
||||
$this->SetXY($x,$this->y); $this->Cell(0,0,$C_translate->translate('pdf_itemized_charges','setup_invoice'));
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_page','setup_invoice').$this->PageNo(),0,0,'R');
|
||||
$this->SetXY($x,$this->y); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number_small','setup_invoice').$invnum,0,0,'C');
|
||||
|
||||
# Draw table headers
|
||||
$this->y += 10;
|
||||
$this->SetFont('helvetica','B',8);
|
||||
$this->SetXY($x,$this->y);
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_item_description','setup_invoice'));
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_item_quantity','setup_invoice'));
|
||||
$this->SetX($x+160);
|
||||
$this->Cell(10,0,$C_translate->translate('pdf_item_cost','setup_invoice'),0,0,'R');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_item_amount','setup_invoice'),0,0,'R');
|
||||
$this->Line($x,$this->y+4,200,$this->y+4);
|
||||
$this->y += 5;
|
||||
$this->SetY($this->y);
|
||||
}
|
||||
|
||||
$this->SetFont('helvetica','',8);
|
||||
$this->SetX($x);
|
||||
$this->Cell(0,0,$line['name']);
|
||||
|
||||
if (isset($line['price_base'])) {
|
||||
$this->SetX($x+160);
|
||||
$this->Cell(10,0,$this->_currency($line['price_base']),0,0,'R');
|
||||
}
|
||||
|
||||
if (isset($line['qty'])) {
|
||||
$this->SetX($x+130);
|
||||
$this->Cell(10,0,$line['qty'],0,0,'R');
|
||||
}
|
||||
|
||||
$this->SetX($x+130);
|
||||
$this->Cell(0,0,$this->_currency($line['total_amt']),0,0,'R');
|
||||
|
||||
if ($this->show_service_range && $line['daterange']) {
|
||||
$this->SetFont('helvetica','I',7);
|
||||
$this->y += 3;
|
||||
$this->SetXY($x+10,$this->y); $this->Cell(0,0,'Service Period');
|
||||
$this->SetFont('helvetica','',7);
|
||||
$this->SetXY($x+40,$this->y); $this->Cell(0,0,$line['daterange']);
|
||||
}
|
||||
|
||||
if ($line['domain']) {
|
||||
$this->SetFont('helvetica','I',7);
|
||||
$this->y += 3;
|
||||
$this->SetXY($x+10,$this->y); $this->Cell(0,0,'Domain');
|
||||
$this->SetFont('helvetica','',7);
|
||||
$this->SetXY($x+40,$this->y); $this->Cell(0,0,$line['domain']);
|
||||
}
|
||||
|
||||
if ($line['attr']) {
|
||||
$showchars = 20;
|
||||
foreach (explode("\n",$line['attr']) as $attr) {
|
||||
list($field,$value) = explode('==',$attr);
|
||||
|
||||
$this->SetFont('helvetica','I',7);
|
||||
$this->y += 3;
|
||||
$this->SetXY(20,$this->y); $this->Cell(0,0,strlen($field) > $showchars ? substr($field,0,$showchars-2).'...' : $field);
|
||||
$this->SetFont('helvetica','',7);
|
||||
$this->SetXY(50,$this->y); $this->Cell(0,0,$value);
|
||||
}
|
||||
}
|
||||
|
||||
$this->y += 5;
|
||||
$this->SetY($this->y);
|
||||
$this->i++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the Item Detail for Iteration 1.
|
||||
*/
|
||||
private function drawLineItems_1($db,$line,$invnum) {
|
||||
global $C_translate;
|
||||
|
||||
if ($this->show_itemized != 1) return;
|
||||
if ($line['price_type'] != 0 || $line['item_type'] != 5)
|
||||
return;
|
||||
|
||||
$x = 10; $this->y = 5;
|
||||
if ($this->i == 0 || $this->i%51 == 0) {
|
||||
$this->AddPage();
|
||||
|
||||
$this->SetFont('helvetica','B',12);
|
||||
$this->SetXY($x,$this->y); $this->Cell(0,0,$C_translate->translate('pdf_itemized_calls','setup_invoice'));
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_page','setup_invoice').$this->PageNo(),0,0,'R');
|
||||
$this->SetXY($x,$this->y); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number_small','setup_invoice').$invnum,0,0,'C');
|
||||
|
||||
# Draw table headers
|
||||
$this->SetFont('helvetica','B',8);
|
||||
$this->SetXY($x,$this->y);
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_item_from','setup_invoice'));
|
||||
$this->SetX(69);
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_item_to','setup_invoice'));
|
||||
$this->SetX(119);
|
||||
$this->Cell(0,0,'Date & Time');
|
||||
$this->SetX(160);
|
||||
$this->Cell(10,0,'Seconds' /*$C_translate->translate('pdf_item_min','setup_invoice')*/,0,0,'R');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_item_amount','setup_invoice'),0,0,'R');
|
||||
$this->Line($x,$this->y+4,200,$this->y+4);
|
||||
$this->y += 5;
|
||||
$this->SetY($this->y);
|
||||
}
|
||||
|
||||
if ($line['price_type'] != 0) {
|
||||
$this->SetFont('helvetica','I',6);
|
||||
} else {
|
||||
$this->SetFont('helvetica','',6);
|
||||
}
|
||||
|
||||
$val = $line['name'];
|
||||
if (strlen($line['attr'])) {
|
||||
$val = "";
|
||||
$atrs = preg_split("/\r\n/", str_replace('\r\n',"\r\n",$line['attr']));
|
||||
foreach ($atrs as $a) {
|
||||
$parts = preg_split("/==/", $a);
|
||||
switch ($parts[0]) {
|
||||
case "Destination":
|
||||
$this->SetX(69);
|
||||
$this->Cell(0,0,$parts[1]);
|
||||
$cc = ""; $npa = ""; $nxx = ""; $e164 = "";
|
||||
if ($this->v->e164($parts[1], $e164, $cc, $npa, $nxx)) {
|
||||
$this->SetX(89);
|
||||
$this->Cell(0,0,substr($this->v->where_is($db, $cc, $npa, $nxx), 0, 20));
|
||||
}
|
||||
break;
|
||||
case "Source":
|
||||
$this->SetX(9);
|
||||
$this->Cell(0,0,$parts[1]);
|
||||
$cc = ""; $npa = ""; $nxx = ""; $e164 = "";
|
||||
if ($this->v->e164($parts[1], $e164, $cc, $npa, $nxx)) {
|
||||
$this->SetX(29);
|
||||
$this->Cell(0,0,substr($this->v->where_is($db, $cc, $npa, $nxx), 0, 20));
|
||||
}
|
||||
break;
|
||||
case "parent_service_id":
|
||||
$sql = sqlSelect($db,"service","prod_attr","id=::".$parts[1]."::");
|
||||
$rstmp = $db->Execute($sql);
|
||||
$atrs2 = split("\r\n", $rstmp->fields['prod_attr']);
|
||||
foreach ($atrs2 as $a2) {
|
||||
$parts2 = split("==", $a2);
|
||||
switch ($parts2[0]) {
|
||||
case "station":
|
||||
case "ported":
|
||||
$val = $line['name']." for ".$parts2[1];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "station":
|
||||
case "ported":
|
||||
$val = $line['name']." for ".$parts[1];
|
||||
break;
|
||||
case "date_orig":
|
||||
$this->SetX(119);
|
||||
$this->Cell(0,0,date(UNIX_DATE_FORMAT." H:i:s",$parts[1]));
|
||||
break;
|
||||
case "voip_cdr_id":
|
||||
$sql = "SELECT billsec, amount FROM ".AGILE_DB_PREFIX."voip_cdr WHERE site_id=".DEFAULT_SITE." AND id=".$parts[1];
|
||||
$row = $db->GetRow($sql);
|
||||
$this->SetX(160);
|
||||
$this->Cell(10,0,$row[0],0,0,'R');
|
||||
$this->SetX(160);
|
||||
$this->Cell(0,0,$this->_currency($row[1]),0,0,'R');
|
||||
$val = "";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->SetX(9);
|
||||
$this->Cell(0,0, $val);
|
||||
if ($line['price_type'] == 0) {
|
||||
$this->SetX(160);
|
||||
//$this->Cell(10,0, $line['qty']." M",0,0,'R');
|
||||
} else {
|
||||
$q = $line['qty'];
|
||||
if(empty($q)) $q = 1;
|
||||
$this->SetX(160);
|
||||
$this->Cell(10,0, $line['qty'],0,0,'R');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0, $this->_currency($line['amount']), 0,0,'R');
|
||||
}
|
||||
$this->y += 5;
|
||||
$this->SetY($this->y);
|
||||
$this->i++;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will draw the Summary Box, with the summary of the items
|
||||
* on the invoice.
|
||||
*/
|
||||
public function drawSummaryLineItems($inv) {
|
||||
global $C_translate;
|
||||
|
||||
if (! $this->show_itemized)
|
||||
return;
|
||||
|
||||
$items = $inv->summarizeLineItems($inv->print['invoiceitems']);
|
||||
|
||||
# Calculate the box size
|
||||
$box = count($items) < $this->itemsSummaryMax ? count($items) : $this->itemsSummaryMax;
|
||||
|
||||
$x = 10; $y = $this->sum_y ? $this->sum_y : 55;
|
||||
|
||||
# Draw a box.
|
||||
$this->SetFillColor(245);
|
||||
$this->SetXY($x-1,$y-1); $this->Cell(0,5*(1+1+1+5+$box)+1,'',1,0,'',1);
|
||||
|
||||
$this->SetFont('helvetica','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,$C_translate->translate('pdf_cur_charge_summary','setup_invoice')); $y += 5;
|
||||
|
||||
$this->SetY($y);
|
||||
$this->SetFont('helvetica','',9);
|
||||
|
||||
$i=0;
|
||||
if (is_array($items)) {
|
||||
foreach($items as $line) {
|
||||
$this->SetX($x);
|
||||
|
||||
$q = $line['quantity'];
|
||||
if (empty($q))
|
||||
$q = 1;
|
||||
|
||||
$this->Cell(0,0,$q);
|
||||
$this->SetX($x+8);
|
||||
$this->Cell(0,0,sprintf('%s (%s)',$line['summaryname'],$this->_currency($line['price_base'])));
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$this->_currency($line['price_base']*$line['quantity']),0,0,'R');
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
$i++;
|
||||
if ($i > $this->itemsSummaryMax) {
|
||||
$this->SetFont('helvetica','B',11);
|
||||
$this->SetX($x);
|
||||
$this->Cell(0,0,$C_translate->translate('pdf_summary','setup_invoice'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
# Calculate our rounding error
|
||||
$subtotal = 0;
|
||||
foreach($items as $line)
|
||||
$subtotal += $line['price_base']*$line['quantity'];
|
||||
|
||||
$subtotal = round($subtotal,2);
|
||||
|
||||
if (round($inv->print['invoice']['total_amt']-$inv->print['invoice']['tax_amt'],2) != $subtotal) {
|
||||
$this->SetFont('helvetica','',9);
|
||||
$this->SetX($x);
|
||||
$this->Cell(0,0,'Rounding');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$this->_currency($inv->print['invoice']['total_amt']-$inv->print['invoice']['tax_amt']-$subtotal),0,0,'R');
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
}
|
||||
|
||||
# @todo Draw discounts
|
||||
# Sub total and tax.
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
$this->SetFont('helvetica','B',9);
|
||||
$this->SetX($x+8);
|
||||
$this->Cell(0,0,'Sub Total');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$this->_currency($inv->print['invoice']['total_amt']-$inv->print['invoice']['tax_amt']),0,0,'R');
|
||||
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
$this->SetX($x+8);
|
||||
$this->Cell(0,0,'Taxes');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$this->_currency($inv->print['invoice']['tax_amt']),0,0,'R');
|
||||
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
$this->SetX($x+8);
|
||||
$this->Cell(0,0,'Total Charges');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$this->_currency($inv->print['invoice']['total_amt']),0,0,'R');
|
||||
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
$this->SetX($x+8);
|
||||
$this->Cell(0,0,'Payments Received');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$this->_currency($inv->print['invoice']['billed_amt']),0,0,'R');
|
||||
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
$this->SetX($x+8);
|
||||
$this->Cell(0,0,'Balance Due');
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,$this->_currency($inv->print['invoice']['total_amt']-$inv->print['invoice']['billed_amt']),0,0,'R');
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@@ -1,13 +1,41 @@
|
||||
<?php
|
||||
$auth_methods = Array
|
||||
(
|
||||
Array ('module' => 'invoice', 'method' => 'user_search'),
|
||||
Array ('module' => 'invoice', 'method' => 'user_search_show'),
|
||||
Array ('module' => 'invoice', 'method' => 'user_view'),
|
||||
Array ('module' => 'invoice', 'method' => 'pdf'),
|
||||
Array ('module' => 'invoice', 'method' => 'checkoutnow'),
|
||||
Array ('module' => 'invoice', 'method' => 'checkout_multiple_preview'),
|
||||
Array ('module' => 'invoice', 'method' => 'custom_tracking'),
|
||||
Array ('module' => 'invoice', 'method' => 'has_unpaid'),
|
||||
<?php
|
||||
/**
|
||||
* AgileBill - Open Billing Software
|
||||
*
|
||||
* This body of work is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Open AgileBill License
|
||||
* License as published at http://www.agileco.com/agilebill/license1-4.txt
|
||||
*
|
||||
* Originally authored by Tony Landis, AgileBill LLC
|
||||
*
|
||||
* Recent modifications by Deon George
|
||||
*
|
||||
* @author Deon George <deonATleenooksDOTnet>
|
||||
* @copyright 2009 Deon George
|
||||
* @link http://osb.leenooks.net
|
||||
*
|
||||
* @link http://www.agileco.com/
|
||||
* @copyright 2004-2008 Agileco, LLC.
|
||||
* @license http://www.agileco.com/agilebill/license1-4.txt
|
||||
* @author Tony Landis <tony@agileco.com>
|
||||
* @package AgileBill
|
||||
* @subpackage Modules:Invoice
|
||||
*/
|
||||
|
||||
/**
|
||||
* The main AgileBill Invoice Class
|
||||
*
|
||||
* @package AgileBill
|
||||
*/
|
||||
|
||||
$auth_methods = array (
|
||||
array('module'=>'invoice','method'=>'user_search'),
|
||||
array('module'=>'invoice','method'=>'user_search_show'),
|
||||
array('module'=>'invoice','method'=>'user_view'),
|
||||
array('module'=>'invoice','method'=>'pdf'),
|
||||
array('module'=>'invoice','method'=>'checkoutnow'),
|
||||
array('module'=>'invoice','method'=>'tpl_checkout_multiple_preview'),
|
||||
array('module'=>'invoice','method'=>'custom_tracking'),
|
||||
array('module'=>'invoice','method'=>'has_unpaid'),
|
||||
);
|
||||
?>
|
||||
?>
|
||||
|
File diff suppressed because it is too large
Load Diff
197
modules/invoice/invoice_base_fpdf.inc.php
Normal file
197
modules/invoice/invoice_base_fpdf.inc.php
Normal file
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
/**
|
||||
* AgileBill - Open Billing Software
|
||||
*
|
||||
* This body of work is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Open AgileBill License
|
||||
* License as published at http://www.agileco.com/agilebill/license1-4.txt
|
||||
*
|
||||
* Originally authored by Joseph Benden
|
||||
* Modifications by Tony Landis, AgileBill LLC
|
||||
*
|
||||
* Recent modifications by Deon George
|
||||
*
|
||||
* @author Deon George <deonATleenooksDOTnet>
|
||||
* @copyright 2009 Deon George
|
||||
* @link http://osb.leenooks.net
|
||||
*
|
||||
* @link http://www.agileco.com/
|
||||
* @copyright 2004-2008 Agileco, LLC.
|
||||
* @license http://www.agileco.com/agilebill/license1-4.txt
|
||||
* @author Tony Landis <tony@agileco.com>
|
||||
* @package AgileBill
|
||||
* @subpackage Module:Invoice
|
||||
*/
|
||||
|
||||
define('FPDF_FONTPATH',PATH_INCLUDES.'fpdf/font/');
|
||||
require_once(PATH_INCLUDES.'fpdf/fpdf.php');
|
||||
|
||||
/**
|
||||
* PDF Invoice Base
|
||||
*
|
||||
* @package AgileBill
|
||||
* @subpackage Module:Invoice
|
||||
*/
|
||||
abstract class pdf_invoice_base extends fpdf {
|
||||
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($inv) {
|
||||
parent::__construct();
|
||||
|
||||
$this->SetCreator('Open Source Billing');
|
||||
$this->SetAuthor($inv->print['site']['NAME']);
|
||||
$this->SetTitle(sprintf('%s Invoice',$inv->print['site']['NAME']));
|
||||
$this->SetSubject(sprintf('Invoice #%06s',$inv->getInvoiceNum()));
|
||||
$this->SetKeywords($inv->getInvoiceID());
|
||||
$this->SetAutoPageBreak(TRUE,25);
|
||||
$this->SetDisplayMode('fullwidth');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function load_setup(&$rs) {
|
||||
if (! $rs) {
|
||||
$db =& DB();
|
||||
$rs = $db->Execute(sqlSelect($db,'setup_invoice','*',''));
|
||||
}
|
||||
|
||||
$this->billToCompany = $rs->fields['bill_to_company'];
|
||||
$this->invoiceCurrency = $rs->fields['invoice_currency'];
|
||||
$this->invoiceDecimals = $rs->fields['invoice_decimals'];
|
||||
$this->itemsSummaryMax = $rs->fields['items_summary_max'];
|
||||
$this->news = $rs->fields['news'];
|
||||
$this->pageType = $rs->fields['page_type'];
|
||||
$this->show_itemized = $rs->fields['invoice_show_itemized'];
|
||||
$this->show_service_range = $rs->fields['invoice_show_service_dates'];
|
||||
}
|
||||
|
||||
abstract public function drawCompanyLogo();
|
||||
abstract public function drawCompanyAddress($inv);
|
||||
abstract public function drawInvoiceHeader($inv);
|
||||
|
||||
/**
|
||||
* Enable re-iteration of the invoices items, so that they can be displayed many ways
|
||||
*/
|
||||
abstract public function drawLineItems_pre($iteration);
|
||||
|
||||
/**
|
||||
* This is called for each line item.
|
||||
*/
|
||||
abstract public function drawLineItems($db,$line,$invnum);
|
||||
|
||||
/**
|
||||
* Draws the summary on the first page
|
||||
*/
|
||||
abstract public function drawSummaryLineItems($inv);
|
||||
abstract public function drawPaymentMethods($inv);
|
||||
|
||||
public function drawRemittenceStub() {}
|
||||
public function drawCustom() {}
|
||||
public function drawInvoiceDueNotice() {}
|
||||
public function drawInvoicePaidNotice() {}
|
||||
public function setLateFeeNotice() {}
|
||||
|
||||
/**
|
||||
* Get a blank invoice template
|
||||
*/
|
||||
public function getTemplate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns the invoice fields to this object.
|
||||
*/
|
||||
public function setInvoiceFields($flds) {
|
||||
$this->invoice = $flds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns the account fields to this object.
|
||||
*/
|
||||
public function setAccountFields($flds) {
|
||||
$this->account = $flds;
|
||||
}
|
||||
|
||||
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']);
|
||||
}
|
||||
|
||||
protected function Rotate($angle,$x=-1,$y=-1) {
|
||||
if ($x==-1)
|
||||
$x = $this->x;
|
||||
if ($y==-1)
|
||||
$y = $this->y;
|
||||
if ($this->angle!=0)
|
||||
$this->_out('Q');
|
||||
$this->angle = $angle;
|
||||
|
||||
if ($angle != 0) {
|
||||
$angle *= M_PI/180;
|
||||
$c = cos($angle);
|
||||
$s = sin($angle);
|
||||
$cx = $x*$this->k;
|
||||
$cy = ($this->h-$y)*$this->k;
|
||||
$this->_out(sprintf('q %.5f %.5f %.5f %.5f %.2f %.2f cm 1 0 0 1 %.2f %.2f cm',$c,$s,-$s,$c,$cx,$cy,-$cx,-$cy));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a watermark to the PDF
|
||||
*/
|
||||
public function addWaterMark($text) {
|
||||
$this->SetFont('arial','B',50);
|
||||
$this->SetTextColor(203,203,203);
|
||||
$this->Rotate(0);
|
||||
$this->Text(10,50,$text);
|
||||
$this->Rotate(0);
|
||||
$this->SetTextColor(0,0,0);
|
||||
}
|
||||
}
|
||||
?>
|
314
modules/invoice/invoice_base_fpdi.inc.php
Normal file
314
modules/invoice/invoice_base_fpdi.inc.php
Normal file
@@ -0,0 +1,314 @@
|
||||
<?php
|
||||
/**
|
||||
* AgileBill - Open Billing Software
|
||||
*
|
||||
* This body of work is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Open AgileBill License
|
||||
* License as published at http://www.agileco.com/agilebill/license1-4.txt
|
||||
*
|
||||
* Originally authored by Joseph Benden
|
||||
* Modifications by Tony Landis, AgileBill LLC
|
||||
*
|
||||
* Recent modifications by Deon George
|
||||
*
|
||||
* @author Deon George <deonATleenooksDOTnet>
|
||||
* @copyright 2009 Deon George
|
||||
* @link http://osb.leenooks.net
|
||||
*
|
||||
* @link http://www.agileco.com/
|
||||
* @copyright 2004-2008 Agileco, LLC.
|
||||
* @license http://www.agileco.com/agilebill/license1-4.txt
|
||||
* @author Tony Landis <tony@agileco.com>
|
||||
* @package AgileBill
|
||||
* @subpackage Module:Invoice
|
||||
*/
|
||||
|
||||
define('FPDF_FONTPATH',PATH_INCLUDES.'pdf/font/');
|
||||
require_once(PATH_INCLUDES.'pdf/fpdi.php');
|
||||
require_once(PATH_INCLUDES.'pdf/fpdf_tpl.php');
|
||||
require_once(PATH_INCLUDES.'pdf/fpdf.php');
|
||||
|
||||
/**
|
||||
* PDF Invoice Base
|
||||
*
|
||||
* @package AgileBill
|
||||
* @subpackage Module:Invoice
|
||||
*/
|
||||
abstract class pdf_invoice_base extends fpdi {
|
||||
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($inv) {
|
||||
parent::__construct();
|
||||
|
||||
$this->SetCreator('Open Source Billing');
|
||||
$this->SetAuthor($inv->print['site']['NAME']);
|
||||
$this->SetTitle(sprintf('%s Invoice',$inv->print['site']['NAME']));
|
||||
$this->SetSubject(sprintf('Invoice #%06s',$inv->getInvoiceNum()));
|
||||
$this->SetKeywords($inv->getInvoiceID());
|
||||
$this->SetAutoPageBreak(TRUE,25);
|
||||
$this->SetDisplayMode('fullwidth');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function load_setup(&$rs) {
|
||||
if (! $rs) {
|
||||
$db =& DB();
|
||||
$rs = $db->Execute(sqlSelect($db,'setup_invoice','*',''));
|
||||
}
|
||||
|
||||
$this->billToCompany = $rs->fields['bill_to_company'];
|
||||
$this->invoiceCurrency = $rs->fields['invoice_currency'];
|
||||
$this->invoiceDecimals = $rs->fields['invoice_decimals'];
|
||||
$this->itemsSummaryMax = $rs->fields['items_summary_max'];
|
||||
$this->news = $rs->fields['news'];
|
||||
$this->pageType = $rs->fields['page_type'];
|
||||
$this->show_itemized = $rs->fields['invoice_show_itemized'];
|
||||
$this->show_service_range = $rs->fields['invoice_show_service_dates'];
|
||||
}
|
||||
|
||||
abstract public function drawCompanyLogo();
|
||||
abstract public function drawCompanyAddress($inv);
|
||||
abstract public function drawInvoiceHeader($inv);
|
||||
|
||||
/**
|
||||
* Enable re-iteration of the invoices items, so that they can be displayed many ways
|
||||
*/
|
||||
abstract public function drawLineItems_pre($iteration);
|
||||
|
||||
/**
|
||||
* This is called for each line item.
|
||||
*/
|
||||
abstract public function drawLineItems($db,$line,$invnum);
|
||||
|
||||
/**
|
||||
* Draws the summary on the first page
|
||||
*/
|
||||
abstract public function drawSummaryLineItems($inv);
|
||||
abstract public function drawPaymentMethods($inv);
|
||||
|
||||
public function drawRemittenceStub() {}
|
||||
public function drawCustom() {}
|
||||
public function drawInvoiceDueNotice() {}
|
||||
public function drawInvoicePaidNotice() {}
|
||||
public function setLateFeeNotice() {}
|
||||
|
||||
/**
|
||||
* Get a blank invoice template
|
||||
*/
|
||||
public function getTemplate() {
|
||||
return PATH_THEMES.DEFAULT_THEME.'/invoice/invoice-'.$this->pageType.'.pdf';
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns the invoice fields to this object.
|
||||
*/
|
||||
public function setInvoiceFields($flds) {
|
||||
$this->invoice = $flds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns the account fields to this object.
|
||||
*/
|
||||
public function setAccountFields($flds) {
|
||||
$this->account = $flds;
|
||||
}
|
||||
|
||||
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']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override fpdf functions
|
||||
*/
|
||||
public function _putpages() {
|
||||
$nb = $this->page;
|
||||
if (! empty($this->AliasNbPages)) {
|
||||
//Replace number of pages
|
||||
for ($n=1;$n<=$nb;$n++)
|
||||
$this->pages[$n]=($this->compress) ? gzcompress(str_replace($this->AliasNbPages,$nb,gzuncompress($this->pages[$n]))) : str_replace($this->AliasNbPages,$nb,$this->pages[$n]) ;
|
||||
}
|
||||
|
||||
if ($this->DefOrientation=='P') {
|
||||
$wPt=$this->fwPt;
|
||||
$hPt=$this->fhPt;
|
||||
} else {
|
||||
$wPt=$this->fhPt;
|
||||
$hPt=$this->fwPt;
|
||||
}
|
||||
|
||||
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
|
||||
for($n=1;$n<=$nb;$n++) {
|
||||
//Page
|
||||
$this->_newobj();
|
||||
$this->_out('<</Type /Page');
|
||||
$this->_out('/Parent 1 0 R');
|
||||
if (isset($this->OrientationChanges[$n]))
|
||||
$this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]',$hPt,$wPt));
|
||||
$this->_out('/Resources 2 0 R');
|
||||
if(isset($this->PageLinks[$n])) {
|
||||
//Links
|
||||
$annots='/Annots [';
|
||||
foreach($this->PageLinks[$n] as $pl) {
|
||||
$rect=sprintf('%.2f %.2f %.2f %.2f',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
|
||||
$annots.='<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
|
||||
if(is_string($pl[4]))
|
||||
$annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
|
||||
else {
|
||||
$l=$this->links[$pl[4]];
|
||||
$h=isset($this->OrientationChanges[$l[0]]) ? $wPt : $hPt;
|
||||
$annots.=sprintf('/Dest [%d 0 R /XYZ 0 %.2f null]>>',1+2*$l[0],$h-$l[1]*$this->k);
|
||||
}
|
||||
}
|
||||
$this->_out($annots.']');
|
||||
}
|
||||
$this->_out('/Contents '.($this->n+1).' 0 R>>');
|
||||
$this->_out('endobj');
|
||||
//Page content
|
||||
$this->_newobj();
|
||||
$this->_out('<<'.$filter.'/Length '.strlen($this->pages[$n]).'>>');
|
||||
$this->_putstream($this->pages[$n]);
|
||||
$this->_out('endobj');
|
||||
}
|
||||
|
||||
//Pages root
|
||||
$this->offsets[1]=strlen($this->buffer);
|
||||
$this->_out('1 0 obj');
|
||||
$this->_out('<</Type /Pages');
|
||||
$kids='/Kids [';
|
||||
for ($i=0;$i<$nb;$i++)
|
||||
$kids.=(3+2*$i).' 0 R ';
|
||||
$this->_out($kids.']');
|
||||
$this->_out('/Count '.$nb);
|
||||
$this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]',$wPt,$hPt));
|
||||
$this->_out('>>');
|
||||
$this->_out('endobj');
|
||||
}
|
||||
|
||||
public function _endpage() {
|
||||
//End of page contents
|
||||
$this->pages[$this->page] = ($this->compress) ? gzcompress($this->pages[$this->page]) : $this->pages[$this->page];
|
||||
$this->state=1;
|
||||
}
|
||||
|
||||
protected function RoundedRect($x,$y,$w,$h,$r,$style='') {
|
||||
$k = $this->k;
|
||||
$hp = $this->h;
|
||||
|
||||
if ($style=='F')
|
||||
$op = 'f';
|
||||
elseif ($style=='FD' || $style=='DF')
|
||||
$op = 'B';
|
||||
else
|
||||
$op = 'S';
|
||||
|
||||
$MyArc = 4/3*(sqrt(2)-1);
|
||||
$this->_out(sprintf('%.2f %.2f m',($x+$r)*$k,($hp-$y)*$k));
|
||||
$xc = $x+$w-$r ;
|
||||
$yc = $y+$r;
|
||||
$this->_out(sprintf('%.2f %.2f l',$xc*$k,($hp-$y)*$k));
|
||||
|
||||
$this->_Arc($xc+$r*$MyArc,$yc-$r,$xc+$r,$yc-$r*$MyArc,$xc+$r,$yc);
|
||||
$xc = $x+$w-$r;
|
||||
$yc = $y+$h-$r;
|
||||
$this->_out(sprintf('%.2f %.2f l',($x+$w)*$k,($hp-$yc)*$k));
|
||||
|
||||
$this->_Arc($xc+$r,$yc+$r*$MyArc,$xc+$r*$MyArc,$yc+$r,$xc,$yc+$r);
|
||||
$xc = $x+$r;
|
||||
$yc = $y+$h-$r;
|
||||
$this->_out(sprintf('%.2f %.2f l',$xc*$k,($hp-($y+$h))*$k));
|
||||
|
||||
$this->_Arc($xc-$r*$MyArc,$yc+$r,$xc-$r,$yc+$r*$MyArc,$xc-$r,$yc);
|
||||
$xc = $x+$r;
|
||||
$yc = $y+$r;
|
||||
$this->_out(sprintf('%.2f %.2f l',($x)*$k,($hp-$yc)*$k));
|
||||
|
||||
$this->_Arc($xc-$r,$yc-$r*$MyArc,$xc-$r*$MyArc,$yc-$r,$xc,$yc-$r);
|
||||
$this->_out($op);
|
||||
}
|
||||
|
||||
private function _Arc($x1,$y1,$x2,$y2,$x3,$y3) {
|
||||
$h = $this->h;
|
||||
$this->_out(sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c ',
|
||||
$x1*$this->k,($h-$y1)*$this->k,$x2*$this->k,($h-$y2)*$this->k,$x3*$this->k,($h-$y3)*$this->k));
|
||||
}
|
||||
|
||||
protected function Rotate($angle,$x=-1,$y=-1) {
|
||||
if ($x==-1)
|
||||
$x = $this->x;
|
||||
if ($y==-1)
|
||||
$y = $this->y;
|
||||
if ($this->angle!=0)
|
||||
$this->_out('Q');
|
||||
$this->angle = $angle;
|
||||
|
||||
if ($angle != 0) {
|
||||
$angle *= M_PI/180;
|
||||
$c = cos($angle);
|
||||
$s = sin($angle);
|
||||
$cx = $x*$this->k;
|
||||
$cy = ($this->h-$y)*$this->k;
|
||||
$this->_out(sprintf('q %.5f %.5f %.5f %.5f %.2f %.2f cm 1 0 0 1 %.2f %.2f cm',$c,$s,-$s,$c,$cx,$cy,-$cx,-$cy));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a watermark to the PDF
|
||||
*/
|
||||
public function addWaterMark($text) {
|
||||
$this->SetFont('arial','B',50);
|
||||
$this->SetTextColor(203,203,203);
|
||||
$this->Rotate(0);
|
||||
$this->Text(10,50,$text);
|
||||
$this->Rotate(0);
|
||||
$this->SetTextColor(0,0,0);
|
||||
}
|
||||
}
|
||||
?>
|
182
modules/invoice/invoice_base_tcpdf.inc.php
Normal file
182
modules/invoice/invoice_base_tcpdf.inc.php
Normal file
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
/**
|
||||
* AgileBill - Open Billing Software
|
||||
*
|
||||
* This body of work is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Open AgileBill License
|
||||
* License as published at http://www.agileco.com/agilebill/license1-4.txt
|
||||
*
|
||||
* Originally authored by Joseph Benden
|
||||
* Modifications by Tony Landis, AgileBill LLC
|
||||
*
|
||||
* Recent modifications by Deon George
|
||||
*
|
||||
* @author Deon George <deonATleenooksDOTnet>
|
||||
* @copyright 2009 Deon George
|
||||
* @link http://osb.leenooks.net
|
||||
*
|
||||
* @link http://www.agileco.com/
|
||||
* @copyright 2004-2008 Agileco, LLC.
|
||||
* @license http://www.agileco.com/agilebill/license1-4.txt
|
||||
* @author Tony Landis <tony@agileco.com>
|
||||
* @package AgileBill
|
||||
* @subpackage Module:Invoice
|
||||
*/
|
||||
|
||||
define('FPDF_FONTPATH',PATH_INCLUDES.'tcpdf/fonts/');
|
||||
require_once(PATH_INCLUDES.'tcpdf/tcpdf.php');
|
||||
|
||||
/**
|
||||
* PDF Invoice Base
|
||||
*
|
||||
* @package AgileBill
|
||||
* @subpackage Module:Invoice
|
||||
*/
|
||||
abstract class pdf_invoice_base extends TCPDF {
|
||||
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($inv) {
|
||||
parent::__construct();
|
||||
|
||||
$this->SetCreator('Open Source Billing');
|
||||
$this->SetAuthor($inv->print['site']['NAME']);
|
||||
$this->SetTitle(sprintf('%s Invoice',$inv->print['site']['NAME']));
|
||||
$this->SetSubject(sprintf('Invoice #%06s',$inv->getInvoiceNum()));
|
||||
$this->SetKeywords($inv->getInvoiceID());
|
||||
$this->SetAutoPageBreak(TRUE,25);
|
||||
$this->SetHeaderMargin(1);
|
||||
$this->SetFooterMargin(10);
|
||||
$this->SetDisplayMode('fullwidth');
|
||||
#$this->setHeaderFont(array('helvetica','',8));
|
||||
$this->setFooterFont(array('helvetica','',8));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function load_setup(&$rs) {
|
||||
if (! $rs) {
|
||||
$db =& DB();
|
||||
$rs = $db->Execute(sqlSelect($db,'setup_invoice','*',''));
|
||||
}
|
||||
|
||||
$this->billToCompany = $rs->fields['bill_to_company'];
|
||||
$this->invoiceCurrency = $rs->fields['invoice_currency'];
|
||||
$this->invoiceDecimals = $rs->fields['invoice_decimals'];
|
||||
$this->itemsSummaryMax = $rs->fields['items_summary_max'];
|
||||
$this->news = $rs->fields['news'];
|
||||
$this->pageType = $rs->fields['page_type'];
|
||||
$this->show_itemized = $rs->fields['invoice_show_itemized'];
|
||||
$this->show_service_range = $rs->fields['invoice_show_service_dates'];
|
||||
}
|
||||
|
||||
abstract public function drawCompanyLogo();
|
||||
abstract public function drawCompanyAddress($inv);
|
||||
abstract public function drawInvoiceHeader($inv);
|
||||
|
||||
/**
|
||||
* Enable re-iteration of the invoices items, so that they can be displayed many ways
|
||||
*/
|
||||
abstract public function drawLineItems_pre($iteration);
|
||||
|
||||
/**
|
||||
* This is called for each line item.
|
||||
*/
|
||||
abstract public function drawLineItems($db,$line,$invnum);
|
||||
|
||||
/**
|
||||
* Draws the summary on the first page
|
||||
*/
|
||||
abstract public function drawSummaryLineItems($inv);
|
||||
abstract public function drawPaymentMethods($inv);
|
||||
|
||||
public function drawRemittenceStub() {}
|
||||
public function drawCustom() {}
|
||||
public function drawInvoiceDueNotice() {}
|
||||
public function drawInvoicePaidNotice() {}
|
||||
public function setLateFeeNotice() {}
|
||||
|
||||
/**
|
||||
* Get a blank invoice template
|
||||
*/
|
||||
public function getTemplate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns the invoice fields to this object.
|
||||
*/
|
||||
public function setInvoiceFields($flds) {
|
||||
$this->invoice = $flds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns the account fields to this object.
|
||||
*/
|
||||
public function setAccountFields($flds) {
|
||||
$this->account = $flds;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
?>
|
@@ -1,182 +1,304 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<construct>
|
||||
<!-- define the module name -->
|
||||
<module>invoice</module>
|
||||
<!-- define the module table name -->
|
||||
<table>invoice</table>
|
||||
<!-- define the module dependancy(s) -->
|
||||
<dependancy/>
|
||||
<!-- define the DB cache in seconds -->
|
||||
<cache>0</cache>
|
||||
<!-- define the default order_by field for SQL queries -->
|
||||
<order_by>date_orig</order_by>
|
||||
<!-- define the methods -->
|
||||
<limit>25</limit>
|
||||
<!-- define database indexes -->
|
||||
<index>
|
||||
<orig>date_orig</orig>
|
||||
<last>date_last</last>
|
||||
<parent>parent_id</parent>
|
||||
<billing>billing_status</billing>
|
||||
<process>process_status</process>
|
||||
<suspend>suspend_billing</suspend>
|
||||
<refund>refund_status</refund>
|
||||
<account>account_id</account>
|
||||
<affiliate>affiliate_id</affiliate>
|
||||
<campaign>campaign_id</campaign>
|
||||
<reseller>reseller_id</reseller>
|
||||
<amount>total_amt</amount>
|
||||
<due_date>due_date</due_date>
|
||||
<checkout>checkout_plugin_id</checkout>
|
||||
<tax>tax_id</tax>
|
||||
</index>
|
||||
<!-- define the fields -->
|
||||
<field>
|
||||
<id>
|
||||
<type>I4</type>
|
||||
<unique>1</unique>
|
||||
<index>1</index>
|
||||
</id>
|
||||
<site_id>
|
||||
<type>I4</type>
|
||||
<index>1</index>
|
||||
</site_id>
|
||||
<date_orig>
|
||||
<type>I8</type>
|
||||
<convert>date-time</convert>
|
||||
</date_orig>
|
||||
<date_last>
|
||||
<type>I8</type>
|
||||
<convert>date-now</convert>
|
||||
</date_last>
|
||||
<parent_id>
|
||||
<type>I4</type>
|
||||
</parent_id>
|
||||
<type>
|
||||
<type>L</type>
|
||||
</type>
|
||||
<process_status>
|
||||
<type>L</type>
|
||||
</process_status>
|
||||
<billing_status>
|
||||
<type>L</type>
|
||||
</billing_status>
|
||||
<refund_status>
|
||||
<type>L</type>
|
||||
</refund_status>
|
||||
<suspend_billing>
|
||||
<type>L</type>
|
||||
</suspend_billing>
|
||||
<print_status>
|
||||
<type>L</type>
|
||||
</print_status>
|
||||
<account_id>
|
||||
<type>I8</type>
|
||||
<asso_table>account</asso_table>
|
||||
<asso_field>first_name,last_name</asso_field>
|
||||
</account_id>
|
||||
<account_billing_id>
|
||||
<type>I4</type>
|
||||
</account_billing_id>
|
||||
<affiliate_id>
|
||||
<type>C(32)</type>
|
||||
</affiliate_id>
|
||||
<campaign_id>
|
||||
<type>I4</type>
|
||||
</campaign_id>
|
||||
<custom_affiliate_status>
|
||||
<type>L</type>
|
||||
</custom_affiliate_status>
|
||||
<reseller_id>
|
||||
<type>C(32)</type>
|
||||
</reseller_id>
|
||||
<checkout_plugin_id>
|
||||
<type>I4</type>
|
||||
</checkout_plugin_id>
|
||||
<checkout_plugin_data>
|
||||
<type>C(255)</type>
|
||||
<convert>array</convert>
|
||||
</checkout_plugin_data>
|
||||
<tax_id>
|
||||
<type>I4</type>
|
||||
</tax_id>
|
||||
<tax_amt>
|
||||
<type>F</type>
|
||||
</tax_amt>
|
||||
<discount_arr>
|
||||
<type>C(255)</type>
|
||||
<convert>array</convert>
|
||||
</discount_arr>
|
||||
<discount_amt>
|
||||
<type>F</type>
|
||||
</discount_amt>
|
||||
<recur_amt>
|
||||
<type>F</type>
|
||||
</recur_amt>
|
||||
<total_amt>
|
||||
<type>F</type>
|
||||
</total_amt>
|
||||
<billed_amt>
|
||||
<type>F</type>
|
||||
</billed_amt>
|
||||
<billed_currency_id>
|
||||
<type>I4</type>
|
||||
</billed_currency_id>
|
||||
<actual_billed_amt>
|
||||
<type>F</type>
|
||||
</actual_billed_amt>
|
||||
<actual_billed_currency_id>
|
||||
<type>I4</type>
|
||||
</actual_billed_currency_id>
|
||||
<notice_count>
|
||||
<type>I4</type>
|
||||
</notice_count>
|
||||
<notice_max>
|
||||
<type>I4</type>
|
||||
</notice_max>
|
||||
<notice_next_date>
|
||||
<type>I8</type>
|
||||
<convert>date-time</convert>
|
||||
</notice_next_date>
|
||||
<grace_period>
|
||||
<type>I4</type>
|
||||
</grace_period>
|
||||
<due_date>
|
||||
<type>I8</type>
|
||||
<convert>date-time</convert>
|
||||
</due_date>
|
||||
<recur_arr>
|
||||
<type>X</type>
|
||||
</recur_arr>
|
||||
<notes>
|
||||
<type>X</type>
|
||||
</notes>
|
||||
<net_term_id>
|
||||
<type>L</type>
|
||||
</net_term_id>
|
||||
<net_term_date_last>
|
||||
<type>I8</type>
|
||||
</net_term_date_last>
|
||||
<net_term_intervals>
|
||||
<type>I4</type>
|
||||
</net_term_intervals>
|
||||
<ip>
|
||||
<type>C(32)</type>
|
||||
</ip>
|
||||
</field>
|
||||
<!-- define all the methods for this class, and the fields they have access to, if applicable. -->
|
||||
<method>
|
||||
<add>id,site_id,date_orig,date_last,type,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,tax_id,tax_amt,discount_arr,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date</add>
|
||||
<update>id,site_id,date_orig,date_last,type,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,tax_id,tax_amt,discount_arr,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals</update>
|
||||
<delete>id,site_id,date_orig,date_last,type,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,tax_id,tax_amt,discount_arr,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date</delete>
|
||||
<view>id,site_id,date_orig,date_last,type,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,tax_id,tax_amt,discount_arr,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals,ip</view>
|
||||
<search>id,site_id,date_orig,date_last,type,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,tax_id,tax_amt,discount_arr,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals,ip</search>
|
||||
<export_excel>id,date_orig,date_last,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,tax_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals</export_excel>
|
||||
<export_pdf>id,date_orig,date_last,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,tax_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals</export_pdf>
|
||||
<export_xml>id,date_orig,date_last,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,tax_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals</export_xml>
|
||||
<export_csv>id,date_orig,date_last,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,tax_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals</export_csv>
|
||||
<export_tab>id,date_orig,date_last,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,tax_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals</export_tab>
|
||||
</method>
|
||||
<!-- define the method triggers -->
|
||||
<trigger>0</trigger>
|
||||
<!-- Module name -->
|
||||
<module>invoice</module>
|
||||
<!-- Module supporting database table -->
|
||||
<table>invoice</table>
|
||||
<!-- Module dependancy(s) (module wont install if these modules are not yet installed) -->
|
||||
<dependancy></dependancy>
|
||||
<!-- DB cache in seconds -->
|
||||
<cache>0</cache>
|
||||
<!-- Default order_by field for SQL queries -->
|
||||
<order_by>date_orig</order_by>
|
||||
<!-- Default SQL limit for SQL queries -->
|
||||
<limit>25</limit>
|
||||
<!-- Schema version (used to determine if the schema has change during upgrades) -->
|
||||
<version>1</version>
|
||||
|
||||
<!-- Database indexes -->
|
||||
<index>
|
||||
<orig>date_orig</orig>
|
||||
<last>date_last</last>
|
||||
<parent>parent_id</parent>
|
||||
<billing>billing_status</billing>
|
||||
<process>process_status</process>
|
||||
<suspend>suspend_billing</suspend>
|
||||
<refund>refund_status</refund>
|
||||
<account>account_id</account>
|
||||
<affiliate>affiliate_id</affiliate>
|
||||
<campaign>campaign_id</campaign>
|
||||
<reseller>reseller_id</reseller>
|
||||
<amount>total_amt</amount>
|
||||
<due_date>due_date</due_date>
|
||||
<checkout>checkout_plugin_id</checkout>
|
||||
<tax>tax_id</tax>
|
||||
<net_term>net_term_id</net_term>
|
||||
</index>
|
||||
|
||||
<!-- Database fields -->
|
||||
<field>
|
||||
<!-- Record ID -->
|
||||
<id>
|
||||
<display>Invoice</display>
|
||||
<index>1</index>
|
||||
<type>I4</type>
|
||||
<unique>1</unique>
|
||||
</id>
|
||||
<!-- Site ID -->
|
||||
<site_id>
|
||||
<index>1</index>
|
||||
<type>I4</type>
|
||||
</site_id>
|
||||
<!-- Date record created -->
|
||||
<date_orig>
|
||||
<convert>date-now</convert>
|
||||
<display>Invoice Date</display>
|
||||
<type>I8</type>
|
||||
</date_orig>
|
||||
<!-- Date record updated -->
|
||||
<date_last>
|
||||
<convert>date-now</convert>
|
||||
<display>Date Updated</display>
|
||||
<type>I8</type>
|
||||
</date_last>
|
||||
<!-- Record active (BOOL)-->
|
||||
<status>
|
||||
<display>Active</display>
|
||||
<type>L</type>
|
||||
</status>
|
||||
<!-- @todo UNKNOWN -->
|
||||
<parent_id>
|
||||
<type>I4</type>
|
||||
</parent_id>
|
||||
<!-- @todo UNKNOWN 1 = normal, !1 = upgrade? -->
|
||||
<type>
|
||||
<type>L</type>
|
||||
</type>
|
||||
<!-- Can new services be provisioned -->
|
||||
<process_status>
|
||||
<type>L</type>
|
||||
</process_status>
|
||||
<!-- Invoice is PAID when Billing STATUS = 1 -->
|
||||
<billing_status>
|
||||
<display>Invoice Status</display>
|
||||
<type>L</type>
|
||||
</billing_status>
|
||||
<!-- Invoice has been refunded when STATUS = 1 -->
|
||||
<refund_status>
|
||||
<display>Refund Status</display>
|
||||
<type>L</type>
|
||||
</refund_status>
|
||||
<!-- Suspend billing of reocurring invoices, where this invoice is the 1st/parent invoice -->
|
||||
<suspend_billing>
|
||||
<type>L</type>
|
||||
</suspend_billing>
|
||||
<!-- Has this invoice been printed -->
|
||||
<print_status>
|
||||
<type>L</type>
|
||||
</print_status>
|
||||
<!-- The account this invoice belongs to -->
|
||||
<account_id>
|
||||
<type>I8</type>
|
||||
<asso_table>account</asso_table>
|
||||
<asso_field>first_name,last_name</asso_field>
|
||||
</account_id>
|
||||
<!-- @todo UNKNOWN -->
|
||||
<account_billing_id>
|
||||
<type>I4</type>
|
||||
</account_billing_id>
|
||||
<!-- The afflicate who should be credited for this invoice revenue -->
|
||||
<affiliate_id>
|
||||
<type>C(32)</type>
|
||||
</affiliate_id>
|
||||
<!-- The compaign that resulted in this revenue -->
|
||||
<campaign_id>
|
||||
<type>I4</type>
|
||||
</campaign_id>
|
||||
<!-- @todo UNKNOWN -->
|
||||
<custom_affiliate_status>
|
||||
<type>L</type>
|
||||
</custom_affiliate_status>
|
||||
<!-- The reseller who should be credited for this invoice revenue -->
|
||||
<reseller_id>
|
||||
<type>C(32)</type>
|
||||
</reseller_id>
|
||||
<!-- Checkout plugin for this invoice -->
|
||||
<checkout_plugin_id>
|
||||
<type>I4</type>
|
||||
</checkout_plugin_id>
|
||||
<!-- Checkout plugin data -->
|
||||
<checkout_plugin_data>
|
||||
<type>C(255)</type>
|
||||
<convert>array</convert>
|
||||
</checkout_plugin_data>
|
||||
<!-- The TAX id applicable for this invoice -->
|
||||
<tax_id>
|
||||
<display>Taxes</display>
|
||||
<type>I4</type>
|
||||
</tax_id>
|
||||
<!-- The amount of TAX this invoice includes -->
|
||||
<tax_amt>
|
||||
<display>Total Taxes</display>
|
||||
<type>F</type>
|
||||
</tax_amt>
|
||||
<!-- @todo - ? The discounts that were applied to this invoice -->
|
||||
<discount_arr>
|
||||
<type>C(255)</type>
|
||||
<convert>array</convert>
|
||||
</discount_arr>
|
||||
<!-- The amount of DISCOUNT this invoice includes -->
|
||||
<discount_amt>
|
||||
<display>Total Discounts</display>
|
||||
<type>F</type>
|
||||
</discount_amt>
|
||||
<!-- @todo?? The amount of re-ocurring items on this invoice -->
|
||||
<recur_amt>
|
||||
<type>F</type>
|
||||
</recur_amt>
|
||||
<!-- Invoice Total Charges (including taxes ??) -->
|
||||
<total_amt>
|
||||
<display>Amount</display>
|
||||
<type>F</type>
|
||||
</total_amt>
|
||||
<!-- Amount already paid -->
|
||||
<billed_amt>
|
||||
<display>Amount Paid</display>
|
||||
<type>F</type>
|
||||
</billed_amt>
|
||||
<!-- The currency that this invoice is due -->
|
||||
<billed_currency_id>
|
||||
<type>I4</type>
|
||||
</billed_currency_id>
|
||||
<!-- The amount (in actual_billed_currency_id units) that originally this invoice was billed in -->
|
||||
<actual_billed_amt>
|
||||
<type>F</type>
|
||||
</actual_billed_amt>
|
||||
<!-- The current that was used when the invoice was created -->
|
||||
<actual_billed_currency_id>
|
||||
<type>I4</type>
|
||||
</actual_billed_currency_id>
|
||||
<!-- @todo ?? -->
|
||||
<notice_count>
|
||||
<type>I4</type>
|
||||
</notice_count>
|
||||
<!-- @todo ?? -->
|
||||
<notice_max>
|
||||
<type>I4</type>
|
||||
</notice_max>
|
||||
<!-- @todo ?? -->
|
||||
<notice_next_date>
|
||||
<type>I8</type>
|
||||
<convert>date-time</convert>
|
||||
</notice_next_date>
|
||||
<!-- @todo ?? -->
|
||||
<grace_period>
|
||||
<type>I4</type>
|
||||
</grace_period>
|
||||
<!-- The date this invoice is due -->
|
||||
<due_date>
|
||||
<display>Date Due</display>
|
||||
<type>I8</type>
|
||||
<convert>date-time</convert>
|
||||
</due_date>
|
||||
<!-- @todo ?? -->
|
||||
<recur_arr>
|
||||
<type>X</type>
|
||||
</recur_arr>
|
||||
<!-- Admin notes attached to the invoice -->
|
||||
<notes>
|
||||
<type>X</type>
|
||||
</notes>
|
||||
<!-- Invoice terms that govern when this invoice is overdue, and when notices should go out -->
|
||||
<net_term_id>
|
||||
<type>L</type>
|
||||
</net_term_id>
|
||||
<!-- @todo ?? -->
|
||||
<net_term_date_last>
|
||||
<type>I8</type>
|
||||
</net_term_date_last>
|
||||
<!-- @todo ?? -->
|
||||
<net_term_intervals>
|
||||
<type>I4</type>
|
||||
</net_term_intervals>
|
||||
<!-- @todo ?? -->
|
||||
<ip>
|
||||
<type>C(32)</type>
|
||||
</ip>
|
||||
</field>
|
||||
|
||||
<!-- Methods for this class, and the fields they have access to, if applicable -->
|
||||
<method>
|
||||
<add>id,site_id,date_orig,date_last,type,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,tax_id,tax_amt,discount_arr,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date</add>
|
||||
<update>id,site_id,date_orig,date_last,type,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,tax_id,tax_amt,discount_arr,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals</update>
|
||||
<delete>id,site_id,date_orig,date_last,type,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,tax_id,tax_amt,discount_arr,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date</delete>
|
||||
<view>id,site_id,date_orig,date_last,type,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,tax_id,tax_amt,discount_arr,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals,ip</view>
|
||||
<search>id,site_id,date_orig,date_last,type,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,tax_id,tax_amt,discount_arr,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals,ip</search>
|
||||
<export_excel>id,date_orig,date_last,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,tax_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals</export_excel>
|
||||
<export_pdf>id,date_orig,date_last,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,tax_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals</export_pdf>
|
||||
<export_xml>id,date_orig,date_last,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,tax_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals</export_xml>
|
||||
<export_csv>id,date_orig,date_last,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,tax_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals</export_csv>
|
||||
<export_tab>id,date_orig,date_last,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,tax_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals</export_tab>
|
||||
</method>
|
||||
|
||||
<!-- Method triggers -->
|
||||
<trigger></trigger>
|
||||
|
||||
<!-- Template page display titles -->
|
||||
<title>
|
||||
<user_view>Invoice</user_view>
|
||||
</title>
|
||||
|
||||
<!-- Template helpers -->
|
||||
<tpl>
|
||||
<search_show>
|
||||
<checkbox>
|
||||
<field>id</field>
|
||||
<type>checkbox</type>
|
||||
<width>25px</width>
|
||||
</checkbox>
|
||||
<id>
|
||||
<field>id</field>
|
||||
</id>
|
||||
<account_id>
|
||||
<field>account_id</field>
|
||||
</account_id>
|
||||
<date_orig>
|
||||
<field>date_orig</field>
|
||||
<type>date</type>
|
||||
</date_orig>
|
||||
<due_date>
|
||||
<field>due_date</field>
|
||||
<type>date</type>
|
||||
</due_date>
|
||||
<total_amt>
|
||||
<field>total_amt</field>
|
||||
<type>currency</type>
|
||||
</total_amt>
|
||||
<icon>
|
||||
<width>120px</width>
|
||||
</icon>
|
||||
</search_show>
|
||||
|
||||
<user_search_show>
|
||||
<checkbox>
|
||||
<field>id</field>
|
||||
<type>checkbox</type>
|
||||
<width>25px</width>
|
||||
</checkbox>
|
||||
<id>
|
||||
<field>id</field>
|
||||
</id>
|
||||
<date_orig>
|
||||
<field>date_orig</field>
|
||||
<type>date</type>
|
||||
</date_orig>
|
||||
<total_amt>
|
||||
<field>total_amt</field>
|
||||
<type>currency</type>
|
||||
</total_amt>
|
||||
<icon>
|
||||
<width>60px</width>
|
||||
</icon>
|
||||
</user_search_show>
|
||||
</tpl>
|
||||
</construct>
|
||||
|
@@ -1,393 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* AgileBill - Open Billing Software
|
||||
*
|
||||
* This body of work is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Open AgileBill License
|
||||
* License as published at http://www.agileco.com/agilebill/license1-4.txt
|
||||
*
|
||||
* For questions, help, comments, discussion, etc., please join the
|
||||
* Agileco community forums at http://forum.agileco.com/
|
||||
*
|
||||
* @link http://www.agileco.com/
|
||||
* @copyright 2004-2008 Agileco, LLC.
|
||||
* @license http://www.agileco.com/agilebill/license1-4.txt
|
||||
* @author Tony Landis <tony@agileco.com>
|
||||
* @package AgileBill
|
||||
* @version 1.4.93
|
||||
*/
|
||||
|
||||
require_once(PATH_INCLUDES.'pdf/fpdf.php');
|
||||
define('EURO', chr(128) );
|
||||
define('EURO_VAL', 6.55957 );
|
||||
|
||||
class INVOICE_FPDF extends FPDF
|
||||
{
|
||||
// private variables
|
||||
var $colonnes;
|
||||
var $format;
|
||||
var $angle=0;
|
||||
|
||||
// private functions
|
||||
function RoundedRect($x, $y, $w, $h, $r, $style = '')
|
||||
{
|
||||
$k = $this->k;
|
||||
$hp = $this->h;
|
||||
if($style=='F')
|
||||
$op='f';
|
||||
elseif($style=='FD' or $style=='DF')
|
||||
$op='B';
|
||||
else
|
||||
$op='S';
|
||||
$MyArc = 4/3 * (sqrt(2) - 1);
|
||||
$this->_out(sprintf('%.2f %.2f m',($x+$r)*$k,($hp-$y)*$k ));
|
||||
$xc = $x+$w-$r ;
|
||||
$yc = $y+$r;
|
||||
$this->_out(sprintf('%.2f %.2f l', $xc*$k,($hp-$y)*$k ));
|
||||
|
||||
$this->_Arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc);
|
||||
$xc = $x+$w-$r ;
|
||||
$yc = $y+$h-$r;
|
||||
$this->_out(sprintf('%.2f %.2f l',($x+$w)*$k,($hp-$yc)*$k));
|
||||
$this->_Arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r);
|
||||
$xc = $x+$r ;
|
||||
$yc = $y+$h-$r;
|
||||
$this->_out(sprintf('%.2f %.2f l',$xc*$k,($hp-($y+$h))*$k));
|
||||
$this->_Arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc);
|
||||
$xc = $x+$r ;
|
||||
$yc = $y+$r;
|
||||
$this->_out(sprintf('%.2f %.2f l',($x)*$k,($hp-$yc)*$k ));
|
||||
$this->_Arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r);
|
||||
$this->_out($op);
|
||||
}
|
||||
|
||||
function _Arc($x1, $y1, $x2, $y2, $x3, $y3)
|
||||
{
|
||||
$h = $this->h;
|
||||
$this->_out(sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c ', $x1*$this->k, ($h-$y1)*$this->k,
|
||||
$x2*$this->k, ($h-$y2)*$this->k, $x3*$this->k, ($h-$y3)*$this->k));
|
||||
}
|
||||
|
||||
function Rotate($angle,$x=-1,$y=-1)
|
||||
{
|
||||
if($x==-1)
|
||||
$x=$this->x;
|
||||
if($y==-1)
|
||||
$y=$this->y;
|
||||
if($this->angle!=0)
|
||||
$this->_out('Q');
|
||||
$this->angle=$angle;
|
||||
if($angle!=0)
|
||||
{
|
||||
$angle*=M_PI/180;
|
||||
$c=cos($angle);
|
||||
$s=sin($angle);
|
||||
$cx=$x*$this->k;
|
||||
$cy=($this->h-$y)*$this->k;
|
||||
$this->_out(sprintf('q %.5f %.5f %.5f %.5f %.2f %.2f cm 1 0 0 1 %.2f %.2f cm',$c,$s,-$s,$c,$cx,$cy,-$cx,-$cy));
|
||||
}
|
||||
}
|
||||
|
||||
function _endpage()
|
||||
{
|
||||
if($this->angle!=0)
|
||||
{
|
||||
$this->angle=0;
|
||||
$this->_out('Q');
|
||||
}
|
||||
parent::_endpage();
|
||||
}
|
||||
|
||||
// public functions
|
||||
function sizeOfText( $texte, $largeur )
|
||||
{
|
||||
$index = 0;
|
||||
$nb_lines = 0;
|
||||
$loop = TRUE;
|
||||
while ( $loop )
|
||||
{
|
||||
$pos = strpos($texte, "\n");
|
||||
if (!$pos)
|
||||
{
|
||||
$loop = FALSE;
|
||||
$ligne = $texte;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ligne = substr( $texte, $index, $pos);
|
||||
$texte = substr( $texte, $pos+1 );
|
||||
}
|
||||
$length = floor( $this->GetStringWidth( $ligne ) );
|
||||
//$res = 1 + floor( $length / $largeur) ;
|
||||
$nb_lines += $res;
|
||||
}
|
||||
return $nb_lines;
|
||||
}
|
||||
|
||||
// Company
|
||||
function addCompany( $nom, $adresse )
|
||||
{
|
||||
$this->Image(PATH_THEMES.'default/images/invoice_logo.jpg',11,8,50);
|
||||
$x1 = 10;
|
||||
$y1 = 20;
|
||||
$this->SetXY( $x1, $y1 );
|
||||
$this->SetFont('Arial','B',12);
|
||||
$length = $this->GetStringWidth( $nom );
|
||||
$this->Cell( $length, 2, $nom);
|
||||
$this->SetXY( $x1, $y1 + 4 );
|
||||
$this->SetFont('Arial','',10);
|
||||
$length = $this->GetStringWidth( $adresse );
|
||||
$lignes = $this->sizeOfText( $adresse, $length) ;
|
||||
$this->MultiCell($length, 4, $adresse);
|
||||
}
|
||||
|
||||
function addDate( $date )
|
||||
{
|
||||
global $C_translate;
|
||||
|
||||
$r1 = $this->w - 40;
|
||||
$r2 = $r1 + 30;
|
||||
$y1 = 8;
|
||||
$y2 = $y1 ;
|
||||
$mid = $y1 + ($y2 / 2);
|
||||
$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 3.5, 'D');
|
||||
$this->Line( $r1, $mid, $r2, $mid);
|
||||
$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1 );
|
||||
$this->SetFont( "Helvetica", "B", 10);
|
||||
$this->Cell(10,5, $C_translate->translate('pdf_date','invoice',''), 0, 0, "C");
|
||||
$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1+4 );
|
||||
$this->SetFont( "Helvetica", "", 10);
|
||||
$this->Cell(10,5,$date, 0,0, "C");
|
||||
}
|
||||
|
||||
function addPageNumber( $page )
|
||||
{
|
||||
global $C_translate;
|
||||
|
||||
$r1 = $this->w - 59;
|
||||
$r2 = $r1 + 19;
|
||||
$y1 = 8;
|
||||
$y2 = $y1;
|
||||
$mid = $y1 + ($y2 / 2);
|
||||
$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 3.5, 'D');
|
||||
$this->Line( $r1, $mid, $r2, $mid);
|
||||
$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1 );
|
||||
$this->SetFont( "Helvetica", "B", 10);
|
||||
$this->Cell(10,5, $C_translate->translate('pdf_page','invoice',''), 0, 0, "C");
|
||||
$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1+4 );
|
||||
$this->SetFont( "Helvetica", "", 10);
|
||||
$this->Cell(10,5,$page, 0,0, "C");
|
||||
}
|
||||
|
||||
// Client address
|
||||
function addClient( $adresse )
|
||||
{
|
||||
$r1 = 140;
|
||||
$r2 = $r1 + 68;
|
||||
$y1 = 35;
|
||||
$this->SetXY( $r1, $y1);
|
||||
$this->MultiCell( 60, 4, $adresse);
|
||||
}
|
||||
|
||||
// Invoice number
|
||||
function addInvoiceNo($id)
|
||||
{
|
||||
global $C_translate;
|
||||
|
||||
$r1 = 10;
|
||||
$r2 = $r1 + 60;
|
||||
$y1 = 65;
|
||||
$y2 = $y1+10;
|
||||
$mid = $y1 + (($y2-$y1) / 2);
|
||||
$this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 2.5, 'D');
|
||||
$this->Line( $r1, $mid, $r2, $mid);
|
||||
$this->SetXY( $r1 + ($r2-$r1)/2 - 20 , $y1+1 );
|
||||
$this->SetFont( "Helvetica", "B", 10);
|
||||
$this->Cell(40, 4, $C_translate->translate('pdf_invoice_number','invoice',''), 0, 0, "C");
|
||||
$this->SetFont( "Helvetica", "", 10);
|
||||
$this->SetXY( $r1 + 9 , $y1+5 );
|
||||
$this->Cell(40, 5, $id, '', '', "C");
|
||||
}
|
||||
|
||||
// Payment Status
|
||||
function addStatus( $mode )
|
||||
{
|
||||
global $C_translate;
|
||||
|
||||
$r1 = 75;
|
||||
$r2 = $r1 + 60;
|
||||
$y1 = 65;
|
||||
$y2 = $y1+10;
|
||||
$mid = $y1 + (($y2-$y1) / 2);
|
||||
$this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 2.5, 'D');
|
||||
$this->Line( $r1, $mid, $r2, $mid);
|
||||
$this->SetXY( $r1 + ($r2-$r1)/2 -5 , $y1+1 );
|
||||
$this->SetFont( "Helvetica", "B", 10);
|
||||
$this->Cell(10,4, $C_translate->translate('pdf_payment_status','invoice',''), 0, 0, "C");
|
||||
$this->SetXY( $r1 + ($r2-$r1)/2 -5 , $y1 + 5 );
|
||||
$this->SetFont( "Helvetica", "", 10);
|
||||
$this->Cell(10,5,$mode, 0,0, "C");
|
||||
}
|
||||
|
||||
// Due date
|
||||
function addDueDate( $date )
|
||||
{
|
||||
global $C_translate;
|
||||
|
||||
$r1 = 140;
|
||||
$r2 = $r1 + 60;
|
||||
$y1 = 65;
|
||||
$y2 = $y1+10;
|
||||
$mid = $y1 + (($y2-$y1) / 2);
|
||||
$this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 2.5, 'D');
|
||||
$this->Line( $r1, $mid, $r2, $mid);
|
||||
$this->SetXY( $r1 + ($r2 - $r1)/2 - 5 , $y1+1 );
|
||||
$this->SetFont( "Helvetica", "B", 10);
|
||||
$this->Cell(10,4, $C_translate->translate('pdf_date_due','invoice',''), 0, 0, "C");
|
||||
$this->SetXY( $r1 + ($r2-$r1)/2 - 5 , $y1 + 5 );
|
||||
$this->SetFont( "Helvetica", "", 10);
|
||||
$this->Cell(10,5,$date, 0,0, "C");
|
||||
}
|
||||
|
||||
function addCols( $tab )
|
||||
{
|
||||
global $colonnes;
|
||||
|
||||
$r1 = 10;
|
||||
$r2 = $this->w - ($r1 * 2) ;
|
||||
$y1 = 80;
|
||||
$y2 = $this->h - 50 - $y1;
|
||||
$this->SetXY( $r1, $y1 );
|
||||
$this->Rect( $r1, $y1, $r2, $y2, "D");
|
||||
$this->Line( $r1, $y1+6, $r1+$r2, $y1+6);
|
||||
$colX = $r1;
|
||||
$colonnes = $tab;
|
||||
while ( list( $lib, $pos ) = each ($tab) )
|
||||
{
|
||||
$this->SetXY( $colX, $y1+2 );
|
||||
$this->Cell( $pos, 1, $lib, 0, 0, "C");
|
||||
$colX += $pos;
|
||||
$this->Line( $colX, $y1, $colX, $y1+$y2);
|
||||
}
|
||||
}
|
||||
|
||||
function addLineFormat( $tab )
|
||||
{
|
||||
global $format, $colonnes;
|
||||
|
||||
while ( list( $lib, $pos ) = each ($colonnes) )
|
||||
{
|
||||
if ( isset( $tab["$lib"] ) )
|
||||
$format[ $lib ] = $tab["$lib"];
|
||||
}
|
||||
}
|
||||
|
||||
function lineVert( $tab )
|
||||
{
|
||||
global $colonnes;
|
||||
|
||||
reset( $colonnes );
|
||||
$maxSize=0;
|
||||
while ( list( $lib, $pos ) = each ($colonnes) )
|
||||
{
|
||||
$texte = $tab[ $lib ];
|
||||
$longCell = $pos -2;
|
||||
$size = $this->sizeOfText( $texte, $longCell );
|
||||
if ($size > $maxSize)
|
||||
$maxSize = $size;
|
||||
}
|
||||
return $maxSize;
|
||||
}
|
||||
|
||||
function addLine( $ligne, $tab )
|
||||
{
|
||||
global $colonnes, $format;
|
||||
|
||||
$ordonnee = 10;
|
||||
$maxSize = $ligne;
|
||||
|
||||
reset( $colonnes );
|
||||
while ( list( $lib, $pos ) = each ($colonnes) )
|
||||
{
|
||||
$longCell = $pos -2;
|
||||
$texte = $tab[ $lib ];
|
||||
$length = $this->GetStringWidth( $texte );
|
||||
$tailleTexte = $this->sizeOfText( $texte, $length );
|
||||
$formText = $format[ $lib ];
|
||||
$this->SetXY( $ordonnee, $ligne-1);
|
||||
$this->MultiCell( $longCell, 4 , $texte, 0, $formText);
|
||||
if ( $maxSize < ($this->GetY() ) )
|
||||
$maxSize = $this->GetY() ;
|
||||
$ordonnee += $pos;
|
||||
}
|
||||
return ( $maxSize - $ligne );
|
||||
}
|
||||
|
||||
function addTotals($a, $b, $a_total, $a_paid, $a_due, $b_total, $b_paid, $b_due, $a_disc, $b_disc)
|
||||
{
|
||||
global $C_translate;
|
||||
|
||||
$r1 = $this->w - 102;
|
||||
$r2 = $r1 + 92;
|
||||
$y1 = $this->h - 45;
|
||||
$y2 = $y1+25;
|
||||
$this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 2.5, 'D');
|
||||
$this->Line( $r1+20, $y1, $r1+20, $y2); // avant EUROS
|
||||
$this->Line( $r1+20, $y1+4, $r2, $y1+4); // Sous Euros & Francs
|
||||
$this->Line( $r1+55, $y1, $r1+55, $y2); // Entre Euros & Francs
|
||||
$this->SetFont( "Arial", "B", 8);
|
||||
$this->SetXY( $r1+30, $y1 );
|
||||
$this->Cell(15,4, $a, 0, 0, "C");
|
||||
$this->SetFont( "Arial", "", 8);
|
||||
$this->SetXY( $r1+65, $y1 );
|
||||
$this->Cell(15,4, $b, 0, 0, "C");
|
||||
$this->SetFont( "Arial", "B", 6);
|
||||
|
||||
$this->SetXY( $r1, $y1+5 );
|
||||
$this->Cell(20,4, $C_translate->translate('pdf_discounts','invoice',''), 0, 0, "C");
|
||||
$this->SetXY( $r1, $y1+10 );
|
||||
$this->Cell(20,4, $C_translate->translate('pdf_total','invoice',''), 0, 0, "C");
|
||||
$this->SetXY( $r1, $y1+15 );
|
||||
$this->Cell(20,4, $C_translate->translate('pdf_paid','invoice',''), 0, 0, "C");
|
||||
$this->SetXY( $r1, $y1+20 );
|
||||
$this->Cell(20,4, $C_translate->translate('pdf_due','invoice',''), 0, 0, "C");
|
||||
|
||||
$re = $this->w - 65;
|
||||
$rf = $this->w - 28;
|
||||
$y1 = $this->h - 40;
|
||||
|
||||
// A total
|
||||
$this->SetFont( "Arial", "", 8);
|
||||
$this->SetXY( $re, $y1+0 );
|
||||
$this->Cell( 17,4, $a_disc, '', '', 'R');
|
||||
$this->SetXY( $re, $y1+5 );
|
||||
$this->Cell( 17,4, $a_total, '', '', 'R');
|
||||
$this->SetXY( $re, $y1+10 );
|
||||
$this->Cell( 17,4, $a_paid, '', '', 'R');
|
||||
$this->SetXY( $re, $y1+15 );
|
||||
$this->Cell( 17,4, $a_due, '', '', 'R');
|
||||
$this->SetXY( $rf, $y1+5 );
|
||||
|
||||
// B Total
|
||||
if(!empty($b)) {
|
||||
$this->Cell( 17,4, $b_total, '', '', 'R');
|
||||
$this->SetXY( $rf, $y1+10 );
|
||||
$this->Cell( 17,4, $b_paid, '', '', 'R');
|
||||
$this->SetXY( $rf, $y1+14.8 );
|
||||
$this->Cell( 17,4, $b_due, '', '', 'R');
|
||||
}
|
||||
}
|
||||
|
||||
// watermark
|
||||
function addWatermark( $text )
|
||||
{
|
||||
$this->SetFont('Arial','B',50);
|
||||
$this->SetTextColor(203,203,203);
|
||||
$this->Rotate(0);
|
||||
$this->Text(10,50,$text);
|
||||
$this->Rotate(0);
|
||||
$this->SetTextColor(0,0,0);
|
||||
}
|
||||
}
|
||||
?>
|
@@ -1,65 +1,99 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<install>
|
||||
<!-- Tree Menu Module Properties -->
|
||||
<module_properties>
|
||||
<name>invoice</name>
|
||||
<parent>invoice</parent>
|
||||
<notes><![CDATA[This module controls the invoicing]]></notes>
|
||||
<!-- MODULE Dependancy, this module wont be installed if the dependant modules dont exist -->
|
||||
<dependancy></dependancy>
|
||||
<!-- Translated display to use on the tree -->
|
||||
<display>Invoices</display>
|
||||
<!-- Display a module in the menu tree -->
|
||||
<menu_display>1</menu_display>
|
||||
<!-- MODULE Name -->
|
||||
<name>invoice</name>
|
||||
<!-- MODULE Notes, these notes show up in the modules table, as a description of the module -->
|
||||
<notes><![CDATA[This module controls the invoicing]]></notes>
|
||||
<!-- MODULE Parent, the parent node in the tree -->
|
||||
<parent>invoice</parent>
|
||||
<!-- SUB Modules to install with this one -->
|
||||
<sub_modules></sub_modules>
|
||||
<!-- MODULE Type (core|base), core modules cannot be deleted, unrecognised types are ignored. -->
|
||||
<type>base</type>
|
||||
</module_properties>
|
||||
<sql_inserts>
|
||||
<module_method>
|
||||
<add>
|
||||
<name>add</name>
|
||||
<menu_display>1</menu_display>
|
||||
</add>
|
||||
<update>
|
||||
<name>update</name>
|
||||
</update>
|
||||
<delete>
|
||||
<name>delete</name>
|
||||
</delete>
|
||||
<view>
|
||||
<name>view</name>
|
||||
<page><![CDATA[core:search&module=%%&_escape=1]]></page>
|
||||
<menu_display>1</menu_display>
|
||||
</view>
|
||||
<search>
|
||||
<name>search</name>
|
||||
<page><![CDATA[%%:search_form]]></page>
|
||||
<menu_display>1</menu_display>
|
||||
</search>
|
||||
<search_form>
|
||||
<name>search_form</name>
|
||||
</search_form>
|
||||
<search_show>
|
||||
<name>search_show</name>
|
||||
</search_show>
|
||||
<resend>
|
||||
<name>resend</name>
|
||||
</resend>
|
||||
<search_export>
|
||||
<name>search_export</name>
|
||||
</search_export>
|
||||
<approveinvoice>
|
||||
<name>approveinvoice</name>
|
||||
</approveinvoice>
|
||||
<voidinvoice>
|
||||
<name>voidinvoice</name>
|
||||
</voidinvoice>
|
||||
<performance>
|
||||
<name>performance</name>
|
||||
</performance>
|
||||
<refund>
|
||||
<name>refund</name>
|
||||
</refund>
|
||||
<reconcile>
|
||||
<name>reconcile</name>
|
||||
</reconcile>
|
||||
<autobill>
|
||||
<name>autobill</name>
|
||||
</autobill>
|
||||
<generatedomaininvoice>
|
||||
<name>generatedomaininvoice</name>
|
||||
</generatedomaininvoice>
|
||||
</module_method>
|
||||
</sql_inserts>
|
||||
</install>
|
||||
|
||||
<!-- Tree Menu & Module Methods to load, they will be assigned the group permissions on install time, as selected by the user. -->
|
||||
<module_method>
|
||||
<add>
|
||||
<display>Add</display>
|
||||
<menu_display>1</menu_display>
|
||||
<name>add</name>
|
||||
<notes><![CDATA[Add records]]></notes>
|
||||
</add>
|
||||
<delete>
|
||||
<name>delete</name>
|
||||
<notes><![CDATA[Delete records]]></notes>
|
||||
</delete>
|
||||
<search>
|
||||
<display>List</display>
|
||||
<menu_display>1</menu_display>
|
||||
<name>search</name>
|
||||
<notes><![CDATA[List records]]></notes>
|
||||
<page><![CDATA[core:search&module=%%&_next_page_one=view]]></page>
|
||||
</search>
|
||||
<search_form>
|
||||
<display>Search</display>
|
||||
<menu_display>1</menu_display>
|
||||
<name>search_form</name>
|
||||
<notes><![CDATA[Search for records]]></notes>
|
||||
</search_form>
|
||||
<search_show>
|
||||
<name>search_show</name>
|
||||
<notes><![CDATA[Show the results of a search]]></notes>
|
||||
</search_show>
|
||||
<update>
|
||||
<name>update</name>
|
||||
<notes><![CDATA[Update a record]]></notes>
|
||||
</update>
|
||||
<view>
|
||||
<name>view</name>
|
||||
<notes><![CDATA[View a record]]></notes>
|
||||
</view>
|
||||
<invoicesoon>
|
||||
<display>Upcoming Invoices</display>
|
||||
<menu_display>1</menu_display>
|
||||
<name>Invoice Soon</name>
|
||||
</invoicesoon>
|
||||
<resend>
|
||||
<name>resend</name>
|
||||
</resend>
|
||||
<search_export>
|
||||
<name>search_export</name>
|
||||
</search_export>
|
||||
<approveinvoice>
|
||||
<name>approveinvoice</name>
|
||||
</approveinvoice>
|
||||
<voidinvoice>
|
||||
<name>voidinvoice</name>
|
||||
</voidinvoice>
|
||||
<performance>
|
||||
<name>performance</name>
|
||||
</performance>
|
||||
<refund>
|
||||
<name>refund</name>
|
||||
</refund>
|
||||
<reconcile>
|
||||
<name>reconcile</name>
|
||||
</reconcile>
|
||||
<autobill>
|
||||
<name>autobill</name>
|
||||
</autobill>
|
||||
<generatedomaininvoice>
|
||||
<name>generatedomaininvoice</name>
|
||||
</generatedomaininvoice>
|
||||
<generateinvoice>
|
||||
<name>generateinvoice</name>
|
||||
</generateinvoice>
|
||||
<generateinvoice_account>
|
||||
<name>generateinvoice_account</name>
|
||||
</generateinvoice_account>
|
||||
</module_method>
|
||||
</install>
|
||||
|
@@ -77,8 +77,8 @@ class receipt_print extends FPDF
|
||||
// draw the logo
|
||||
function drawCompanyLogo() {
|
||||
$width = 50;
|
||||
if(is_file(PATH_THEMES.'default/images/invoice_logo.jpg'))
|
||||
$this->Image(PATH_THEMES.'default/images/invoice_logo.jpg',0,0,$width);
|
||||
if(is_file(PATH_THEMES.'default/images/logo-invoice.png'))
|
||||
$this->Image(PATH_THEMES.'default/images/logo-invoice.png',0,0,$width);
|
||||
}
|
||||
|
||||
// draw the company address
|
||||
@@ -90,4 +90,4 @@ class receipt_print extends FPDF
|
||||
$this->SetXY(0,40); $this->Cell(50,10, SITE_CITY. ", ". SITE_STATE . " " . SITE_ZIP);
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
Reference in New Issue
Block a user