Changes to AgileBill

This commit is contained in:
Deon George
2009-08-03 14:10:16 +10:00
parent 0a22cfe22c
commit 27aee719b0
1051 changed files with 219109 additions and 117219 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,254 +0,0 @@
<?php
/*
AgileBill - Base class for all PDF invoice generation
(C) 2006 Agileco LLC. All rights reserved.
File orginally written by Joseph Benden on 1/9/2006
$Id:$
*/
class pdf_invoice_base extends fpdi
{
var $iteration;
var $show_service_range=false;
function load_setup(&$rs)
{
if(!$rs) {
$db =& DB();
$rs = $db->Execute(sqlSelect($db,"setup_invoice","*",""));
}
$this->billToCompany = $rs->fields['bill_to_company'];
$this->invoiceCurrency = $rs->fields['invoice_currency'];
$this->invoiceDecimals = $rs->fields['invoice_decimals'];
$this->itemsSummaryMax = $rs->fields['items_summary_max'];
$this->news = $rs->fields['news'];
$this->pageType = $rs->fields['page_type'];
$this->show_itemized = $rs->fields['invoice_show_itemized'];
$this->show_service_range = $rs->fields['invoice_show_service_dates'];
$this->contact_us_url = $rs->fields['contact_us_url'];
$this->contact_us_phone = $rs->fields['contact_us_phone'];
#$this->currency;
$this->currency = $rs->fields['invoice_currency'];
}
function drawCustom() {
}
function getTemplate() {
return PATH_INCLUDES."pdf/invoice.pdf";
}
function drawCompanyLogo() {
}
function drawCompanyAddress() {
}
function drawAccountMailing() {
}
function drawAccountId() {
}
function drawAccountName() {
}
function drawAccountUsername() {
}
function drawAccountAddress() {
}
function drawInvoiceNo() {
}
function drawInvoiceCreatedDate() {
}
function drawInvoiceRange() {
}
function drawInvoiceDueDate() {
}
function drawInvoiceTotalAmt() {
}
function drawInvoicePaidAmt() {
}
function drawInvoiceDueAmt() {
}
function drawInvoiceDiscountAmt() {
}
function drawInvoiceDueNotice() {
}
function drawInvoicePaidNotice() {
}
function drawInvoiceTaxAmt() {
}
function drawInvoiceShippingAmt() {
}
/**
* Actual second plus pages of details. This is the constructor.
*/
function drawLineItems_pre($iteration) {
}
/**
* This is called for each line item on the second plus pages of details.
*/
function drawLineItems(&$db, &$line) {
}
/**
* Draws the summary on the first page
*/
function drawSummaryLineItems($items) {
}
/**
* Assigns the invoice fields to this object.
*/
function setInvoiceFields($flds) {
$this->invoice = $flds;
}
/**
* Assigns the account fields to this object.
*/
function setAccountFields($flds) {
$this->account = $flds;
}
/**
* Assigns the item summary fields to this object.
*/
function setItemsSummary($items) {
$this->itemsSummary = $items;
}
function setItemsFull($items) {
$this->itemsFull = $items;
}
function setDateRange($periodStart, $periodEnd) {
$this->dateRange = date(UNIX_DATE_FORMAT, $periodStart) . ' - ' . date(UNIX_DATE_FORMAT, $periodEnd);
}
function setCurrency($currency) {
$this->invoiceCurrency = $currency;
}
function setDecimals($decimals) {
$this->invoiceDecimals = $decimals;
}
function setLateFeeNotice() {
}
function setDueAmt($amt) {
$this->invoiceDueAmt=$amt;
}
function setNetTerms($terms) {
$this->netTerms=$terms;
}
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']);
}
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');
}
function _endpage() {
//End of page contents
$this->pages[$this->page] = ($this->compress) ? gzcompress($this->pages[$this->page]) : $this->pages[$this->page];
$this->state=1;
}
}
?>

View File

@@ -1,278 +0,0 @@
<?php
/*
AgileBill - Default PDF invoice with summary detail
(C) 2006 Agileco LLC. All rights reserved.
$Id:$
*/
require_once PATH_INCLUDES.'pdf/invoice_base.inc.php';
class pdf_invoice_overview extends pdf_invoice_base
{
var $billToCompany = true;
var $invoiceDueAmt = 0;
var $invoiceCurrency = '$';
var $invoiceDecimals = '2';
var $itemsSummary;
var $itemsSummaryMax=6;
var $itemsFull;
var $news = '';
var $v, $i, $y;
var $pageType = 1;
var $show_itemized = 1;
// draw the logo
function drawCompanyLogo() {
$x = 10;
$y = 10;
$width = 50;
if(is_file(PATH_THEMES.'default/images/invoice_logo.jpg'))
$this->Image(PATH_THEMES.'default/images/invoice_logo.jpg',$x,$y,$width);
}
// draw the company address
function drawCompanyAddress() {
// add the company address on the payment stub (1)
$this->SetFont('times','B', 10);
$this->SetXY(18,202); $this->Cell(50,10, $this->companyName);
$this->SetXY(18,206); $this->Cell(50,10, $this->companyAddress);
$this->SetXY(18,210); $this->Cell(50,10, $this->companyCity. ", ". $this->companyState . " " . $this->companyZip);
}
function drawAccountMailing() {
// add the company address on the payment stub (2)
$this->SetFont('times','B', 10);
if($this->billToCompany && !empty($this->account['company']))
$name = $this->account['company'];
else
$name = $this->account['first_name'].' '.$this->account['last_name'];
$this->SetXY(120,240); $this->Cell(10,10, html_entity_decode($name,ENT_NOQUOTES));
$this->SetXY(120,244); $this->Cell(50,10, $this->account['address1'] .' '. $this->account['address2']);
$this->SetXY(120,248); $this->Cell(50,10, $this->account['city'] . ", ". $this->account['state'] . " " . $this->account['zip']);
}
function drawAccountId() {
$this->SetFont('times','B',11);
$this->SetXY(28, 39.5);
$this->Cell(10,10, $this->account['id']); // add to top of invoice
}
function drawAccountName() {
$this->SetFont('times','B',11);
$this->SetXY(36, 44);
if($this->billToCompany && !empty($this->account['company']))
$this->Cell(10,10, html_entity_decode($this->account['company'],ENT_NOQUOTES));
else
$this->Cell(10,10, html_entity_decode($this->account['first_name'].' '.$this->account['last_name'],ENT_NOQUOTES));
}
function drawAccountUsername() {
$this->SetFont('times','B',11);
$this->SetXY(161, 44);
$this->Cell(10,10, $this->account['username']);
}
function drawAccountAddress() {
$this->SetFont('times','B',11);
}
function drawInvoiceNo() {
$this->SetFont('times','',11);
$this->SetXY(180, 222);
$this->Cell(10,10, $this->invoice["id"]); // draw at the bottom of invoice
}
function drawInvoiceRange() {
if($this->show_service_range) {
global $C_translate;
$this->SetFont('times','B',11);
$this->SetXY(8,85.5);
$this->Cell(50,10, $C_translate->translate('pdf_service_range_month','setup_invoice') . " {$this->dateRange}");
}
}
function drawInvoiceDueDate() {
$this->SetFont('times','B',11);
$this->SetXY(161, 39.5);
$this->Cell(10,10, date(UNIX_DATE_FORMAT, $this->invoice['due_date'])); // draw at top of invoice
$this->SetFont('times','',11);
$this->SetXY(151, 222);
$this->Cell(10,10, date(UNIX_DATE_FORMAT, $this->invoice['due_date']),0,0,'C'); // draw at the bottom of invoice
}
function drawInvoiceTotalAmt() {
$this->SetXY(147.5,72);
$this->Cell(10,10, $this->_currency($this->invoice['total_amt']),0,0,'C'); // draw at the top
}
function drawInvoicePaidAmt() {
$this->SetFont('times','',11);
$this->SetXY(47,72);
$this->Cell(10,10, $this->_currency($this->invoice['billed_amt']), 0,0,'C');
}
function drawInvoiceDueAmt() {
$this->SetFont('times','',11);
$this->SetXY(114,72);
$this->Cell(10,10, $this->_currency($this->invoiceDueAmt),0,0,'C'); // draw at the top
$this->SetXY(181,72);
$this->Cell(10,10, $this->_currency($this->invoiceDueAmt),0,0,'C'); // draw at the top
$this->SetXY(123, 222);
$this->Cell(10,10, $this->_currency($this->invoiceDueAmt),0,0,'C'); // draw at the bottom
}
function drawInvoiceDiscountAmt() {
$this->SetXY(80.5, 72);
$this->Cell(10,10, $this->_currency($this->invoice['discount_amt']), 0,0,'C');
}
function drawInvoiceTaxAmt() {
$this->SetFont('times','',11);
$this->SetXY(16,72);
$this->Cell(10,10, $this->_currency($this->invoice['tax_amt']),0,0,'C'); // draw at the top
}
/**
* Called before begining to loop the invoice_item table. Used to set initial values.
*/
function drawLineItems_pre($iteration) {
$this->iteration = $iteration;
if($iteration>0)
return false;
$this->i = 0;
$this->y = 0;
return true;
}
/**
* Called once per line item to add to the PDF invoice.
*/
function drawSubLineItems(&$db, $line) {
global $C_translate;
if ($this->i == 0 || $this->i%51 == 0) {
$this->AddPage();
$this->SetFont('times','B',12);
$this->SetXY(3,10); $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(3,10); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number_small','setup_invoice').$this->invoice['id'],0,0,'C');
# Draw table headers
$this->SetFont('times','B',8);
$this->SetXY(9,20);
$this->Cell(0,0,$C_translate->translate('pdf_item_description','setup_invoice'));
$this->SetX(145);
$this->Cell(0,0,$C_translate->translate('pdf_item_quantity','setup_invoice'));
$this->SetX(170);
$this->Cell(10,0,$C_translate->translate('pdf_item_cost','setup_invoice'),0,0,'R');
$this->SetX(145);
$this->Cell(0,0,$C_translate->translate('pdf_item_amount','setup_invoice'),0,0,'R');
$this->Line(9,21,200,21);
$this->y = 24;
$this->SetY($this->y);
}
$this->SetFont('times','',8);
$this->SetX(18);
$this->Cell(0,0, $line);
$this->y += 5;
$this->SetY($this->y);
$this->i++;
}
/**
* Called once per line item to add to the PDF invoice.
*/
function drawLineItems(&$db, &$line) {
global $C_translate;
if ($this->i == 0 || $this->i%51 == 0) {
$this->AddPage();
$this->SetFont('times','B',12);
$this->SetXY(3,10); $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(3,10); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number_small','setup_invoice').$this->invoice['id'],0,0,'C');
# Draw table headers
$this->SetFont('times','B',8);
$this->SetXY(9,20);
$this->Cell(0,0,$C_translate->translate('pdf_item_description','setup_invoice'));
$this->SetX(145);
$this->Cell(0,0,$C_translate->translate('pdf_item_quantity','setup_invoice'));
$this->SetX(170);
$this->Cell(10,0,$C_translate->translate('pdf_item_cost','setup_invoice'),0,0,'R');
$this->SetX(145);
$this->Cell(0,0,$C_translate->translate('pdf_item_amount','setup_invoice'),0,0,'R');
$this->Line(9,21,200,21);
$this->y = 24;
$this->SetY($this->y);
}
$this->SetFont('times','',8);
$this->SetX(9);
$this->Cell(0,0, $line['name']);
$this->SetX(170);
$this->Cell(10,0, $this->_currency($line['amount']/$line['qty']),0,0,'R');
$this->SetX(145);
$this->Cell(10,0, $line['qty'],0,0,'R');
$this->SetX(145);
$this->Cell(0,0, $this->_currency($line['amount']), 0,0,'R');
$this->y += 5;
$this->SetY($this->y);
$this->i++;
# Draw attributes if they are present
if (strlen($line['attr'])) {
$atrs = preg_split("/\r\n/", str_replace('\r\n',"\r\n",$line['attr']));
foreach ($atrs as $a) {
$parts = preg_split("/==/", $a);
switch ($parts[0]) {
default:
if(strlen($parts[0]))
$this->drawSubLineItems($db, $parts[0].": ".$parts[1]);
break;
}
}
}
}
function drawSummaryLineItems($items) {
global $C_translate;
if (!$this->show_itemized) return;
$y = 105;
$this->SetY($y);
$this->SetFont('times','',11);
$i=0;
if(is_array($items)) {
foreach($items as $line) {
$val = $line['name'];
$this->SetX(9);
$this->Cell(0,0, $val);
$this->SetX(145);
$this->Cell(0,0, $this->_currency($line['amount']), 0,0,'R');
$y += 5;
$this->SetY($y);
$i++;
if($i > $this->itemsSummaryMax) {
$this->SetFont('times','B',11);
$this->SetX(9);
$this->Cell(0,0,$C_translate->translate('pdf_summary','setup_invoice'));
break;
}
}
}
}
}
?>

View File

@@ -1,406 +0,0 @@
<?php
/*
AgileVoice - Highly detailed PDF invoice
(C) 2006 Agileco LLC. All rights reserved.
$Id:$
*/
require_once PATH_INCLUDES.'pdf/invoice_base.inc.php';
class pdf_invoice_overview extends pdf_invoice_base
{
var $billToCompany = true;
var $invoiceDueAmt = 0;
var $invoiceCurrency = '$';
var $invoiceDecimals = '5';
var $itemsSummary;
var $itemsSummaryMax=16;
var $itemsFull;
var $news = 'News you can use!\n\n';
var $v, $i, $y;
var $pageType = 2;
var $show_itemized = 1;
function getTemplate() {
if ($this->pageType == 2)
return PATH_INCLUDES."pdf/invoice2.pdf";
return PATH_INCLUDES."pdf/invoice1.pdf";
}
// draw the logo
function drawCompanyLogo() {
$x = 9;
$y = 7;
$width = 50;
if(is_file(PATH_THEMES.DEFAULT_THEME.'/images/invoice_logo.png'))
$this->Image(PATH_THEMES.DEFAULT_THEME.'/images/invoice_logo.png',$x,$y,$width);
}
// draw the company address
function drawCompanyAddress() {
global $C_translate;
// add the company address on the payment stub (1)
$this->SetFont('arial','B', 13);
$this->SetXY(18,202); $this->Cell(0,0,$C_translate->translate('pdf_payment_coupon','setup_invoice'));
$this->SetFont('arial','', 8);
$this->SetXY(18,206); $this->Cell(0,0,$C_translate->translate('pdf_return1','setup_invoice'));
$this->SetXY(18,209); $this->Cell(0,0,$C_translate->translate('pdf_return2','setup_invoice').$this->companyName);
$this->SetFont('arial','', 10);
$x = 18; $y = 216;
if ($this->pageType == 2) {
$y = 230;
}
$this->SetXY(18,$y); $this->Cell(0,0, $this->companyName); $y += 4;
$this->SetXY(18,$y); $this->Cell(0,0, $this->companyAddress); $y += 4;
$this->SetXY(18,$y); $this->Cell(0,0, $this->companyCity. ", ". $this->companyState . " " . $this->companyZip); $y += 4;
}
function drawAccountMailing() {
// add the company address on the payment stub (2)
$this->SetFont('arial','B', 10);
if($this->billToCompany && !empty($this->account['company']))
$name = $this->account['company'];
else
$name = $this->account['first_name'].' '.$this->account['last_name'];
$x = 110; $y = 248;
if ($this->pageType == 2) {
$x = 18; $y = 268;
}
$this->SetXY($x,$y); $this->Cell(0,0, html_entity_decode($name,ENT_NOQUOTES)); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0, $this->account['address1'] .' '. $this->account['address2']); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0, $this->account['city'] . ", ". $this->account['state'] . " " . $this->account['zip']); $y += 4;
}
function drawAccountId() {
global $C_translate;
$this->SetFont('arial','',11);
$this->SetXY(110, 205); $this->Cell(0,0,$C_translate->translate('pdf_account_number','setup_invoice'));
$this->SetXY(150, 205);
$this->Cell(0,0, $this->account['id']); // add to bottom of invoice
}
function drawAccountUsername() {
global $C_translate;
$this->SetFont('arial','B',11);
$this->SetXY(95, 18); $this->Cell(0,0,$C_translate->translate('pdf_account_username','setup_invoice'));
$this->SetXY(201,18); $this->Cell(0,0,$this->account['username'],0,0,'R');
$this->SetFont('arial','',11);
$this->SetXY(95,30);
$contact = $C_translate->translate('pdf_contact','setup_invoice')."\n";
$contact .= $C_translate->translate('pdf_contact_online','setup_invoice').$this->contact_us_url."\n";
$contact .= $C_translate->translate('pdf_contact_phone','setup_invoice').$this->contact_us_phone;
$this->MultiCell(0,4,$contact);
$this->SetXY(9,170);
$this->MultiCell(0, 4, str_replace('\n',"\n",$this->news));
}
function drawAccountAddress() {
$this->SetFont('times','B',11);
}
function drawInvoiceNo() {
global $C_translate;
$this->SetFont('arial','B',11);
$this->SetXY(95, 14); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number','setup_invoice'));
$this->SetXY(201, 14); $this->Cell(0,0, $this->invoice['id'],0,0,'R'); // add to bottom of invoice
$this->SetFont('arial','',11);
$this->SetXY(110, 210); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number','setup_invoice'));
$this->SetXY(150, 210); $this->Cell(0,0, $this->invoice['id']); // add to bottom of invoice
}
function drawInvoiceDueDate() {
global $C_translate;
$this->SetFont('arial','B',11);
$this->SetXY(95,10); $this->Cell(0,0,$C_translate->translate('pdf_billing_date','setup_invoice'));
$this->SetXY(201,10); $this->Cell(0,0, date(UNIX_DATE_FORMAT, $this->invoice['due_date']),0,0,'R'); // draw at top of invoice
$this->SetFont('arial','',11);
$this->SetXY(110, 200); $this->Cell(0,0,$C_translate->translate('pdf_bill_date','setup_invoice'));
$this->SetXY(150, 200);
$this->Cell(0,0, date(UNIX_DATE_FORMAT, $this->invoice['due_date'])); // draw at the bottom of invoice
}
function drawInvoiceTotalAmt() {
global $C_translate;
$this->SetFont('arial','B',11);
$this->SetXY(95, 22); $this->Cell(0,0,$C_translate->translate('pdf_current_charges','setup_invoice'));
$this->SetXY(201, 22); $this->Cell(0,0, $this->_currency($this->invoice['total_amt']),0,0,'R'); // draw at the top
$this->SetFont('arial','',9);
$this->SetXY(110, 222); $this->Cell(0,0,$C_translate->translate('pdf_current_charges','setup_invoice'));
$this->SetXY(201, 222); $this->Cell(0,0, $this->_currency($this->invoice['total_amt']),0,0,'R'); // draw at the top
}
function drawInvoiceDueAmt() {
global $C_translate;
$this->SetFont('times','',11);
$this->SetFont('arial','',9);
$this->SetXY(110, 226); $this->Cell(0,0,$C_translate->translate('pdf_amount_due_by','setup_invoice').date(UNIX_DATE_FORMAT, $this->invoice['due_date']));
$this->SetXY(201, 226); $this->Cell(0,0, $this->_currency($this->invoiceDueAmt),0,0,'R');
$this->SetXY(110, 230); $this->Cell(0,0,$C_translate->translate('pdf_make_check','setup_invoice'));
$this->SetXY(110, 234); $this->Cell(0,0,$this->companyName);
}
/**
* Called before begining to loop the invoice_item table. Used to set initial values.
*/
function drawLineItems_pre($iteration) {
$this->iteration = $iteration;
if($iteration>1)
return false;
# Include the voip class
include_once(PATH_MODULES.'voip/voip.inc.php');
$this->v = new voip;
$this->i = 0;
$this->y = 0;
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.
*/
function drawLineItems(&$db, &$line) {
switch($this->iteration) {
case 0:
$this->drawLineItems_0($db, $line);
break;
case 1:
$this->drawLineItems_1($db, $line);
break;
default:
echo 'Unknown PDF iteration encountered. Halting.';
exit;
}
}
/**
* Draws the non-VoIP related items for iteration 0.
*/
function drawLineItems_0(&$db, &$line) {
global $C_translate;
if ($line['price_type'] == 0 && $line['item_type']==5)
return;
if ($this->i == 0 || $this->i%51 == 0) {
$this->AddPage();
$this->SetFont('arial','B',12);
$this->SetXY(3,10); $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(3,10); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number_small','setup_invoice').$this->invoice['id'],0,0,'C');
# Draw table headers
$this->SetFont('arial','B',8);
$this->SetXY(9,20);
$this->Cell(0,0,$C_translate->translate('pdf_item_description','setup_invoice'));
$this->SetX(145);
$this->Cell(0,0,$C_translate->translate('pdf_item_quantity','setup_invoice'));
$this->SetX(170);
$this->Cell(10,0,$C_translate->translate('pdf_item_cost','setup_invoice'),0,0,'R');
$this->SetX(145);
$this->Cell(0,0,$C_translate->translate('pdf_item_amount','setup_invoice'),0,0,'R');
$this->Line(9,21,200,21);
$this->y = 24;
$this->SetY($this->y);
}
$this->SetFont('arial','',8);
$this->SetX(9);
$this->Cell(0,0, $line['name']);
$this->SetX(170);
$this->Cell(10,0, $this->_currency($line['price_base']),0,0,'R');
$this->SetX(145);
$this->Cell(10,0, $line['qty'],0,0,'R');
$this->SetX(145);
$this->Cell(0,0, $this->_currency($line['total_amt']), 0,0,'R');
$this->y += 5;
$this->SetY($this->y);
$this->i++;
}
/**
* Draws the VoIP Calling Detail for Iteration 1.
*/
function drawLineItems_1(&$db, &$line) {
global $C_translate;
if($this->show_itemized != 1) return;
if($line['price_type'] != 0 || $line['item_type'] != 5)
return;
if ($this->i == 0 || $this->i%51 == 0) {
$this->AddPage();
$this->SetFont('arial','B',12);
$this->SetXY(3,10); $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(3,10); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number_small','setup_invoice').$this->invoice['id'],0,0,'C');
# Draw table headers
$this->SetFont('arial','B',8);
$this->SetXY(9,20);
$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(145);
$this->Cell(0,0,$C_translate->translate('pdf_item_amount','setup_invoice'),0,0,'R');
$this->Line(9,21,200,21);
$this->y = 24;
$this->SetY($this->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(145);
$this->Cell(0,0, $this->_currency($line['amount']), 0,0,'R');
}
$this->y += 5;
$this->SetY($this->y);
$this->i++;
}
function drawSummaryLineItems($items) {
global $C_translate;
#if (!$this->show_itemized) return;
# Include the voip class
include_once(PATH_MODULES.'voip/voip.inc.php');
$v = new voip;
$db = &DB();
$this->SetFont('arial','B',11);
$y = 70;
$this->SetY($y);
$this->SetX(9); $this->Cell(0,0,$C_translate->translate('pdf_cur_charge_summary','setup_invoice').$this->dateRange);
$y += 5;
$this->SetY($y);
$this->SetFont('arial','',9);
$i=0;
if(is_array($items)) {
foreach($items as $line) {
$val = $line['name'];
$this->SetX(9);
if (@$line['item_type'] == 5) {
$val = $line['quantity'].$C_translate->translate('pdf_combine_minutes','setup_invoice');
}
$q = $line['quantity'];
if(empty($q)) $q = 1;
$this->Cell(0,0, $q);
$this->SetX(18);
$this->Cell(0,0, $val);
$this->SetX(145);
$this->Cell(0,0, $this->_currency($line['amount']), 0,0,'R');
$y += 5;
$this->SetY($y);
$i++;
if($i > $this->itemsSummaryMax) {
$this->SetFont('arial','B',11);
$this->SetX(9);
$this->Cell(0,0,$C_translate->translate('pdf_summary','setup_invoice'));
break;
}
}
}
}
}
?>

View File

@@ -1,321 +0,0 @@
<?php
/*
AgileVoice - Detailed PDF invoice with CDR detail
(C) 2006 Agileco LLC. All rights reserved.
$Id:$
*/
require_once PATH_INCLUDES.'pdf/invoice_base.inc.php';
class pdf_invoice_overview extends pdf_invoice_base
{
var $billToCompany = true;
var $invoiceDueAmt = 0;
var $invoiceCurrency = '$';
var $invoiceDecimals = '5';
var $itemsSummary;
var $itemsSummaryMax=16;
var $itemsFull;
var $news = '';
var $v, $i, $y;
var $pageType = 2;
var $show_itemized = 1;
function getTemplate() {
if ($this->pageType == 2)
return PATH_INCLUDES."pdf/invoice2.pdf";
return PATH_INCLUDES."pdf/invoice1.pdf";
}
// draw the logo
function drawCompanyLogo() {
$x = 9;
$y = 7;
$width = 50;
if(is_file(PATH_THEMES.DEFAULT_THEME.'/images/invoice_logo.png'))
$this->Image(PATH_THEMES.DEFAULT_THEME.'/images/invoice_logo.png',$x,$y,$width);
}
// draw the company address
function drawCompanyAddress() {
global $C_translate;
// add the company address on the payment stub (1)
$this->SetFont('arial','B', 13);
$this->SetXY(18,202); $this->Cell(0,0,$C_translate->translate('pdf_payment_coupon','setup_invoice'));
$this->SetFont('arial','', 8);
$this->SetXY(18,206); $this->Cell(0,0,$C_translate->translate('pdf_return1','setup_invoice'));
$this->SetXY(18,209); $this->Cell(0,0,$C_translate->translate('pdf_return2','setup_invoice').$this->companyName);
$this->SetFont('arial','', 10);
$x = 18; $y = 216;
if ($this->pageType == 2) {
$y = 230;
}
$this->SetXY(18,$y); $this->Cell(0,0, $this->companyName); $y += 4;
$this->SetXY(18,$y); $this->Cell(0,0, $this->companyAddress); $y += 4;
$this->SetXY(18,$y); $this->Cell(0,0, $this->companyCity. ", ". $this->companyState . " " . $this->companyZip); $y += 4;
}
function drawAccountMailing() {
// add the company address on the payment stub (2)
$this->SetFont('arial','B', 10);
if($this->billToCompany && !empty($this->account['company']))
$name = $this->account['company'];
else
$name = $this->account['first_name'].' '.$this->account['last_name'];
$x = 110; $y = 248;
if ($this->pageType == 2) {
$x = 18; $y = 268;
}
$this->SetXY($x,$y); $this->Cell(0,0, html_entity_decode($name,ENT_NOQUOTES)); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0, $this->account['address1'] .' '. $this->account['address2']); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0, $this->account['city'] . ", ". $this->account['state'] . " " . $this->account['zip']); $y += 4;
}
function drawAccountId() {
global $C_translate;
$this->SetFont('arial','',11);
$this->SetXY(110, 205); $this->Cell(0,0,$C_translate->translate('pdf_account_number','setup_invoice'));
$this->SetXY(150, 205);
$this->Cell(0,0, $this->account['id']); // add to bottom of invoice
}
function drawAccountUsername() {
global $C_translate;
$this->SetFont('arial','B',11);
$this->SetXY(95, 18); $this->Cell(0,0,$C_translate->translate('pdf_account_username','setup_invoice'));
$this->SetXY(201,18); $this->Cell(0,0,$this->account['username'],0,0,'R');
$this->SetFont('arial','',11);
$this->SetXY(95,30);
$contact = $C_translate->translate('pdf_contact','setup_invoice')."\n";
$contact .= $C_translate->translate('pdf_contact_online','setup_invoice').$this->contact_us_url."\n";
$contact .= $C_translate->translate('pdf_contact_phone','setup_invoice').$this->contact_us_phone;
$this->MultiCell(0,4,$contact);
$this->SetXY(9,170);
$this->MultiCell(0, 4, str_replace('\n',"\n",$this->news));
}
function drawAccountAddress() {
$this->SetFont('times','B',11);
}
function drawInvoiceNo() {
global $C_translate;
$this->SetFont('arial','B',11);
$this->SetXY(95, 14); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number','setup_invoice'));
$this->SetXY(201, 14); $this->Cell(0,0, $this->invoice['id'],0,0,'R'); // add to bottom of invoice
$this->SetFont('arial','',11);
$this->SetXY(110, 210); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number','setup_invoice'));
$this->SetXY(150, 210); $this->Cell(0,0, $this->invoice['id']); // add to bottom of invoice
}
function drawInvoiceDueDate() {
global $C_translate;
$this->SetFont('arial','B',11);
$this->SetXY(95,10); $this->Cell(0,0,$C_translate->translate('pdf_billing_date','setup_invoice'));
$this->SetXY(201,10); $this->Cell(0,0, date(UNIX_DATE_FORMAT, $this->invoice['due_date']),0,0,'R'); // draw at top of invoice
$this->SetFont('arial','',11);
$this->SetXY(110, 200); $this->Cell(0,0,$C_translate->translate('pdf_bill_date','setup_invoice'));
$this->SetXY(150, 200);
$this->Cell(0,0, date(UNIX_DATE_FORMAT, $this->invoice['due_date'])); // draw at the bottom of invoice
}
function drawInvoiceTotalAmt() {
global $C_translate;
$this->SetFont('arial','B',11);
$this->SetXY(95, 22); $this->Cell(0,0,$C_translate->translate('pdf_current_charges','setup_invoice'));
$this->SetXY(201, 22); $this->Cell(0,0, $this->_currency($this->invoice['total_amt']),0,0,'R'); // draw at the top
$this->SetFont('arial','',9);
$this->SetXY(110, 222); $this->Cell(0,0,$C_translate->translate('pdf_current_charges','setup_invoice'));
$this->SetXY(201, 222); $this->Cell(0,0, $this->_currency($this->invoice['total_amt']),0,0,'R'); // draw at the top
}
function drawInvoiceDueAmt() {
global $C_translate;
$this->SetFont('times','',11);
$this->SetFont('arial','',9);
$this->SetXY(110, 226); $this->Cell(0,0,$C_translate->translate('pdf_amount_due_by','setup_invoice').date(UNIX_DATE_FORMAT, $this->invoice['due_date']));
$this->SetXY(201, 226); $this->Cell(0,0, $this->_currency($this->invoiceDueAmt),0,0,'R');
$this->SetXY(110, 230); $this->Cell(0,0,$C_translate->translate('pdf_make_check','setup_invoice'));
$this->SetXY(110, 234); $this->Cell(0,0,$this->companyName);
}
/**
* Called before begining to loop the invoice_item table. Used to set initial values.
*/
function drawLineItems_pre($iteration) {
$this->iteration = $iteration;
if($iteration>0)
return false;
# Include the voip class
include_once(PATH_MODULES.'voip/voip.inc.php');
$this->v = new voip;
$this->i = 0;
$this->y = 0;
return true;
}
/**
* Called once per line item to add to the PDF invoice.
*/
function drawLineItems(&$db, &$line) {
global $C_translate;
if ($this->i == 0 || $this->i%51 == 0) {
$this->AddPage();
$this->SetFont('arial','B',12);
$this->SetXY(3,10); $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(3,10); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number_small','setup_invoice').$this->invoice['id'],0,0,'C');
# Draw table headers
$this->SetFont('arial','B',8);
$this->SetXY(9,20);
$this->Cell(0,0,$C_translate->translate('pdf_item_from','setup_invoice'));
$this->SetX(75);
$this->Cell(0,0,$C_translate->translate('pdf_item_to','setup_invoice'));
$this->SetX(160);
$this->Cell(10,0,$C_translate->translate('pdf_item_min','setup_invoice'),0,0,'R');
$this->SetX(145);
$this->Cell(0,0,$C_translate->translate('pdf_item_amount','setup_invoice'),0,0,'R');
$this->Line(9,21,200,21);
$this->y = 24;
$this->SetY($this->y);
}
if ($line['price_type'] != 0) {
$this->SetFont('arial','I',8);
} else {
$this->SetFont('arial','',8);
}
$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(75);
$this->Cell(0,0,$parts[1]);
$cc = ""; $npa = ""; $nxx = ""; $e164 = "";
if ($this->v->e164($parts[1], $e164, $cc, $npa, $nxx)) {
$this->SetX(115);
$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(39);
$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 = preg_split("/\r\n/", $rstmp->fields['prod_attr']);
foreach ($atrs2 as $a2) {
$parts2 = preg_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;
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(145);
$this->Cell(0,0, $this->_currency($line['total_amt']), 0,0,'R');
$this->y += 5;
$this->SetY($this->y);
$this->i++;
}
function drawSummaryLineItems($items) {
global $C_translate;
if (!$this->show_itemized) return;
# Include the voip class
include_once(PATH_MODULES.'voip/voip.inc.php');
$v = new voip;
$db = &DB();
$this->SetFont('arial','B',11);
$y = 70;
$this->SetY($y);
$this->SetX(9); $this->Cell(0,0,$C_translate->translate('pdf_cur_charge_summary','setup_invoice').$this->dateRange);
$y += 5;
$this->SetY($y);
$this->SetFont('arial','',9);
$i=0;
if(is_array($items)) {
foreach($items as $line) {
$val = $line['name'];
$this->SetX(9);
if (@$line['item_type'] == 5) {
$val = $line['quantity'].$C_translate->translate('pdf_combine_minutes','setup_invoice');
}
$q = $line['quantity'];
if(empty($q)) $q = 1;
$this->Cell(0,0, $q);
$this->SetX(18);
$this->Cell(0,0, $val);
$this->SetX(145);
$this->Cell(0,0, $this->_currency($line['amount']), 0,0,'R');
$y += 5;
$this->SetY($y);
$i++;
if($i > $this->itemsSummaryMax) {
$this->SetFont('arial','B',11);
$this->SetX(9);
$this->Cell(0,0,$C_translate->translate('pdf_summary','setup_invoice'));
break;
}
}
}
}
}
?>