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 @@ Sub Total of Items: subtotal(TRUE); ?>  - discount()) { ?> + total_discounts()) { ?> Discounts: - (discount(TRUE); ?>) + (total_discounts(TRUE); ?>) diff --git a/modules/invoice/views/invoice/user/view.php b/modules/invoice/views/invoice/user/view.php index 8a281d59..875bc702 100644 --- a/modules/invoice/views/invoice/user/view.php +++ b/modules/invoice/views/invoice/user/view.php @@ -168,19 +168,19 @@ subtotal(TRUE); ?> - credit_amt) { ?> + total_credits()) { ?> Credits Received: - display('credit_amt'); ?> + total_credits(TRUE); ?> - total_discount()) { ?> + total_discounts()) { ?> Discounts: - (total_discount(TRUE); ?>) + (total_discounts(TRUE); ?>) diff --git a/modules/payment/classes/Payment/Bulk/Ezypay.php b/modules/payment/classes/Payment/Bulk/Ezypay.php index 54bc67eb..4fe66ffb 100644 --- a/modules/payment/classes/Payment/Bulk/Ezypay.php +++ b/modules/payment/classes/Payment/Bulk/Ezypay.php @@ -42,7 +42,7 @@ class Payment_Bulk_Ezypay { // Field 4 has our account reference if (preg_match('/^'.Company::instance()->site(TRUE).'-/',$array[4]) AND $array[10] == 'Cleared') { - $aid = preg_replace('/^'.Compan::instance()->site(TRUE).'-/','',$array[4]); + $aid = preg_replace('/^'.Company::instance()->site(TRUE).'-/','',$array[4]); $po = ORM::factory('Payment'); $po->account_id = $aid; @@ -85,7 +85,7 @@ class Payment_Bulk_Ezypay { } $return = ''; - $return .= View::Factory('Payment/Admin/Addbulk/Ezypay/head'); + $return .= View::Factory('payment/admin/addbulk/ezypay/head'); $total = $fees = 0; foreach ($payments as $po) { @@ -94,11 +94,11 @@ class Payment_Bulk_Ezypay { $total += $po->total_amt; $fees += $po->fees_amt; - $return .= View::Factory('Payment/Admin/Addbulk/Ezypay/body') + $return .= View::Factory('payment/admin/addbulk/ezypay/body') ->set('o',$po); } - $return .= View::Factory('Payment/Admin/Addbulk/Ezypay/foot') + $return .= View::Factory('payment/admin/addbulk/ezypay/foot') ->set('total',$total) ->set('fees',$fees);; diff --git a/modules/service/classes/Controller/Admin/Service.php b/modules/service/classes/Controller/Admin/Service.php index 21788e11..13f2c536 100644 --- a/modules/service/classes/Controller/Admin/Service.php +++ b/modules/service/classes/Controller/Admin/Service.php @@ -68,10 +68,17 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { * Show a list of services */ public function action_list() { + $id = $this->request->param('id'); + + $svs = ORM::factory('Service'); + + if ($id) + $svs->where_active()->and_where('account_id','=',$id); + Block::add(array( 'title'=>_('Customer Services'), 'body'=>Table::display( - ORM::factory('Service')->find_all(), + $svs->find_all(), 25, array( 'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')), @@ -195,7 +202,16 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { } public function action_listadslservices() { - $svs = ORM::factory('Service')->list_bylistgroup('ADSL'); + $id = $this->request->param('id'); + + $svs = $list = ORM::factory('Service')->list_bylistgroup('ADSL'); + + if ($id) { + $svs = array(); + foreach ($list as $so) + if ($so->account_id == $id) + array_push($svs,$so); + } $google = GoogleChart::factory('ComboChart') ->dataurl(URL::link('admin','service/ajaxjson_traffic',TRUE)) @@ -732,6 +748,8 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin { $save = (isset($_REQUEST['go']) && $_REQUEST['go']=1) ? 1 : 0; $xsid=197; foreach ($so->transactions()->where('item_type','=',0)->find_all() as $iio) { + if (! $iio->invoice->status) continue; + // @todo This hard coding of 3070 should be removed. if ($iio->service_id == $xsid AND $iio->invoice_id < 3070) continue; if ($iio->quantity < 0 OR $iio->price_base < 0) continue; diff --git a/modules/statement/classes/controller/admin/statement.php b/modules/statement/classes/Controller/Admin/Statement.php similarity index 100% rename from modules/statement/classes/controller/admin/statement.php rename to modules/statement/classes/Controller/Admin/Statement.php