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

@@ -80,7 +80,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
$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');
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%06s',$inv->getPrintInvoiceNum()),0,0,'R');
# Company Address
$y = 216;
@@ -93,7 +93,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
$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');
$this->SetXY($x,$y); $this->Cell(0,0,$this->_currency($inv->sPreviousBalance()),0,0,'R');
$y = 219;
$this->SetFont('arial','',9);
@@ -104,7 +104,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
$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');
$this->SetXY($x,$y); $this->Cell(0,0,$this->_currency($inv->sPreviousBalance()+$inv->print['invoice']['total_amt']-$inv->print['invoice']['billed_amt']),0,0,'R');
# Draw the Customers Address
$x = 25; $y = 248;
@@ -134,7 +134,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
$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');
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%06s',$inv->getPrintInvoiceNum()),0,0,'R');
# Invoice number at top of page.
$y += 7;
@@ -151,7 +151,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
$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');
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->sPreviousBalance()),0,0,'R');
$y += 5;
$this->SetFont('arial','',10);
@@ -171,7 +171,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
$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');
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->sPreviousBalance()+$inv->print['invoice']['total_amt']-$inv->print['invoice']['billed_amt']),0,0,'R');
}
#@todo Limit the size of the news to 6 lines
@@ -216,7 +216,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
$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;
$this->SetXY($x+30,$y); $this->Cell(0,0,$inv->getPrintInvoiceID()); $y += 3;
# Direct Debit
$y += 3;
@@ -307,7 +307,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
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; $y = 5;
@@ -519,7 +519,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
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;
@@ -547,7 +547,7 @@ 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->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']),0,0,'R');
$y += 5;

View File

@@ -80,7 +80,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
$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');
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%06s',$inv->getPrintInvoiceNum()),0,0,'R');
# Company Address
$y = 216;
@@ -93,7 +93,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
$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');
$this->SetXY($x,$y); $this->Cell(0,0,$this->_currency($inv->sPreviousBalance()),0,0,'R');
$y = 219;
$this->SetFont('arial','',9);
@@ -104,7 +104,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
$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');
$this->SetXY($x,$y); $this->Cell(0,0,$this->_currency($inv->sPreviousBalance()+$inv->print['invoice']['total_amt']-$inv->print['invoice']['billed_amt']),0,0,'R');
# Draw the Customers Address
$x = 25; $y = 248;
@@ -134,7 +134,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
$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');
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%06s',$inv->getPrintInvoiceNum()),0,0,'R');
# Invoice number at top of page.
$y += 7;
@@ -151,7 +151,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
$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');
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->sPreviousBalance()),0,0,'R');
$y += 5;
$this->SetFont('arial','',10);
@@ -171,7 +171,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
$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');
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->sPreviousBalance()+$inv->print['invoice']['total_amt']-$inv->print['invoice']['billed_amt']),0,0,'R');
}
#@todo Limit the size of the news to 6 lines
@@ -216,7 +216,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
$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;
$this->SetXY($x+30,$y); $this->Cell(0,0,$inv->getPrintInvoiceID()); $y += 3;
# Direct Debit
$y += 3;
@@ -324,7 +324,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
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; $y = 5;
@@ -536,7 +536,7 @@ class pdf_invoice_overview extends pdf_invoice_base {
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;
@@ -564,7 +564,7 @@ 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->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']),0,0,'R');
$y += 5;

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');
}
}
}

View File

@@ -0,0 +1,21 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides invoice capabilities.
*
* @package OSB
* @subpackage Invoice
* @category Controllers/Admin
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_Admin_Invoice extends Controller_TemplateDefault {
public function action_convert() {
if (Config::sitemode() != KOHANA::DEVELOPMENT)
throw new Kohana_Exception(__METHOD__.' can only be run in development');
else
throw new Kohana_Exception(__METHOD__.' can be run in development');
}
}
?>

View File

@@ -0,0 +1,21 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides invoice capabilities.
*
* @package OSB
* @subpackage Invoice
* @category Controllers
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_Invoice extends Controller_TemplateDefault {
public function action_display() {
// @todo - this should be a global config item
$mediapath = Route::get('default/media');
$this->template->content = Kohana::debug(func_get_args());
}
}
?>

View File

@@ -0,0 +1,55 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides User Invoice functions
*
* @package OSB
* @subpackage Invoice
* @category Controllers/User
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Controller_User_Invoice extends Controller_TemplateDefault {
public $secure_actions = array(
'list'=>TRUE,
'view'=>FALSE,
);
/**
* Show a product
*/
public function action_list() {
$id = Auth::instance()->get_user()->id;
$ao = ORM::factory('account',$id);
if (! $ao->loaded())
throw new Kohana_Exception('Account doesnt exist :account ?',array(':account'=>$id));
Block::add(array(
'title'=>sprintf('%s: %s - %s',_('Invoices For'),$ao->accnum(),$ao->name(TRUE)),
'body'=>View::factory('invoice/list')
->set('invoices',$ao->invoice->find_all()),
));
$this->template->content = Block::factory();
}
/**
* View an Invoice
*/
public function action_view($id) {
$io = ORM::factory('invoice',$id);
if (! $io->loaded() OR ! Auth::instance()->authorised($io->account_id)) {
$this->template->content = 'Unauthorised or doesnt exist?';
return FALSE;
}
// @todo media path probably should be a config item
$this->template->content = View::factory('invoice/html')
->set('mediapath',Route::get('default/media'))
->set('invoice',$io);
}
}
?>

View File

@@ -0,0 +1,92 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides invoice information
*
* @package OSB
* @subpackage Invoice
* @category Helpers
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Invoice {
public static function instance() {
return new Invoice;
}
/**
* Return a list of invoices for an invoice
*
* @param $id int Service ID
* @param $paid boolean Optionally only list the ones that are not paid.
* @return array
*/
public static function servicelist($id,$paid=TRUE) {
// @todo need to add the db prefix
$invoices = DB::Query(Database::SELECT,'
SELECT i.id AS iid,i.due_date AS due FROM ab_invoice i,ab_invoice_item ii WHERE ii.invoice_id=i.id AND service_id=:id GROUP BY i.id
')
->param(':id',$id)
->execute();
$service_invoices = array();
foreach ($invoices as $item) {
if ($bal = Invoice::balance($item['iid']) OR $paid) {
$service_invoices[$item['iid']]['id'] = $item['iid'];
$service_invoices[$item['iid']]['total'] = $bal;
$service_invoices[$item['iid']]['due'] = $item['due'];
}
}
return $service_invoices;
}
/**
* Return the total of amount outstanding for a service
*
* @param $id int Service ID
* @param $paid boolean Optionally only list the ones that are not paid.
* @return real Total amount outstanding
* @see Invoice::listservice()
*/
public static function servicetotal($id,$paid=TRUE) {
$total = 0;
foreach (Invoice::servicelist($id,$paid) as $item)
$total += $item['total'];
return $total;
}
/**
* Return the earliest due date of an outstanding invoice
*
* @param $id int Service ID
* @return datetime
*/
public static function servicedue($id) {
$due = 0;
foreach (Invoice::servicelist($id,FALSE) as $item)
if ($due < $item['due'])
$due = $item['due'];
return $due;
}
public static function balance($id) {
$invoice = ORM::factory('invoice')
->where('id','=',$id)
->find();
// @todo We should call check() here to re-run the validation, which re-calcs the total
// @todo might need to cache these results for performance
#if ($invoice->loaded() AND $invoice->check())
if ($invoice->loaded())
return $invoice->total_amt-$invoice->billed_amt-$invoice->credit_amt;
else
return 0;
}
}
?>

View File

@@ -0,0 +1,267 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides invoice capabilities.
*
* @package OSB
* @subpackage Invoice
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Invoice extends ORMOSB {
private $invoice_items = array();
protected $_belongs_to = array(
'account'=>array()
);
protected $_has_many = array(
'invoice_item'=>array(),
'invoice_item_tax'=>array(),
'service'=>array('through'=>'invoice_item'),
'payment'=>array('through'=>'payment_item'),
);
/**
* @var array Filters to render values properly
*/
protected $_filters = array(
// @todo This rounding should be a global configuration
'total_amt'=>array('round'=>array('2')),
);
protected $_callbacks = array(
'id'=>array('get_next_id'),
'total_amt'=>array('calc_total'),
'tax_amt'=>array('calc_tax'),
);
protected $_formats = array(
'date_orig'=>array('Config::date'=>array()),
'due_date'=>array('Config::date'=>array()),
'billed_amt'=>array('Currency::display'=>array()),
'credit_amt'=>array('Currency::display'=>array()),
'status'=>array('StaticList_YesNo::display'=>array()),
'total_amt'=>array('Currency::display'=>array()),
);
/**
* Display the Invoice Number
*/
public function invnum() {
return sprintf('%06s',$this->id);
}
/**
* Display the Invoice Reference Number
*/
public function refnum() {
return sprintf('%02s-%04s-%06s',Config::siteid(),$this->account_id,$this->id);
}
/**
* Display the amount due
*/
public function due($format=FALSE) {
$result = 0;
// If the invoice is active calculate the due amount
if ($this->status)
$result = $this->total_amt-$this->credit_amt-$this->billed_amt;
if ($format)
return Currency::display($result);
else
return $result;
}
public function subtotal($format=FALSE) {
$result = 0;
foreach ($this->items() as $item)
$result += $item->subtotal();
if ($format)
return Currency::display($result);
else
return $result;
}
public function total($format=FALSE) {
$result = 0;
foreach ($this->items() as $item)
$result += $item->total();
// Reduce any credits
$result -= $this->credit_amt;
if ($format)
return Currency::display($result);
else
return $result;
}
/**
* Return a list of invoice items for this invoice.
*/
public function items() {
// Get our invoice items for an existing invoice
if ($this->id AND $this->loaded() AND ! $this->_changed)
return $this->invoice_item->order_by('service_id,item_type,module_id')->find_all();
echo kohana::debug(array('BEFORE'=>$this->invoice_item));
if (! $this->invoice_items)
$this->invoice_items = $this->invoice_item;
echo kohana::debug(array('AFTER'=>$this->invoice_items));die();
return $this->invoice_items;
}
/**
* Return a list of our main invoice items (item_id=0)
*/
public function items_main() {
if ($this->id AND $this->loaded() AND ! $this->_changed)
return $this->invoice_item->where('item_type','=',0)->find_all();
}
/**
* Return a list of our sub invoice items (item_id!=0)
*/
public function items_sub($sid) {
if ($this->id AND $this->loaded() AND ! $this->_changed)
return $this->invoice_item->where('service_id','=',$sid)->and_where('item_type','<>',0)->find_all();
}
/**
* Calculate the total for items for a service
*/
public function items_service_total($sid) {
$total = 0;
foreach ($this->invoice_item->where('service_id','=',$sid)->find_all() as $item)
$total += $item->total();
return $total;
}
/**
* Calculate the tax of items for a service
*/
public function items_service_tax($sid) {
$total = 0;
foreach ($this->invoice_item->where('service_id','=',$sid)->find_all() as $item)
$total += $item->tax_amt;
return $total;
}
/**
* Return a list of items based on a sort criteria
*/
public function sorted_service_items($index) {
$summary = array();
foreach ($this->items() as $item) {
$key = $item->service->$index;
if (! isset($summary[$key]['items'])) {
$summary[$key]['items'] = array();
$summary[$key]['total'] = 0;
}
// Only record items with item_type=0
if ($item->item_type == 0)
array_push($summary[$key]['items'],$item);
$summary[$key]['total'] += $item->total();
}
return $summary;
}
/**
* Return a list of taxes used on this invoice
*/
public function tax_summary() {
$summary = array();
foreach ($this->items() as $item) {
foreach ($item->invoice_item_tax->find_all() as $item_tax) {
if (! isset($summary[$item_tax->tax_id]))
$summary[$item_tax->tax_id] = $item_tax->amount;
else
$summary[$item_tax->tax_id] += $item_tax->amount;
}
}
return $summary;
}
public function add_item() {
$c = count($this->invoice_items);
$this->invoice_items[$c] = ORM::factory('invoice_item');
return $this->invoice_items[$c];
}
public function save() {
// Save the invoice
parent::save();
// Need to save the associated items and their taxes
if ($this->saved()) {
$tax_amt = 0;
$discount_amt = 0;
foreach ($this->items() as $invoice_item) {
$invoice_item->invoice_id = $this->id;
if (! $invoice_item->check()) {
// @todo Mark invoice as cancelled and write a memo, then...
throw new Kohana_Exception('Problem saving invoice_item for invoice :invoice - Failed check()',array(':invoice'=>$invoice->id));
}
$invoice_item->save();
if (! $invoice_item->saved()) {
// @todo Mark invoice as cancelled and write a memo, then...
throw new Kohana_Exception('Problem saving invoice_item for invoice :invoice - Failed save()',array(':invoice'=>$invoice->id));
}
// @todo Need to save tax information
// @todo Need to save discount information
}
} else
throw new Kohana_Exception('Couldnt save invoice for some reason?');
echo Kohana::debug(array('saved'=>$this));
}
public function calc_total(Validate $array, $field) {
$array[$field] = 0;
// @todo Rounding here should come from a global config
foreach ($this->invoice_items as $item)
$array[$field] += round($item->price_base+$item->price_setup,2);
$this->_changed[$field] = $field;
}
public function calc_tax(Validate $array, $field) {
$array[$field] = 0;
// @todo Rounding here should come from a global config
// @todo tax should be evaluated per item
// @todo tax parameters should come from user session
foreach ($this->invoice_items as $item)
$array[$field] += round(Tax::total(61,NULL,$item->price_base+$item->price_setup),2);
$this->_changed[$field] = $field;
}
}
?>

View File

@@ -0,0 +1,93 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides invoice item capabilities.
*
* @package OSB
* @subpackage Invoice
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Invoice_Item extends ORMOSB {
protected $_belongs_to = array(
'product'=>array(),
'invoice'=>array(),
'service'=>array()
);
protected $_has_many = array(
'invoice_item_tax'=>array()
);
protected $_updated_column = FALSE; // @todo No update columns
// Display a transaction number
public function trannum() {
return sprintf('%03s-%06s',$this->item_type,$this->id);
}
// Display the period that a transaction applies
public function period() {
if ($this->date_start == $this->date_stop)
return sprintf('%s: %s',_('Date'),Config::date($this->date_start));
else
return sprintf('%s: %s -> %s',_('Period'),Config::date($this->date_start),Config::date($this->date_stop));
}
/**
* On invoices where there are multiple charges for the same item
* (eg spanning the next invoice period), this should show the period
* range for the additional sub-items.
*/
public function invoice_display() {
return $this->period();
}
public function subtotal() {
return ($this->price_base+$this->price_setup)*$this->quantity;
}
public function total() {
return ($this->price_base+$this->price_setup)*$this->quantity+$this->tax_amt-$this->discount_amt;
}
public function save() {
// Save the invoice item
parent::save();
// Need to save the taxes and discounts associated with the invoice_item
if ($this->saved()) {
$invoice_item_tax = ORM::factory('invoice_item_tax');
$tax_total = 0;
// Save TAX details
// @todo tax parameters should come from user session
foreach (Tax::detail(61,NULL,$this->subtotal()) as $tax) {
$invoice_item_tax->clear();
$invoice_item_tax->invoice_item_id = $this->id;
// @todo Rounding here should come from a global config
$tax_total += ($invoice_item_tax->amount = round($tax['amount'],2));
$invoice_item_tax->tax_id = $tax['id'];
if (! $invoice_item_tax->check())
throw new Kohana_Exception('Couldnt save tax for some reason - failed check()?');
$invoice_item_tax->save();
if (! $invoice_item_tax->saved())
throw new Kohana_Exception('Couldnt save tax for some reason - failed save()?');
}
// Save DISCOUNT details
// @todo calculate discounts
$this->tax_amt = $tax_total;
$this->total_amt = $this->total();
parent::save();
} else
throw new Kohana_Exception('Couldnt save invoice_item for some reason?');
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -60,15 +60,15 @@ abstract class pdf_invoice_base extends fpdf {
$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->SetSubject(sprintf('Invoice #%06s',$inv->getPrintInvoiceNum()));
$this->SetKeywords($inv->getPrintInvoiceID());
$this->SetAutoPageBreak(TRUE,25);
$this->SetDisplayMode('fullwidth');
return $this;
}
public function load_setup(&$rs) {
public function load_setup($rs=false) {
if (! $rs) {
$db =& DB();
$rs = $db->Execute(sqlSelect($db,'setup_invoice','*',''));

View File

@@ -62,15 +62,15 @@ abstract class pdf_invoice_base extends fpdi {
$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->SetSubject(sprintf('Invoice #%06s',$inv->getPrintInvoiceNum()));
$this->SetKeywords($inv->getPrintInvoiceID());
$this->SetAutoPageBreak(TRUE,25);
$this->SetDisplayMode('fullwidth');
return $this;
}
public function load_setup(&$rs) {
public function load_setup($rs=false) {
if (! $rs) {
$db =& DB();
$rs = $db->Execute(sqlSelect($db,'setup_invoice','*',''));

View File

@@ -60,8 +60,8 @@ abstract class pdf_invoice_base extends TCPDF {
$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->SetSubject(sprintf('Invoice #%06s',$inv->getPrintInvoiceNum()));
$this->SetKeywords($inv->getPrintInvoiceID());
$this->SetAutoPageBreak(TRUE,25);
$this->SetHeaderMargin(1);
$this->SetFooterMargin(10);
@@ -72,7 +72,7 @@ abstract class pdf_invoice_base extends TCPDF {
return $this;
}
public function load_setup(&$rs) {
public function load_setup($rs=false) {
if (! $rs) {
$db =& DB();
$rs = $db->Execute(sqlSelect($db,'setup_invoice','*',''));

View File

@@ -66,15 +66,17 @@
<display>Active</display>
<type>L</type>
</status>
<!-- @todo UNKNOWN -->
<parent_id>
<!-- @todo UNKNOWN - used when recurring payments come in, they must be linked to an invoice number -->
<!-- DELETED
<parent_id>
<type>I4</type>
</parent_id>
<!-- @todo UNKNOWN 1 = normal, !1 = upgrade? -->
-->
<!-- NULL = IMPORTED INVOICE, 0=UNUSED, 2 = CHECKOUT INVOICE,1 = REOCURRING INVOICE -->
<type>
<type>L</type>
</type>
<!-- Can new services be provisioned -->
<!-- Invoice Approved: 1=YES, 0=UNUSED, NULL = NO (Approved invoices can have services provisioned) -->
<process_status>
<type>L</type>
</process_status>
@@ -89,18 +91,21 @@
<type>L</type>
</refund_status>
<!-- Suspend billing of reocurring invoices, where this invoice is the 1st/parent invoice -->
<!-- DELETED
<suspend_billing>
<type>L</type>
</suspend_billing>
<!-- Has this invoice been printed -->
-->
<!-- 1 = 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>
<display>Account</display>
<type>I8</type>
</account_id>
<!-- @todo UNKNOWN -->
<account_billing_id>
@@ -115,9 +120,11 @@
<type>I4</type>
</campaign_id>
<!-- @todo UNKNOWN -->
<!-- DELETED
<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>
@@ -126,54 +133,65 @@
<checkout_plugin_id>
<type>I4</type>
</checkout_plugin_id>
<!-- Checkout plugin data -->
<!-- Checkout plugin data (has the subscription ID for reoccurring payments) -->
<checkout_plugin_data>
<type>C(255)</type>
<convert>array</convert>
</checkout_plugin_data>
<!-- The TAX id applicable for this invoice -->
<tax_id>
<!-- DELETED
<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>
<!-- The amount of CREDITS this invoice includes -->
<credit_amt>
<display>Total Credits</display>
<type>F</type>
</credit_amt>
<!-- @todo - ? The discounts that were applied to this invoice -->
<!-- DELETED
<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 -->
<!-- DELETED
<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 -->
<!-- Amount already paid (in site currency) -->
<billed_amt>
<display>Amount Paid</display>
<type>F</type>
</billed_amt>
<!-- The currency that this invoice is due -->
<!-- The currency id that this invoice is due (in site currency) -->
<billed_currency_id>
<type>I4</type>
</billed_currency_id>
<!-- The amount (in actual_billed_currency_id units) that originally this invoice was billed in -->
<!-- The amount (in actual_billed_currency_id units) that payment was made in -->
<actual_billed_amt>
<type>F</type>
</actual_billed_amt>
<!-- The current that was used when the invoice was created -->
<!-- The currency that was used to pay the invoice -->
<actual_billed_currency_id>
<type>I4</type>
</actual_billed_currency_id>
@@ -201,9 +219,10 @@
<convert>date-time</convert>
</due_date>
<!-- @todo ?? -->
<!-- DELETED
<recur_arr>
<type>X</type>
</recur_arr>
</recur_arr> -->
<!-- Admin notes attached to the invoice -->
<notes>
<type>X</type>
@@ -221,23 +240,24 @@
<type>I4</type>
</net_term_intervals>
<!-- @todo ?? -->
<!-- DELETED
<ip>
<type>C(32)</type>
</ip>
</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>
<add>id,type,process_status,billing_status,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,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,status</add>
<update>id,date_last,type,process_status,billing_status,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,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</update>
<delete>id</delete>
<view>id,date_orig,date_last,type,process_status,billing_status,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,tax_amt,discount_amt,total_amt,billed_amt,credit_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</view>
<search>id,date_orig,date_last,type,process_status,billing_status,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,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</search>
<export_excel>id,date_orig,date_last,process_status,billing_status,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_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,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_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,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_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,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_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,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_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 -->
@@ -250,6 +270,30 @@
<!-- Template helpers -->
<tpl>
<invoicesoon>
<checkbox>
<field>id</field>
<type>checkbox</type>
<width>25px</width>
</checkbox>
<account_id>
<field>account_id</field>
</account_id>
<service_id>
<translate>service_id</translate>
</service_id>
<next_invoice_date>
<field>invoice_date</field>
<translate>next_invoice_date</translate>
</next_invoice_date>
<price>
<field>price</field>
<type>currency</type>
</price>
<icon>
<width>120px</width>
</icon>
</invoicesoon>
<search_show>
<checkbox>
<field>id</field>
@@ -278,7 +322,6 @@
<width>120px</width>
</icon>
</search_show>
<user_search_show>
<checkbox>
<field>id</field>
@@ -296,6 +339,10 @@
<field>total_amt</field>
<type>currency</type>
</total_amt>
<balance>
<field>balance</field>
<type>currency</type>
</balance>
<icon>
<width>60px</width>
</icon>

View File

@@ -57,11 +57,11 @@
<name>view</name>
<notes><![CDATA[View a record]]></notes>
</view>
<invoicesoon>
<tmInvoiceSoon>
<display>Upcoming Invoices</display>
<menu_display>1</menu_display>
<name>Invoice Soon</name>
</invoicesoon>
<name>tmInvoiceSoon</name>
</tmInvoiceSoon>
<resend>
<name>resend</name>
</resend>

View File

@@ -33,7 +33,7 @@ class receipt_print extends FPDF
var $active=false;
var $save_path = '';
function add(&$invoiceRs, $payment_amt, $paid_amt) {
function add($invoice, $payment_amt, $paid_amt) {
if(!$this->active) return false;
@@ -46,16 +46,16 @@ class receipt_print extends FPDF
$this->drawCompanyAddress();
$this->SetXY(0,50);
$this->Cell(50,10,"*** INVOICE# {$invoiceRs->fields['id']} ***");
$this->Cell(50,10,"*** INVOICE# {$invoice['id']} ***");
$this->SetXY(0,60);
$this->Cell(50,10,"DATE ".date("d/m/Y D H:i"));
$this->SetXY(0,70); $this->Cell(50,5,"INVOICE TOTAL: ");
$this->SetXY(45,70); $this->Cell(50,5, number_format($invoiceRs->fields['total_amt'],2));
$this->SetXY(45,70); $this->Cell(50,5, number_format($invoice['total_amt'],2));
$this->SetXY(0,75); $this->Cell(50,5,"PREV AMT DUE: " );
$this->SetXY(45,75); $this->Cell(50,5, number_format($invoiceRs->fields['total_amt']-$invoiceRs->fields['billed_amt'],2));
$this->SetXY(45,75); $this->Cell(50,5, number_format($invoice['total_amt']-$invoice['billed_amt'],2));
$this->SetXY(0,80); $this->Cell(50,5,"CURRENT PAYMENT: " );
$this->SetXY(45,80); $this->Cell(50,5, $payment_amt);
@@ -64,7 +64,7 @@ class receipt_print extends FPDF
$this->SetXY(45,85); $this->Cell(50,5, number_format($paid_amt,2));
$this->SetXY(0,90); $this->Cell(50,5,"CURRENY AMT DUE: " );
$this->SetXY(45,90); $this->Cell(50,5, number_format($invoiceRs->fields['total_amt']-$paid_amt,2));
$this->SetXY(45,90); $this->Cell(50,5, number_format($invoice['total_amt']-$paid_amt,2));
$this->SetXY(0,100); $this->Cell(50,5,"Thank You!" );

View File

@@ -0,0 +1,138 @@
<!-- @todo NEED to translate this -->
<table class="box-left" border="0">
<tr>
<td style="vertical-align: top">
<table class="company_details" border="0">
<tr>
<td class="logo"><?php echo Config::logo(); ?></td>
<td class="address"><span class="company_name"><?php echo Config::sitename(); ?></span><br/><?php echo Company::address(); ?><br/><?php echo Company::contacts(); ?></td>
</tr>
</table>
</td>
<td>&nbsp;</td>
<td>
<table class="invoice_summary" border="0">
<tr>
<td>TAX INVOICE</td>
<td class="bold-right"><?php echo $invoice->invnum(); ?></td>
</tr>
<tr>
<td>Issue Date</td>
<td class="bold-right"><?php echo $invoice->display('date_orig'); ?></td>
</tr>
<tr>
<td>Due Date</td>
<td class="bold-right"><?php echo $invoice->display('due_date'); ?></td>
</tr>
<tr>
<td>Current Charges Due</td>
<td class="bold-right"><?php echo $invoice->display('total_amt'); ?></td>
</tr>
<tr>
<td>Payments Received to Date</td>
<td class="bold-right"><?php echo $invoice->display('billed_amt'); ?></td>
</tr>
<tr>
<td>Total Charges Due</td>
<td class="bold-right"><?php echo $invoice->due(TRUE); ?></td>
</tr>
</table>
</td>
</tr>
<tr><td class="spacer" colspan="3">&nbsp;</td></tr>
<tr>
<td colspan="3">
<table class="box-full" border="0">
<tr>
<td class="head" colspan="4">Charges Detail:</td>
</tr>
<?php foreach ($invoice->sorted_service_items('recur_schedule') as $cat => $catitems) { ?>
<tr>
<td><div id="toggle_<?php echo $cat; ?>"><?php echo HTML::image($mediapath->uri(array('file'=>'img/toggle-closed.png')),array('alt'=>'+')); ?></div><script type="text/javascript">$("#toggle_<?php echo $cat; ?>").click(function() {$('#detail_toggle_<?php echo $cat; ?>').toggle();});</script></td>
<td><?php echo StaticList_RecurSchedule::display($cat); ?></td>
<td><?php printf('%s Services',count($catitems['items'])); ?></td>
<td class="bold-right"><?php echo Currency::display($catitems['total']); ?></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2">
<div id="detail_toggle_<?php echo $cat; ?>">
<table class="box-full" border="0">
<?php foreach ($catitems['items'] as $item) {?>
<!-- Product Information -->
<tr class="head">
<td><?php echo HTML::anchor('/user/service/view/'.$item->service->id,$item->service->svcnum()); ?></td>
<td colspan="3"><?php echo $item->product->product_translate->find()->name; ?> (<?php echo $item->product_id; ?>)</td>
<td class="right"><?php echo Currency::display($invoice->items_service_total($item->service_id));?></td>
</tr>
<!-- End Product Information -->
<!-- Product Sub Information -->
<tr>
<td>&nbsp;</td>
<td><?php echo $item->trannum();?></td>
<td><?php echo $item->period();?></td>
<td class="right"><?php echo Currency::display($item->subtotal());?></td>
</tr>
<!-- End Product Sub Information -->
<!-- Product Sub Items -->
<?php
foreach ($invoice->items_sub($item->service_id) as $subitem) {
if (! is_null($subitem->module_id)) {
$m = StaticList_Module::record('module','name','id',$subitem->module_id);
// @todo Need to remove the explicit test for 'charge' and be more dynamic
$mi = ORM::factory($m,$m == 'charge' ? $subitem->charge_id : $subitem->id);
$display = $mi->invoice_display();
} else {
$display = 'Other';
}
?>
<tr>
<td>&nbsp;</td>
<td><?php echo $subitem->trannum(); ?></td>
<td><?php echo $display; ?></td>
<td class="right"><?php echo Currency::display($subitem->subtotal());?></td>
</tr>
<?php } ?>
<!-- Product End Sub Items -->
<!-- Product Sub Items Tax -->
<tr>
<td colspan="2">&nbsp;</td>
<td><?php echo _('Taxes'); ?></td>
<td class="right"><?php echo Currency::display($invoice->items_service_tax($item->service_id));?></td>
</tr>
<!-- Product End Sub Items Tax -->
<?php } ?>
</table>
</div>
</td>
</tr>
<?php } ?>
<tr>
<td class="head" colspan="2">Sub Total:</td>
<td class="bold-right"><?echo $invoice->subtotal(TRUE); ?></td>
</tr>
<tr>
<td class="head" colspan="4">Taxes Included:</td>
</tr>
<?php
foreach ($invoice->tax_summary() as $tid => $amount) {
$m = ORM::factory('tax',$tid);
?>
<tr>
<td>&nbsp;</td>
<td><?php echo $m->description; ?></td>
<td class="bold-right"><?php echo Currency::display($amount); ?></td>
</tr>
<?php }?>
<!-- @todo Add discounts -->
<tr>
<td class="head" colspan="3">Total:</td>
<td class="bold-right"><?echo $invoice->total(TRUE); ?></td>
</tr>
</table>
</td>
</tr>
</table>

View File

@@ -0,0 +1,21 @@
<!-- @todo NEEDS TO BE TRANSLATED -->
<table class="box-left">
<tr>
<td class="head">ID</td>
<td class="head">Total</td>
<td class="head">Credits</td>
<td class="head">Payments</td>
<td class="head">Due</td>
<td class="head">Active</td>
</tr>
<?php $i = 0; foreach ($invoices as $invoice) { ?>
<tr class="<?php echo ++$i%2 ? 'odd' : 'even'; ?>">
<td><?php echo HTML::anchor('/user/invoice/view/'.$invoice->id,$invoice->invnum()); ?></td>
<td><?php echo $invoice->display('total_amt'); ?></td>
<td><?php echo $invoice->display('credit_amt'); ?></td>
<td class="number"><?php echo $invoice->display('billed_amt'); ?></td>
<td style="font-weight: <?php echo $invoice->due() ? 'bold' : 'normal'; ?>"><?php echo Currency::display($invoice->due()); ?></td>
<td><?php echo $invoice->display('status'); ?></td>
</tr>
<?php } ?>
</table>