Removed modules not being used
This commit is contained in:
@@ -1,621 +0,0 @@
|
||||
<?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->getPrintInvoiceNum()),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->sPreviousBalance()),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->sPreviousBalance()+$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->getPrintInvoiceNum()),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->sPreviousBalance()),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->sPreviousBalance()+$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->getPrintInvoiceID()); $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->sInvoiceItemsSummary();
|
||||
|
||||
# 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['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;
|
||||
$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');
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@@ -1,638 +0,0 @@
|
||||
<?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->getPrintInvoiceNum()),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->sPreviousBalance()),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->sPreviousBalance()+$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->getPrintInvoiceNum()),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->sPreviousBalance()),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->sPreviousBalance()+$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->getPrintInvoiceID()); $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->sInvoiceItemsSummary();
|
||||
|
||||
# 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['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;
|
||||
$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');
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@@ -1,673 +0,0 @@
|
||||
<?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) {
|
||||
# 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) {
|
||||
# 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,_('Payment Remittence')); $y +=5;
|
||||
|
||||
$this->SetFont('helvetica','',8);
|
||||
$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,_('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,_('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,_('Invoice Number'));
|
||||
$this->SetFont('helvetica','B',11);
|
||||
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%06s',$inv->getPrintInvoiceNum()),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->sPreviousBalance()),0,0,'R');
|
||||
|
||||
$y = 219;
|
||||
$this->SetFont('helvetica','',9);
|
||||
$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->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;
|
||||
|
||||
$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) {
|
||||
$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)+($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->getPrintInvoiceNum()),0,0,'R');
|
||||
|
||||
# Invoice number at top of page.
|
||||
$y += 7;
|
||||
$this->SetFont('helvetica','',10);
|
||||
$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);
|
||||
$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->sPreviousBalance()),0,0,'R');
|
||||
|
||||
$y += 5;
|
||||
$this->SetFont('helvetica','',10);
|
||||
$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');
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
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->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) {
|
||||
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 = 120; $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 Credit
|
||||
$logo = sprintf('%s/%s','/afs/local/home/gh/.web/au.net.graytech.www/osb/modules/invoice/media/img/','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->getPrintInvoiceID()); $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->getPrintInvoiceNum(),$inv->print['site']['URL']); $y += 3;
|
||||
*/
|
||||
|
||||
# Paypal
|
||||
$y += 3;
|
||||
// $logo = sprintf('%s/%s',PATH_THEMES.DEFAULT_THEME,'invoice/invoice-payment-pp.png');
|
||||
$logo = sprintf('%s/%s','/afs/local/home/gh/.web/au.net.graytech.www/osb/modules/invoice/media/img/','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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
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,_('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,_('Description'));
|
||||
$this->SetX($x+135);
|
||||
$this->Cell(0,0,_('Quantity'));
|
||||
$this->SetX($x+160);
|
||||
$this->Cell(10,0,_('Unit Cost'),0,0,'R');
|
||||
$this->SetX($x+135);
|
||||
$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);
|
||||
}
|
||||
|
||||
$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;
|
||||
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;
|
||||
$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) {
|
||||
if (! $this->show_itemized)
|
||||
return;
|
||||
|
||||
$items = $inv->sInvoiceItemsSummary();
|
||||
|
||||
# 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+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,_('Current Charges Summary for')); $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['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,_('The above is just a summary. To view a detailed list of charges, please visit our website.'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
# Calculate our rounding error
|
||||
$subtotal = 0;
|
||||
foreach($items as $line)
|
||||
$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');
|
||||
$y += 5;
|
||||
$this->SetY($y);
|
||||
}
|
||||
|
||||
# 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->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');
|
||||
|
||||
# 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']-$inv->print['invoice']['credit_amt']),0,0,'R');
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@@ -1,109 +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
|
||||
*/
|
||||
|
||||
/**
|
||||
* Advance invoice e-mail notification class
|
||||
*/
|
||||
class advance_notice
|
||||
{
|
||||
var $advance_days=false;
|
||||
var $advance_days_service;
|
||||
|
||||
function task() {
|
||||
|
||||
$db=&DB();
|
||||
|
||||
/* get the max invoice days from the setup_invoice table */
|
||||
if(!$this->advance_days) {
|
||||
$setup = $db->Execute(sqlSelect($db,"setup_invoice","advance_notice","advance_notice>0 and advance_notice != '' and advance_notice is not null"));
|
||||
if(!$setup->RecordCount()) return false;
|
||||
$this->advance_days = $setup->fields['advance_notice'];
|
||||
}
|
||||
|
||||
/* pre-billing days global setting */
|
||||
if(MAX_INV_GEN_PERIOD <= 0) $max_days = $max_date=1; else $max_days = MAX_INV_GEN_PERIOD;
|
||||
|
||||
/* pre-notification date for service */
|
||||
$this->advance_days_service = $this->advance_days + $max_days;
|
||||
$max_date = time()+($this->advance_days_service*86400);
|
||||
date("Y-m-d", $max_date);
|
||||
|
||||
$p=AGILE_DB_PREFIX; $s=DEFAULT_SITE;
|
||||
$ids=false;
|
||||
$account=false;
|
||||
$date=false;
|
||||
$invoice=false;
|
||||
$sql = "SELECT DISTINCT service.id as serviceId, account.id as accountId, invoice.id as invoiceId, from_unixtime(service.date_next_invoice,'%Y-%m-%d') as dayGroup
|
||||
FROM {$p}service as service
|
||||
JOIN {$p}account as account ON ( service.account_id=account.id and account.site_id={$s} )
|
||||
LEFT JOIN {$p}invoice as invoice ON ( service.invoice_id=invoice.id and invoice.site_id={$s} )
|
||||
WHERE service.site_id={$s}
|
||||
AND service.active = 1
|
||||
AND ( service.invoice_advance_notified IS NULL OR service.invoice_advance_notified = 0 )
|
||||
AND ( service.suspend_billing IS NULL OR service.suspend_billing = 0 )
|
||||
AND ( service.date_next_invoice > 0 AND service.date_next_invoice IS NOT NULL )
|
||||
AND
|
||||
((
|
||||
( account.invoice_advance_gen!='' OR account.invoice_advance_gen is not null ) AND service.date_next_invoice <= ((86400*(account.invoice_advance_gen+{$this->advance_days})) + (UNIX_TIMESTAMP(CURDATE())))
|
||||
) OR (
|
||||
( account.invoice_advance_gen='' OR account.invoice_advance_gen is null ) AND service.date_next_invoice <= {$max_date}
|
||||
))
|
||||
ORDER BY accountId, dayGroup, serviceId";
|
||||
$rs = $db->Execute($sql);
|
||||
if($rs === false) {global $C_debug; $C_debug->error('advance_notice.inc.php','task()', $sql . " \r\n\r\n " . @$db->ErrorMsg()); }
|
||||
if($rs && $rs->RecordCount()) {
|
||||
while(!$rs->EOF) {
|
||||
if( $ids && ($rs->fields['accountId'] != $account ) || ($rs->fields['dayGroup'] != $date) ) {
|
||||
$this->sendEmail($ids, $account, $date);
|
||||
$ids=false;
|
||||
}
|
||||
|
||||
// set the current account and date
|
||||
$account=$rs->fields['accountId'];
|
||||
$invoice=$rs->fields['invoiceId'];
|
||||
$date=$rs->fields['dayGroup'];
|
||||
|
||||
// add to id list
|
||||
if($ids) $ids.=",";
|
||||
$ids.=$rs->fields['serviceId'];
|
||||
$rs->MoveNext();
|
||||
}
|
||||
if($ids) $this->sendEmail($ids, $account, $date);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* send e-mail to user with pre-billing notice */
|
||||
function sendEmail($ids, $account, $date) {
|
||||
if (empty($account)) return;
|
||||
|
||||
//echo "<br> $account - $ids - $date";
|
||||
|
||||
/* send e-mail to user */
|
||||
include_once(PATH_MODULES.'email_template/email_template.inc.php');
|
||||
$mail = new email_template;
|
||||
$mail->send('invoice_pregen_notice', $account, $ids, DEFAULT_CURRENCY, $date);
|
||||
|
||||
/* update service.invoice_advance_notified=1 to stop future notifications */
|
||||
$db=&DB();
|
||||
$db->Execute("UPDATE ".AGILE_DB_PREFIX."service SET invoice_advance_notified=1 WHERE site_id=".DEFAULT_SITE." AND id in ($ids)");
|
||||
}
|
||||
}
|
||||
?>
|
@@ -1,41 +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
|
||||
*
|
||||
* 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
@@ -1,197 +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
|
||||
*
|
||||
* 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->getPrintInvoiceNum()));
|
||||
$this->SetKeywords($inv->getPrintInvoiceID());
|
||||
$this->SetAutoPageBreak(TRUE,25);
|
||||
$this->SetDisplayMode('fullwidth');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function load_setup($rs=false) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
?>
|
@@ -1,314 +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
|
||||
*
|
||||
* 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->getPrintInvoiceNum()));
|
||||
$this->SetKeywords($inv->getPrintInvoiceID());
|
||||
$this->SetAutoPageBreak(TRUE,25);
|
||||
$this->SetDisplayMode('fullwidth');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function load_setup($rs=false) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
?>
|
@@ -1,182 +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
|
||||
*
|
||||
* 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->getPrintInvoiceNum()));
|
||||
$this->SetKeywords($inv->getPrintInvoiceID());
|
||||
$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=false) {
|
||||
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,259 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<construct>
|
||||
<!-- 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>
|
||||
<billing>billing_status</billing>
|
||||
<process>process_status</process>
|
||||
<account>account_id</account>
|
||||
<reseller>reseller_id</reseller>
|
||||
<amount>total_amt</amount>
|
||||
<due_date>due_date</due_date>
|
||||
<checkout>checkout_plugin_id</checkout>
|
||||
<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>
|
||||
<!-- Invoice Approved: 1=YES, 0=UNUSED, NULL = NO (Approved invoices can have services 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>
|
||||
<!-- 1 = Has this invoice been printed -->
|
||||
<print_status>
|
||||
<type>L</type>
|
||||
</print_status>
|
||||
<!-- The account this invoice belongs to -->
|
||||
<account_id>
|
||||
<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>
|
||||
<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 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 (has the subscription ID for reoccurring payments) -->
|
||||
<checkout_plugin_data>
|
||||
<type>C(255)</type>
|
||||
<convert>array</convert>
|
||||
</checkout_plugin_data>
|
||||
<!-- 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>
|
||||
<!-- The amount of DISCOUNT this invoice includes -->
|
||||
<discount_amt>
|
||||
<display>Total Discounts</display>
|
||||
<type>F</type>
|
||||
</discount_amt>
|
||||
<!-- Invoice Total Charges (including taxes ??) -->
|
||||
<total_amt>
|
||||
<display>Amount</display>
|
||||
<type>F</type>
|
||||
</total_amt>
|
||||
<!-- Amount already paid (in site currency) -->
|
||||
<billed_amt>
|
||||
<display>Amount Paid</display>
|
||||
<type>F</type>
|
||||
</billed_amt>
|
||||
<!-- 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 payment was made in -->
|
||||
<actual_billed_amt>
|
||||
<type>F</type>
|
||||
</actual_billed_amt>
|
||||
<!-- The currency that was used to pay the invoice -->
|
||||
<actual_billed_currency_id>
|
||||
<type>I4</type>
|
||||
</actual_billed_currency_id>
|
||||
<!-- The date this invoice is due -->
|
||||
<due_date>
|
||||
<display>Date Due</display>
|
||||
<type>I8</type>
|
||||
<convert>date-time</convert>
|
||||
</due_date>
|
||||
<!-- 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>
|
||||
</field>
|
||||
|
||||
<!-- Methods for this class, and the fields they have access to, if applicable -->
|
||||
<method>
|
||||
<add>id,process_status,billing_status,print_status,account_id,account_billing_id,reseller_id,checkout_plugin_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,due_date,status</add>
|
||||
<update>id,date_last,process_status,billing_status,print_status,account_id,account_billing_id,reseller_id,checkout_plugin_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,due_date,net_term_id</update>
|
||||
<delete>id</delete>
|
||||
<view>id,date_orig,date_last,process_status,billing_status,print_status,account_id,account_billing_id,reseller_id,checkout_plugin_id,tax_amt,discount_amt,total_amt,billed_amt,credit_amt,billed_currency_id,due_date,net_term_id</view>
|
||||
<search>id,date_orig,date_last,process_status,billing_status,print_status,account_id,account_billing_id,reseller_id,checkout_plugin_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,due_date,net_term_id</search>
|
||||
<export_excel>id,date_orig,date_last,process_status,billing_status,print_status,account_id,account_billing_id,reseller_id,checkout_plugin_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,due_date,net_term_id</export_excel>
|
||||
<export_pdf>id,date_orig,date_last,process_status,billing_status,print_status,account_id,account_billing_id,reseller_id,checkout_plugin_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,due_date,net_term_id</export_pdf>
|
||||
<export_xml>id,date_orig,date_last,process_status,billing_status,print_status,account_id,account_billing_id,reseller_id,checkout_plugin_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,due_date,net_term_id</export_xml>
|
||||
<export_csv>id,date_orig,date_last,process_status,billing_status,print_status,account_id,account_billing_id,reseller_id,checkout_plugin_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,due_date,net_term_id</export_csv>
|
||||
<export_tab>id,date_orig,date_last,process_status,billing_status,print_status,account_id,account_billing_id,reseller_id,checkout_plugin_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,due_date,net_term_id</export_tab>
|
||||
</method>
|
||||
|
||||
<!-- Method triggers -->
|
||||
<trigger></trigger>
|
||||
|
||||
<!-- Template page display titles -->
|
||||
<title>
|
||||
<user_view>Invoice</user_view>
|
||||
</title>
|
||||
|
||||
<!-- 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>
|
||||
<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>
|
||||
<balance>
|
||||
<field>balance</field>
|
||||
<type>currency</type>
|
||||
</balance>
|
||||
<icon>
|
||||
<width>60px</width>
|
||||
</icon>
|
||||
</user_search_show>
|
||||
</tpl>
|
||||
</construct>
|
@@ -1,99 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<install>
|
||||
<!-- Tree Menu Module Properties -->
|
||||
<module_properties>
|
||||
<!-- 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>
|
||||
|
||||
<!-- 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>
|
||||
<tmInvoiceSoon>
|
||||
<display>Upcoming Invoices</display>
|
||||
<menu_display>1</menu_display>
|
||||
<name>tmInvoiceSoon</name>
|
||||
</tmInvoiceSoon>
|
||||
<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>
|
@@ -1,93 +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
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* This module creates a printable pdf reciept on manual invoice reconciliation suitable for retail printing.
|
||||
* To enable, simply change "var $active=false;" to "var $active=true" below.
|
||||
* When an invoice is reconciled from the admin menu, a PDF will be displayed inline, and you can use the print
|
||||
* feature in the inline acrobat reader to print.
|
||||
*/
|
||||
|
||||
require_once(PATH_INCLUDES.'pdf/fpdf.php');
|
||||
|
||||
class receipt_print extends FPDF
|
||||
{
|
||||
var $active=false;
|
||||
var $save_path = '';
|
||||
|
||||
function add($invoice, $payment_amt, $paid_amt) {
|
||||
|
||||
if(!$this->active) return false;
|
||||
|
||||
ob_start();
|
||||
|
||||
$this->AddPage();
|
||||
$this->SetFont('Arial','B',10);
|
||||
|
||||
$this->drawCompanyLogo();
|
||||
$this->drawCompanyAddress();
|
||||
|
||||
$this->SetXY(0,50);
|
||||
$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($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($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);
|
||||
|
||||
$this->SetXY(0,85); $this->Cell(50,5,"PAID TO DATE: " );
|
||||
$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($invoice['total_amt']-$paid_amt,2));
|
||||
|
||||
$this->SetXY(0,100); $this->Cell(50,5,"Thank You!" );
|
||||
|
||||
$this->Output();
|
||||
|
||||
ob_flush();
|
||||
}
|
||||
|
||||
|
||||
// draw the logo
|
||||
function drawCompanyLogo() {
|
||||
$width = 50;
|
||||
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
|
||||
function drawCompanyAddress() {
|
||||
// add the company address on the payment stub (1)
|
||||
$this->SetFont('times','B', 10);
|
||||
$this->SetXY(0,30); $this->Cell(50,10, SITE_NAME);
|
||||
$this->SetXY(0,35); $this->Cell(50,10, SITE_ADDRESS);
|
||||
$this->SetXY(0,40); $this->Cell(50,10, SITE_CITY. ", ". SITE_STATE . " " . SITE_ZIP);
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user