OSB enhancements to date

This commit is contained in:
Deon George
2010-11-30 09:41:08 +11:00
parent 8715a2059b
commit ec6a542bc3
478 changed files with 23423 additions and 9309 deletions

View File

@@ -26,8 +26,6 @@ class pdf_invoice_overview extends pdf_invoice_base {
* Draw the Company Address
*/
public function drawCompanyAddress($inv) {
global $C_translate;
# Add the company address next to the logo
$x = 40; $y = 7;
@@ -47,40 +45,38 @@ class pdf_invoice_overview extends pdf_invoice_base {
}
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->SetXY($x,$y); $this->Cell(0,0,_('Payment Remittence')); $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']);
$this->SetXY($x,$y); $this->Cell(0,0,_('Please return this portion with your cheque or money order')); $y +=3;
$this->SetXY($x,$y); $this->Cell(0,0,_('made payable to').' '.$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->SetXY($x,$y); $this->Cell(0,0,_('Issue Date'));
$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->SetXY($x,$y); $this->Cell(0,0,_('Account Number'));
$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->SetXY($x,$y); $this->Cell(0,0,_('Invoice Number'));
$this->SetFont('helvetica','B',11);
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%06s',$inv->getInvoiceNum()),0,0,'R');
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%06s',$inv->getPrintInvoiceNum()),0,0,'R');
# Company Address
$y = 216;
@@ -92,19 +88,19 @@ class pdf_invoice_overview extends pdf_invoice_base {
# 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');
$this->SetXY($x,$y); $this->Cell(0,0,_('Previous Due'));
$this->SetXY($x,$y); $this->Cell(0,0,$this->_currency($inv->sPreviousBalance()),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');
$this->SetXY($x,$y); $this->Cell(0,0,_('Amount Due').' '.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']-$inv->print['invoice']['credit_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');
$this->SetXY($x,$y); $this->Cell(0,0,_('Total Due'));
$this->SetXY($x,$y); $this->Cell(0,0,$this->_currency($inv->sPreviousBalance()+$inv->print['invoice']['total_amt']-$inv->print['invoice']['billed_amt']-$inv->print['invoice']['credit_amt']),0,0,'R');
# Draw the Customers Address
$x = 25; $y = 248;
@@ -122,25 +118,23 @@ class pdf_invoice_overview extends pdf_invoice_base {
}
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);
$this->SetXY($x-1,$y-1); $this->Cell(0,35+($inv->print['invoice']['billed_amt'] ? 5 : 0)+($inv->print['invoice']['credit_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');
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%06s',$inv->getPrintInvoiceNum()),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'));
$this->SetXY($x,$y); $this->Cell(0,0,_('Issue Date')); $y += 5;
$this->SetXY($x,$y); $this->Cell(0,0,_('Amount Due'));
$y -= 5;
$this->SetFont('helvetica','B',11);
@@ -149,13 +143,13 @@ class pdf_invoice_overview extends pdf_invoice_base {
$y += 5;
$this->SetFont('helvetica','',10);
$this->SetXY($x,$y); $this->Cell(0,0,'Previous Due');
$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');
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->sPreviousBalance()),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->SetXY($x,$y); $this->Cell(0,0,_('Current Charges'));
$this->SetFont('helvetica','B',11);
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->print['invoice']['total_amt']),0,0,'R');
@@ -167,17 +161,23 @@ class pdf_invoice_overview extends pdf_invoice_base {
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->print['invoice']['billed_amt']),0,0,'R');
}
if ($inv->print['invoice']['credit_amt']) {
$y += 5;
$this->SetFont('helvetica','',10);
$this->SetXY($x,$y); $this->Cell(0,0,'Credits Received');
$this->SetFont('helvetica','B',11);
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->print['invoice']['credit_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');
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->sPreviousBalance()+$inv->print['invoice']['total_amt']-$inv->print['invoice']['billed_amt']-$inv->print['invoice']['credit_amt']),0,0,'R');
}
#@todo Limit the size of the news to 6 lines
public function drawNews($news) {
global $C_translate;
if (! $news)
return;
@@ -193,7 +193,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
#@todo make this list dynamic
public function drawPaymentMethods($inv) {
$x = 110; $y = 242;
$x = 120; $y = 242;
# Draw a box.
$this->SetFillColor(235);
@@ -202,7 +202,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
$this->SetFont('helvetica','B',8);
$this->SetXY($x,$y); $this->Cell(0,0,'This invoice can also be paid by:'); $y += 4;
# Direct Debit
# Direct Credit
$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);
@@ -216,8 +216,9 @@ class pdf_invoice_overview extends pdf_invoice_base {
$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;
$this->SetXY($x+30,$y); $this->Cell(0,0,$inv->getPrintInvoiceID()); $y += 3;
/*
# Direct Debit
$y += 3;
$logo = sprintf('%s/%s',PATH_THEMES.DEFAULT_THEME,'invoice/invoice-payment-dd.png');
@@ -225,7 +226,17 @@ class pdf_invoice_overview extends pdf_invoice_base {
$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;
$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->getPrintInvoiceNum(),$inv->print['site']['URL']); $y += 3;
*/
# Paypal
$y += 3;
$logo = sprintf('%s/%s',PATH_THEMES.DEFAULT_THEME,'invoice/invoice-payment-pp.png');
$this->Image($logo,$x+1,$y,8);
$this->SetFont('helvetica','B',8);
$this->SetXY($x+10,$y); $this->Cell(0,0,'Pay Pal/Credit Card'); $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->getPrintInvoiceNum(),$inv->print['site']['URL']); $y += 3;
}
/**
@@ -242,7 +253,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
$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->SetXY($x,$y); $this->Cell(0,0,_('Previous Invoices due')); $y += 5;
$this->SetFont('helvetica','',11);
$i = 0;
@@ -307,9 +318,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
* @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)
if ($line['price_type'] == 0 && $line['item_type'] == 5)
return;
$x = 10;
@@ -318,21 +327,21 @@ class pdf_invoice_overview extends pdf_invoice_base {
$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');
$this->SetXY($x,$this->y); $this->Cell(0,0,_('Itemised Charges'));
$this->Cell(0,0,_('Page #').$this->PageNo(),0,0,'R');
$this->SetXY($x,$this->y); $this->Cell(0,0,_('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->Cell(0,0,_('Description'));
$this->SetX($x+135);
$this->Cell(0,0,$C_translate->translate('pdf_item_quantity','setup_invoice'));
$this->Cell(0,0,_('Quantity'));
$this->SetX($x+160);
$this->Cell(10,0,$C_translate->translate('pdf_item_cost','setup_invoice'),0,0,'R');
$this->Cell(10,0,_('Unit Cost'),0,0,'R');
$this->SetX($x+135);
$this->Cell(0,0,$C_translate->translate('pdf_item_amount','setup_invoice'),0,0,'R');
$this->Cell(0,0,_('Amount'),0,0,'R');
$this->Line($x,$this->y+4,200,$this->y+4);
$this->y += 5;
$this->SetY($this->y);
@@ -352,7 +361,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
$this->Cell(10,0,$line['qty'],0,0,'R');
}
$this->SetX($x+130);
$this->SetX($x+130);
$this->Cell(0,0,$this->_currency($line['total_amt']),0,0,'R');
if ($this->show_service_range && $line['daterange']) {
@@ -373,8 +382,22 @@ class pdf_invoice_overview extends pdf_invoice_base {
if ($line['attr']) {
$showchars = 20;
foreach (explode("\n",$line['attr']) as $attr) {
list($field,$value) = explode('==',$attr);
if (preg_match('/^a:/',$line['attr']))
$a = unserialize($line['attr']);
else {
$x = explode("\n",$line['attr']);
$a = array();
foreach ($x as $y)
if ($y) {
list($c,$d) = explode('==',$y);
$a[$c] = $d;
}
}
foreach ($a as $field=>$value) {
if (in_array($field,array('service_account_name','service_address')))
continue;
$this->SetFont('helvetica','I',7);
$this->y += 3;
@@ -504,7 +527,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
if(empty($q)) $q = 1;
$this->SetX(160);
$this->Cell(10,0, $line['qty'],0,0,'R');
$this->SetX($x+135);
$this->SetX($x+135);
$this->Cell(0,0, $this->_currency($line['amount']), 0,0,'R');
}
$this->y += 5;
@@ -517,12 +540,10 @@ class pdf_invoice_overview extends pdf_invoice_base {
* on the invoice.
*/
public function drawSummaryLineItems($inv) {
global $C_translate;
if (! $this->show_itemized)
return;
$items = $inv->summarizeLineItems($inv->print['invoiceitems']);
$items = $inv->sInvoiceItemsSummary();
# Calculate the box size
$box = count($items) < $this->itemsSummaryMax ? count($items) : $this->itemsSummaryMax;
@@ -531,10 +552,12 @@ class pdf_invoice_overview extends pdf_invoice_base {
# 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->SetXY($x-1,$y-1); $this->Cell(0,5*(
1+1+1+3+($inv->print['invoice']['discount_amt'] ? 1 : 0)+($inv->print['invoice']['billed_amt'] ? 1 : 0)+($inv->print['invoice']['credit_amt'] ? 1 : 0)+$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->SetXY($x,$y); $this->Cell(0,0,_('Current Charges Summary for')); $y += 5;
$this->SetY($y);
$this->SetFont('helvetica','',9);
@@ -550,16 +573,16 @@ class pdf_invoice_overview extends pdf_invoice_base {
$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');
$this->Cell(0,0,sprintf('%s (%s)',$line['product_name'],$this->_currency($line['price_base'])));
$this->SetX($x+135);
$this->Cell(0,0,$this->_currency($line['price_base']*$line['quantity']+$line['price_setup']),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'));
$this->Cell(0,0,_('The above is just a summary. To view a detailed list of charges, please visit our website.'));
break;
}
}
@@ -567,57 +590,82 @@ class pdf_invoice_overview extends pdf_invoice_base {
# Calculate our rounding error
$subtotal = 0;
foreach($items as $line)
$subtotal += $line['price_base']*$line['quantity'];
$subtotal += $line['price_base']*$line['quantity']+$line['price_setup'];
$subtotal -= $inv->print['invoice']['discount_amt'];
$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');
$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
# Draw Discounts.
if ($inv->print['invoice']['discount_amt']) {
$y += 5;
$this->SetY($y);
$this->SetFont('helvetica','B',9);
$this->SetX($x+8);
$this->Cell(0,0,_('Discount'));
$this->SetX($x+135);
$this->Cell(0,0,$this->_currency(-$inv->print['invoice']['discount_amt']),0,0,'R');
}
# 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->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->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->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');
# Show payments already received for this invoice
if ($inv->print['invoice']['billed_amt']) {
$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');
}
if ($inv->print['invoice']['credit_amt']) {
$y += 5;
$this->SetY($y);
$this->SetFont('helvetica','B',9);
$this->SetX($x+8);
$this->Cell(0,0,_('Less Credits'));
$this->SetX($x+135);
$this->Cell(0,0,$this->_currency(-$inv->print['invoice']['credit_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');
$this->SetX($x+135);
$this->Cell(0,0,$this->_currency($inv->print['invoice']['total_amt']-$inv->print['invoice']['billed_amt']-$inv->print['invoice']['credit_amt']),0,0,'R');
}
}
}