Improved service display

This commit is contained in:
Deon George 2011-07-14 19:09:03 +10:00
parent 46c3b9a075
commit 27cdab1fe4
37 changed files with 1319 additions and 1042 deletions

View File

@ -195,7 +195,8 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
parent::after(); parent::after();
// Generate and check the ETag for this file // Generate and check the ETag for this file
$this->response->check_cache(NULL,$this->request); if (Kohana::$environment === Kohana::PRODUCTION)
$this->response->check_cache(NULL,$this->request);
} }
/** /**

View File

@ -16,10 +16,10 @@
class Model_Module extends ORMOSB { class Model_Module extends ORMOSB {
// Relationships // Relationships
protected $_has_many = array( protected $_has_many = array(
'module_method'=>array(), 'module_method'=>array('far_key'=>'id'),
); );
protected $_has_one = array( protected $_has_one = array(
'record_id'=>array() 'record_id'=>array('far_key'=>'id'),
); );
protected $_sorting = array( protected $_sorting = array(

View File

@ -31,16 +31,6 @@ abstract class ORMOSB extends ORM {
); );
} }
/**
* Our child models should provide an invoice display, this is shown
* on printed invoices.
*
* @todo This is no longer used I think?
*/
public function invoice_display() {
throw new Kohana_Exception(':module has not configured an :method, but has made the call',array(':module'=>get_class($this),'method'=>__METHOD__));
}
/** /**
* This function will enhance the [Validate::filter], since it always passes * This function will enhance the [Validate::filter], since it always passes
* the value as the first argument and sometimes functions need that to not * the value as the first argument and sometimes functions need that to not
@ -101,5 +91,20 @@ abstract class ORMOSB extends ORM {
return TRUE; return TRUE;
} }
/**
* Generate a view path to help View::factory() calls
*
* The purpose of this method is to ensure that we have a consistant
* layout for our view files, including those that are needed by
* plugins
*
* @param string Plugin Name (optional)
*/
public function viewpath($plugin='') {
$request = Request::current();
return $plugin ? sprintf('%s/%s/%s/%s',$request->controller(),$request->directory(),$plugin,$request->action()) : sprintf('%s/%s/%s',$request->controller(),$request->directory(),$request->action());
}
} }
?> ?>

View File

@ -36,7 +36,7 @@ class StaticList_RecurSchedule extends StaticList {
* *
* @uses product * @uses product
*/ */
public static function form($name,$product='',$addblank=FALSE) { public static function form($name,$product='',$default='',$addblank=FALSE) {
if (empty($product)) if (empty($product))
throw new Kohana_Exception('Product is a required field for :method',array(':method'=>__METHOD__)); throw new Kohana_Exception('Product is a required field for :method',array(':method'=>__METHOD__));
@ -50,7 +50,7 @@ class StaticList_RecurSchedule extends StaticList {
$x[$term] .= sprintf(' + %s %s',Currency::display($price['price_setup']),_('Setup')); $x[$term] .= sprintf(' + %s %s',Currency::display($price['price_setup']),_('Setup'));
} }
return Form::select($name,$x,$product->price_recurr_default); return Form::select($name,$x,$default);
} }
} }
?> ?>

View File

@ -0,0 +1,29 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This is class renders Recurring Schedule Types on responses and forms.
*
* @package OSB
* @subpackage Utilities
* @category Helpers
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class StaticList_RecurType extends StaticList {
protected function table() {
return array(
0=>_('Bill on Aniversary Date of Subscription'),
1=>_('Bill on Fixed Schedule'),
);
}
public static function factory() {
return new StaticList_RecurType;
}
public static function display($value) {
return static::_display($value);
}
}
?>

View File

@ -11,6 +11,7 @@
*/ */
return array( return array(
'cache_type' => 'file', 'cache_type' => 'file',
'currency_format' => '2',
'date_format' => 'd-M-Y', 'date_format' => 'd-M-Y',
'email_admin_only'=> array( 'email_admin_only'=> array(
'adsl_traffic_notice'=>array('deon@c5t61p.leenooks.vpn'=>'Deon George'), 'adsl_traffic_notice'=>array('deon@c5t61p.leenooks.vpn'=>'Deon George'),

View File

@ -10,6 +10,6 @@
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
return array( return array(
'driver' => 'TCPDF', 'driver' => 'default',
); );
?> ?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -75,23 +75,20 @@ class Model_Account extends Model_Auth_UserDefault {
* Get a list of all invoices for this account * Get a list of all invoices for this account
*/ */
public function invoices() { public function invoices() {
$return = array(); return $this->invoice->distinct('id')->find_all();
foreach ($this->invoice->distinct('id')->find_all() as $invoice)
$return[$invoice->id] = $invoice;
return $return;
} }
/** /**
* Get a list of due invoices for this account * Get a list of due invoices for this account
*
* @param int Date (in secs) to only retrieve invoices prior to this date
*/ */
public function invoices_due() { public function invoices_due($date=NULL) {
$return = array(); $return = array();
foreach ($this->invoices() as $invoice) foreach ($this->invoices() as $io)
if ($invoice->due()) if ((is_null($date) OR $io->date_orig < $date) AND $io->due())
$return[$invoice->id] = $invoice; $return[$io->id] = $io;
return $return; return $return;
} }
@ -99,16 +96,13 @@ class Model_Account extends Model_Auth_UserDefault {
/** /**
* Calculate the total of invoices due for this account * Calculate the total of invoices due for this account
*/ */
public function invoices_due_total($format=FALSE) { public function invoices_due_total($date=NULL,$format=FALSE) {
$result = 0; $result = 0;
foreach ($this->invoices_due() as $invoice) foreach ($this->invoices_due($date) as $io)
$result += $invoice->due(); $result += $io->due();
if ($format) return $format ? Currency::display($result) : $result;
return Currency::display($result);
else
return $result;
} }
} }
?> ?>

View File

@ -28,22 +28,6 @@ class ADSL {
return new ADSL; return new ADSL;
} }
/**
* Return the additional information used by product_view
*/
public function product_view($data) {
// @todo - this test shouldnt be required
if (preg_match('/^a:/',$data))
throw new Kohana_Exception('Data shouldnt be a serialized array');
$ao = ORM::factory('adsl_plan',$data);
$output = View::factory('adsl/product_view')
->set('record',$ao);
return $output;
}
public function contract_view($data,$price_base,$price_setup) { public function contract_view($data,$price_base,$price_setup) {
// @todo - this test shouldnt be required // @todo - this test shouldnt be required
if (preg_match('/^a:/',$data)) if (preg_match('/^a:/',$data))

View File

@ -37,23 +37,5 @@ class Model_ADSL_Plan extends ORMOSB {
'Currency::display'=>array(), 'Currency::display'=>array(),
), ),
); );
/**
* Show the ADSL allowance as a peak/offpeak metric
*/
public function allowance($string=TRUE) {
$output = ADSL::allowance(array(
'base_down_peak'=>$this->base_down_peak,
'base_down_offpeak'=>$this->base_down_offpeak,
'base_up_peak'=>$this->base_up_peak,
'base_up_offpeak'=>$this->base_up_offpeak,
'extra_down_peak'=>$this->extra_down_peak,
'extra_down_offpeak'=>$this->extra_down_offpeak,
'extra_up_peak'=>$this->extra_up_peak,
'extra_up_offpeak'=>$this->extra_up_offpeak,
));
return $string ? implode('/',$output) : $output;
}
} }
?> ?>

View File

@ -1,26 +0,0 @@
<!-- //@todo To translate -->
<table class="box-full">
<tr>
<td style="width: 60%;">Speed</td>
<td class="head" colspan="2"><?php echo $record->display('speed'); ?></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>Peak</td>
<td>Off Peak</td>
</tr>
<tr>
<td>Included Download Traffic</td>
<!-- // @todo Since price is stored in the DB in GB, so should the traffic. -->
<td class="head"><?php echo $record->base_down_peak/1000; ?> GB</td>
<td class="head"><?php echo $record->base_down_offpeak/1000; ?> GB</td>
</tr>
<tr>
<td>Extra Download Traffic</td>
<td class="head"><?php echo $record->display('extra_down_peak'); ?>/GB</td>
<td class="head"><?php echo $record->display('extra_down_offpeak'); ?>/GB</td>
</tr>
</table>

View File

@ -11,14 +11,10 @@
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Model_Charge extends ORMOSB { class Model_Charge extends ORMOSB {
protected $_formats = array( protected $_display_filters = array(
'amount'=>array('Currency::display'=>array()), 'amount'=>array(
'Currency::display',array(':value')
),
); );
// Show our description on the invoice.
public function invoice_display() {
// @todo The rounding should be a global config
return sprintf('%s: %2s x %s (%s)',Config::date($this->date_orig),$this->quantity,$this->description,$this->display('amount'));
}
} }
?> ?>

View File

@ -56,7 +56,9 @@ class Controller_User_Invoice extends Controller_TemplateDefault {
public function action_download($id) { public function action_download($id) {
$io = ORM::factory('invoice',$id); $io = ORM::factory('invoice',$id);
return Invoice::instance()->pdf($io)->Output(sprintf('%s.pdf',$io->refnum()),'D'); $this->response->body(Invoice::instance($io)->pdf()->Output(sprintf('%s.pdf',$io->refnum()),'D'));
$this->response->headers(array('Content-Type' => 'application/pdf'));
$this->auto_render = FALSE;
} }
} }
?> ?>

View File

@ -14,8 +14,12 @@ class Invoice {
// This invoice Object // This invoice Object
private $io; private $io;
public static function instance() { public function __construct($io) {
return new Invoice; $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 * Generate a PDF invoice
*/ */
public function pdf($io) { public function pdf() {
$invoice_class = sprintf('invoice_pdf_%s',Kohana::config('invoice.driver')); $invoice_class = sprintf('invoice_tcpdf_%s',Kohana::config('invoice.driver'));
if (! class_exists($invoice_class)) $pdf = new $invoice_class($this->io);
throw new Kohana_Exception('Invoice class :class doesnt exist',array(':class'=>$invoice_class));
$this->io = $io;
$pdf = new $invoice_class($io);
if ($pdf->getTemplate()) { if ($pdf->getTemplate()) {
$pagecount = $pdf->setSourceFile($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->drawRemittenceStub();
$pdf->drawPaymentMethods(); $pdf->drawPaymentMethods();
if ($this->io->billing_status !=1 && $this->io->suspend_billing != 1 && $this->io->due_date <= time()) if ($this->io->billing_status !=1 && $this->io->suspend_billing != 1 && $this->io->due_date <= time())
$pdf->drawInvoiceDueNotice(); $pdf->drawInvoiceDueNotice();
elseif($this->io->billing_status == 1) elseif($this->io->billing_status == 1)
$pdf->drawInvoicePaidNotice(); $pdf->drawInvoicePaidNotice();
if ($this->io->account->invoices_due_total()) if ($this->io->account->invoices_due_total())
$pdf->drawSummaryInvoicesDue(); $pdf->drawSummaryInvoicesDue();
$pdf->drawSummaryLineItems(); $pdf->drawSummaryLineItems();
return;
#unset($pdf->itemsSummary);
# BEGIN loop for enumerating information in multiple ways on the invoice // Next Page
$iteration = 0; $pdf->drawDetailLineItems();
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']));
}
$line = array( // Draw any Custom functions:
'name'=>$this->sLineItemDesc($index), $pdf->drawCustom();
'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();
} }
} }
?> ?>

View File

@ -1,539 +0,0 @@
<?php
class Invoice_PDF_TCPDF extends Invoice_PDF {
// Current line being printed
public $sum_y = 0;
/**
* Draw the logo
*/
public function drawCompanyLogo() {
$x = 9; $y = 7;
$size = 25;
$logo = Config::logo_file();
if (is_file($logo))
$this->Image($logo,$x,$y,$size);
}
/**
* Draw the Company Address
*/
public function drawCompanyAddress() {
# 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,Config::sitename()); $y += 4;
$this->SetFont('helvetica','',10);
$this->SetXY($x,$y); $this->Cell(0,0,Company::taxid()); $y += 6;
$this->SetXY($x,$y); $this->Cell(0,0,Company::street()); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%s, %s %s',Company::city(),Company::state(),Company::pcode())); $y += 4;
$y += 2;
$this->SetXY($x,$y); $this->Cell(0,0,'Phone:'); $this->SetXY($x+16,$y); $this->Cell(0,0,Company::phone()); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0,'Fax:'); $this->SetXY($x+16,$y); $this->Cell(0,0,Company::fax()); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0,'Web:'); $this->SetXY($x+16,$y); $this->addHtmlLink(URL::base(TRUE,TRUE),URL::base(TRUE,TRUE)); $y += 4;
}
public function drawRemittenceStub() {
# 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').' '.Config::sitename());
# 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,$this->io->display('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,$this->io->account->accnum(),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,$this->io->invnum(),0,0,'R');
# Company Address
$y = 216;
$this->SetFont('helvetica','',10);
$this->SetXY(18,$y); $this->Cell(0,0,Config::sitename()); $y += 4;
$this->SetXY(18,$y); $this->Cell(0,0,Company::street()); $y += 4;
$this->SetXY(18,$y); $this->Cell(0,0,sprintf('%s, %s %s',Company::city(),Company::state(),Company::pcode())); $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->io->other_due(TRUE),0,0,'R');
$y = 219;
$this->SetFont('helvetica','',9);
$this->SetXY($x,$y); $this->Cell(0,0,_('Amount Due').' '.$this->io->display('due_date'));
$this->SetXY($x,$y); $this->Cell(0,0,$this->io->due(TRUE),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,Currency::display($this->io->due() ? $this->io->account->invoices_due_total() : 0),0,0,'R');
# Draw the Customers Address
$x = 25; $y = 248;
$this->SetFont('helvetica','B',12);
if ($this->billToCompany && ! empty($this->io->account->company))
$name = $this->io->account->company;
else
$name = $this->io->account->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 ',$this->io->account->address1,$this->io->account->address2)); $y += 5;
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%s, %s %s',$this->io->account->city,$this->io->account->state,$this->io->account->zip)); $y += 5;
}
public function drawInvoiceHeader() {
$x = 125; $y = 10;
# Draw a box.
$this->SetFillColor(245);
$this->SetXY($x-1,$y-1); $this->Cell(0,35+($this->io->billed_amt ? 5 : 0)+($this->io->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,$this->io->invnum(),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,$this->io->display('date_orig'),0,0,'R'); $y += 5;
$this->SetXY($x,$y); $this->Cell(0,0,$this->io->display('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->io->other_due(TRUE),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->io->total(TRUE),0,0,'R');
if ($this->io->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->io->display('billed_amt'),0,0,'R');
}
if ($this->io->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->io->display('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,Currency::display($this->io->due() ? $this->io->account->invoices_due_total() : 0),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() {
$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 = Kohana::find_file('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,Company::bsb()); $y += 3;
$this->SetXY($x+30,$y); $this->Cell(0,0,Company::account()); $y += 3;
$this->SetXY($x+30,$y); $this->Cell(0,0,$this->io->refnum()); $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 = Kohana::find_file('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(URL::base(TRUE,TRUE),URL::base(TRUE,TRUE)); $y += 3;
}
/**
* Draw previous invoices due
*/
public function drawSummaryInvoicesDue() {
$x = 125; $y = $this->sum_y ? $this->sum_y : 50;
$items = $this->io->account->invoices_due();
# 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 #%s',$line->display('date_orig'),$line->invnum()));
$this->Cell(0,0,$line->due(TRUE),0,0,'R'); $y += 5;
} else {
$sum_total += $line->due();
}
}
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,Currency::display($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($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 drawLineItem($line) {
switch($this->iteration) {
case 0:
$this->drawLineItems_0($line);
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($line) {
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++;
}
/**
* This will draw the Summary Box, with the summary of the items
* on the invoice.
*/
public function drawSummaryLineItems() {
if (! $this->show_itemized)
return;
$items = $this->io->items_summary();
# 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+($this->io->discount_amt ? 1 : 0)+($this->io->billed_amt ? 1 : 0)+($this->io->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;
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->product_translate->find()->name,Currency::display($line->price_base)));
$this->SetX($x+135);
$this->Cell(0,0,Currency::display($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 -= $this->io->discount_amt;
$subtotal = round($subtotal,2);
if (round($this->io->total_amt-$this->io->tax_amt,2) != $subtotal) {
$this->SetFont('helvetica','',9);
$this->SetX($x);
$this->Cell(0,0,'Rounding');
$this->SetX($x+135);
$this->Cell(0,0,
Currency::display($this->io->total_amt-$this->io->tax_amt-$subtotal),0,0,'R');
$y += 5;
$this->SetY($y);
}
# Draw Discounts.
if ($this->io->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,Currency::display(-$this->io->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,Currency::display($this->io->total_amt-$this->io->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,Currency::display($this->io->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,Currency::display($this->io->total_amt),0,0,'R');
# Show payments already received for this invoice
if ($this->io->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,Currency::display($this->io->billed_amt),0,0,'R');
}
if ($this->io->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,Currency::display(-$this->io->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->io->due(TRUE),0,0,'R');
}
}
?>

View File

@ -1,5 +1,14 @@
<?php <?php defined('SYSPATH') or die('No direct access allowed.');
/** /**
* This class provides invoice PDF rendering capability
*
* @package OSB
* @subpackage Invoice
* @category Helpers
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/ */
define('FPDF_FONTPATH','includes/tcpdf/fonts/'); define('FPDF_FONTPATH','includes/tcpdf/fonts/');
@ -8,10 +17,9 @@ require_once('includes/tcpdf/tcpdf.php');
/** /**
* PDF Invoice Base * PDF Invoice Base
* *
* @package AgileBill
* @subpackage Module:Invoice * @subpackage Module:Invoice
*/ */
abstract class Invoice_PDF extends TCPDF { abstract class Invoice_TCPDF extends TCPDF {
// Our invoice object // Our invoice object
protected $io; protected $io;
@ -45,8 +53,8 @@ abstract class Invoice_PDF extends TCPDF {
$this->SetCreator('Open Source Billing'); $this->SetCreator('Open Source Billing');
$this->SetAuthor(Config::sitename()); $this->SetAuthor(Config::sitename());
$this->SetTitle(sprintf('%s Invoice',Config::sitename())); $this->SetTitle(sprintf('%s Invoice',Config::sitename()));
$this->SetSubject(sprintf('Invoice #%06s',$this->io->invnum())); $this->SetSubject(sprintf('Invoice #%06s',$this->io->id()));
$this->SetKeywords($this->io->invnum()); $this->SetKeywords($this->io->id());
$this->SetAutoPageBreak(TRUE,25); $this->SetAutoPageBreak(TRUE,25);
$this->SetHeaderMargin(1); $this->SetHeaderMargin(1);
$this->SetFooterMargin(10); $this->SetFooterMargin(10);
@ -58,20 +66,6 @@ abstract class Invoice_PDF extends TCPDF {
abstract public function drawCompanyLogo(); abstract public function drawCompanyLogo();
abstract public function drawCompanyAddress(); abstract public function drawCompanyAddress();
abstract public function drawInvoiceHeader(); abstract public function drawInvoiceHeader();
/**
* Enable re-iteration of the invoices items, so that they can be displayed many ways
*/
abstract public function drawLineItems($iteration);
/**
* This is called for each line item.
*/
abstract public function drawLineItem($line);
/**
* Draws the summary on the first page
*/
abstract public function drawSummaryLineItems(); abstract public function drawSummaryLineItems();
abstract public function drawPaymentMethods(); abstract public function drawPaymentMethods();
abstract public function drawRemittenceStub(); abstract public function drawRemittenceStub();

View File

@ -0,0 +1,523 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides invoice rending use TCPDF
*
* @package OSB
* @subpackage Invoice
* @category Helpers
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Invoice_TCPDF_Default extends Invoice_TCPDF {
// Current line being printed
public $sum_y = 0;
private $max_lines_page = 51;
protected $show_service_range = TRUE;
/**
* Draw the logo
*/
public function drawCompanyLogo() {
$x = 9; $y = 7;
$size = 25;
$logo = Config::logo_file();
if (is_file($logo))
$this->Image($logo,$x,$y,$size);
}
/**
* Draw the Company Address
*/
public function drawCompanyAddress() {
// 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,Config::sitename()); $y += 4;
$this->SetFont('helvetica','',10);
$this->SetXY($x,$y); $this->Cell(0,0,Company::taxid()); $y += 6;
$this->SetXY($x,$y); $this->Cell(0,0,Company::street()); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%s, %s %s',Company::city(),Company::state(),Company::pcode())); $y += 4;
$y += 2;
$this->SetXY($x,$y); $this->Cell(0,0,'Phone:'); $this->SetXY($x+16,$y); $this->Cell(0,0,Company::phone()); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0,'Fax:'); $this->SetXY($x+16,$y); $this->Cell(0,0,Company::fax()); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0,'Web:'); $this->SetXY($x+16,$y); $this->addHtmlLink(URL::base(TRUE,TRUE),URL::base(TRUE,TRUE)); $y += 4;
}
/**
* Draw the remmittence stub
*/
public function drawRemittenceStub() {
// 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').' '.Config::sitename());
// 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,$this->io->display('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,$this->io->account->accnum(),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,$this->io->id(),0,0,'R');
// Company Address
$y = 216;
$this->SetFont('helvetica','',10);
$this->SetXY(18,$y); $this->Cell(0,0,Config::sitename()); $y += 4;
$this->SetXY(18,$y); $this->Cell(0,0,Company::street()); $y += 4;
$this->SetXY(18,$y); $this->Cell(0,0,sprintf('%s, %s %s',Company::city(),Company::state(),Company::pcode())); $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->io->account->invoices_due_total($this->io->date_orig,TRUE),0,0,'R');
$y = 219;
$this->SetFont('helvetica','',9);
$this->SetXY($x,$y); $this->Cell(0,0,_('Amount Due').' '.$this->io->display('due_date'));
$this->SetXY($x,$y); $this->Cell(0,0,$this->io->due(TRUE),0,0,'R');
// Total Due
$y = 224;
$this->SetFont('helvetica','B',10);
$this->SetXY($x,$y); $this->Cell(0,0,_('Total Payable'));
$this->SetXY($x,$y); $this->Cell(0,0,Currency::display($this->io->due() ? $this->io->total()+$this->io->account->invoices_due_total($this->io->date_orig,TRUE) : 0),0,0,'R');
// Draw the Customers Address
$x = 25; $y = 248;
$this->SetFont('helvetica','B',12);
if ($this->billToCompany && ! empty($this->io->account->company))
$name = $this->io->account->company;
else
$name = $this->io->account->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 ',$this->io->account->address1,$this->io->account->address2)); $y += 5;
$this->SetXY($x,$y); $this->Cell(0,0,sprintf('%s, %s %s',$this->io->account->city,$this->io->account->state,$this->io->account->zip)); $y += 5;
}
/**
* Draw the invoice header
*/
public function drawInvoiceHeader() {
$x = 125; $y = 10;
// Draw a box.
$this->SetFillColor(245);
$this->SetXY($x-1,$y-1); $this->Cell(0,35+($this->io->billed_amt ? 5 : 0)+($this->io->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,$this->io->id(),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,$this->io->display('date_orig'),0,0,'R'); $y += 5;
$this->SetXY($x,$y); $this->Cell(0,0,$this->io->display('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->io->account->invoices_due_total($this->io->date_orig,TRUE),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->io->total(TRUE),0,0,'R');
if ($this->io->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->io->display('billed_amt'),0,0,'R');
}
if ($this->io->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->io->display('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,Currency::display($this->io->due() ? $this->io->total()+$this->io->account->invoices_due_total($this->io->date_orig) : 0),0,0,'R');
}
/**
* Draw any news messages
* @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);
}
/**
* Draw our available payment methods
* @todo make this list dynamic
*/
public function drawPaymentMethods() {
$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 be paid by:'); $y += 4;
# Direct Credit
$logo = Kohana::find_file('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,Company::bsb()); $y += 3;
$this->SetXY($x+30,$y); $this->Cell(0,0,Company::account()); $y += 3;
$this->SetXY($x+30,$y); $this->Cell(0,0,$this->io->refnum()); $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 = Kohana::find_file('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(URL::base(TRUE,TRUE),URL::base(TRUE,TRUE)); $y += 3;
}
/**
* Draw previous invoices due
*/
public function drawSummaryInvoicesDue() {
$x = 125; $y = $this->sum_y ? $this->sum_y : 50;
$items = $this->io->account->invoices_due($this->io->date_orig);
# 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 %s',$line->display('date_orig'),$line->id()));
$this->Cell(0,0,$line->due(TRUE),0,0,'R'); $y += 5;
} else {
$sum_total += $line->due();
}
}
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,Currency::display($sum_total),0,0,'R'); $y += 5;
}
$this->sum_y = $y+5;
}
/**
* This will draw the Summary Box, with the summary of the items
* on the invoice.
*/
public function drawSummaryLineItems() {
if (! $this->show_itemized)
return;
$items = $this->io->items_summary();
// Calculate the box size
$box = count($items) < $this->itemsSummaryMax ? count($items) : $this->itemsSummaryMax;
// Our starting position
$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+($this->io->discount_amt ? 1 : 0)+($this->io->billed_amt ? 1 : 0)+($this->io->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')); $y += 5;
$this->SetY($y);
$this->SetFont('helvetica','',9);
$i = $subtotal = 0;
foreach ($items as $name => $line) {
if ($i < $this->itemsSummaryMax) {
$this->SetX($x);
$this->Cell(0,0,$line['quantity']);
$this->SetX($x+8);
$this->Cell(0,0,$name);
$this->SetX($x+135);
$this->Cell(0,0,Currency::display($line['subtotal']),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.'));
}
$subtotal += $line['subtotal'];
}
// Calculate our rounding error
// @todo This shouldnt be required.
$subtotal = round($subtotal-$this->io->discount_amt,Kohana::config('config.currency_format'));
if (round($this->io->subtotal(),Kohana::config('config.currency_format')) != $subtotal) {
$this->SetFont('helvetica','',9);
$this->SetX($x);
$this->Cell(0,0,'Rounding');
$this->SetX($x+135);
$this->Cell(0,0,Currency::display($this->io->subtotal()-$subtotal),0,0,'R');
$y += 5;
$this->SetY($y);
}
// Draw Discounts.
if ($this->io->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,Currency::display(-$this->io->discount_amt),0,0,'R');
}
// Subtotal 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,Currency::display($this->io->subtotal()),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,Currency::display($this->io->tax()),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,Currency::display($this->io->total()),0,0,'R');
// Show payments already received for this invoice
if ($this->io->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,Currency::display($this->io->payments()),0,0,'R');
}
if ($this->io->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,Currency::display(-$this->io->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->io->due(TRUE),0,0,'R');
}
/**
* This will draw the Summary Box, with the summary of the items
* on the invoice.
*/
public function drawDetailLineItems() {
$this->i = 0;
foreach ($this->io->items() as $io)
$this->drawLineItem($io);
}
/**
* Draws Invoice Detail Item
*
* @todo need to make sure that this pages well, when there are many items (with many sub details).
*/
private function drawLineItem($ito) {
$x = 10;
if ($this->i == 0 || $this->i%$this->max_lines_page == 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 #').$this->io->id(),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,$ito->service->service_name());
if ($ito->price_base) {
$this->SetX($x+160);
$this->Cell(10,0,Currency::display($ito->price_base),0,0,'R');
}
if ($ito->quantity) {
$this->SetX($x+130);
$this->Cell(10,0,$ito->quantity,0,0,'R');
}
$this->SetX($x+130);
$this->Cell(0,0,Currency::display($ito->total_amt),0,0,'R');
if ($this->show_service_range && $ito->period()) {
$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,$ito->period());
}
if ($ito->invoice_detail_items())
foreach ($ito->invoice_detail_items() as $k=>$v) {
$this->SetFont('helvetica','I',7);
$this->y += 3;
$this->SetXY($x+10,$this->y); $this->Cell(0,0,$k);
$this->SetFont('helvetica','',7);
$this->SetXY($x+40,$this->y); $this->Cell(0,0,$v);
}
$this->y += 5;
$this->SetY($this->y);
$this->i++;
}
}
?>

View File

@ -37,19 +37,31 @@ class Model_Invoice extends ORMOSB {
'tax_amt'=>array('calc_tax'), 'tax_amt'=>array('calc_tax'),
); );
protected $_formats = array( protected $_display_filters = array(
'date_orig'=>array('Config::date'=>array()), 'date_orig'=>array(
'due_date'=>array('Config::date'=>array()), array('Config::date',array(':value')),
'billed_amt'=>array('Currency::display'=>array()), ),
'credit_amt'=>array('Currency::display'=>array()), 'due_date'=>array(
'status'=>array('StaticList_YesNo::display'=>array()), array('Config::date',array(':value')),
'total_amt'=>array('Currency::display'=>array()), ),
'billed_amt'=>array(
array('Currency::display',array(':value')),
),
'credit_amt'=>array(
array('Currency::display',array(':value')),
),
'status'=>array(
array('StaticList_YesNo::display',array(':value')),
),
'total_amt'=>array(
array('Currency::display',array(':value')),
),
); );
/** /**
* Display the Invoice Number * Display the Invoice Number
*/ */
public function invnum() { public function id() {
return sprintf('%06s',$this->id); return sprintf('%06s',$this->id);
} }
@ -64,127 +76,115 @@ class Model_Invoice extends ORMOSB {
* Display the amount due * Display the amount due
*/ */
public function due($format=FALSE) { public function due($format=FALSE) {
$result = 0;
// If the invoice is active calculate the due amount // If the invoice is active calculate the due amount
if ($this->status) $result = $this->status ? round($this->total_amt-$this->credit_amt-$this->billed_amt,Kohana::config('config.currency_format')) : 0;
// @todo This rounding should be a system setting
$result = round($this->total_amt-$this->credit_amt-$this->billed_amt,2);
if ($format) return $format ? Currency::display($result) : $result;
return Currency::display($result);
else
return $result;
}
/**
* Return a total invoices overdue excluding this invoice
*/
public function other_due($format=FALSE) {
$result = $this->account->invoices_due_total()-$this->due();
if ($format)
return Currency::display($result);
else
return $result;
}
public function subtotal($format=FALSE) {
$result = 0;
foreach ($this->items() as $item)
$result += $item->subtotal();
if ($format)
return Currency::display($result);
else
return $result;
}
public function total($format=FALSE) {
$result = 0;
foreach ($this->items() as $item)
$result += $item->total();
// Reduce any credits
$result -= $this->credit_amt;
if ($format)
return Currency::display($result);
else
return $result;
} }
/** /**
* Return a list of invoice items for this invoice. * Return a list of invoice items for this invoice.
*
* We only return the items, if the invoice hasnt been changed.
*/ */
public function items() { public function items() {
// Get our invoice items for an existing invoice return ($this->loaded() AND ! $this->_changed) ? $this->invoice_item->order_by('service_id,item_type,module_id')->find_all() : NULL;
if ($this->id AND $this->loaded() AND ! $this->_changed) }
return $this->invoice_item->order_by('service_id,item_type,module_id')->find_all();
echo kohana::debug(array('BEFORE'=>$this->invoice_item)); /**
if (! $this->invoice_items) * Return the subtotal of all items
$this->invoice_items = $this->invoice_item; */
public function subtotal($format=FALSE) {
$result = 0;
echo kohana::debug(array('AFTER'=>$this->invoice_items));die(); foreach ($this->items() as $ito)
return $this->invoice_items; $result += $ito->subtotal();
return $format ? Currency::display($result) : $result;
}
public function tax($format=FALSE) {
$result = 0;
foreach ($this->items() as $ito)
$result += $ito->tax_amt;
return $format ? Currency::display($result) : $result;
}
/**
* Return the total of all items
*/
public function total($format=FALSE) {
$result = 0;
foreach ($this->items() as $ito)
$result += $ito->total();
// Reduce by any credits
$result -= $this->credit_amt;
return $format ? Currency::display($result) : $result;
}
public function payments() {
return ($this->loaded() AND ! $this->_changed) ? $this->payments->find_all() : NULL;
}
public function payments_total($format=FALSE) {
$result = 0;
foreach ($this->payments() as $po)
$result += $po->total_amt;
return $format ? Currency::display($result) : $result;
} }
/** /**
* Return a list of our main invoice items (item_id=0) * Return a list of our main invoice items (item_id=0)
*/ */
public function items_main() { public function items_main() {
if ($this->id AND $this->loaded() AND ! $this->_changed) return ($this->loaded() AND ! $this->_changed) ? $this->invoice_item->where('item_type','=',0)->find_all() : NULL;
return $this->invoice_item->where('item_type','=',0)->find_all();
} }
/** /**
* Return a list of our sub invoice items (item_id!=0) * Return a list of our sub invoice items (item_id!=0)
*
* @param sid int Service ID
*/ */
public function items_sub($sid) { public function items_sub($sid) {
if ($this->id AND $this->loaded() AND ! $this->_changed) return ($this->loaded() AND ! $this->_changed) ? $this->invoice_item->where('service_id','=',$sid)->and_where('item_type','<>',0)->find_all() : NULL;
return $this->invoice_item->where('service_id','=',$sid)->and_where('item_type','<>',0)->find_all();
} }
/** /**
* Summarise the items on an invoice * Summarise the items on an invoice
*/ */
public function items_summary() { public function items_summary() {
$sum = array(); $result = array();
foreach ($this->items_main() as $item) { foreach ($this->items_main() as $ito) {
$unique = TRUE; $unique = TRUE;
# Unique line item $t = $ito->product->summary();
if (isset($sum[$item->product->sku])) { if (! isset($result[$t])) {
# Is unique price/attributes? $result[$t]['quantity'] = 0;
$result[$t]['subtotal'] = 0;
foreach ($sum[$item->product->sku] as $sid => $flds) {
if ($flds->price_base == $item->price_base &&
$flds->price_setup == $item->price_setup) {
$sum[$item->product->sku][$sid]->quantity += $item->quantity;
$unique = FALSE;
break;
}
}
} }
# Unique line item $result[$t]['quantity'] += $ito->quantity;
if ($unique) $result[$t]['subtotal'] += $ito->subtotal();
$sum[$item->product->sku][] = $item;
} }
if (count($sum)) { return $result;
$items = array(); }
foreach ($sum as $sku => $item)
foreach ($item as $sitem)
array_push($items,$sitem);
return $items; /**
} * Find all the invoice items relating to a service
*
* @param int Service ID
*/
private function items_service($sid) {
return $this->invoice_item->where('service_id','=',$sid)->find_all();
} }
/** /**
@ -193,8 +193,8 @@ class Model_Invoice extends ORMOSB {
public function items_service_total($sid) { public function items_service_total($sid) {
$total = 0; $total = 0;
foreach ($this->invoice_item->where('service_id','=',$sid)->find_all() as $item) foreach ($this->items_service($sid) as $ito)
$total += $item->total(); $total += $ito->total();
return $total; return $total;
} }
@ -205,8 +205,8 @@ class Model_Invoice extends ORMOSB {
public function items_service_tax($sid) { public function items_service_tax($sid) {
$total = 0; $total = 0;
foreach ($this->invoice_item->where('service_id','=',$sid)->find_all() as $item) foreach ($this->items_service($sid) as $ito)
$total += $item->tax_amt; $total += $ito->tax_amt;
return $total; return $total;
} }
@ -217,8 +217,8 @@ class Model_Invoice extends ORMOSB {
public function sorted_service_items($index) { public function sorted_service_items($index) {
$summary = array(); $summary = array();
foreach ($this->items() as $item) { foreach ($this->items() as $ito) {
$key = $item->service->$index; $key = $ito->service->$index;
if (! isset($summary[$key]['items'])) { if (! isset($summary[$key]['items'])) {
$summary[$key]['items'] = array(); $summary[$key]['items'] = array();
@ -226,10 +226,10 @@ class Model_Invoice extends ORMOSB {
} }
// Only record items with item_type=0 // Only record items with item_type=0
if ($item->item_type == 0) if ($ito->item_type == 0)
array_push($summary[$key]['items'],$item); array_push($summary[$key]['items'],$ito);
$summary[$key]['total'] += $item->total(); $summary[$key]['total'] += $ito->total();
} }
return $summary; return $summary;
@ -241,8 +241,8 @@ class Model_Invoice extends ORMOSB {
public function tax_summary() { public function tax_summary() {
$summary = array(); $summary = array();
foreach ($this->items() as $item) { foreach ($this->items() as $ito) {
foreach ($item->invoice_item_tax->find_all() as $item_tax) { foreach ($ito->invoice_item_tax->find_all() as $item_tax) {
if (! isset($summary[$item_tax->tax_id])) if (! isset($summary[$item_tax->tax_id]))
$summary[$item_tax->tax_id] = $item_tax->amount; $summary[$item_tax->tax_id] = $item_tax->amount;
else else
@ -253,6 +253,9 @@ class Model_Invoice extends ORMOSB {
return $summary; return $summary;
} }
/**
* Add an item to an invoice
*/
public function add_item() { public function add_item() {
$c = count($this->invoice_items); $c = count($this->invoice_items);
@ -299,8 +302,8 @@ class Model_Invoice extends ORMOSB {
$array[$field] = 0; $array[$field] = 0;
// @todo Rounding here should come from a global config // @todo Rounding here should come from a global config
foreach ($this->invoice_items as $item) foreach ($this->invoice_items as $ito)
$array[$field] += round($item->price_base+$item->price_setup,2); $array[$field] += round($ito->price_base+$ito->price_setup,2);
$this->_changed[$field] = $field; $this->_changed[$field] = $field;
} }
@ -311,8 +314,8 @@ class Model_Invoice extends ORMOSB {
// @todo Rounding here should come from a global config // @todo Rounding here should come from a global config
// @todo tax should be evaluated per item // @todo tax should be evaluated per item
// @todo tax parameters should come from user session // @todo tax parameters should come from user session
foreach ($this->invoice_items as $item) foreach ($this->invoice_items as $ito)
$array[$field] += round(Tax::total(61,NULL,$item->price_base+$item->price_setup),2); $array[$field] += round(Tax::total(61,NULL,$ito->price_base+$ito->price_setup),2);
$this->_changed[$field] = $field; $this->_changed[$field] = $field;
} }

View File

@ -32,16 +32,14 @@ class Model_Invoice_Item extends ORMOSB {
return sprintf('%s: %s',_('Date'),Config::date($this->date_start)); return sprintf('%s: %s',_('Date'),Config::date($this->date_start));
else else
return sprintf('%s: %s -> %s',_('Period'),Config::date($this->date_start),Config::date($this->date_stop)); return sprintf('%s -> %s',Config::date($this->date_start),Config::date($this->date_stop));
} }
/** public function invoice_detail_items() {
* On invoices where there are multiple charges for the same item if ($this->item_type != 0)
* (eg spanning the next invoice period), this should show the period return;
* range for the additional sub-items.
*/ return $this->service->details('invoice');
public function invoice_display() {
return $this->period();
} }
public function subtotal() { public function subtotal() {

View File

@ -14,7 +14,7 @@
<table class="invoice_summary" border="0"> <table class="invoice_summary" border="0">
<tr> <tr>
<td>TAX INVOICE</td> <td>TAX INVOICE</td>
<td class="bold-right"><?php echo $invoice->invnum(); ?></td> <td class="bold-right"><?php echo $invoice->id(); ?></td>
</tr> </tr>
<tr> <tr>
<td>Issue Date</td> <td>Issue Date</td>
@ -61,7 +61,7 @@
<?php foreach ($catitems['items'] as $item) {?> <?php foreach ($catitems['items'] as $item) {?>
<!-- Product Information --> <!-- Product Information -->
<tr class="head"> <tr class="head">
<td><?php echo HTML::anchor('/user/service/view/'.$item->service->id,$item->service->svcnum()); ?></td> <td><?php echo HTML::anchor('/user/service/view/'.$item->service->id,$item->service->id()); ?></td>
<td colspan="3"><?php echo $item->product->product_translate->find()->name; ?> (<?php echo $item->product_id; ?>)</td> <td colspan="3"><?php echo $item->product->product_translate->find()->name; ?> (<?php echo $item->product_id; ?>)</td>
<td class="right"><?php echo Currency::display($invoice->items_service_total($item->service_id));?></td> <td class="right"><?php echo Currency::display($invoice->items_service_total($item->service_id));?></td>
</tr> </tr>

View File

@ -10,7 +10,7 @@
</tr> </tr>
<?php $i = 0; foreach ($invoices as $invoice) { ?> <?php $i = 0; foreach ($invoices as $invoice) { ?>
<tr class="<?php echo ++$i%2 ? 'odd' : 'even'; ?>"> <tr class="<?php echo ++$i%2 ? 'odd' : 'even'; ?>">
<td><?php echo HTML::anchor('/user/invoice/view/'.$invoice->id,$invoice->invnum()); ?></td> <td><?php echo HTML::anchor('/user/invoice/view/'.$invoice->id,$invoice->id()); ?></td>
<td><?php echo $invoice->display('total_amt'); ?></td> <td><?php echo $invoice->display('total_amt'); ?></td>
<td><?php echo $invoice->display('credit_amt'); ?></td> <td><?php echo $invoice->display('credit_amt'); ?></td>
<td class="number"><?php echo $invoice->display('billed_amt'); ?></td> <td class="number"><?php echo $invoice->display('billed_amt'); ?></td>

View File

@ -45,6 +45,7 @@ class Controller_Admin_Module extends Controller_Module {
* Edit a Module Configuration * Edit a Module Configuration
* *
* @param int $mid Module ID * @param int $mid Module ID
* @todo Highlight those methods that have security, but the class does not have auth_required set to YES or the method isnt defined in secure_actions
*/ */
public function action_edit($mid) { public function action_edit($mid) {
$mo = ORM::factory('module',$mid); $mo = ORM::factory('module',$mid);

View File

@ -15,7 +15,7 @@ class Controller_Module extends Controller_TemplateDefault {
'edit'=>TRUE, 'edit'=>TRUE,
'list'=>TRUE, 'list'=>TRUE,
'menu'=>TRUE, 'menu'=>TRUE,
); );
public function action_menu() { public function action_menu() {
// Redirect us to the admin menu, no user facilities here! // Redirect us to the admin menu, no user facilities here!

View File

@ -21,12 +21,71 @@ class Model_Product extends ORMOSB {
'sku'=>'asc', 'sku'=>'asc',
); );
protected $_formats = array( protected $_display_format = array(
'price_type'=>array('StaticList_PriceType::display'=>array()), 'price_type'=>array('StaticList_PriceType::display'=>array()),
); );
/**
* The feature summary should be implemented in child objects.
* It is displayed on the product overview page, as a summary of the products features.
*/
protected function _feature_summary() {
throw new Kohana_Exception(':method not defined in child class :class',array(':method'=>__METHOD__,':class'=>get_class($this)));
}
/**
* The summary should be implemented in child objects.
*/
protected function _summary() {
return _('No Description');
}
/**
* Return the object of the product plugin
*/
private function plugin() {
if (! $this->prod_plugin_file)
return NULL;
if (! is_numeric($this->prod_plugin_data))
throw new Kohana_Exception('Missing plugin_id for :product (:type)',array(':product'=>$this->id,':type'=>$this->prod_plugin_file));
$spn = sprintf('%s_%s',get_class($this),$this->prod_plugin_file);
return new $spn($this->prod_plugin_data);
}
/**
* Get the product name, after translating
*/
public function name() {
return $this->product_translate->find()->display('name');
}
/**
* This will render the product feature summary information
*/
public function feature_summary() {
if (is_null($plugin = $this->plugin()))
return HTML::nbsp('');
else
return $plugin->_feature_summary();
}
/**
* Get the summary description
*
* Generally this is used on the invoice summary page
*/
public function summary() {
if (is_null($plugin = $this->plugin()))
return _('Other');
else
return $plugin->_summary();
}
/** /**
* Return the products for a given category * Return the products for a given category
* @todo This shouldnt be here.
*/ */
public function category($cat) { public function category($cat) {
$results = array(); $results = array();

View File

@ -0,0 +1,58 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports ADSL products
*
* @package OSB
* @subpackage Product/ADSL
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Product_ADSL extends Model_Product {
protected $_table_name = 'adsl_plan';
protected $_primary_key = 'id';
protected $_sorting = array(
);
protected $_display_filters = array(
'extra_down_peak'=>array(
array('Tax::add',array(':value')),
array('Currency::display',array(':value')),
),
'extra_down_offpeak'=>array(
array('Tax::add',array(':value')),
array('Currency::display',array(':value')),
),
);
protected function _feature_summary() {
return View::factory('product/adsl/feature_summary')
->set('po',$this);
}
protected function _summary() {
return sprintf('%s: %s %s','ADSL Services',$this->speed,$this->allowance(TRUE));
}
/**
* Show the ADSL allowance as a peak/offpeak metric
*/
public function allowance($string=TRUE) {
$output = ADSL::allowance(array(
'base_down_peak'=>$this->base_down_peak,
'base_down_offpeak'=>$this->base_down_offpeak,
'base_up_peak'=>$this->base_up_peak,
'base_up_offpeak'=>$this->base_up_offpeak,
'extra_down_peak'=>$this->extra_down_peak,
'extra_down_offpeak'=>$this->extra_down_offpeak,
'extra_up_peak'=>$this->extra_up_peak,
'extra_up_offpeak'=>$this->extra_up_offpeak,
));
return $string ? implode('/',$output) : $output;
}
}
?>

View File

@ -0,0 +1,28 @@
<!-- //@todo To translate -->
<table class="box-full">
<tr>
<td style="width: 40%;">Speed</td>
<td class="data" style="width: 60%;" colspan="2"><?php echo $po->display('speed'); ?></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>Peak</td>
<?php if ($po->base_down_offpeak OR $po->extra_down_offpeak) { ?>
<td>Off Peak</td>
<?php } ?>
</tr>
<tr>
<td>Included Download Traffic</td>
<!-- // @todo Since price is stored in the DB in GB, so should the traffic. -->
<td class="data"><?php echo $po->base_down_peak/1000; ?> GB</td>
<td class="data"><?php echo $po->base_down_offpeak ? ($po->base_down_offpeak/1000).'GB' : HTML::nbsp(''); ?></td>
</tr>
<tr>
<td>Extra Download Traffic</td>
<td class="data"><?php echo $po->display('extra_down_peak'); ?>/GB</td>
<td class="data"><?php echo $po->extra_down_offpeak ? $po->display('extra_down_offpeak').'/GB' : HTML::nbsp(''); ?></td>
</tr>
</table>

View File

@ -9,6 +9,7 @@
* @author Deon George * @author Deon George
* @copyright (c) 2010 Open Source Billing * @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
* @todo Replace View::factory files to use $this->viewpath()
*/ */
class Controller_Admin_Service extends Controller_TemplateDefault { class Controller_Admin_Service extends Controller_TemplateDefault {
protected $control = array('Services'=>'services'); protected $control = array('Services'=>'services');
@ -17,6 +18,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault {
'listbycheckout'=>TRUE, 'listbycheckout'=>TRUE,
'listadslservices'=>TRUE, 'listadslservices'=>TRUE,
'listhspaservices'=>TRUE, 'listhspaservices'=>TRUE,
'update'=>TRUE,
); );
/** /**
@ -355,7 +357,7 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
Block::add(array( Block::add(array(
'title'=>_('ADSL Services'), 'title'=>_('ADSL Services'),
'body'=>$output, 'body'=>$output,
)); ));
if ($summary) if ($summary)
Block::add(array( Block::add(array(
@ -411,5 +413,28 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
return $return; return $return;
} }
public function action_update($id) {
$so = ORM::factory('service',$id);
if (! $so->loaded())
Request::current()->redirect('welcome/index');
if ($_POST) {
if (isset($_POST['plugin']) AND $_POST['plugin'])
if (! $so->plugin()->values($_POST['plugin'])->update()->saved())
throw new Kohana_Exception('Failed to save updates to plugin data for record :record',array(':record'=>$so->id()));
if (! $so->values($_POST)->update()->saved())
throw new Kohana_Exception('Failed to save updates to plugin data for record :record',array(':record'=>$so->id()));
}
Block::add(array(
'title'=>sprintf('%s %s:%s',_('Update Service'),$so->id(),$so->name()),
'body'=>View::factory($so->viewpath())
->set('so',$so)
->set('plugin_form',$so->admin_update()),
));
}
} }
?> ?>

View File

@ -40,66 +40,15 @@ class Controller_User_Service extends Controller_TemplateDefault {
public function action_view($id) { public function action_view($id) {
$so = ORM::factory('service',$id); $so = ORM::factory('service',$id);
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account_id)) { if (! $so->loaded() OR ! Auth::instance()->authorised($so->account_id)) {
$this->template->content = 'Unauthorised or doesnt exist?'; $this->template->content = 'Unauthorised or doesnt exist?';
return FALSE; return FALSE;
}
$graph = $graph_data = $product_info = $product_detail = '';
// @todo Work this out dynamically
if ($so->product->prod_plugin AND in_array($so->product->prod_plugin_file,array('ADSL'))) {
$google = GoogleChart::factory('vertical_bar');
// If we came in via a post to show a particular month, then show that, otherwise show the yearly result
if ($_POST AND isset($_POST['month'])) {
$google->title = sprintf('DSL traffic usage for %s',$_POST['month']);
$traffic_data = $so->service_adsl->get_traffic_data_daily(strtotime($_POST['month'].'-01'));
foreach ($traffic_data as $k => $details)
$google->series(array(
'title'=>array((isset($friendly[$k]) ? $friendly[$k] : $k)),
'axis'=>'x',
'data'=>array((isset($friendly[$k]) ? $friendly[$k] : $k)=>$traffic_data[$k])));
foreach ($traffic_data as $k => $details)
$google->series(array(
'title'=>array((isset($friendly['cumulative'.$k]) ? $friendly['cumulative'.$k] : 'cumulative'.$k)),
'axis'=>'r',
'data'=>array((isset($friendly['cumulative'.$k]) ? $friendly['cumulative'.$k] : 'cumulative'.$k)=>$so->service_adsl->cumulative($traffic_data[$k]))));
$graph_data = View::factory('service/view_detail_adsl_traffic')
->set('traffic',$so->service_adsl->traffic_month(strtotime($_POST['month'].'-01'),FALSE));
} else {
// @todo Change the date to the last record date
$google->title = sprintf('Monthly DSL traffic usage as at %s',Config::date(strtotime('yesterday')));
$traffic_data = $so->service_adsl->get_traffic_data_monthly();
foreach ($traffic_data as $k => $details)
$google->series(array(
'title'=>array((isset($friendly[$k]) ? $friendly[$k] : $k)),
'axis'=>'x',
'data'=>array((isset($friendly[$k]) ? $friendly[$k] : $k)=>$traffic_data[$k])));
}
$graph = (string)$google;
$product_info = ADSL::instance()->product_view($so->service_adsl->adsl_plan_id,$so->price,$so->product->price_setup);
$product_detail = View::factory('service/view_detail_adsl')
->set('graph',$graph)
->set('graph_data',$graph_data)
->set('service',$so);
} }
// @todo need to get the monthly price
Block::add(array( Block::add(array(
'title'=>sprintf('%06s: %s',$so->id,$so->product->product_translate->find()->name), 'title'=>sprintf('%s: %s',$so->id(),$so->product->name()),
'body'=>View::factory('service/view') 'body'=>View::factory('service/view')
->set('service',$so) ->set('so',$so),
->set('product_info',$product_info)
->set('product_detail',$product_detail),
)); ));
} }
} }

View File

@ -14,10 +14,10 @@ class Model_Service extends ORMOSB {
// Relationships // Relationships
protected $_has_many = array( protected $_has_many = array(
'invoice'=>array('through'=>'invoice_item'), 'invoice'=>array('through'=>'invoice_item'),
'adsl_plan'=>array('through'=>'service__adsl'),
); );
protected $_has_one = array( protected $_has_one = array(
'service_adsl'=>array('far_key'=>'id'), 'service_adsl'=>array('far_key'=>'id'),
'service_domain'=>array('far_key'=>'id'),
); );
protected $_belongs_to = array( protected $_belongs_to = array(
'product'=>array(), 'product'=>array(),
@ -31,6 +31,9 @@ class Model_Service extends ORMOSB {
'active'=>array( 'active'=>array(
array('StaticList_YesNo::display',array(':value')), array('StaticList_YesNo::display',array(':value')),
), ),
'date_last_invoice'=>array(
array('Config::date',array(':value')),
),
'date_next_invoice'=>array( 'date_next_invoice'=>array(
array('Config::date',array(':value')), array('Config::date',array(':value')),
), ),
@ -43,23 +46,107 @@ class Model_Service extends ORMOSB {
), ),
); );
/**
* The service_name should be implemented in child objects.
* It renders the name of the service, typically used on invoice
*/
protected function _service_name() {
throw new Kohana_Exception(':method not defined in child class :class',array(':method'=>__METHOD__,':class'=>get_class($this)));
}
/**
* The service_view should be implemented in child objects.
* It renders the details of the ordered service
*/
protected function _service_view() {
throw new Kohana_Exception(':method not defined in child class :class',array(':method'=>__METHOD__,':class'=>get_class($this)));
}
/**
* The _details should be implemented in child objects.
*/
protected function _details($type) {
throw new Kohana_Exception(':method not defined in child class :class',array(':method'=>__METHOD__,':class'=>get_class($this)));
}
protected function _admin_update() {
throw new Kohana_Exception(':method not defined in child class :class',array(':method'=>__METHOD__,':class'=>get_class($this)));
}
/**
* Return the object of the product plugin
*/
public function plugin() {
if (! $this->product->prod_plugin_file)
return NULL;
if (! is_numeric($this->product->prod_plugin_data))
throw new Kohana_Exception('Missing plugin_id for :product (:type)',array(':product'=>$this->product->id,':type'=>$this->product->prod_plugin_file));
$spn = sprintf('%s_%s',get_class($this),$this->product->prod_plugin_file);
return new $spn(array('service_id'=>$this->id));
}
/** /**
* Display the service number * Display the service number
*/ */
public function svcnum() { public function id() {
return sprintf('%05s',$this->id); return sprintf('%05s',$this->id);
} }
// Nothing to directly display on invoices for this module. /**
public function invoice_display() { * Display the service product name
if ($this->sku) */
return sprintf('%s: %s',_('Service'),$this->sku); public function name() {
else return $this->product->name();
return '';
} }
public function name() { /**
return $this->product->product_translate->find()->name; * Display the product feature summary
*/
public function product_feature_summary() {
return $this->product->feature_summary();
}
/**
* Display the service details
*/
public function service_view() {
if (is_null($plugin = $this->plugin()))
return HTML::nbsp('');
else
return $plugin->_service_view();
}
public function service_name() {
if (is_null($plugin = $this->plugin()))
return $this->name();
else
return $plugin->_service_name();
}
/**
* Render some details for specific calls, eg: invoice
*/
public function details($type) {
switch ($type) {
case 'invoice':
if (is_null($plugin = $this->plugin()))
return array();
else
return $plugin->_details($type);
break;
default:
throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type));
}
}
public function admin_update() {
if (is_null($plugin = $this->plugin()))
return NULL;
else
return $plugin->_admin_update();
} }
// @todo To implement // @todo To implement

View File

@ -10,7 +10,7 @@
* @copyright (c) 2010 Open Source Billing * @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Model_Service_ADSL extends ORMOSB { class Model_Service_ADSL extends Model_Service {
protected $_table_name = 'service__adsl'; protected $_table_name = 'service__adsl';
protected $_updated_column = FALSE; protected $_updated_column = FALSE;
@ -20,6 +20,13 @@ class Model_Service_ADSL extends ORMOSB {
'service'=>array(), 'service'=>array(),
); );
protected $_display_filters = array(
'service_connect_date'=>array(
array('Config::date',array(':value')),
),
);
/** /**
* Return the IP Address for the service * Return the IP Address for the service
*/ */
@ -27,14 +34,8 @@ class Model_Service_ADSL extends ORMOSB {
return $this->ipaddress ? $this->ipaddress : _('Dynamic'); return $this->ipaddress ? $this->ipaddress : _('Dynamic');
} }
public function contract_date_start() {
//@todo Use the system configured date format
return date('Y-m-d',$this->service_connect_date);
}
public function contract_date_end() { public function contract_date_end() {
//@todo Use the system configured date format return Config::date(strtotime(sprintf('+%s months',$this->contract_term),$this->service_connect_date));
return date('Y-m-d',strtotime(sprintf('+%s months',$this->adsl_plan->contract_term),$this->service_connect_date));
} }
/** /**
@ -324,5 +325,79 @@ class Model_Service_ADSL extends ORMOSB {
// If we get here, then we dont need to report usage. // If we get here, then we dont need to report usage.
return FALSE; return FALSE;
} }
protected function _service_name() {
return sprintf('%s - %s',$this->service->product->name(),$this->service_number);
}
protected function _service_view() {
return View::factory('service/adsl/view')
->set('so',$this);
}
/**
* Get specific service details for use in other modules
* For Example: Invoice
*
* @todo Make the rendered items configurable
*/
protected function _details($type) {
switch ($type) {
case 'invoice':
return array(
_('Service Address')=>$this->display('service_address'),
_('Contact Until')=>$this->contract_date_end(),
);
break;
default:
throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type));
}
}
protected function _admin_update() {
return View::factory($this->viewpath(strtolower($this->service->prod_plugin_name)))
->set('so',$this);
}
/**
* Render a google chart of traffic
*/
public function graph_traffic($month=null) {
$google = GoogleChart::factory('vertical_bar');
// If we came in via a post to show a particular month, then show that, otherwise show the yearly result
if (! is_null($month) AND trim($month)) {
$google->title = sprintf('DSL traffic usage for %s',$_POST['month']);
$traffic_data = $this->get_traffic_data_daily(strtotime($_POST['month'].'-01'));
foreach ($traffic_data as $k => $details)
$google->series(array(
'title'=>array((isset($friendly[$k]) ? $friendly[$k] : $k)),
'axis'=>'x',
'data'=>array((isset($friendly[$k]) ? $friendly[$k] : $k)=>$traffic_data[$k])));
foreach ($traffic_data as $k => $details)
$google->series(array(
'title'=>array((isset($friendly['cumulative'.$k]) ? $friendly['cumulative'.$k] : 'cumulative'.$k)),
'axis'=>'r',
'data'=>array((isset($friendly['cumulative'.$k]) ? $friendly['cumulative'.$k] : 'cumulative'.$k)=>$this->cumulative($traffic_data[$k]))));
$graph_data = View::factory('service/view_detail_adsl_traffic')
->set('traffic',$this->traffic_month(strtotime($_POST['month'].'-01'),FALSE));
} else {
// @todo Change the date to the last record date
$google->title = sprintf('Monthly DSL traffic usage as at %s',Config::date(strtotime('yesterday')));
$traffic_data = $this->get_traffic_data_monthly();
foreach ($traffic_data as $k => $details)
$google->series(array(
'title'=>array((isset($friendly[$k]) ? $friendly[$k] : $k)),
'axis'=>'x',
'data'=>array((isset($friendly[$k]) ? $friendly[$k] : $k)=>$traffic_data[$k])));
}
return (string)$google;
}
} }
?> ?>

View File

@ -19,7 +19,7 @@
<index> <index>
<date>site_id,date_orig</date> <date>site_id,date_orig</date>
<parent>site_id,parent_id</parent> <parent>site_id,parent_id</parent>
<invoice>site_id,invoice_id</invoice> <invoice>site_id</invoice>
<invoice_item>site_id,invoice_item_id</invoice_item> <invoice_item>site_id,invoice_item_id</invoice_item>
<account>site_id,account_id</account> <account>site_id,account_id</account>
<billing>site_id,account_billing_id</billing> <billing>site_id,account_billing_id</billing>
@ -132,9 +132,6 @@
<recur_weekday> <recur_weekday>
<type>I4</type> <type>I4</type>
</recur_weekday> </recur_weekday>
<recur_week>
<type>I4</type>
</recur_week>
<recur_schedule_change> <recur_schedule_change>
<display>User Change Schedule</display> <display>User Change Schedule</display>
<type>L</type> <type>L</type>
@ -143,26 +140,9 @@
<display>User May Cancel</display> <display>User May Cancel</display>
<type>C(16)</type> <type>C(16)</type>
</recur_cancel> </recur_cancel>
<group_grant>
<type>X2</type>
<convert>array</convert>
</group_grant>
<group_type>
<type>I4</type>
</group_type>
<group_days>
<type>I4</type>
</group_days>
<host_server_id> <host_server_id>
<type>I4</type> <type>I4</type>
</host_server_id> </host_server_id>
<host_provision_plugin_data>
<type>X2</type>
<convert>array</convert>
</host_provision_plugin_data>
<host_ip>
<type>C(16)</type>
</host_ip>
<host_username> <host_username>
<display>Hosting User Name</display> <display>Hosting User Name</display>
<type>C(128)</type> <type>C(128)</type>
@ -200,9 +180,6 @@
<convert>array</convert> <convert>array</convert>
<type>X2</type> <type>X2</type>
</prod_attr> </prod_attr>
<prod_attr_cart>
<type>X2</type>
</prod_attr_cart>
<prod_plugin_name> <prod_plugin_name>
<type>C(128)</type> <type>C(128)</type>
</prod_plugin_name> </prod_plugin_name>
@ -214,23 +191,15 @@
<display>User May Modify</display> <display>User May Modify</display>
<type>L</type> <type>L</type>
</recur_modify> </recur_modify>
<invoice_advance_notified>
<type>L</type>
</invoice_advance_notified>
</field> </field>
<!-- Methods for this class, and the fields they have access to, if applicable --> <!-- Methods for this class, and the fields they have access to, if applicable -->
<method> <method>
<add>id,account_id,account_billing_id,product_id,sku,active,type,price,price_type,taxable,queue,date_last_invoice,date_next_invoice,recur_type,recur_schedule,recur_weekday,recur_week,recur_schedule_change,recur_cancel,group_grant,group_type,group_days,host_server_id,host_provision_plugin_data,host_ip,host_username,host_password,domain_name,domain_tld,domain_term,domain_type,domain_date_expire,domain_host_tld_id,domain_host_registrar_id,suspend_billing,prod_plugin_name,prod_plugin_data,recur_modify</add> <add>id,account_id,account_billing_id,product_id,sku,active,type,price,price_type,taxable,queue,date_last_invoice,date_next_invoice,recur_type,recur_schedule,recur_weekday,recur_schedule_change,recur_cancel,host_server_id,host_username,host_password,domain_name,domain_tld,domain_term,domain_type,domain_date_expire,domain_host_tld_id,domain_host_registrar_id,suspend_billing,prod_plugin_name,prod_plugin_data,recur_modify</add>
<update>id,date_last,account_id,account_billing_id,product_id,sku,active,type,price,taxable,queue,date_last_invoice,date_next_invoice,recur_type,recur_schedule,recur_weekday,recur_week,recur_schedule_change,recur_cancel,group_grant,group_type,group_days,host_server_id,host_provision_plugin_data,host_ip,host_username,host_password,domain_name,domain_tld,domain_term,domain_type,domain_date_expire,domain_host_tld_id,domain_host_registrar_id,suspend_billing,prod_plugin_name,prod_plugin_data,recur_modify,prod_attr</update> <update>id,date_last,account_id,account_billing_id,product_id,sku,active,type,price,taxable,queue,date_last_invoice,date_next_invoice,recur_type,recur_schedule,recur_weekday,recur_schedule_change,recur_cancel,host_server_id,host_username,host_password,domain_name,domain_tld,domain_term,domain_type,domain_date_expire,domain_host_tld_id,domain_host_registrar_id,suspend_billing,prod_plugin_name,prod_plugin_data,recur_modify,prod_attr</update>
<delete>id</delete> <delete>id</delete>
<view>id,date_orig,date_last,account_id,account_billing_id,product_id,sku,active,type,price,price_type,taxable,queue,date_last_invoice,date_next_invoice,recur_type,recur_schedule,recur_weekday,recur_week,recur_schedule_change,recur_cancel,group_grant,group_type,group_days,host_server_id,host_provision_plugin_data,host_ip,host_username,host_password,domain_name,domain_tld,domain_term,domain_type,domain_date_expire,domain_host_tld_id,domain_host_registrar_id,suspend_billing,prod_plugin_name,prod_plugin_data,recur_modify,prod_attr</view> <view>id,date_orig,date_last,account_id,account_billing_id,product_id,sku,active,type,price,price_type,taxable,queue,date_last_invoice,date_next_invoice,recur_type,recur_schedule,recur_weekday,recur_schedule_change,recur_cancel,host_server_id,host_username,host_password,domain_name,domain_tld,domain_term,domain_type,domain_date_expire,domain_host_tld_id,domain_host_registrar_id,suspend_billing,prod_plugin_name,prod_plugin_data,recur_modify,prod_attr</view>
<search>id,date_orig,date_last,account_id,account_billing_id,product_id,sku,active,type,price,price_type,taxable,queue,date_last_invoice,date_next_invoice,recur_type,recur_schedule,recur_weekday,recur_week,recur_schedule_change,recur_cancel,group_grant,group_type,group_days,host_server_id,host_provision_plugin_data,host_ip,host_username,host_password,domain_name,domain_tld,domain_term,domain_type,domain_date_expire,domain_host_tld_id,domain_host_registrar_id,suspend_billing,prod_plugin_name,prod_plugin_data,recur_modify,prod_attr</search> <search>id,date_orig,date_last,account_id,account_billing_id,product_id,sku,active,type,price,price_type,taxable,queue,date_last_invoice,date_next_invoice,recur_type,recur_schedule,recur_weekday,recur_schedule_change,recur_cancel,suspend_billing,prod_plugin_name,prod_plugin_data,recur_modify,prod_attr</search>
<search_export>id,date_last,account_id,account_billing_id,product_id,sku,active,type,price,price_type,taxable,queue,date_last_invoice,date_next_invoice,recur_type,recur_schedule,recur_weekday,host_server_id,host_ip,host_username,host_password,domain_name,domain_tld,domain_term,domain_type,domain_date_expire,domain_host_tld_id,domain_host_registrar_id,suspend_billing</search_export>
<export_excel>id,date_orig,date_last,account_id,account_billing_id,product_id,sku,active,type,price,price_type,taxable,queue,date_last_invoice,date_next_invoice,recur_type,recur_schedule,recur_weekday,host_server_id,host_ip,host_username,host_password,domain_name,domain_tld,domain_term,domain_type,domain_date_expire,domain_host_tld_id,domain_host_registrar_id,suspend_billing</export_excel>
<export_csv>id,date_orig,date_last,account_id,account_billing_id,product_id,sku,active,type,price,price_type,taxable,queue,date_last_invoice,date_next_invoice,recur_type,recur_schedule,recur_weekday,host_server_id,host_ip,host_username,host_password,domain_name,domain_tld,domain_term,domain_type,domain_date_expire,domain_host_tld_id,domain_host_registrar_id,suspend_billing</export_csv>
<export_tab>id,date_orig,date_last,account_id,account_billing_id,product_id,sku,active,type,price,price_type,taxable,queue,date_last_invoice,date_next_invoice,recur_type,recur_schedule,recur_weekday,host_server_id,host_ip,host_username,host_password,domain_name,domain_tld,domain_term,domain_type,domain_date_expire,domain_host_tld_id,domain_host_registrar_id,suspend_billing</export_tab>
<export_xml>id,date_orig,date_last,account_id,account_billing_id,product_id,sku,active,type,price,price_type,taxable,queue,date_last_invoice,date_next_invoice,recur_type,recur_schedule,recur_weekday,host_server_id,host_ip,host_username,host_password,domain_name,domain_tld,domain_term,domain_type,domain_date_expire,domain_host_tld_id,domain_host_registrar_id,suspend_billing</export_xml>
</method> </method>
<!-- Method triggers --> <!-- Method triggers -->

View File

@ -0,0 +1,36 @@
<!-- @todo NEEDS TO BE TRANSLATED -->
<table width="100%">
<tr>
<td class="head">Plugin Details</td>
</tr>
<tr>
<td style="width: 50%; vertical-align: top;">
<table>
<tr>
<td style="width: 40%;">Service Number</td>
<td style="width: 60%;" class="data"><?php echo Form::input('plugin[service_number]',$so->service_number); ?></td>
</tr>
<tr>
<td>Service Address</td>
<td class="data"><?php echo Form::input('plugin[service_address]',$so->service_address); ?></td>
</tr>
<tr>
<td>Service Connect Date</td>
<td class="data"><?php echo Form::input('plugin[service_connect_date]',$so->service_connect_date); ?></td>
</tr>
<tr>
<td>Service Username</td>
<td class="data"><?php echo Form::input('plugin[service_username]',$so->service_username); ?></td>
</tr>
<tr>
<td>Service Password</td>
<td class="data"><?php echo Form::input('plugin[service_password]',$so->service_password); ?></td>
</tr>
<tr>
<td>Service IP Address</td>
<td class="data"><?php echo Form::input('plugin[ipaddress]',$so->ipaddress); ?></td>
</tr>
</table>
</td>
</tr>
</table>

View File

@ -0,0 +1,62 @@
<!-- @todo NEEDS TO BE TRANSLATED -->
<?php echo Form::open(); ?>
<table width="100%">
<tr>
<td style="width: 50%; vertical-align: top;">
<table>
<tr>
<td style="width: 40%;">Service Active</td>
<td style="width: 60%;" class="data"><?php echo StaticList_YesNo::form('active',$so->active); ?></td>
</tr>
<tr>
<td>Queue</td>
<td class="data"><?php echo $so->display('queue'); ?></td>
</tr>
<tr>
<td>Billing Period</td>
<td class="data"><?php echo StaticList_RecurSchedule::form('recure_schedule',$so->product,$so->recur_schedule);?></td>
</tr>
<tr>
<td>Date Last Invoice</td>
<td class="data"><?php echo $so->display('date_last_invoice'); ?></td>
</tr>
<tr>
<td>Date Next Invoice</td>
<td class="data"><?php echo $so->display('date_next_invoice'); ?></td>
</tr>
<tr>
<td>Taxable</td>
<td class="data"><?php echo StaticList_YesNo::form('taxable',$so->taxable); ?></td>
</tr>
<tr>
<td>Type</td>
<td class="data"><?php echo StaticList_RecurType::display($so->recur_type); ?></td>
</tr>
<tr>
<td>Recur on Weekday</td>
<td class="data"><?php echo Form::input('recur_weekday',$so->recur_weekday,array('size'=>4)); ?></td>
</tr>
<tr>
<td>User Can Change Schedule</td>
<td class="data"><?php echo StaticList_YesNo::form('recur_schedule_change',$so->recur_schedule_change); ?></td>
</tr>
<tr>
<td>User Can Cancel</td>
<td class="data"><?php echo StaticList_YesNo::form('recur_cancel',$so->recur_cancel); ?></td>
</tr>
<tr>
<td>User Can Modify</td>
<td class="data"><?php echo StaticList_YesNo::form('recur_modify',$so->recur_modify); ?></td>
</tr>
<tr>
<td>Suspend Billing</td>
<td class="data"><?php echo StaticList_YesNo::form('suspend_billing',$so->suspend_billing); ?></td>
</tr>
</table>
<?php if ($plugin_form) { echo '<br/>'.$plugin_form; } ?>
<!-- END Service Information -->
</td>
</tr>
</table>
<?php echo Form::submit('submit',_('Update')); ?>
<?php echo Form::close(); ?>

View File

@ -0,0 +1,72 @@
<!-- //@todo To translate -->
<table class="box-full">
<tr>
<td class="head" colspan="2">Service Details</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td style="width: 50%">
<table>
<tr>
<td style="width: 40%;">Service Number</td>
<td style="width: 60%;" class="data"><?php echo $so->display('service_number'); ?></td>
</tr>
<tr>
<td>Service Address</td>
<td class="data"><?php echo $so->display('service_address'); ?></td>
</tr>
<tr>
<td>Contract Term</td>
<td class="data"><?php echo $so->display('contract_term'); ?></td>
</tr>
<tr>
<td>Connect Date</td>
<td class="data"><?php echo $so->display('service_connect_date'); ?></td>
</tr>
<tr>
<td>Contract End Date</td>
<td class="data"><?php echo $so->contract_date_end(); ?></td>
</tr>
<tr>
<td>Service Username</td>
<td class="data"><?php echo $so->display('service_username'); ?></td>
</tr>
<tr>
<td>Service Password</td>
<td class="data"><?php echo $so->display('service_password'); ?></td>
</tr>
<tr>
<td>Service IP</td>
<td class="data"><?php echo $so->ipaddress(); ?></td>
</tr>
</table>
</td>
<td style="width: 50%; vertical-align: top;">
<table width="100%">
<tr>
<td style="width: 40%;">Traffic Used This Month</td>
<td style="width: 60%;" class="data"><?php echo $so->traffic_month(null); ?></td>
</tr>
<tr>
<td style="width: 40%;">Traffic Used Last Month</td>
<td style="width: 60%;" class="data"><?php echo $so->traffic_lastmonth(); ?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td>View Daily Traffic for Month</td>
<td><?php echo Form::open(); echo Form::select('month',array_merge(array(''),$so->get_traffic_months()),(isset($_POST['month']) ? $_POST['month'] : '')); echo Form::submit('submit',_('Show')); echo Form::close(); ?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2"><?php echo $so->graph_traffic(isset($_POST['month']) ? $_POST['month'] : ''); ?><td>
</tr>
</table>

View File

@ -3,37 +3,62 @@
<tr> <tr>
<td> <td>
<!-- Service Information --> <!-- Service Information -->
<table> <table class="box-full">
<tr> <tr>
<td>Service Name</td> <td style="width: 40%;">Service Active</td>
<td class="head"><?php echo $service->product->product_translate->find()->name; ?></td> <td style="width: 60%;" class="data"><?php echo $so->display('active'); ?></td>
</tr>
<tr>
<td>Service Active</td>
<td class="head"><?php echo $service->display('active'); ?></td>
</tr> </tr>
<tr> <tr>
<td>Billing Period</td> <td>Billing Period</td>
<td class="head"><?php echo $service->display('recur_schedule');?></td> <td class="data"><?php echo $so->display('recur_schedule');?></td>
</tr> </tr>
<tr> <tr>
<td>Cost</td> <td>Cost</td>
<td class="head"><?php echo $service->display('price'); ?></td> <td class="data"><?php echo $so->display('price'); ?></td>
</tr> </tr>
<tr> <tr>
<td>Date Next Invoice</td> <td>Date Next Invoice</td>
<td class="head"><?php echo Config::date($service->date_next_invoice); ?></td> <td class="data"><?php echo $so->display('date_next_invoice'); ?></td>
</tr> </tr>
<tr> <tr>
<td>Current Invoices Due</td> <td>Current Invoices Due</td>
<td class="head"><?php echo Currency::display($service->account->invoices_due_total()); ?></td> <td class="data"><?php echo Currency::display($so->account->invoices_due_total()); ?></td>
</tr> </tr>
</table> </table>
<!-- END Service Information -->
</td> </td>
<td style="vertical-align: top;"> <td style="vertical-align: top;">
<!-- Product Info --> <!-- Product Summary Info -->
<?php echo $product_info; ?> <?php echo $so->product_feature_summary(); ?>
<!-- END Product Summary Info -->
</td> </td>
</tr> </tr>
</table> </table>
<?php echo $product_detail; ?> <br/>
<?php echo $so->service_view(); ?>
<br/>
<table class="box-left" width="50%">
<tr>
<td class="head" colspan="2">Invoices for this service</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2">Number</td>
<td>Invoice Date</td>
<td>Due Date</td>
<td>Total</td>
<td>Balance</td>
</tr>
<?php $i=0; foreach ($so->invoice->distinct('id')->order_by('id DESC')->find_all() as $io) { ?>
<tr class="<?php echo $i++%2 ? 'odd' : 'even'; ?>">
<td class="icon" width="20px"><?php echo HTML::anchor('/user/invoice/download/'.$io->id,HTML::image('media/img/gnome-pdf.png',array('alt'=>_('Download'),'width'=>20))); ?></td>
<td class="data"><?php echo HTML::anchor('/user/invoice/view/'.$io->id,$io->id()); ?></td>
<td class="data"><?php echo $io->display('date_orig'); ?></td>
<td class="data"><?php echo $io->display('due_date'); ?></td>
<td class="data"><?php echo $io->total(TRUE); ?></td>
<td class="data"><?php echo $io->due(TRUE); ?></td>
</tr>
<?php } ?>
</table>

View File

@ -1,32 +0,0 @@
<!-- @todo NEEDS TO BE TRANSLATED -->
<table>
<tr>
<td>View Daily Traffic for Month</td>
<td><?echo Form::open(); echo Form::select('month',$service->service_adsl->get_traffic_months(),(isset($_POST['month']) ? $_POST['month'] : '')); echo Form::submit('submit',_('Show')); echo Form::close(); ?></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td style="vertical-align: top" rowspan="2"><?php echo $graph; ?></td>
<td style="vertical-align: top" width="30%">
<table class="box-left">
<tr>
<td>ADSL Service</td>
<td class="head"><?php echo $service->service_adsl->service_number; ?></td>
</tr>
<tr>
<td>Contract Term</td>
<td class="head"><?php echo $service->service_adsl->contract_term; ?></td>
</tr>
<tr>
<td>Contract End</td>
<td class="head"><?php echo $service->service_adsl->contract_date_end(); ?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><?php echo $graph_data; ?></td>
</tr>
</table>