From e8ed74549ad9a35aa99e6cf84e355193bfdd2c30 Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 28 May 2013 21:35:54 +1000 Subject: [PATCH] Improved User Welcome --- application/classes/Company.php | 2 +- .../classes/Controller/User/Welcome.php | 58 +++++++++++++++++-- application/classes/Kohana.php | 7 +-- application/views/welcome/user/shortcuts.php | 4 ++ modules/export/classes/Model/Export.php | 2 +- .../export/classes/Model/Export/DataMap.php | 2 +- modules/export/classes/Model/Export/Item.php | 2 +- .../export/classes/Model/Export/Module.php | 2 +- modules/invoice/classes/Model/Invoice.php | 9 +++ 9 files changed, 75 insertions(+), 13 deletions(-) create mode 100644 application/views/welcome/user/shortcuts.php diff --git a/application/classes/Company.php b/application/classes/Company.php index 213a1ff9..88ac3aed 100644 --- a/application/classes/Company.php +++ b/application/classes/Company.php @@ -13,7 +13,7 @@ class Company { // Our Company Setup object private $so; - public function __construct(Model_Setup $so) { + protected function __construct(Model_Setup $so) { $this->so = $so; if (! $this->so->loaded()) diff --git a/application/classes/Controller/User/Welcome.php b/application/classes/Controller/User/Welcome.php index af752976..f6ed6883 100644 --- a/application/classes/Controller/User/Welcome.php +++ b/application/classes/Controller/User/Welcome.php @@ -16,10 +16,60 @@ class Controller_User_Welcome extends Controller_Welcome { ); public function action_index() { - Block::add(array( - 'title'=>sprintf('%s: %s',$this->ao->accnum(),$this->ao->name(TRUE)), - 'body'=>View::factory('welcome/user'), - )); + Block::factory() + ->title(sprintf('Active Service for Account: %s',$this->ao->accnum())) + ->title_icon('icon-info-sign') + ->span(6) + ->body(Table::factory() + ->data($this->ao->service->list_active()) + ->jssort('service') + ->columns(array( + 'id'=>'ID', + 'service_name()'=>'Service', + )) + ->prepend(array( + 'id'=>array('url'=>URL::link('user','service/view/')), + )) + ); + + Block::factory() + ->title('Quick Shortcuts') + ->title_icon('icon-bookmark') + ->span(6) + ->body(View::factory('welcome/user/shortcuts')); + + Block::factory() + ->title(sprintf('Invoices Due Account: %s (%s)',$this->ao->accnum(),$this->ao->invoice->list_due_total(TRUE))) + ->title_icon('icon-info-sign') + ->span(6) + ->body(Table::factory() + ->data($this->ao->invoice->list_due()) + ->columns(array( + 'id'=>'ID', + 'due_date'=>'Date Due', + 'total(TRUE)'=>'Invoice Total', + 'due(TRUE)'=>'Amount Due', + )) + ->prepend(array( + 'id'=>array('url'=>URL::link('user','invoice/view/')), + )) + ); + + Block::factory() + ->title(sprintf('Services Expiring for Account: %s',$this->ao->accnum())) + ->title_icon('icon-info-sign') + ->span(6) + ->body(Table::factory() + ->data($this->ao->service->list_expiring()) + ->columns(array( + 'id'=>'ID', + 'service_name()'=>'Service', + 'expire(TRUE)'=>'Date', + )) + ->prepend(array( + 'id'=>array('url'=>URL::link('user','service/view/')), + )) + ); } } ?> diff --git a/application/classes/Kohana.php b/application/classes/Kohana.php index 1865e16b..4664ef92 100644 --- a/application/classes/Kohana.php +++ b/application/classes/Kohana.php @@ -42,12 +42,11 @@ abstract class Kohana extends Kohana_Core { '', ); - foreach ($prefixes as $p) { + foreach ($prefixes as $p) if ($x = parent::find_file($dir,$p.$file,$ext,$array)) - return $x; - } + break; - // We found a site path. + // We found a path. return $x; } diff --git a/application/views/welcome/user/shortcuts.php b/application/views/welcome/user/shortcuts.php new file mode 100644 index 00000000..98762d2a --- /dev/null +++ b/application/views/welcome/user/shortcuts.php @@ -0,0 +1,4 @@ +
+ Invoices + Services +
diff --git a/modules/export/classes/Model/Export.php b/modules/export/classes/Model/Export.php index 71d81cc3..149f8d7a 100644 --- a/modules/export/classes/Model/Export.php +++ b/modules/export/classes/Model/Export.php @@ -4,7 +4,7 @@ * This class supports OSB exporting. * * @package Export - * @category Model + * @category Models * @author Deon George * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html diff --git a/modules/export/classes/Model/Export/DataMap.php b/modules/export/classes/Model/Export/DataMap.php index 6bbd5d2f..05ee7a8a 100644 --- a/modules/export/classes/Model/Export/DataMap.php +++ b/modules/export/classes/Model/Export/DataMap.php @@ -4,7 +4,7 @@ * This class supports OSB exporting. * * @package Export - * @category Model + * @category Models * @author Deon George * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html diff --git a/modules/export/classes/Model/Export/Item.php b/modules/export/classes/Model/Export/Item.php index ee901886..e46b9ffd 100644 --- a/modules/export/classes/Model/Export/Item.php +++ b/modules/export/classes/Model/Export/Item.php @@ -4,7 +4,7 @@ * This class supports OSB exporting. * * @package Export - * @category Model + * @category Models * @author Deon George * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html diff --git a/modules/export/classes/Model/Export/Module.php b/modules/export/classes/Model/Export/Module.php index 9e057255..246997c5 100644 --- a/modules/export/classes/Model/Export/Module.php +++ b/modules/export/classes/Model/Export/Module.php @@ -4,7 +4,7 @@ * This class supports OSB exporting. * * @package Export - * @category Model + * @category Models * @author Deon George * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html diff --git a/modules/invoice/classes/Model/Invoice.php b/modules/invoice/classes/Model/Invoice.php index a609d3b8..4a5f9842 100644 --- a/modules/invoice/classes/Model/Invoice.php +++ b/modules/invoice/classes/Model/Invoice.php @@ -620,6 +620,15 @@ class Model_Invoice extends ORM_OSB implements Cartable { return $result; } + public function list_due_total($format=FALSE,$time=NULL) { + $result = 0; + + foreach ($this->list_due($time) as $io) + $result += $io->due(); + + return $format ? Currency::display($result) : Currency::round($result); + } + /** * Return a list of invoices that need to be sent. * @todo This should be optimised a little to return only invoices to send, instead of looking for them.