diff --git a/application/classes/Config.php b/application/classes/Config.php index 6f2b7d98..e16eacee 100644 --- a/application/classes/Config.php +++ b/application/classes/Config.php @@ -31,15 +31,6 @@ class Config extends Kohana_Config { public function __construct() { if (defined('PHPUNITTEST')) $_SERVER['SERVER_NAME'] = PHPUNITTEST; - - // We need to know our site here, so that we can subsequently load our enabled modules. - if (Kohana::$is_cli) { - if (! $site = Minion_CLI::options('site')) - // @todo Need to figure out how to make this CLI error nicer. - throw new Minion_Exception_InvalidTask(_('Cant figure out the site, use --site= for CLI')); - else - $_SERVER['SERVER_NAME'] = $site; - } } /** @@ -116,9 +107,19 @@ class Config extends Kohana_Config { public static function modules() { static $return = array(); - if (! count($return)) + if (! count($return)) { + // We need to know our site here, so that we can subsequently load our enabled modules. + if (PHP_SAPI === 'cli') { + if (! $site = Minion_CLI::options('site')) + // @todo Need to figure out how to make this CLI error nicer. + throw new Minion_Exception_InvalidTask(_('Cant figure out the site, use --site= for CLI')); + else + $_SERVER['SERVER_NAME'] = $site; + } + foreach (ORM::factory('Module')->list_external() as $mo) $return[$mo->name] = MODPATH.$mo->name; + } return $return; } diff --git a/application/classes/URL.php b/application/classes/URL.php index 3174e142..8ef0b9c8 100644 --- a/application/classes/URL.php +++ b/application/classes/URL.php @@ -16,6 +16,7 @@ class URL extends Kohana_URL { 'admin'=>'a', 'affiliate'=>'affiliate', // @todo To retire 'reseller'=>'r', + 'task'=>'task', 'user'=>'u', ); diff --git a/application/config/config.php b/application/config/config.php index 266eaec3..9598681f 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -12,7 +12,7 @@ */ return array( - 'appname' => 'OS Billing', + 'appname' => 'OS Billing', // Our application name, as shown in the title bar of pages 'cache_type' => 'file', 'email_from' => array('noreply@graytech.net.au'=>'Graytech Hosting'), 'email_admin_only'=> array( diff --git a/application/config/userguide.php b/application/config/userguide.php new file mode 100644 index 00000000..e8443653 --- /dev/null +++ b/application/config/userguide.php @@ -0,0 +1,46 @@ + TRUE, + + // Enable these packages in the API browser. TRUE for all packages, or a string of comma seperated packages, using 'None' for a class with no @package + // Example: 'api_packages' => 'Kohana,Kohana/Database,Kohana/ORM,None', + 'api_packages' => TRUE, + + // Enables Disqus comments on the API and User Guide pages + 'show_comments' => Kohana::$environment === Kohana::PRODUCTION, + + // Leave this alone + 'modules' => array( + + 'kohana' => array('enabled'=>FALSE), + 'auth' => array('enabled'=>FALSE), + 'cache' => array('enabled'=>FALSE), + 'database' => array('enabled'=>FALSE), + 'minion' => array('enabled'=>FALSE), + 'orm' => array('enabled'=>FALSE), + 'pagination' => array('enabled'=>FALSE), + // This should be the path to this modules userguide pages, without the 'guide/'. Ex: '/guide/modulename/' would be 'modulename' + 'userguide' => array( + + // Whether this modules userguide pages should be shown + 'enabled' => TRUE, + + // The name that should show up on the userguide index page + 'name' => 'Userguide', + + // A short description of this module, shown on the index page + 'description' => 'Documentation viewer and api generation.', + + // Copyright message, shown in the footer for this module + 'copyright' => '© 2008–2012 Kohana Team', + ) + ), + + // Set transparent class name segments + 'transparent_prefixes' => array( + 'Kohana' => TRUE, + ) +); diff --git a/modules/checkout/classes/Checkout/Plugin/Paypal/Cart.php b/modules/checkout/classes/Checkout/Plugin/Paypal/Cart.php index dc7da88c..67b0fc7e 100644 --- a/modules/checkout/classes/Checkout/Plugin/Paypal/Cart.php +++ b/modules/checkout/classes/Checkout/Plugin/Paypal/Cart.php @@ -11,7 +11,7 @@ * @license http://dev.leenooks.net/license.html */ class Checkout_Plugin_Paypal_Cart extends Checkout_Plugin_Paypal { - private $test_mode = TRUE; + private $test_mode = FALSE; /** * Set payment via Paypal diff --git a/modules/export/classes/Export/Quicken.php b/modules/export/classes/Export/Quicken.php index 11808677..2f2970d8 100644 --- a/modules/export/classes/Export/Quicken.php +++ b/modules/export/classes/Export/Quicken.php @@ -147,14 +147,14 @@ class Export_Quicken extends Export { # @todo, get this from OSB $qto->TAXCODE = 'GST'; $qto->TAXRATE = sprintf('%3.2f%%','0.10'); - $tax = round($pio->invoice->credit_amt/11,2); + $tax = round($pio->invoice->total_credits()/11,2); $qto->TAXAMOUNT = sprintf('%3.2f',$tax); } else { $qto->TAXAMOUNT = 0; } - $qto->PRICE = sprintf('%3.2f',round(($pio->invoice->credit_amt-$tax)*-1,2)); - $qto->AMOUNT = sprintf('%3.2f',round(($pio->invoice->credit_amt-$tax),2)); + $qto->PRICE = sprintf('%3.2f',round(($pio->invoice->total_credits()-$tax)*-1,2)); + $qto->AMOUNT = sprintf('%3.2f',round(($pio->invoice->total_credits()-$tax),2)); $qio->addInvoiceItem($qto); $qo->addInvoice($qio); diff --git a/modules/invoice/classes/Controller/Admin/Invoice.php b/modules/invoice/classes/Controller/Admin/Invoice.php index e2c9f6ef..665263c5 100644 --- a/modules/invoice/classes/Controller/Admin/Invoice.php +++ b/modules/invoice/classes/Controller/Admin/Invoice.php @@ -40,16 +40,23 @@ class Controller_Admin_Invoice extends Controller_TemplateDefault_Admin { * Show a list of invoices */ public function action_list() { + $id = $this->request->param('id'); + + $invs = ORM::factory('Invoice'); + + if ($id) + $invs->where('account_id','=',$id); + Block::add(array( 'title'=>_('System Customer Invoices'), 'body'=>Table::display( - ORM::factory('Invoice')->find_all(), + $invs->find_all(), 25, array( 'id'=>array('label'=>'ID','url'=>URL::link('user','invoice/view/')), 'date_orig'=>array('label'=>'Date'), 'total(TRUE)'=>array('label'=>'Total','class'=>'right'), - 'credit_amt'=>array('label'=>'Credits','class'=>'right'), + 'total_credits(TRUE)'=>array('label'=>'Credits','class'=>'right'), 'payments_total(TRUE)'=>array('label'=>'Payments','class'=>'right'), 'due(TRUE)'=>array('label'=>'Still Due','class'=>'right'), 'account->accnum()'=>array('label'=>'Cust ID'), diff --git a/modules/invoice/classes/Controller/Task/Invoice.php b/modules/invoice/classes/Controller/Task/Invoice.php index 92f11ead..366adb4f 100644 --- a/modules/invoice/classes/Controller/Task/Invoice.php +++ b/modules/invoice/classes/Controller/Task/Invoice.php @@ -128,7 +128,7 @@ class Controller_Task_Invoice extends Controller_Task { $et->variables = array( 'DUE'=>$io->due(TRUE), 'DUE_DATE'=>$io->display('due_date'), - 'EMAIL'=>Company::email(), + 'EMAIL'=>Company::instance()->email(), 'FIRST_NAME'=>$io->account->first_name, 'INV_NUM'=>$io->refnum(), 'INV_URL'=>URL::site(URL::link('user','invoice/view/'.$io->id),'http'), @@ -299,7 +299,7 @@ class Controller_Task_Invoice extends Controller_Task { $et->variables = array( 'DUE'=>$io->due(TRUE), 'DUE_DATE'=>$io->display('due_date'), - 'EMAIL'=>Company::email(), + 'EMAIL'=>Company::instance()->email(), 'FIRST_NAME'=>$io->account->first_name, 'HTML_INVOICE'=>$io->html(), 'INV_NUM'=>$io->refnum(), diff --git a/modules/invoice/classes/Controller/User/Invoice.php b/modules/invoice/classes/Controller/User/Invoice.php index 01b26816..11695022 100644 --- a/modules/invoice/classes/Controller/User/Invoice.php +++ b/modules/invoice/classes/Controller/User/Invoice.php @@ -31,7 +31,7 @@ class Controller_User_Invoice extends Controller_TemplateDefault_User { 'date_orig'=>array('label'=>'Date Issued'), 'due_date'=>array('label'=>'Date Due'), 'total(TRUE)'=>array('label'=>'Total','class'=>'right'), - 'credit_amt'=>array('label'=>'Credits','class'=>'right'), + 'total_credits(TRUE)'=>array('label'=>'Credits','class'=>'right'), 'payments_total(TRUE)'=>array('label'=>'Payments','class'=>'right'), 'due(TRUE)'=>array('label'=>'Still Due','class'=>'right'), ), diff --git a/modules/invoice/classes/Invoice/TCPDF/Default.php b/modules/invoice/classes/Invoice/TCPDF/Default.php index e4b30399..0b00df2b 100644 --- a/modules/invoice/classes/Invoice/TCPDF/Default.php +++ b/modules/invoice/classes/Invoice/TCPDF/Default.php @@ -135,7 +135,7 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF { // Draw a box. $this->SetFillColor(245); - $this->SetXY($x-1,$y-1); $this->Cell(0,35+5+($this->io->credit_amt ? 5 : 0),'',1,0,'',1); + $this->SetXY($x-1,$y-1); $this->Cell(0,35+5+($this->io->total_credits() ? 5 : 0),'',1,0,'',1); // Draw a box around the invoice due date and amount due. $this->SetFont('helvetica','B',11); @@ -172,12 +172,12 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF { $this->SetFont('helvetica','B',11); $this->SetXY($x+55,$y); $this->Cell(0,0,$this->io->payments_total('TRUE'),0,0,'R'); - if ($this->io->credit_amt) { + if ($this->io->total_credits()) { $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'); + $this->SetXY($x+55,$y); $this->Cell(0,0,$this->io->total_credits(TRUE),0,0,'R'); } $y += 5; @@ -319,7 +319,7 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF { $this->SetFillColor(245); $this->SetXY($x-1,$y-1); $this->Cell(0,5*( - 1+1+1+3+($this->io->discount_amt ? 1 : 0)+1+($this->io->credit_amt ? 1 : 0)+$box + 1+1+1+3+($this->io->total_discounts() ? 1 : 0)+1+($this->io->total_credits() ? 1 : 0)+$box )+1+4,'',1,0,'',1); $this->SetFont('helvetica','B',11); @@ -355,7 +355,7 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF { // Calculate our rounding error // @todo This shouldnt be required. - $subtotal = Currency::round($subtotal-$this->io->discount_amt); + #$subtotal = Currency::round($subtotal-$this->io->total_discounts()); if (Currency::round($this->io->subtotal()) != $subtotal) { $this->SetFont('helvetica','',9); @@ -369,7 +369,7 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF { } // Draw Discounts. - if ($this->io->discount_amt) { + if ($this->io->total_discounts()) { $y += 5; $this->SetY($y); @@ -377,7 +377,7 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF { $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'); + $this->Cell(0,0,Currency::display(-$this->io->total_discounts()),0,0,'R'); } // Subtotal and tax. @@ -415,7 +415,7 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF { $this->SetX($x+135); $this->Cell(0,0,$this->io->payments_total(TRUE),0,0,'R'); - if ($this->io->credit_amt) { + if ($this->io->total_credits()) { $y += 5; $this->SetY($y); @@ -423,7 +423,7 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF { $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'); + $this->Cell(0,0,Currency::display(-$this->io->total_credits()),0,0,'R'); } $y += 5; @@ -479,7 +479,7 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF { $this->SetFont('helvetica','',8); $this->SetX($x); - $this->Cell(0,0,$ito->service->service_name()); + $this->Cell(0,0,sprintf('%s - %s',$ito->product->name(),$ito->service->name())); if ($ito->price_base) { $this->SetX($x+160); diff --git a/modules/invoice/classes/Model/Invoice.php b/modules/invoice/classes/Model/Invoice.php index b08df1e0..8e54da6c 100644 --- a/modules/invoice/classes/Model/Invoice.php +++ b/modules/invoice/classes/Model/Invoice.php @@ -503,12 +503,10 @@ class Model_Invoice extends ORM_OSB implements Cartable { if ($this->loaded() AND ! count($this->items())) $this->_load_sub_items(); + // This will include charges and credits foreach ($this->items() as $ito) $result += $ito->total(); - // Reduce by any credits - $result -= $this->credit_amt; - return $format ? Currency::display($result) : Currency::round($result); } @@ -524,17 +522,13 @@ class Model_Invoice extends ORM_OSB implements Cartable { public function total_credits($format=FALSE) { $result = 0; - // @todo Remove when credit_amt is dropped. - if ($this->credit_amt) - $result = $this->credit_amt; - foreach ($this->items('CREDIT') as $ito) $result += ($ito->subtotal()+$ito->tax())*-1; return $format ? Currency::display($result) : Currency::round($result); } - public function total_discount($format=FALSE) { + public function total_discounts($format=FALSE) { $result = 0; foreach ($this->items() as $ito) diff --git a/modules/invoice/views/invoice/user/email.php b/modules/invoice/views/invoice/user/email.php index 121f059f..3c7cd8f4 100644 --- a/modules/invoice/views/invoice/user/email.php +++ b/modules/invoice/views/invoice/user/email.php @@ -111,10 +111,10 @@