From 684b46f585f1f6fe26578e639d0911d65404bbd0 Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 14 May 2013 23:53:04 +1000 Subject: [PATCH] Overhauled export, and other minor updates --- application/classes/Config.php | 2 +- .../classes/Model/Module/Method/Token.php | 6 +- application/classes/ORM.php | 4 + application/classes/ORM/OSB.php | 4 + application/classes/StaticList/Module.php | 91 ------ application/views/account/user/edit.php | 4 +- application/views/errors/403.php | 5 - application/views/errors/404.php | 5 - application/views/errors/501.php | 6 - application/views/pages/register.php | 2 +- application/views/setup/admin/edit.php | 2 +- .../classes/Controller/Admin/Export.php | 130 ++++++-- .../classes/Controller/Affiliate/Export.php | 87 ------ .../classes/Controller/Reseller/Export.php | 104 +++++++ modules/export/classes/Export.php | 21 -- modules/export/classes/Export/Plugin.php | 19 ++ .../export/classes/Export/Plugin/Quicken.php | 288 ++++++++++++++++++ modules/export/classes/Export/Quicken.php | 217 ------------- modules/export/classes/Model/Export.php | 29 +- .../export/classes/Model/Export/DataMap.php | 36 +++ .../Payment.php => Model/Export/Item.php} | 11 +- .../export/classes/Model/Export/Module.php | 42 +++ modules/export/classes/OSBExport.php | 35 --- modules/export/classes/Quicken.php | 69 ----- modules/export/classes/Quicken/Invoice.php | 26 -- .../export/classes/Quicken/InvoiceItem.php | 14 - modules/export/views/export/admin/add.php | 41 +-- .../export/views/export/module/admin/edit.php | 20 ++ .../invoice/classes/Model/Invoice/Item.php | 13 + modules/lnApp | 2 +- modules/payment/classes/Model/Payment.php | 3 + modules/task/classes/Task/Task/Listactive.php | 2 +- modules/task/classes/Task/Task/Run.php | 2 +- 33 files changed, 690 insertions(+), 652 deletions(-) delete mode 100644 application/classes/StaticList/Module.php delete mode 100644 application/views/errors/403.php delete mode 100644 application/views/errors/404.php delete mode 100644 application/views/errors/501.php delete mode 100644 modules/export/classes/Controller/Affiliate/Export.php create mode 100644 modules/export/classes/Controller/Reseller/Export.php delete mode 100644 modules/export/classes/Export.php create mode 100644 modules/export/classes/Export/Plugin.php create mode 100644 modules/export/classes/Export/Plugin/Quicken.php delete mode 100644 modules/export/classes/Export/Quicken.php create mode 100644 modules/export/classes/Model/Export/DataMap.php rename modules/export/classes/{Quicken/Payment.php => Model/Export/Item.php} (55%) create mode 100644 modules/export/classes/Model/Export/Module.php delete mode 100644 modules/export/classes/OSBExport.php delete mode 100644 modules/export/classes/Quicken.php delete mode 100644 modules/export/classes/Quicken/Invoice.php delete mode 100644 modules/export/classes/Quicken/InvoiceItem.php create mode 100644 modules/export/views/export/module/admin/edit.php diff --git a/application/classes/Config.php b/application/classes/Config.php index a55e4405..0527e6b5 100644 --- a/application/classes/Config.php +++ b/application/classes/Config.php @@ -65,7 +65,7 @@ class Config extends Kohana_Config { } public static function date($date) { - return date(Company::instance()->date_format(),($date ? $date : time())); + return is_null($date) ? NULL : date(Company::instance()->date_format(),$date); } /** diff --git a/application/classes/Model/Module/Method/Token.php b/application/classes/Model/Module/Method/Token.php index dc47f564..02f17580 100644 --- a/application/classes/Model/Module/Method/Token.php +++ b/application/classes/Model/Module/Method/Token.php @@ -10,6 +10,9 @@ * @license http://dev.osbill.net/license.html */ class Model_Module_Method_Token extends ORM_OSB { + // This module doesnt keep track of column updates automatically + protected $_updated_column = FALSE; + // Relationships protected $_belongs_to = array( 'account'=>array(), @@ -19,9 +22,6 @@ class Model_Module_Method_Token extends ORM_OSB { 'record_id'=>array(), ); - // This module doesnt keep track of column updates automatically - protected $_update_column = FALSE; - public function method(array $modmeth) { list($module,$method) = $modmeth; diff --git a/application/classes/ORM.php b/application/classes/ORM.php index 6eb68d52..a80fa536 100644 --- a/application/classes/ORM.php +++ b/application/classes/ORM.php @@ -115,6 +115,10 @@ abstract class ORM extends Kohana_ORM { return $value; } + public function display_filters(array $filters) { + $this->_display_filters = Arr::merge($this->_display_filters,$filters); + } + /** * Function help to find records that are active */ diff --git a/application/classes/ORM/OSB.php b/application/classes/ORM/OSB.php index 70930531..0237aed2 100644 --- a/application/classes/ORM/OSB.php +++ b/application/classes/ORM/OSB.php @@ -171,6 +171,10 @@ abstract class ORM_OSB extends ORM { return array_key_exists($key,$this->$column) ? $this->{$column}[$key] : NULL; } + final public function module() { + return ORM::factory(Kohana::classname($this->name)); + } + final public function mid() { return ORM::factory('Module',array('name'=>$this->_table_name)); } diff --git a/application/classes/StaticList/Module.php b/application/classes/StaticList/Module.php deleted file mode 100644 index ffd33df5..00000000 --- a/application/classes/StaticList/Module.php +++ /dev/null @@ -1,91 +0,0 @@ -from($table)->where($skey,'=',$value)->execute(); - - if ($db->count() !== 1) - return sprintf('No Value (%s)',$value); - else - return $db->get($key); - } - - /** - * This function is to return the cached value of the current active record - * This is so that a follow up call to get an attribute of a value retrieved - * can reuse the active record values. - * This gets over a limitation where the query to form() to get a default - * no longer exists (or is invalid) and you want other attributes of the - * remaining active record, which may not be the default record. - */ - public static function record($table,$attribute,$skey,$value) { - if (empty(static::$record[$table])) - return static::display($table,$attribute,$skey,$value); - else - return static::$record[$table][$attribute]; - } - - /** - * Renders form input - */ - public static function form($name,$default='',$addblank=FALSE) { - // Override our argument list as defined in parent - list($name,$table,$default,$key,$value,$where,$addblank,$attributes) = func_get_args(); - - $db = DB::select()->from($table); - - foreach ($where as $k=>$v) { - list ($op,$v) = explode(':',$v); - $db->where($k,$op,$v); - } - - $db = $db->execute(); - - // If we only have one record, dont make a select list - if ($db->count() == 1) { - static::$record[$table] = $db->as_array(); - static::$record[$table] = array_shift(static::$record[$table]); - - return Form::hidden($name,$db->get($key)).$db->get($value); - } - - // Else we return a select list - $x = array(); - if ($addblank) - $x[] = ''; - - foreach ($db as $record) { - $x[$record[$key]] = $record[$value]; - - // Save our static record, in case we reference this item again. - if ($record[$key] == $default) - static::$record[$table] = $record; - } - - return Form::select($name,$x,$default,$attributes); - } - - public static function get($value) { - return static::factory()->_get($value); - } -} -?> diff --git a/application/views/account/user/edit.php b/application/views/account/user/edit.php index b7545e7f..bde82b3f 100644 --- a/application/views/account/user/edit.php +++ b/application/views/account/user/edit.php @@ -52,8 +52,8 @@
- - + +
diff --git a/application/views/errors/403.php b/application/views/errors/403.php deleted file mode 100644 index e0e0516a..00000000 --- a/application/views/errors/403.php +++ /dev/null @@ -1,5 +0,0 @@ -

Oops!

-

403 Not Found or Not Authorised?

-
- Sorry, either the item doesnt exist, or you are not authorised to see it. -
diff --git a/application/views/errors/404.php b/application/views/errors/404.php deleted file mode 100644 index 539ad469..00000000 --- a/application/views/errors/404.php +++ /dev/null @@ -1,5 +0,0 @@ -

Oops!

-

404 Not Found?

-
- Sorry, an error has occured, requested page not found? -
diff --git a/application/views/errors/501.php b/application/views/errors/501.php deleted file mode 100644 index 29350929..00000000 --- a/application/views/errors/501.php +++ /dev/null @@ -1,6 +0,0 @@ -

Oops!

-

501 Bother, something went wrong.

- -
- If this keeps happening, please let us know. -
diff --git a/application/views/pages/register.php b/application/views/pages/register.php index 0164d34e..268b7f98 100644 --- a/application/views/pages/register.php +++ b/application/views/pages/register.php @@ -57,7 +57,7 @@ Country - + list_select(),$o->country_id,array('label'=>'Country','required')); ?> + diff --git a/modules/export/views/export/module/admin/edit.php b/modules/export/views/export/module/admin/edit.php new file mode 100644 index 00000000..a9c8371a --- /dev/null +++ b/modules/export/views/export/module/admin/edit.php @@ -0,0 +1,20 @@ +
+
+
+ Export Module Update + +

Available module->table_name(); ?> Columns to display

+ + data($o->module->module()->table_columns()) + ->jssort(FALSE) + ->columns(array( + 'column_name'=>'Name', + )) + ->select(URL::link('reseller','export/export'),$o->id,array('export_module_id'=>$o->id)) + ->prepend(array( + 'column_name'=>array('input'=>array('key'=>'display[__VALUE__]','values'=>$o->display)), + )); ?> +
+
+
diff --git a/modules/invoice/classes/Model/Invoice/Item.php b/modules/invoice/classes/Model/Invoice/Item.php index 2835a9f9..2b85f970 100644 --- a/modules/invoice/classes/Model/Invoice/Item.php +++ b/modules/invoice/classes/Model/Invoice/Item.php @@ -84,6 +84,19 @@ class Model_Invoice_Item extends ORM_OSB { return Currency::round($result); } + public function tax_items() { + $result = array(); + + foreach ($this->invoice_item_tax->find_all() as $iit) { + if (! isset($result[$iit->tax_id])) + $result[$iit->tax_id] = 0; + + $result[$iit->tax_id] += $iit->amount; + } + + return $result; + } + // This total of this item before discounts and taxes public function subtotal() { return Currency::round($this->price_base*$this->quantity); diff --git a/modules/lnApp b/modules/lnApp index b65ddab2..41e777bd 160000 --- a/modules/lnApp +++ b/modules/lnApp @@ -1 +1 @@ -Subproject commit b65ddab2d0499e00e2b0e4caebc2178433b25c5b +Subproject commit 41e777bd9d85fdc9d32a3aa22f916d0d94530048 diff --git a/modules/payment/classes/Model/Payment.php b/modules/payment/classes/Model/Payment.php index 9df00880..fb05d657 100644 --- a/modules/payment/classes/Model/Payment.php +++ b/modules/payment/classes/Model/Payment.php @@ -25,6 +25,9 @@ class Model_Payment extends ORM_OSB { ); protected $_display_filters = array( + 'date_orig'=>array( + array('Config::date',array(':value')), + ), 'date_payment'=>array( array('Config::date',array(':value')), ), diff --git a/modules/task/classes/Task/Task/Listactive.php b/modules/task/classes/Task/Task/Listactive.php index deee9918..de674c8c 100644 --- a/modules/task/classes/Task/Task/Listactive.php +++ b/modules/task/classes/Task/Task/Listactive.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Task_Task_Listactive extends Task { +class Task_Task_Listactive extends Minion_Task { protected function _execute(array $params) { $header = "%2s %30s %21s %21s %40s\n"; diff --git a/modules/task/classes/Task/Task/Run.php b/modules/task/classes/Task/Task/Run.php index 2a330033..eac08fda 100644 --- a/modules/task/classes/Task/Task/Run.php +++ b/modules/task/classes/Task/Task/Run.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Task_Task_Run extends Task { +class Task_Task_Run extends Minion_Task { protected function _execute(array $params) { if ($params['id']) { $to = ORM::factory('Task',$params['id']);