2009-08-03 04:10:16 +00:00
|
|
|
<?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);
|
2010-11-29 22:41:08 +00:00
|
|
|
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%06s',$inv->getPrintInvoiceNum()),0,0,'R');
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
# 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');
|
2010-11-29 22:41:08 +00:00
|
|
|
$this->SetXY($x,$y); $this->Cell(0,0,$this->_currency($inv->sPreviousBalance()),0,0,'R');
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
$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');
|
2010-11-29 22:41:08 +00:00
|
|
|
$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');
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
# 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);
|
2010-11-29 22:41:08 +00:00
|
|
|
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%06s',$inv->getPrintInvoiceNum()),0,0,'R');
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
# 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);
|
2010-11-29 22:41:08 +00:00
|
|
|
$this->SetXY($x+55,$y); $this->Cell(0,0,$this->_currency($inv->sPreviousBalance()),0,0,'R');
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
$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);
|
2010-11-29 22:41:08 +00:00
|
|
|
$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');
|
2009-08-03 04:10:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#@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;
|
2010-11-29 22:41:08 +00:00
|
|
|
$this->SetXY($x+30,$y); $this->Cell(0,0,$inv->getPrintInvoiceID()); $y += 3;
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
# 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;
|
|
|
|
|
2010-11-29 22:41:08 +00:00
|
|
|
if ($line['price_type'] == 0 && $line['item_type'] == 5)
|
2009-08-03 04:10:16 +00:00
|
|
|
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;
|
|
|
|
|
2010-11-29 22:41:08 +00:00
|
|
|
$items = $inv->sInvoiceItemsSummary();
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
# 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);
|
2010-11-29 22:41:08 +00:00
|
|
|
$this->Cell(0,0,sprintf('%s (%s)',$line['product_name'],$this->_currency($line['price_base'])));
|
2009-08-03 04:10:16 +00:00
|
|
|
$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');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|