Improved service display
This commit is contained in:
@@ -14,8 +14,12 @@ class Invoice {
|
||||
// This invoice Object
|
||||
private $io;
|
||||
|
||||
public static function instance() {
|
||||
return new Invoice;
|
||||
public function __construct($io) {
|
||||
$this->io = $io;
|
||||
}
|
||||
|
||||
public static function instance($io) {
|
||||
return new Invoice($io);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,14 +93,10 @@ SELECT i.id AS iid,i.due_date AS due FROM ab_invoice i,ab_invoice_item ii WHERE
|
||||
/**
|
||||
* Generate a PDF invoice
|
||||
*/
|
||||
public function pdf($io) {
|
||||
$invoice_class = sprintf('invoice_pdf_%s',Kohana::config('invoice.driver'));
|
||||
public function pdf() {
|
||||
$invoice_class = sprintf('invoice_tcpdf_%s',Kohana::config('invoice.driver'));
|
||||
|
||||
if (! class_exists($invoice_class))
|
||||
throw new Kohana_Exception('Invoice class :class doesnt exist',array(':class'=>$invoice_class));
|
||||
|
||||
$this->io = $io;
|
||||
$pdf = new $invoice_class($io);
|
||||
$pdf = new $invoice_class($this->io);
|
||||
|
||||
if ($pdf->getTemplate()) {
|
||||
$pagecount = $pdf->setSourceFile($pdf->getTemplate());
|
||||
@@ -125,105 +125,21 @@ SELECT i.id AS iid,i.due_date AS due FROM ab_invoice i,ab_invoice_item ii WHERE
|
||||
$pdf->drawRemittenceStub();
|
||||
$pdf->drawPaymentMethods();
|
||||
|
||||
if ($this->io->billing_status !=1 && $this->io->suspend_billing != 1 && $this->io->due_date <= time())
|
||||
$pdf->drawInvoiceDueNotice();
|
||||
elseif($this->io->billing_status == 1)
|
||||
$pdf->drawInvoicePaidNotice();
|
||||
if ($this->io->billing_status !=1 && $this->io->suspend_billing != 1 && $this->io->due_date <= time())
|
||||
$pdf->drawInvoiceDueNotice();
|
||||
elseif($this->io->billing_status == 1)
|
||||
$pdf->drawInvoicePaidNotice();
|
||||
|
||||
if ($this->io->account->invoices_due_total())
|
||||
$pdf->drawSummaryInvoicesDue();
|
||||
if ($this->io->account->invoices_due_total())
|
||||
$pdf->drawSummaryInvoicesDue();
|
||||
|
||||
$pdf->drawSummaryLineItems();
|
||||
return;
|
||||
#unset($pdf->itemsSummary);
|
||||
$pdf->drawSummaryLineItems();
|
||||
|
||||
# BEGIN loop for enumerating information in multiple ways on the invoice
|
||||
$iteration = 0;
|
||||
while ($pdf->drawLineItems_pre($iteration)) {
|
||||
foreach ($this->sInvoiceItems() as $index => $items) {
|
||||
# Get the date range if set
|
||||
if (! empty($items['date_start']) && ! empty($items['date_stop'])) {
|
||||
global $C_translate;
|
||||
$C_translate->value('invoice','start',date(UNIX_DATE_FORMAT,$items['date_start']));
|
||||
$C_translate->value('invoice','stop',date(UNIX_DATE_FORMAT,$items['date_stop']));
|
||||
}
|
||||
// Next Page
|
||||
$pdf->drawDetailLineItems();
|
||||
|
||||
$line = array(
|
||||
'name'=>$this->sLineItemDesc($index),
|
||||
'domain'=>$items['domain_name'],
|
||||
'amount'=>$items['price_base'],
|
||||
'sku'=>$items['sku'],
|
||||
'qty'=>$items['quantity'],
|
||||
'cost'=>$items['price_base'],
|
||||
'attr'=>$items['product_attr'],
|
||||
'price_type'=>$items['price_type'],
|
||||
'price_base'=>$items['price_base'],
|
||||
'item_type'=>$items['item_type'],
|
||||
'total_amt'=>$items['total_amt']
|
||||
);
|
||||
|
||||
if ($items['date_start'] && $items['date_stop'])
|
||||
if ($items['date_start'] == $items['date_stop'])
|
||||
$line['daterange'] = sprintf('%s',date(UNIX_DATE_FORMAT,$items['date_start']));
|
||||
else
|
||||
$line['daterange'] = sprintf('%s - %s',date(UNIX_DATE_FORMAT,$items['date_start']),date(UNIX_DATE_FORMAT,$items['date_stop']));
|
||||
|
||||
$pdf->drawLineItems($db,$line,$this->getRecordAttr('id'));
|
||||
|
||||
if ($items['price_setup']) {
|
||||
$line = array(
|
||||
'name'=>sprintf('%s - %s',$this->sLineItemDesc($index),_('Setup Charge')),
|
||||
'amount'=>$items['price_setup'],
|
||||
'qty'=>'1',
|
||||
'sku'=>$items['sku'],
|
||||
'cost'=>$items['price_setup'],
|
||||
'price_base'=>$items['price_setup'],
|
||||
'price_type'=>999
|
||||
);
|
||||
|
||||
$pdf->drawLineItems($db,$line,$this->getRecordAttr('id'));
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->print['invoice']['discount_amt']) {
|
||||
$line = array(
|
||||
'name'=>_('Discount'),
|
||||
'amount'=>-($this->print['invoice']['discount_amt']),
|
||||
'qty'=>'1',
|
||||
'cost'=>-($this->print['invoice']['discount_amt']),
|
||||
'price_base'=>-($this->print['invoice']['discount_amt']),
|
||||
'price_type'=>999);
|
||||
|
||||
$pdf->drawLineItems($db,$line,$this->getRecordAttr('id'));
|
||||
}
|
||||
|
||||
if ($this->print['invoice']['tax_amt']) {
|
||||
$rs = $db->Execute(sqlSelect($db,array('invoice_item_tax','tax'),'A.amount,B.description',sprintf('A.tax_id=B.id AND A.invoice_id=%s',$this->getRecordAttr('id'))));
|
||||
if ($rs && $rs->RecordCount()) {
|
||||
$taxes = array();
|
||||
|
||||
while (! $rs->EOF) {
|
||||
if (! isset($taxes[$rs->fields['description']]))
|
||||
$taxes[$rs->fields['description']] = $rs->fields['amount'];
|
||||
else
|
||||
$taxes[$rs->fields['description']] += $rs->fields['amount'];
|
||||
|
||||
$rs->MoveNext();
|
||||
}
|
||||
|
||||
foreach ($taxes as $txds => $txamt) {
|
||||
$line = array('name'=>$txds,'amount'=>$txamt,'total_amt'=>$txamt,'price_type'=>999);
|
||||
$pdf->drawLineItems($db,$line,$this->getRecordAttr('id'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Increment the iteration
|
||||
++$iteration;
|
||||
}
|
||||
|
||||
# Custom functions:
|
||||
$pdf->drawCustom();
|
||||
// Draw any Custom functions:
|
||||
$pdf->drawCustom();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user