From 07de13f67800dba8c8d28727cf8c520c977d619c Mon Sep 17 00:00:00 2001 From: Deon George Date: Mon, 15 Aug 2016 21:23:18 +1000 Subject: [PATCH] Removed redundant functions, some Standardisation work --- .../Controller/Admin/Module/Method.php | 2 +- .../classes/Controller/TemplateDefault.php | 13 +-- application/classes/Model/Account.php | 30 ++--- application/classes/Model/Account/Log.php | 2 +- application/classes/Model/Country.php | 2 +- application/classes/Model/Currency.php | 2 +- application/classes/Model/Group/Method.php | 2 +- application/classes/Model/Language.php | 2 +- application/classes/Model/Log/Error.php | 2 +- application/classes/Model/Module.php | 2 +- application/classes/Model/Module/Method.php | 2 +- .../classes/Model/Module/Method/Token.php | 2 +- application/classes/Model/RTM.php | 2 +- application/classes/Model/Record/ID.php | 2 +- application/classes/Model/Setup.php | 2 +- application/classes/ORM/OSB.php | 14 --- .../adsl/classes/Controller/Admin/Adsl.php | 2 +- modules/adsl/classes/Model/ADSL/Supplier.php | 2 +- .../adsl/classes/Model/ADSL/Supplier/Plan.php | 2 +- .../Model/Service/Plugin/Adsl/Traffic.php | 2 +- .../category/list/adslcompare-large.php | 6 +- .../product/category/list/adslcompare.php | 6 +- modules/cart/classes/Model/Cart.php | 2 +- modules/charge/classes/Controller/Charge.php | 1 + .../classes/Controller/Reseller/Charge.php | 69 +---------- modules/charge/classes/Model/Charge.php | 26 +---- .../charge/views/charge/reseller/add_edit.php | 71 +++++++----- modules/checkout/classes/Model/Checkout.php | 10 +- .../classes/Model/Checkout/Notify.php | 6 +- .../domain/classes/Model/Domain/Registrar.php | 2 +- modules/domain/classes/Model/Domain/TLD.php | 2 +- modules/email/classes/Model/Email/Log.php | 2 +- .../email/classes/Model/Email/Template.php | 2 +- .../Model/Email/Template/Translate.php | 2 +- .../export/classes/Export/Plugin/Quicken.php | 4 +- modules/export/classes/Model/Export.php | 2 +- .../export/classes/Model/Export/DataMap.php | 5 +- modules/export/classes/Model/Export/Item.php | 2 +- .../export/classes/Model/Export/Module.php | 2 +- modules/host/classes/Model/Host/Server.php | 2 +- .../classes/Model/Host/Server/Affiliate.php | 2 +- .../product/category/list/hostcompare.php | 6 +- .../classes/Controller/Task/Invoice.php | 4 +- modules/invoice/classes/Invoicable.php | 16 --- modules/invoice/classes/Model/Invoice.php | 24 ++-- .../invoice/classes/Model/Invoice/Item.php | 108 ++++++++---------- .../invoice/classes/Model/Invoice/Memo.php | 2 +- modules/oauth/classes/Model/Account/Oauth.php | 6 +- modules/oauth/classes/Model/Oauth.php | 2 +- modules/payment/classes/Model/Payment.php | 2 +- .../payment/classes/Model/Payment/Item.php | 2 +- .../classes/Controller/Admin/Product.php | 2 +- modules/product/classes/Model/Product.php | 85 +++++--------- .../classes/Model/Product/Category.php | 49 +++++--- .../Model/Product/Category/Translate.php | 2 +- .../product/classes/Model/Product/Plugin.php | 2 +- .../classes/Model/Product/Translate.php | 2 +- .../media/theme/focusbusiness/pages/plans.css | 4 +- modules/product/views/product/admin/edit.php | 2 +- .../views/product/category/list/supercat.php | 4 +- modules/product/views/product/list.php | 2 +- modules/product/views/product/view.php | 6 +- .../classes/Controller/Admin/Service.php | 106 ++--------------- modules/service/classes/Model/Service.php | 38 +++--- .../service/classes/Model/Service/Billing.php | 2 +- .../service/classes/Model/Service/Change.php | 4 +- .../service/classes/Model/Service/Memo.php | 2 +- .../service/classes/Model/Service/Plugin.php | 2 +- modules/service/views/service/admin/add.php | 66 +++++++---- modules/service/views/service/admin/edit.php | 34 ++---- modules/service/views/service/admin/view.php | 6 +- modules/service/views/service/info.php | 3 +- .../ssl/classes/Controller/Reseller/Ssl.php | 4 +- modules/ssl/classes/Model/SSL.php | 2 +- modules/ssl/classes/Model/SSL/CA.php | 2 +- .../ssl/classes/Model/Service/Plugin/Ssl.php | 18 +-- modules/ssl/config/ssl.php | 3 + .../views/service/admin/plugin/ssl/edit.php | 8 +- modules/task/classes/Model/Task.php | 2 +- modules/task/classes/Model/Task/Log.php | 2 +- .../tax/classes/Model/Invoice/Item/Tax.php | 2 +- modules/tax/classes/Model/Tax.php | 2 +- 82 files changed, 367 insertions(+), 590 deletions(-) delete mode 100644 application/classes/ORM/OSB.php delete mode 100644 modules/invoice/classes/Invoicable.php diff --git a/application/classes/Controller/Admin/Module/Method.php b/application/classes/Controller/Admin/Module/Method.php index 55a0a7a5..d62ae561 100644 --- a/application/classes/Controller/Admin/Module/Method.php +++ b/application/classes/Controller/Admin/Module/Method.php @@ -69,7 +69,7 @@ class Controller_Admin_Module_Method extends Controller_Admin_Module { foreach (ORM::factory('Group')->find_all() as $go) { // If the group was defined and no longer - if ($mmo->has('group',$go) AND (! $this->request->post('groups')) OR ! in_array($go->id,$this->request->post('groups'))) { + if ($mmo->has('group',$go) AND (! $this->request->post('groups') OR ! in_array($go->id,$this->request->post('groups')))) { $gmo = ORM::factory('Group_Method',array('method_id'=>$mmo->id,'group_id'=>$go->id)); if (! $gmo->delete()) diff --git a/application/classes/Controller/TemplateDefault.php b/application/classes/Controller/TemplateDefault.php index 144d30ad..c20ff51f 100644 --- a/application/classes/Controller/TemplateDefault.php +++ b/application/classes/Controller/TemplateDefault.php @@ -12,17 +12,6 @@ abstract class Controller_TemplateDefault extends lnApp_Controller_TemplateDefault { protected $auth_required = TRUE; - // @todo To rework - public function after() { - $dc = URL::link('user','welcome/index'); - $m = sprintf('%s/%s',Request::current()->directory(),Request::current()->controller()); - - BreadCrumb::URL(Request::current()->directory(),sprintf('%s/%s',Request::current()->directory(),$dc),FALSE); - BreadCrumb::URL($m,method_exists($this,'action_menu') ? $m.'/menu' : sprintf('%s/%s',Request::current()->directory(),$dc),FALSE); - - parent::after(); - } - protected function save(Model $o) { try { return $o->save(); @@ -48,7 +37,7 @@ abstract class Controller_TemplateDefault extends lnApp_Controller_TemplateDefau if ($config_items) { Block::factory() ->title('Update Module Configuration') - ->title_icon('icon-wrench') + ->title_icon('fa fa-wrench') ->type('form-horizontal') ->body(View::factory('setup/admin/module')->set('o',Company::instance()->so())->set('mid',$mo->id)); } diff --git a/application/classes/Model/Account.php b/application/classes/Model/Account.php index f20cfe18..3e3a252e 100644 --- a/application/classes/Model/Account.php +++ b/application/classes/Model/Account.php @@ -44,21 +44,7 @@ class Model_Account extends lnApp_Model_Account { /** REQUIRED ABSTRACT METHODS **/ - /** - * Returns the company name if it exists, otherwise the persons name - */ - public function name($variable=NULL) { - return $this->isCompany() ? $this->company : $this->namesub(); - } - - /* - * Returns the persons name - */ - public function namesub($variable=NULL) { - return trim(sprintf('%s %s',$this->first_name,$this->last_name)); - } - - /** OTHER METHODS **/ + /** LOCAL METHODS **/ public function activated() { return $this->has('group'); @@ -115,6 +101,20 @@ class Model_Account extends lnApp_Model_Account { return $this->RTM->loaded(); } + /** + * Returns the company name if it exists, otherwise the persons name + */ + public function name($variable=NULL) { + return $this->isCompany() ? $this->company : $this->namesub(); + } + + /* + * Returns the persons name + */ + public function namesub($variable=NULL) { + return trim(sprintf('%s %s',$this->first_name,$this->last_name)); + } + /** * The key we use to sort entries of this model type */ diff --git a/application/classes/Model/Account/Log.php b/application/classes/Model/Account/Log.php index a5aa201e..d68e8519 100644 --- a/application/classes/Model/Account/Log.php +++ b/application/classes/Model/Account/Log.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Account_Log extends ORM_OSB { +class Model_Account_Log extends ORM { protected $_belongs_to = array( 'account'=>array(), ); diff --git a/application/classes/Model/Country.php b/application/classes/Model/Country.php index 5fa25e79..db19fc9a 100644 --- a/application/classes/Model/Country.php +++ b/application/classes/Model/Country.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Country extends ORM_OSB { +class Model_Country extends ORM { protected $_has_one = array( 'currency'=>array('far_key'=>'id'), ); diff --git a/application/classes/Model/Currency.php b/application/classes/Model/Currency.php index 23943eb6..8f612986 100644 --- a/application/classes/Model/Currency.php +++ b/application/classes/Model/Currency.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Currency extends ORM_OSB { +class Model_Currency extends ORM { protected $_sorting = array( 'name'=>'ASC', ); diff --git a/application/classes/Model/Group/Method.php b/application/classes/Model/Group/Method.php index 1db20700..1dc8fdea 100644 --- a/application/classes/Model/Group/Method.php +++ b/application/classes/Model/Group/Method.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Group_Method extends ORM_OSB { +class Model_Group_Method extends ORM { // Relationships protected $_has_one = array( 'record_id'=>array(), diff --git a/application/classes/Model/Language.php b/application/classes/Model/Language.php index 212c178b..98f4d4d1 100644 --- a/application/classes/Model/Language.php +++ b/application/classes/Model/Language.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Language extends ORM_OSB { +class Model_Language extends ORM { protected $_sorting = array( 'name'=>'ASC', ); diff --git a/application/classes/Model/Log/Error.php b/application/classes/Model/Log/Error.php index 357fb856..50f8cc9f 100644 --- a/application/classes/Model/Log/Error.php +++ b/application/classes/Model/Log/Error.php @@ -9,6 +9,6 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Log_Error extends ORM_OSB { +class Model_Log_Error extends ORM { } ?> diff --git a/application/classes/Model/Module.php b/application/classes/Model/Module.php index 68e56310..ef49b929 100644 --- a/application/classes/Model/Module.php +++ b/application/classes/Model/Module.php @@ -12,7 +12,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Module extends ORM_OSB { +class Model_Module extends ORM { // Relationships protected $_has_one = array( 'record_id'=>array('model'=>'Record_ID','far_key'=>'id'), diff --git a/application/classes/Model/Module/Method.php b/application/classes/Model/Module/Method.php index 14e617b7..b2a4ff69 100644 --- a/application/classes/Model/Module/Method.php +++ b/application/classes/Model/Module/Method.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Module_Method extends ORM_OSB { +class Model_Module_Method extends ORM { // This module doesnt keep track of column updates automatically protected $_created_column = FALSE; protected $_updated_column = FALSE; diff --git a/application/classes/Model/Module/Method/Token.php b/application/classes/Model/Module/Method/Token.php index 02f17580..d2d9f849 100644 --- a/application/classes/Model/Module/Method/Token.php +++ b/application/classes/Model/Module/Method/Token.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Module_Method_Token extends ORM_OSB { +class Model_Module_Method_Token extends ORM { // This module doesnt keep track of column updates automatically protected $_updated_column = FALSE; diff --git a/application/classes/Model/RTM.php b/application/classes/Model/RTM.php index fee28708..70a3ed15 100644 --- a/application/classes/Model/RTM.php +++ b/application/classes/Model/RTM.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_RTM extends ORM_OSB { +class Model_RTM extends ORM { protected $_belongs_to = array( 'account' => array(), ); diff --git a/application/classes/Model/Record/ID.php b/application/classes/Model/Record/ID.php index b6c19e38..8e1e6af3 100644 --- a/application/classes/Model/Record/ID.php +++ b/application/classes/Model/Record/ID.php @@ -8,7 +8,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Record_ID extends ORM_OSB { +class Model_Record_ID extends ORM { protected $_primary_key = 'module_id'; // This module doesnt keep track of column updates automatically diff --git a/application/classes/Model/Setup.php b/application/classes/Model/Setup.php index 9c68c725..63679987 100644 --- a/application/classes/Model/Setup.php +++ b/application/classes/Model/Setup.php @@ -12,7 +12,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Setup extends ORM_OSB { +class Model_Setup extends ORM { // Setup doesnt use the update column protected $_updated_column = FALSE; diff --git a/application/classes/ORM/OSB.php b/application/classes/ORM/OSB.php deleted file mode 100644 index 3316f44a..00000000 --- a/application/classes/ORM/OSB.php +++ /dev/null @@ -1,14 +0,0 @@ -data($apo->products()) ->columns(array( 'id'=>'ID', - 'title()'=>'Name', + 'name(Site::language())'=>'Name', 'status'=>'Active', )) ->prepend(array( diff --git a/modules/adsl/classes/Model/ADSL/Supplier.php b/modules/adsl/classes/Model/ADSL/Supplier.php index 269796d4..ecae14bf 100644 --- a/modules/adsl/classes/Model/ADSL/Supplier.php +++ b/modules/adsl/classes/Model/ADSL/Supplier.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_ADSL_Supplier extends ORM_OSB { +class Model_ADSL_Supplier extends ORM { protected $_updated_column = FALSE; // Relationships diff --git a/modules/adsl/classes/Model/ADSL/Supplier/Plan.php b/modules/adsl/classes/Model/ADSL/Supplier/Plan.php index 4353c548..2eb12fba 100644 --- a/modules/adsl/classes/Model/ADSL/Supplier/Plan.php +++ b/modules/adsl/classes/Model/ADSL/Supplier/Plan.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_ADSL_Supplier_Plan extends ORM_OSB { +class Model_ADSL_Supplier_Plan extends ORM { // Relationships protected $_belongs_to = array( 'supplier'=>array('model'=>'ADSL_Supplier'), diff --git a/modules/adsl/classes/Model/Service/Plugin/Adsl/Traffic.php b/modules/adsl/classes/Model/Service/Plugin/Adsl/Traffic.php index 59f0fdb1..0b5d6d7a 100644 --- a/modules/adsl/classes/Model/Service/Plugin/Adsl/Traffic.php +++ b/modules/adsl/classes/Model/Service/Plugin/Adsl/Traffic.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Service_Plugin_Adsl_Traffic extends ORM_OSB { +class Model_Service_Plugin_Adsl_Traffic extends ORM { protected $_table_name = 'service__adsl_traffic'; protected $_primary_key = 'service'; protected $_disable_wild_select = TRUE; diff --git a/modules/adsl/views/product/category/list/adslcompare-large.php b/modules/adsl/views/product/category/list/adslcompare-large.php index 3d931742..a5709d12 100644 --- a/modules/adsl/views/product/category/list/adslcompare-large.php +++ b/modules/adsl/views/product/category/list/adslcompare-large.php @@ -1,5 +1,5 @@
-

title(); ?>

+

name(Site::language()); ?>

description(); ?>
@@ -10,12 +10,12 @@ Plan Name products() as $po) : ?> - title(); ?> (id; ?>) + name(Site::language()); ?> (id; ?>) - Price + Price products() as $po) : ?> price_best($o->recur_schedule,TRUE); ?> diff --git a/modules/adsl/views/product/category/list/adslcompare.php b/modules/adsl/views/product/category/list/adslcompare.php index a0dda90d..2e38b0ec 100644 --- a/modules/adsl/views/product/category/list/adslcompare.php +++ b/modules/adsl/views/product/category/list/adslcompare.php @@ -1,5 +1,5 @@
-

title(); ?>

+

name(Site::language()); ?>

description(); ?>
@@ -23,9 +23,7 @@
-
- title(); ?> (id; ?>) -
+
name(Site::language()); ?> (id; ?>)
$ .recur_schedule); ?> diff --git a/modules/cart/classes/Model/Cart.php b/modules/cart/classes/Model/Cart.php index 50505521..85521f7f 100644 --- a/modules/cart/classes/Model/Cart.php +++ b/modules/cart/classes/Model/Cart.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Cart extends ORM_OSB { +class Model_Cart extends ORM { // Cart doesnt use the update column protected $_updated_column = FALSE; diff --git a/modules/charge/classes/Controller/Charge.php b/modules/charge/classes/Controller/Charge.php index e55daace..55a31768 100644 --- a/modules/charge/classes/Controller/Charge.php +++ b/modules/charge/classes/Controller/Charge.php @@ -10,5 +10,6 @@ * @license http://dev.osbill.net/license.html */ class Controller_Charge extends Controller_TemplateDefault { + protected $icon = 'fa fa-dollar'; } ?> diff --git a/modules/charge/classes/Controller/Reseller/Charge.php b/modules/charge/classes/Controller/Reseller/Charge.php index 3d8e0b27..c5a30bc2 100644 --- a/modules/charge/classes/Controller/Reseller/Charge.php +++ b/modules/charge/classes/Controller/Reseller/Charge.php @@ -21,8 +21,8 @@ class Controller_Reseller_Charge extends Controller_Charge { public function action_add() { Block::factory() ->type('form-horizontal') - ->title('Add/View Charge') - ->title_icon('fa fa-wrench') + ->title('New Charge') + ->title_icon($this->icon) ->body($this->add_edit()); } @@ -54,72 +54,11 @@ class Controller_Reseller_Charge extends Controller_Charge { private function add_edit($id=NULL,$output='') { $co = ORM::factory('Charge',$id); - $this->meta->title = sprintf('Charge: %s (%s)',$co->name(),$co->account->name()); + $this->meta->title = $co->loaded() ? sprintf('Charge: %s (%s)',$co->name(),$co->account->name()) : 'New Charge'; if ($this->request->post() AND $co->values($this->request->post())->changed() AND (! $this->save($co))) $co->reload(); - Script::factory() - ->type('file') - ->data('media/theme/bootstrap/js/bootstrap.datepicker.js'); - - Style::factory() - ->type('file') - ->data('media/theme/bootstrap/css/bootstrap.datepicker.css'); - - Script::factory() - ->type('stdin') - ->data(' -$(document).ready(function() { - $("#date_charge_label").datepicker({ - autoclose : true, - endDate : new Date(), - todayHighlight: true, - format : "dd-M-yyyy", - todayBtn : true, - }).on("hide",function(ev) { - $("input[name=date_charge]").val(ev.date.valueOf()/1000); - }); - - $("input[name=account_id_label]").typeahead({ - minLength: 2, - source: function (query,process) { - search("'.URL::link('reseller','charge/ajaxlist').'",query,process); - }, - - matcher: function () { return true; }, - - updater: function (item) { - $("input[name=account_id]").val(users[item]); - - // Send the request and update sub category dropdown - $.ajax({ - type: "GET", - data: "key="+users[item], - dataType: "json", - cache: false, - url: "'.URL::link('reseller','charge/ajaxlistservice',TRUE).'", - timeout: 2000, - error: function(x) { - alert("Failed to submit"); - }, - success: function(data) { - $("select[name=service_id]").empty(); - $.each(data, function(i, j){ - var row = ""; - $(row).appendTo("select[name=service_id]"); - }); - } - }); - - return item; - }, - - }); - -}); - '); - return View::factory('charge/reseller/add_edit') ->set('o',$co); } @@ -130,7 +69,7 @@ $(document).ready(function() { Block::factory() ->type('form-horizontal') ->title(sprintf('%s: %s',_('View Charges'),$id)) - ->title_icon('fa fa-wrench') + ->title_icon($this->icon) ->body($this->add_edit($id,$output)); } diff --git a/modules/charge/classes/Model/Charge.php b/modules/charge/classes/Model/Charge.php index a8de2cf1..417baa75 100644 --- a/modules/charge/classes/Model/Charge.php +++ b/modules/charge/classes/Model/Charge.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Charge extends ORM_OSB implements Invoicable { +class Model_Charge extends ORM { protected $_belongs_to = array( 'account'=>array(), 'product'=>array(), @@ -80,9 +80,6 @@ class Model_Charge extends ORM_OSB implements Invoicable { } /** REQUIRED ABSTRACT METHODS **/ - public function namesub($variable=NULL) { - return sprintf('%d@%2.2f - %s (%s)',$this->quantity,$this->amount,($this->description ? ' '.$this->description : '').($this->attributes ? ' ['.join('|',$this->attributes).']' : ''),$this->display('date_charge')); - } /** LOCAL METHODS **/ @@ -100,26 +97,9 @@ class Model_Charge extends ORM_OSB implements Invoicable { return $iio; } - public function invoice_item($item_type) { - switch ($item_type) { - case 5: - return sprintf('%s (%s x %s%s%s) %s', - StaticList_ItemType::get($item_type), - $this->quantity, - $this->display('amount'), - ($this->description ? ' '.$this->description : ''), - ($this->attributes ? ' ['.join('|',$this->attributes).']' : ''), - $this->display('date_charge')); - - default: - return sprintf('%s %s',StaticList_ItemType::get($item_type),$this->display('date_charge')).($this->description ? ' ('.$this->description.')' : ''); - } + public function namesub($variable=NULL) { + return sprintf('%d@%2.2f - %s (%s)',$this->quantity,$this->amount,($this->description ? ' '.$this->description : '').($this->attributes ? ' ['.join('|',$this->attributes).']' : ''),$this->display('date_charge')); } - - public function xtitle() { - return $this->invoice_item(5); - } - public function total($format=FALSE) { $result = $this->quantity * $this->amount; diff --git a/modules/charge/views/charge/reseller/add_edit.php b/modules/charge/views/charge/reseller/add_edit.php index f5ddd8de..b406895a 100644 --- a/modules/charge/views/charge/reseller/add_edit.php +++ b/modules/charge/views/charge/reseller/add_edit.php @@ -1,39 +1,56 @@ -
+
Charge Details - -
- - -
- date_charge); ?> - - account->name(),array('label'=>'Account','placeholder'=>'Account','data-provide'=>'typeahead')); ?> - account_id); ?> - - account_id ? $o->account->service->list_select() : array(),$o->service_id,array('label'=>'Service')); ?> - - sweep_type) ? 6 : $o->sweep_type,FALSE,array('label'=>'Sweep')); ?> - type) ? 6 : $o->type,FALSE,array('label'=>'Item Type')); ?> - - quantity,array('label'=>'Quantity','placeholder'=>'Quantity')); ?> - amount,array('label'=>'Amount','placeholder'=>'Total',)); ?> - taxable) ? TRUE : $o->taxable,FALSE,array('label'=>'Taxable')); ?> - description,array('label'=>'Description','placeholder'=>'Any notes about this charge?')); ?> - +set('data',['field'=>'date_charge','value'=>$o->date_charge ? $o->date_charge : time(),'text'=>'Date Charge','enddate'=>'new Date()']); + echo View::factory('field/account')->set('data',['field'=>'account_id','value'=>$o->account_id,'text'=>'Account','name'=>sprintf('%s: %s',$o->account->refnum(),$o->account->name()),'ajaxurl'=>URL::link('reseller','charge/ajaxlist')]); + echo View::factory('field/select')->set('data',['field'=>'service_id','value'=>$o->account_id ? $o->account->service->list_select() : [],'text'=>'Service','default'=>$o->service_id,'class'=>'col-md-6']); + echo View::factory('field/select')->set('data',['field'=>'sweep_type','value'=>Arr::merge([''=>''],StaticList_SweepType::table()),'text'=>'Sweep','default'=>is_null($o->sweep_type) ? 6 : $o->sweep_type,'class'=>'col-md-2']); + echo View::factory('field/select')->set('data',['field'=>'type','value'=>Arr::merge([''=>''],StaticList_ItemType::table()),'text'=>'Item Type','default'=>$o->type,'class'=>'col-md-2']); + echo View::factory('field/number')->set('data',['field'=>'quantity','value'=>$o->quantity,'text'=>'Quantity','class'=>'col-md-2']); + echo View::factory('field/money')->set('data',['field'=>'amount','value'=>$o->amount,'text'=>'Amount','class'=>'col-md-2']); + echo View::factory('field/select')->set('data',['field'=>'taxable','value'=>StaticList_YesNo::table(),'text'=>'Taxable','default'=>$o->taxable,'class'=>'col-md-1']); + echo View::factory('field/text')->set('data',['field'=>'description','value'=>$o->description,'text'=>'Description','class'=>'col-md-5']); +?> attributes) foreach ($o->attributes as $key => $value) : echo Form::input("attributes[$key]",$value,array('label'=>$key)); $i++; endforeach ?> attributes[$i]) ? $o->attributes[$i] : '',array('label'=>'Attributes')); + echo Form::input("attributes[$i]",isset($o->attributes[$i]) ? $o->attributes[$i] : '',array('label'=>'Attributes')); endfor ?>
-
- - -
-
+ +
+ +type('stdin') + ->data(' +$(document).ready(function() { + $("input[name=account_id]").change(function(){ + // Send the request and update sub category dropdown + $.ajax({ + type: "GET", + data: "key="+$(this).val(), + dataType: "json", + cache: false, + url: "'.URL::link('reseller','charge/ajaxlistservice',TRUE).'", + timeout: 2000, + error: function(x) { + alert("Failed to submit"); + }, + success: function(data) { + $("select[name=service_id]").empty(); + $.each(data, function(i, j){ + var row = ""; + $(row).appendTo("select[name=service_id]"); + }); + } + }); + }); +});'); +?> diff --git a/modules/checkout/classes/Model/Checkout.php b/modules/checkout/classes/Model/Checkout.php index c7ed8d74..0fcca695 100644 --- a/modules/checkout/classes/Model/Checkout.php +++ b/modules/checkout/classes/Model/Checkout.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Checkout extends ORM_OSB { +class Model_Checkout extends ORM { protected $_has_many = array( 'payment'=>array(), 'service'=>array('through'=>'account_billing','foreign_key'=>'checkout_id'), @@ -20,10 +20,6 @@ class Model_Checkout extends ORM_OSB { /** REQUIRED ABSTRACT METHODS **/ - public function name($variable=NULL) { - return $this->name; - } - /** LOCAL METHODS **/ /** @@ -46,6 +42,10 @@ class Model_Checkout extends ORM_OSB { return Currency::round($net-$amt); } + public function name($variable=NULL) { + return $this->name; + } + /** * Return the object of the checkout plugin */ diff --git a/modules/checkout/classes/Model/Checkout/Notify.php b/modules/checkout/classes/Model/Checkout/Notify.php index 0950e959..4196e3ae 100644 --- a/modules/checkout/classes/Model/Checkout/Notify.php +++ b/modules/checkout/classes/Model/Checkout/Notify.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Checkout_Notify extends ORM_OSB implements Invoicable { +class Model_Checkout_Notify extends ORM { // Relationships protected $_has_one = array( 'checkout'=>array('far_key'=>'checkout_id','foreign_key'=>'id'), @@ -25,10 +25,6 @@ class Model_Checkout_Notify extends ORM_OSB implements Invoicable { 'data', ); - public function invoice_item($item_type) { - return sprintf('Payment Fee: %s',$this->checkout->name); - } - public function process() { return $this->checkout->plugin()->notify($this); } diff --git a/modules/domain/classes/Model/Domain/Registrar.php b/modules/domain/classes/Model/Domain/Registrar.php index a1b0e57c..bf2d2101 100644 --- a/modules/domain/classes/Model/Domain/Registrar.php +++ b/modules/domain/classes/Model/Domain/Registrar.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Domain_Registrar extends ORM_OSB { +class Model_Domain_Registrar extends ORM { /** * The button that provides a login to the Registrar to manage the domain license */ diff --git a/modules/domain/classes/Model/Domain/TLD.php b/modules/domain/classes/Model/Domain/TLD.php index 566c3c11..cd566b1a 100644 --- a/modules/domain/classes/Model/Domain/TLD.php +++ b/modules/domain/classes/Model/Domain/TLD.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Domain_Tld extends ORM_OSB { +class Model_Domain_Tld extends ORM { protected $_display_filters = array( 'name'=>array( array('strtoupper',array(':value')), diff --git a/modules/email/classes/Model/Email/Log.php b/modules/email/classes/Model/Email/Log.php index 5992d26d..2ee4ceb2 100644 --- a/modules/email/classes/Model/Email/Log.php +++ b/modules/email/classes/Model/Email/Log.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Email_Log extends ORM_OSB { +class Model_Email_Log extends ORM { // Email Log doesnt use the update column protected $_updated_column = FALSE; diff --git a/modules/email/classes/Model/Email/Template.php b/modules/email/classes/Model/Email/Template.php index 343d6f27..ea8e72ca 100644 --- a/modules/email/classes/Model/Email/Template.php +++ b/modules/email/classes/Model/Email/Template.php @@ -8,7 +8,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Email_Template extends ORM_OSB { +class Model_Email_Template extends ORM { protected $_has_many = array( 'translate'=>array('model'=>'Email_Template_Translate','foreign_key'=>'email_template_id','far_key'=>'id'), ); diff --git a/modules/email/classes/Model/Email/Template/Translate.php b/modules/email/classes/Model/Email/Template/Translate.php index 4d17496b..53d5fbb9 100644 --- a/modules/email/classes/Model/Email/Template/Translate.php +++ b/modules/email/classes/Model/Email/Template/Translate.php @@ -8,7 +8,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Email_Template_Translate extends ORM_OSB { +class Model_Email_Template_Translate extends ORM { // This module doesnt keep track of column updates automatically protected $_created_column = FALSE; protected $_updated_column = FALSE; diff --git a/modules/export/classes/Export/Plugin/Quicken.php b/modules/export/classes/Export/Plugin/Quicken.php index e814dcfa..75f5084a 100644 --- a/modules/export/classes/Export/Plugin/Quicken.php +++ b/modules/export/classes/Export/Plugin/Quicken.php @@ -100,10 +100,10 @@ class Export_Plugin_Quicken extends Export_Plugin { $items[$c]['INVITEM'] = $edo->map_data['item']; } else { - throw HTTP_Exception::factory(501,'Missing product map data for :product (:id)',array(':product'=>$iio->module()->title(),':id'=>$iio->module_ref)); + throw HTTP_Exception::factory(501,'Missing product map data for :product (:id)',array(':product'=>$iio->product->name(Site::language()),':id'=>$iio->module_ref)); } - $items[$c]['MEMO'] = sprintf('%s (%s)',$iio->module()->title(),$iio->period()); + $items[$c]['MEMO'] = $iio->name(); // Non product item } else { diff --git a/modules/export/classes/Model/Export.php b/modules/export/classes/Model/Export.php index 149f8d7a..4830d81d 100644 --- a/modules/export/classes/Model/Export.php +++ b/modules/export/classes/Model/Export.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Export extends ORM_OSB { +class Model_Export extends ORM { // Relationships protected $_has_many = array( 'export_module' => array('far_key'=>'id','xforeign_key'=>'x'), diff --git a/modules/export/classes/Model/Export/DataMap.php b/modules/export/classes/Model/Export/DataMap.php index fa845472..13e5e619 100644 --- a/modules/export/classes/Model/Export/DataMap.php +++ b/modules/export/classes/Model/Export/DataMap.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Export_DataMap extends ORM_OSB { +class Model_Export_DataMap extends ORM { // Relationships protected $_belongs_to = array( 'export_module' => array(), @@ -20,12 +20,11 @@ class Model_Export_DataMap extends ORM_OSB { 'map_data', ); - public function list_itemsnoexport(Model $o,$emoid,$desc='title()') { + public function list_itemsnoexport(Model $o,$emoid,$desc='name(Site::language())') { $result = array(); $o->select(array($this->table_name().'.id','edm')) ->join($this->table_name(),'LEFT OUTER') - ->on($this->table_name().'.site_id','=',$o->table_name().'.site_id') // @todo This should be automatic ->on($this->table_name().'.item_id','=',$o->table_name().'.id') ->on('export_module_id','=',$emoid) ->where($o->table_name().'.status','=',TRUE) diff --git a/modules/export/classes/Model/Export/Item.php b/modules/export/classes/Model/Export/Item.php index e46b9ffd..9e6e9d9f 100644 --- a/modules/export/classes/Model/Export/Item.php +++ b/modules/export/classes/Model/Export/Item.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Export_Item extends ORM_OSB { +class Model_Export_Item extends ORM { // Relationships protected $_belongs_to = array( 'export_module' => array(), diff --git a/modules/export/classes/Model/Export/Module.php b/modules/export/classes/Model/Export/Module.php index 74f394e5..5294b1b6 100644 --- a/modules/export/classes/Model/Export/Module.php +++ b/modules/export/classes/Model/Export/Module.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Export_Module extends ORM_OSB { +class Model_Export_Module extends ORM { protected $_created_column = FALSE; protected $_updated_column = FALSE; diff --git a/modules/host/classes/Model/Host/Server.php b/modules/host/classes/Model/Host/Server.php index fd40e4a5..08d2a52b 100644 --- a/modules/host/classes/Model/Host/Server.php +++ b/modules/host/classes/Model/Host/Server.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Host_Server extends ORM_OSB { +class Model_Host_Server extends ORM { // Host Server doesnt use the update column protected $_updated_column = FALSE; diff --git a/modules/host/classes/Model/Host/Server/Affiliate.php b/modules/host/classes/Model/Host/Server/Affiliate.php index a61b5590..a0fb7d28 100644 --- a/modules/host/classes/Model/Host/Server/Affiliate.php +++ b/modules/host/classes/Model/Host/Server/Affiliate.php @@ -9,6 +9,6 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Host_Server_Affiliate extends ORM_OSB { +class Model_Host_Server_Affiliate extends ORM { } ?> diff --git a/modules/host/views/product/category/list/hostcompare.php b/modules/host/views/product/category/list/hostcompare.php index f3d7ac4d..5bafe3c0 100644 --- a/modules/host/views/product/category/list/hostcompare.php +++ b/modules/host/views/product/category/list/hostcompare.php @@ -1,5 +1,5 @@
-

title(); ?>

+

name(Site::language()); ?>

description(); ?>
@@ -23,9 +23,7 @@
-
- title(); ?> -
+
name(Site::language()); ?>
$ .recur_schedule); ?> diff --git a/modules/invoice/classes/Controller/Task/Invoice.php b/modules/invoice/classes/Controller/Task/Invoice.php index c0ee930c..4136abe1 100644 --- a/modules/invoice/classes/Controller/Task/Invoice.php +++ b/modules/invoice/classes/Controller/Task/Invoice.php @@ -17,11 +17,11 @@ class Controller_Task_Invoice extends Controller_Task { foreach (ORM::factory('Invoice_Item')->find_all() as $iio) { if ($iio->product_name AND $iio->product_id) { - if (md5(strtoupper($iio->product_name)) == md5(strtoupper($iio->product->title()))) { + if (md5(strtoupper($iio->product_name)) == md5(strtoupper($iio->product->name(Site::language())))) { $iio->product_name = NULL; $iio->save(); } else { - print_r(array("DIFF",'id'=>$iio->id,'pn'=>serialize($iio->product_name),'ppn'=>serialize($iio->product->title()),'pid'=>$iio->product_id,'test'=>strcasecmp($iio->product_name,$iio->product->title()))); + print_r(array("DIFF",'id'=>$iio->id,'pn'=>serialize($iio->product_name),'ppn'=>serialize($iio->product->name(Site::language())),'pid'=>$iio->product_id,'test'=>strcasecmp($iio->product_name,$iio->product->name(Site::language())))); } } } diff --git a/modules/invoice/classes/Invoicable.php b/modules/invoice/classes/Invoicable.php deleted file mode 100644 index d37eef25..00000000 --- a/modules/invoice/classes/Invoicable.php +++ /dev/null @@ -1,16 +0,0 @@ - diff --git a/modules/invoice/classes/Model/Invoice.php b/modules/invoice/classes/Model/Invoice.php index 97a98e89..4e015409 100644 --- a/modules/invoice/classes/Model/Invoice.php +++ b/modules/invoice/classes/Model/Invoice.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Invoice extends ORM_OSB implements Cartable { +class Model_Invoice extends ORM implements Cartable { protected $_belongs_to = array( 'account'=>array() ); @@ -54,14 +54,6 @@ class Model_Invoice extends ORM_OSB implements Cartable { /** REQUIRED ABSTRACT METHODS **/ - /** - * Display the Invoice Reference Number - */ - public function refnum($short=FALSE) { - return ($short ? '' : $this->account->refnum(FALSE).'-').sprintf('%06s',$this->id); - } - - /** REQUIRED INTERFACE METHODS **/ public function cart_item() { @@ -127,7 +119,7 @@ class Model_Invoice extends ORM_OSB implements Cartable { $c = 0; if (! $this->_loaded) foreach ($this->_sub_items as $iio) - $iio->id = 'FAKE:'.$c++; + $iio->id = '****:'.$c++; // First work through our recurring schedule items $result['s'] = array(); @@ -191,14 +183,15 @@ class Model_Invoice extends ORM_OSB implements Cartable { */ public function items_summary() { $result = array(); + $lo = $this->account->language; foreach ($this->subitems() as $iio) { // We only summarise item_type=0 if (! $iio->item_type == 0) continue; - if ($iio->module() instanceof Model_Product) { - $p = $iio->module()->title(); + if ($iio->product) { + $p = $iio->product->name($lo); if (! isset($result[$p])) { $result[$p]['quantity'] = 0; @@ -258,6 +251,13 @@ class Model_Invoice extends ORM_OSB implements Cartable { return $result; } + /** + * Display the Invoice Reference Number + */ + public function refnum($short=FALSE) { + return ($short ? '' : $this->account->refnum(FALSE).'-').sprintf('%06s',$this->id); + } + /** * Check the reminder value */ diff --git a/modules/invoice/classes/Model/Invoice/Item.php b/modules/invoice/classes/Model/Invoice/Item.php index 9bc5854f..c84fd6db 100644 --- a/modules/invoice/classes/Model/Invoice/Item.php +++ b/modules/invoice/classes/Model/Invoice/Item.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Invoice_Item extends ORM_OSB { +class Model_Invoice_Item extends ORM { // Relationships protected $_belongs_to = array( 'invoice'=>array(), @@ -66,51 +66,6 @@ class Model_Invoice_Item extends ORM_OSB { /** REQUIRED ABSTRACT METHODS **/ - public function name($variable=NULL) { - if (! $this->isValid()) - return sprintf('Record Error [%s-%s]',$this->item_type,$this->id); - - switch ($this->item_type) { - case 0: - case 2: - case 3: - case 4: - case 5: - return sprintf('%s: %s',$this->product->name($variable),$this->service->namesub($variable)); - case 124: - return StaticList_ItemType::get($this->item_type); - default: - return sprintf('Unknown [%s-%s]',$this->item_type,$this->id); - } - } - - public function namesub($variable=NULL) { - if (! $this->isValid()) - return sprintf('Record Error [%s-%s]',$this->item_type,$this->id); - - switch ($this->item_type) { - case 0: - return sprintf('%s: %s',StaticList_ItemType::get($this->item_type),$this->period()); - case 2: - return sprintf('%s: %s',StaticList_ItemType::get($this->item_type),$this->_module() ? $this->_module()->display('date_charge') : $this->period()); - case 3: - case 4: - case 6: - return sprintf('%s: %s',StaticList_ItemType::get($this->item_type),($this->_module()->attributes ? $this->_module()->namesub($variable) : $this->_module()->display('date_charge'))); - case 5: - return $this->_module()->namesub($variable); - default: - return sprintf('Unknown [%s-%s]',$this->item_type,$this->id); - } - } - - /** - * Display the Invoice Item Reference Number - */ - public function refnum($short=FALSE) { - return $short ? '' : sprintf('%03s-',$this->item_type).sprintf('%06s',$this->id); - } - /** LOCAL METHODS **/ /** @@ -185,6 +140,7 @@ class Model_Invoice_Item extends ORM_OSB { break; case 3: case 4: + case 7: if (! $this->service_id OR ! $this->product_id OR ! $this->module_id OR ! $this->module_ref OR $this->product_name OR ! is_null($this->recurring_schedule)) return FALSE; break; @@ -210,11 +166,57 @@ class Model_Invoice_Item extends ORM_OSB { return $this->_module(); } + public function name($variable=NULL) { + if (! $this->isValid()) + return sprintf('Record Error [%s-%s]',$this->item_type,$this->id); + + switch ($this->item_type) { + case 0: + case 2: + case 3: + case 4: + case 5: + return sprintf('%s: %s',$this->product->name($variable),$this->service->namesub($variable)); + case 124: + return StaticList_ItemType::get($this->item_type); + default: + return sprintf('Unknown [%s-%s]',$this->item_type,$this->id); + } + } + + public function namesub($variable=NULL) { + if (! $this->isValid()) + return sprintf('Record Error [%s-%s]',$this->item_type,$this->id); + + switch ($this->item_type) { + case 0: + return sprintf('%s: %s',StaticList_ItemType::get($this->item_type),$this->period()); + case 2: + return sprintf('%s: %s',StaticList_ItemType::get($this->item_type),$this->_module() ? $this->_module()->display('date_charge') : $this->period()); + case 3: + case 4: + case 6: + return sprintf('%s: %s',StaticList_ItemType::get($this->item_type),($this->_module()->attributes ? $this->_module()->namesub($variable) : $this->_module()->display('date_charge'))); + case 5: + case 7: + return $this->_module()->namesub($variable); + default: + return sprintf('Unknown [%s-%s]',$this->item_type,$this->id); + } + } + // Display the period that a transaction applies public function period() { return ($this->date_start == $this->date_stop) ? Site::Date($this->date_start) : sprintf('%s -> %s',Site::Date($this->date_start),Site::Date($this->date_stop)); } + /** + * Display the Invoice Item Reference Number + */ + public function refnum($short=FALSE) { + return $short ? '' : sprintf('%03s-',$this->item_type).sprintf('%06s',$this->id); + } + public function save(Validation $validation = NULL) { // Our items will be clobbered once we save the object, so we need to save it here. $subitems = $this->subitems(); @@ -276,20 +278,6 @@ class Model_Invoice_Item extends ORM_OSB { return $result; } - /** - * The title for invoice items - */ - public function title() { - if ($this->service_id AND $this->module_id AND method_exists($this->module(),'invoice_title')) - return $this->service->name(); #$this->module_ref ? sprintf('%s: %s',$this->module()->invoice_title(),$this->service->name()) : $this->service->name(); - elseif ($x=$this->module() AND ($x instanceof Model_Charge) AND $x->product_id) - return $x->product->title().' '.$this->service->name(); - elseif ($this->product_id) - return sprintf('* %s: %s',$this->product->invoice_title(),$this->service->name()); - else - return 'Unknown Item'; - } - public function total($format=FALSE) { $result = $this->void ? 0 : $this->subtotal()+$this->tax()-$this->discount(); diff --git a/modules/invoice/classes/Model/Invoice/Memo.php b/modules/invoice/classes/Model/Invoice/Memo.php index aae7131a..32208d46 100644 --- a/modules/invoice/classes/Model/Invoice/Memo.php +++ b/modules/invoice/classes/Model/Invoice/Memo.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Invoice_Memo extends ORM_OSB { +class Model_Invoice_Memo extends ORM { // Relationships protected $_belongs_to = array( 'invoice'=>array(), diff --git a/modules/oauth/classes/Model/Account/Oauth.php b/modules/oauth/classes/Model/Account/Oauth.php index 2daff0a8..940a909f 100644 --- a/modules/oauth/classes/Model/Account/Oauth.php +++ b/modules/oauth/classes/Model/Account/Oauth.php @@ -9,7 +9,11 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Account_Oauth extends ORM_OSB { +class Model_Account_Oauth extends ORM { + protected $_serialize_column = array( + 'oauth_data', + ); + protected $_compress_column = array( 'oauth_data', ); diff --git a/modules/oauth/classes/Model/Oauth.php b/modules/oauth/classes/Model/Oauth.php index fb60c812..e98072e2 100644 --- a/modules/oauth/classes/Model/Oauth.php +++ b/modules/oauth/classes/Model/Oauth.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Oauth extends ORM_OSB { +class Model_Oauth extends ORM { // Relationships protected $_has_many = array( 'account_oauth' => array('far_key'=>'id'), diff --git a/modules/payment/classes/Model/Payment.php b/modules/payment/classes/Model/Payment.php index ddc27b2c..6edfc745 100644 --- a/modules/payment/classes/Model/Payment.php +++ b/modules/payment/classes/Model/Payment.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Payment extends ORM_OSB { +class Model_Payment extends ORM { // Relationships protected $_belongs_to = array( 'account'=>array(), diff --git a/modules/payment/classes/Model/Payment/Item.php b/modules/payment/classes/Model/Payment/Item.php index 1f5002d1..d24c0c4e 100644 --- a/modules/payment/classes/Model/Payment/Item.php +++ b/modules/payment/classes/Model/Payment/Item.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Payment_Item extends ORM_OSB { +class Model_Payment_Item extends ORM { // Relationships protected $_belongs_to = array( 'payment'=>array(), diff --git a/modules/product/classes/Controller/Admin/Product.php b/modules/product/classes/Controller/Admin/Product.php index 5a5fb755..30d9359a 100644 --- a/modules/product/classes/Controller/Admin/Product.php +++ b/modules/product/classes/Controller/Admin/Product.php @@ -246,7 +246,7 @@ $.ajax({ throw HTTP_Exception::factory(403,'Product either doesnt exist, or you are not authorised to see it'); Block::factory() - ->title(sprintf('%s: %s',_('Current Services Using this Product'),$po->title())) + ->title(sprintf('%s: %s',_('Current Services Using this Product'),$po->name(Site::language()))) ->title_icon('icon-th-list') ->body(View::factory('service/reseller/list')->set('o',$po->service->where_active()->find_all())); } diff --git a/modules/product/classes/Model/Product.php b/modules/product/classes/Model/Product.php index 07e929c4..ee4224c8 100644 --- a/modules/product/classes/Model/Product.php +++ b/modules/product/classes/Model/Product.php @@ -12,9 +12,7 @@ * Column Definitions: * + price_type: 0=One Time, 1=Recurring, 2=Trial */ -class Model_Product extends ORM_OSB implements Invoicable { - private $_pto = NULL; - +class Model_Product extends ORM { protected $_has_many = array( 'invoice'=>array('through'=>'invoice_item'), 'service'=>array('far_key'=>'id'), @@ -50,6 +48,8 @@ class Model_Product extends ORM_OSB implements Invoicable { 'price_group', ); + private $_pto = NULL; + // Our attributes that are arrays, we'll convert/unconvert them protected $_serialize_column = array( 'price_group', @@ -59,46 +59,6 @@ class Model_Product extends ORM_OSB implements Invoicable { /** REQUIRED ABSTRACT METHODS **/ - public function name($variable=NULL) { - if (! $variable instanceof Model_Language) - throw HTTP_Exception::factory(500,'Call to :method incorrect',array(':method'=>__METHOD__)); - - $pto = $this->_pto($variable); - - return (! $pto->loaded() OR ! $pto->name) ? sprintf('Unknown: [%s]',$this->id) : $pto->name; - } - - public function namesub($variable=NULL) { - if (! $variable instanceof Model_Language) - throw HTTP::Exception(500,'Call to :method incorrect',array(':method'=>__METHOD__)); - - $pto = $this->_pto($variable); - - return (! $pto->loaded() OR ! $pto->description_short) ? sprintf('Unknown: [%s]',$this->id) : $pto->description_short; - } - - public function refnum($short=FALSE) { - return ($short ? '' : sprintf('%02s-',Site::id())).sprintf('%04s',$this->id); - } - - /** REQUIRED INTERFACE METHODS **/ - - public function invoice_item($item_type) { - switch ($item_type) { - case 0: - case 7: - return 'Service'; - case 6: - return 'Service Cancellation'; - default: - return 'Product Charge'; - } - } - - public function invoice_title() { - return $this->title(); - } - /** LOCAL METHODS **/ // Our database index for pricing values @@ -134,9 +94,9 @@ class Model_Product extends ORM_OSB implements Invoicable { * Return the translated description for a category. */ public function description($full=FALSE) { - $x = $this->translate(); + $pto = $this->_pto(Site::language()); - return $x->loaded() ? $x->display($full ? 'description_full' : 'description_short') : 'No Description'; + return $pto->loaded() ? $pto->display($full ? 'description_full' : 'description_short') : 'No Description'; } /** @@ -167,6 +127,24 @@ class Model_Product extends ORM_OSB implements Invoicable { return ($this->price_type == 2) ? TRUE : FALSE; } + public function name($variable=NULL) { + if (! $variable instanceof Model_Language) + throw HTTP_Exception::factory(500,'Call to :method incorrect',array(':method'=>__METHOD__)); + + $pto = $this->_pto($variable); + + return (! $pto->loaded() OR ! $pto->name) ? sprintf('Unknown: [%s]',$this->id) : $pto->name; + } + + public function namesub($variable=NULL) { + if (! $variable instanceof Model_Language) + throw HTTP::Exception(500,'Call to :method incorrect',array(':method'=>__METHOD__)); + + $pto = $this->_pto($variable); + + return (! $pto->loaded() OR ! $pto->description_short) ? sprintf('Unknown: [%s]',$this->id) : $pto->description_short; + } + /** * Return the object of the product plugin */ @@ -235,6 +213,10 @@ class Model_Product extends ORM_OSB implements Invoicable { return $this->_price_options; } + public function refnum($short=FALSE) { + return ($short ? '' : sprintf('%02s-',Site::id())).sprintf('%04s',$this->id); + } + public function save(Validation $validation=NULL) { parent::save($validation); @@ -257,18 +239,5 @@ class Model_Product extends ORM_OSB implements Invoicable { public function supplier() { return $this->plugin() ? $this->plugin()->supplier() : 'other'; } - - private function translate() { - return $this->translate->where('language_id','=',Company::instance()->language())->find(); - } - - /** - * Return the translated title for a category - */ - public function title() { - $x = $this->translate(); - - return $x->loaded() ? $x->display('name') : 'No Title'; - } } ?> diff --git a/modules/product/classes/Model/Product/Category.php b/modules/product/classes/Model/Product/Category.php index 3a000d23..60187280 100644 --- a/modules/product/classes/Model/Product/Category.php +++ b/modules/product/classes/Model/Product/Category.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Product_Category extends ORM_OSB { +class Model_Product_Category extends ORM { protected $_table_name = 'product_cat'; protected $_created_column = FALSE; protected $_updated_column = FALSE; @@ -28,21 +28,46 @@ class Model_Product_Category extends ORM_OSB { 'position'=>'ASC', ); + private $_pto = NULL; + protected $_save_message = TRUE; + /** REQUIRED ABSTRACT METHODS **/ + + /** LOCAL METHODS **/ + + /** + * Return the translated langauge object + */ + private function _pto(Model_Language $lo) { + if (! $this->_pto) { + + // First try the called langauge. + $pto = $this->translate->where('language_id','=',$lo->id)->find(); + + // Second try the called langauge. + if (! $pto->loaded()) + $pto = $this->translate->where('language_id','=',Company::instance()->language()->id)->find(); + + $this->_pto = $pto; + } + + return $this->_pto; + } + /** * Return the translated description for a category. */ public function description() { - $x = $this->translate(); + $pto = $this->_pto(Site::language()); - return $x->loaded() ? $x->display('description') : 'No Description'; + return $pto->loaded() ? $pto->display('description') : 'No Description'; } public function name($variable=NULL) { - $x = $this->translate(); + $pto = $this->_pto(Site::language()); - return $x->loaded() ? $x->display('name') : 'No Name'; + return $pto->loaded() ? $pto->display('name') : 'No Name'; } /** @@ -100,19 +125,5 @@ class Model_Product_Category extends ORM_OSB { return $result; } - - /** - * Return the translated title for a category - */ - public function title() { - $x = $this->translate(); - - return $x->loaded() ? $x->display('name') : 'No Title'; - } - - - private function translate() { - return $this->translate->where('language_id','=',Company::instance()->language())->find(); - } } ?> diff --git a/modules/product/classes/Model/Product/Category/Translate.php b/modules/product/classes/Model/Product/Category/Translate.php index 8545808e..92e5dceb 100644 --- a/modules/product/classes/Model/Product/Category/Translate.php +++ b/modules/product/classes/Model/Product/Category/Translate.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Product_Category_Translate extends ORM_OSB { +class Model_Product_Category_Translate extends ORM { protected $_table_name = 'product_cat_translate'; protected $_created_column = FALSE; protected $_updated_column = FALSE; diff --git a/modules/product/classes/Model/Product/Plugin.php b/modules/product/classes/Model/Product/Plugin.php index b9926d30..4ef8e1ef 100644 --- a/modules/product/classes/Model/Product/Plugin.php +++ b/modules/product/classes/Model/Product/Plugin.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -abstract class Model_Product_Plugin extends ORM_OSB { +abstract class Model_Product_Plugin extends ORM { // Reset any sorting that may be defined in our parent protected $_sorting = array(); diff --git a/modules/product/classes/Model/Product/Translate.php b/modules/product/classes/Model/Product/Translate.php index b9465b69..2aa9f836 100644 --- a/modules/product/classes/Model/Product/Translate.php +++ b/modules/product/classes/Model/Product/Translate.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Product_Translate extends ORM_OSB { +class Model_Product_Translate extends ORM { protected $_created_column = FALSE; protected $_updated_column = FALSE; diff --git a/modules/product/media/theme/focusbusiness/pages/plans.css b/modules/product/media/theme/focusbusiness/pages/plans.css index 12f586d0..63582b7e 100644 --- a/modules/product/media/theme/focusbusiness/pages/plans.css +++ b/modules/product/media/theme/focusbusiness/pages/plans.css @@ -122,8 +122,6 @@ padding: 1em 0; margin: 0 2em; - text-align: center; - border-bottom: 1px dotted #CCC; } @@ -379,6 +377,7 @@ font-weight: 500; font-size: 11px; margin: 0 0; + width: 100%; } .plan.plain td:first-of-type { border-left: 1px solid #D8D7D7; @@ -421,7 +420,6 @@ border-top: 1px dotted #D8D7D7; } .plan.plain .plan-features th { - text-align: center; padding: 5px; font-size: 110%; font-weight: normal; diff --git a/modules/product/views/product/admin/edit.php b/modules/product/views/product/admin/edit.php index 6b26b784..b3ad8749 100644 --- a/modules/product/views/product/admin/edit.php +++ b/modules/product/views/product/admin/edit.php @@ -1,6 +1,6 @@
- title();?> + name(Site::language());?>
diff --git a/modules/product/views/product/category/list/supercat.php b/modules/product/views/product/category/list/supercat.php index 703f7539..de9d7c28 100644 --- a/modules/product/views/product/category/list/supercat.php +++ b/modules/product/views/product/category/list/supercat.php @@ -1,7 +1,7 @@
-

// title(); ?>

+

// name(Site::language()); ?>

subcategories->find_all() as $pco) : ?> @@ -14,7 +14,7 @@
-

title(); ?>

+

name(Site::language()); ?>

description())<$x ? $pco->description() : substr($pco->description(),0,$x).'...'; ?>

More Details ยป

diff --git a/modules/product/views/product/list.php b/modules/product/views/product/list.php index ae7fc4e2..7f0b3941 100644 --- a/modules/product/views/product/list.php +++ b/modules/product/views/product/list.php @@ -4,7 +4,7 @@ ->page_items(25) ->columns(array( 'id'=>'ID', - 'title()'=>'Details', + 'name(Site::language())'=>'Name', 'status'=>'Active', 'prod_plugin_file'=>'Plugin Name', 'prod_plugin_data'=>'Plugin Data', diff --git a/modules/product/views/product/view.php b/modules/product/views/product/view.php index 01ad6a7a..76e0bfd8 100644 --- a/modules/product/views/product/view.php +++ b/modules/product/views/product/view.php @@ -1,11 +1,11 @@
-

title(); ?>

+

name(Site::language()); ?>

description(); ?>
-
+
description(TRUE); ?> -
+
diff --git a/modules/service/classes/Controller/Admin/Service.php b/modules/service/classes/Controller/Admin/Service.php index 8026cd31..8ffb8727 100644 --- a/modules/service/classes/Controller/Admin/Service.php +++ b/modules/service/classes/Controller/Admin/Service.php @@ -23,89 +23,13 @@ class Controller_Admin_Service extends Controller_Service { if ($this->request->post() AND $so=$this->add_edit() AND $so->loaded()) HTTP::redirect(URL::link('admin','service/edit/'.$so->id)); - Script::factory() - ->type('file') - ->data('media/theme/bootstrap/js/bootstrap.datepicker.js'); + $this->meta->title = 'New Service'; - Style::factory() - ->type('file') - ->data('media/theme/bootstrap/css/bootstrap.datepicker.css'); - - // @todo This AJAX URL should be a service one - Script::factory() - ->type('stdin') - ->data(' -$(document).ready(function() { - $("#date_next_invoice_label").datepicker({ - autoclose : true, - todayHighlight: true, - format : "dd-mm-yyyy", - todayBtn : true, - }).on("hide",function(ev) { - $("input[name=date_next_invoice]").val(ev.date.valueOf()/1000); - }); - - $("input[name=account_id_label]").typeahead({ - minLength: 2, - source: function (query,process) { - search("'.URL::link('admin','payment/ajaxlist').'",query,process); - }, - - matcher: function () { return true; }, - - updater: function (item) { - $("input[name=account_id]").val(users[item]); - - // Send the request and update sub category dropdown - $.ajax({ - type: "GET", - data: "key="+users[item], - dataType: "html", - cache: false, - url: "'.URL::link('admin','payment/ajaxitemlist',TRUE).'", - timeout: 2000, - error: function(x) { - alert("Failed to submit"); - }, - success: function(data) { - $("div[id=items]").empty().append(data); - } - }); - - return item; - }, - }); - - $("select[name=product_id]").change(function() { - // If we select a blank, then dont continue - if (this.value == 0) - return false; - - // Send the request and update sub category dropdown - $.ajax({ - type: "GET", - data: "key="+$(this).val(), - dataType: "html", - cache: false, - url: "'.URL::link('admin','service/ajaxaddplugin/',TRUE).'", - timeout: 2000, - error: function(x) { - alert("Failed to submit"); - }, - success: function(data) { - $("div[id=plugin]").empty().append(data); - } - }); - }); -}); - '); - -// @todo Move this to automatically add this if a date format is used Block::factory() ->type('form-horizontal') - ->title('Add/View Charge') - ->title_icon('fa fa-wrench') - ->body(View::factory('service/admin/add')); + ->title('Add New Service') + ->title_icon($this->icon) + ->body(View::factory('service/admin/add')->set('o',ORM::factory('Service'))); } public function action_ajaxaddplugin() { @@ -129,26 +53,10 @@ $(document).ready(function() { if (! $so->loaded()) HTTP::redirect('welcome/index'); - Script::factory() - ->type('file') - ->data('media/theme/bootstrap/vendor/datepicker/js/bootstrap-datepicker.js'); - - Style::factory() - ->type('file') - ->data('media/theme/bootstrap/vendor/datepicker/css/datepicker.css'); - Script::factory() ->type('stdin') ->data(' $(document).ready(function() { - $("#date_next_invoice_label").datepicker({ - autoclose : true, - format : "dd-M-yyyy", - todayBtn : true, - }).on("hide",function(ev) { - $("input[name=date_next_invoice]").val(ev.date.valueOf()/1000); - }); - $("#service_connect_date_label").datepicker({ autoclose : true, format : "dd-M-yyyy", @@ -314,12 +222,12 @@ $(document).ready(function() { HTTP::redirect(URL::link('admin','service/view/'.$so->id)); Block::add(array( - 'title'=>sprintf('Transaction History for %s: %s',$so->id(),$so->name()), + 'title'=>sprintf('Transaction History for %s: %s',$so->refnum(TRUE),$so->name()), 'body'=>$loutput, )); Block::add(array( - 'title'=>sprintf('Transaction Debug for %s: %s',$so->id(),$so->name()), + 'title'=>sprintf('Transaction Debug for %s: %s',$so->refnum(TRUE),$so->name()), 'body'=>$doutput, )); @@ -327,7 +235,7 @@ $(document).ready(function() { ->set('o',$so); Block::add(array( - 'title'=>sprintf('%s: %s',$so->id(),$so->service_name()), + 'title'=>sprintf('%s: %s',$so->refnum(TRUE),$so->name()), 'body'=>$output, )); } diff --git a/modules/service/classes/Model/Service.php b/modules/service/classes/Model/Service.php index b82442b8..48f55116 100644 --- a/modules/service/classes/Model/Service.php +++ b/modules/service/classes/Model/Service.php @@ -12,7 +12,7 @@ * Fields: * + queue: PROVISION (to be provisioned) */ -class Model_Service extends ORM_OSB { +class Model_Service extends ORM { private $_plugin = NULL; // Relationships @@ -88,24 +88,6 @@ class Model_Service extends ORM_OSB { /** REQUIRED ABSTRACT METHODS **/ - /** - * Display the service product name - */ - public function name($variable=NULL) { - if (! $variable instanceOf Model_Language) - $variable = Company::instance()->language(); - - return $this->product->name($variable).(($x=$this->namesub($variable)) ? ': '.$x : ''); - } - - public function namesub($variable=NULL) { - return is_null($plugin=$this->_plugin()) ? '' : $plugin->name($variable); - } - - public function refnum($short=FALSE) { - return ($short ? '' : sprintf('%02s-',Site::id())).sprintf('%05s',$this->id); - } - /** LOCAL METHODS **/ private function _plugin() { @@ -234,6 +216,20 @@ class Model_Service extends ORM_OSB { ->order_by('date_stop','DESC'); } + /** + * Display the service product name + */ + public function name($variable=NULL) { + if (! $variable instanceOf Model_Language) + $variable = Company::instance()->language(); + + return $this->product->name($variable).(($x=$this->namesub($variable)) ? ': '.$x : ''); + } + + public function namesub($variable=NULL) { + return is_null($plugin=$this->_plugin()) ? '' : $plugin->name($variable); + } + /** * Returns the date that an item has been paid to */ @@ -284,6 +280,10 @@ class Model_Service extends ORM_OSB { return (is_null($x = $this->plugin())) ? NULL : $x->render_edit(); } + public function refnum($short=FALSE) { + return ($short ? '' : sprintf('%02s-',Site::id())).sprintf('%05s',$this->id); + } + public function revenue($annual=FALSE) { $multiple = $annual ? Period::multiple($this->recur_schedule) : 1; diff --git a/modules/service/classes/Model/Service/Billing.php b/modules/service/classes/Model/Service/Billing.php index ac9f8c3e..7b107ec7 100644 --- a/modules/service/classes/Model/Service/Billing.php +++ b/modules/service/classes/Model/Service/Billing.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Service_Billing extends ORM_OSB { +class Model_Service_Billing extends ORM { protected $_table_name = 'account_billing'; // Relationships diff --git a/modules/service/classes/Model/Service/Change.php b/modules/service/classes/Model/Service/Change.php index 9cb7102e..4e17fbb0 100644 --- a/modules/service/classes/Model/Service/Change.php +++ b/modules/service/classes/Model/Service/Change.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Service_Change extends ORM_OSB { +class Model_Service_Change extends ORM { protected $_table_name = 'service_change'; // Relationships @@ -35,7 +35,7 @@ class Model_Service_Change extends ORM_OSB { $output = array(); foreach ($this->find_all() as $sco) { - array_push($output,sprintf('%s %s',$sco->product->title(),$sco->display('date_effective'))); + array_push($output,sprintf('%s %s',$sco->product->name($sco->service->account->language),$sco->display('date_effective'))); } } else { diff --git a/modules/service/classes/Model/Service/Memo.php b/modules/service/classes/Model/Service/Memo.php index 29f4b667..95c40ae6 100644 --- a/modules/service/classes/Model/Service/Memo.php +++ b/modules/service/classes/Model/Service/Memo.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Service_Memo extends ORM_OSB { +class Model_Service_Memo extends ORM { // Relationships protected $_belongs_to = array( 'service'=>array(), diff --git a/modules/service/classes/Model/Service/Plugin.php b/modules/service/classes/Model/Service/Plugin.php index abc083d7..81f3a46b 100644 --- a/modules/service/classes/Model/Service/Plugin.php +++ b/modules/service/classes/Model/Service/Plugin.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -abstract class Model_Service_Plugin extends ORM_OSB { +abstract class Model_Service_Plugin extends ORM { // Reset any sorting that may be defined in our parent protected $_sorting = array(); diff --git a/modules/service/views/service/admin/add.php b/modules/service/views/service/admin/add.php index 0a1558e7..3b879280 100644 --- a/modules/service/views/service/admin/add.php +++ b/modules/service/views/service/admin/add.php @@ -1,30 +1,50 @@ -
+
Service Information +set('data',['field'=>'account_id','value'=>$o->account_id,'text'=>'Account','name'=>'','ajaxurl'=>URL::link('admin','payment/ajaxlist')]); + echo View::factory('field/select')->set('data',['field'=>'status','value'=>StaticList_YesNo::table(),'text'=>'Active','default'=>$o->status,'class'=>'col-md-1']); + echo View::factory('field/select')->set('data',['field'=>'recur_schedule','value'=>StaticList_RecurSchedule::table(),'text'=>'Billing Period','default'=>$o->recur_schedule,'class'=>'col-md-2']); + echo View::factory('field/date')->set('data',['field'=>'data_next_invoice','value'=>$o->date_next_invoice ? $o->date_next_invoice : time(),'text'=>'Date Next Invoice','enddate'=>NULL]); + echo View::factory('field/select')->set('data',['field'=>'taxable','value'=>StaticList_YesNo::table(),'text'=>'Taxable','default'=>is_null($o->taxable) ? TRUE : $o->taxable,'class'=>'col-md-1']); + echo View::factory('field/select')->set('data',['field'=>'suspend_billing','value'=>StaticList_YesNo::table(),'text'=>'Suspend Billing','default'=>$o->suspend_billing,'class'=>'col-md-1']); + echo View::factory('field/money')->set('data',['field'=>'price','value'=>$o->price,'text'=>'Price']); + echo View::factory('field/money')->set('data',['field'=>'price_override','value'=>$o->price_override,'text'=>'Override Price']); + echo View::factory('field/select')->set('data',['field'=>'product_id','value'=>ORM::factory('Product')->where_active()->list_select(TRUE),'text'=>'Product','default'=>NULL,'class'=>'col-md-5']); +?> - 'Account','placeholder'=>'Account','autocomplete'=>'no','data-provide'=>'typeahead')); ?> - - - 'Active')); ?> - 'Billing Period','required'));?> - - -
- - -
- - - 'Taxable')); ?> - 'Suspend Billing')); ?> - 'Override Price')); ?> - list_select(TRUE),NULL,array('label'=>'Product','sort'=>TRUE)); ?>
-
- - -
-
+ +
+ +type('stdin') + ->data(' +$(document).ready(function() { + $("select[name=product_id]").change(function() { + // If we select a blank, then dont continue + if (this.value == 0) + return false; + + // Send the request and update sub category dropdown + $.ajax({ + type: "GET", + data: "key="+$(this).val(), + dataType: "html", + cache: false, + url: "'.URL::link('admin','service/ajaxaddplugin/',TRUE).'", + timeout: 2000, + error: function(x) { + alert("Failed to submit"); + }, + success: function(data) { + $("div[id=plugin]").empty().append(data); + } + }); + }); +});'); +?> diff --git a/modules/service/views/service/admin/edit.php b/modules/service/views/service/admin/edit.php index f0252f6c..8bdea37f 100644 --- a/modules/service/views/service/admin/edit.php +++ b/modules/service/views/service/admin/edit.php @@ -1,29 +1,17 @@ -
+
Update Service - - status,FALSE,array('label'=>'Active')); ?> - - recur_schedule,FALSE,array('label'=>'Billing Period','required'));?> - - -
- - -
- date_next_invoice); ?> - - taxable,FALSE,array('label'=>'Taxable')); ?> - - suspend_billing,FALSE,array('label'=>'Suspend Billing')); ?> - - price_override,array('label'=>'Override Price')); ?> +set('data',['field'=>'status','value'=>StaticList_YesNo::table(),'text'=>'Active','default'=>$o->status,'class'=>'col-md-1']); + echo View::factory('field/select')->set('data',['field'=>'recur_schedule','value'=>StaticList_RecurSchedule::table(),'text'=>'Billing Period','default'=>$o->recur_schedule,'class'=>'col-md-2']); + echo View::factory('field/date')->set('data',['field'=>'data_next_invoice','value'=>$o->date_next_invoice,'text'=>'Date Next Invoice','enddate'=>NULL]); + echo View::factory('field/select')->set('data',['field'=>'taxable','value'=>StaticList_YesNo::table(),'text'=>'Taxable','default'=>$o->taxable,'class'=>'col-md-1']); + echo View::factory('field/select')->set('data',['field'=>'suspend_billing','value'=>StaticList_YesNo::table(),'text'=>'Suspend Billing','default'=>$o->suspend_billing,'class'=>'col-md-1']); + echo View::factory('field/money')->set('data',['field'=>'price_override','value'=>$o->price_override,'text'=>'Override Price']); +?>
-
- - -
-
+ +
diff --git a/modules/service/views/service/admin/view.php b/modules/service/views/service/admin/view.php index e367b374..c91d0383 100644 --- a/modules/service/views/service/admin/view.php +++ b/modules/service/views/service/admin/view.php @@ -1,10 +1,10 @@ pending_change()) : ?> -
+
Pending change to: service_change->list_details(); ?>
-
+
Service Transaction Details @@ -28,7 +28,7 @@ product_id) AND $lp != $iio->product_id) : $lp = $iio->product_id; ?> product_id; ?> - product->title(); ?> + product->name($o->account->language); ?> diff --git a/modules/service/views/service/info.php b/modules/service/views/service/info.php index 219e6d6c..1e14b446 100644 --- a/modules/service/views/service/info.php +++ b/modules/service/views/service/info.php @@ -20,10 +20,9 @@
Cost
price_override) ? sprintf('%s ',$o->price(TRUE,TRUE,TRUE)) : ''). $o->price(TRUE,TRUE); if ($o->pending_change()) echo ' *'; ?>
- price) OR ($o->price<=$o->product->price($o->price_group,$o->recur_schedule,'base'))) : ?>
Service
-
product_id,$o->product->title()); ?>
+
product_id,$o->product->name($o->account->language)); ?>
Invoiced To
diff --git a/modules/ssl/classes/Controller/Reseller/Ssl.php b/modules/ssl/classes/Controller/Reseller/Ssl.php index e1d87b76..ae5622c8 100644 --- a/modules/ssl/classes/Controller/Reseller/Ssl.php +++ b/modules/ssl/classes/Controller/Reseller/Ssl.php @@ -122,12 +122,12 @@ class Controller_Reseller_Ssl extends Controller_Ssl { } public function action_renew() { - $so = ORM::factory('Service',Request::current()->param('id')); + $so = ORM::factory('Service',$this->request->param('id')); if (! $so->loaded() OR ! Auth::instance()->authorised($so->account)) throw HTTP_Exception::factory(403,'Service either doesnt exist, or you are not authorised to see it'); - $so->plugin()->renew(); + $so->plugin()->renew($this->request->query('force')); HTTP::redirect(URL::link('user','service/view/'.$so->id)); } diff --git a/modules/ssl/classes/Model/SSL.php b/modules/ssl/classes/Model/SSL.php index 42b0d1a5..04d3141c 100644 --- a/modules/ssl/classes/Model/SSL.php +++ b/modules/ssl/classes/Model/SSL.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_SSL extends ORM_OSB { +class Model_SSL extends ORM { protected $_updated_column = FALSE; } ?> diff --git a/modules/ssl/classes/Model/SSL/CA.php b/modules/ssl/classes/Model/SSL/CA.php index 5df1b3f8..daf3de5e 100644 --- a/modules/ssl/classes/Model/SSL/CA.php +++ b/modules/ssl/classes/Model/SSL/CA.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_SSL_CA extends ORM_OSB { +class Model_SSL_CA extends ORM { protected $_updated_column = FALSE; // Relationships diff --git a/modules/ssl/classes/Model/Service/Plugin/Ssl.php b/modules/ssl/classes/Model/Service/Plugin/Ssl.php index db348df4..514e8a3b 100644 --- a/modules/ssl/classes/Model/Service/Plugin/Ssl.php +++ b/modules/ssl/classes/Model/Service/Plugin/Ssl.php @@ -47,14 +47,6 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin { return (! $this->_so) ? ($format ? 'Not Issued' : 0) : $this->_so->get_valid_to($format); } - public function name($variable=NULL) { - return ($this->cert AND $this->ca->loaded()) ? sprintf('%s:%s',$this->ca->subject(),$this->display('cert')) : $this->display('csr'); - } - - public function namesub($variable=NULL) { - return $this->ca->dn(); - } - public function password() {} // Not used public function username() {} // Not used @@ -156,6 +148,14 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin { return 'Unknown'; } + public function name($variable=NULL) { + return ($this->cert AND $this->ca->loaded()) ? sprintf('%s:%s',$this->ca->subject(),$this->display('cert')) : $this->display('csr'); + } + + public function namesub($variable=NULL) { + return $this->ca->dn(); + } + /** * Renew an SSL Certificate */ @@ -180,7 +180,7 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin { $res = openssl_csr_sign($this->csr,$this->ca->sign_cert,$this->ca->sign_pk,$days,array( 'config'=>$ssl_conf['config'], 'x509_extensions'=>$this->service->product->plugin()->extensions, - 'digest_alg'=>'sha1', + 'digest_alg'=>$ssl_conf['digest'], ),time()); if ($res AND openssl_x509_export($res,$cert)) { diff --git a/modules/ssl/config/ssl.php b/modules/ssl/config/ssl.php index 729a4970..0576dd2d 100644 --- a/modules/ssl/config/ssl.php +++ b/modules/ssl/config/ssl.php @@ -18,5 +18,8 @@ return array( // Location to openssl config 'config' => 'application/config/openssl.cnf', + + // Algorithm to use for signing certs + 'digest' => 'sha256', ); ?> diff --git a/modules/ssl/views/service/admin/plugin/ssl/edit.php b/modules/ssl/views/service/admin/plugin/ssl/edit.php index bff575f9..24d6168a 100644 --- a/modules/ssl/views/service/admin/plugin/ssl/edit.php +++ b/modules/ssl/views/service/admin/plugin/ssl/edit.php @@ -1,7 +1,9 @@
SSL Certificate Service Details - service->plugin()->csr,array('label'=>'CSR','placeholder'=>'CSR','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->csr),'cols'=>Form::textarea_width($o->service->plugin()->csr))); ?> - service->plugin()->pk,array('label'=>'Private Key','placeholder'=>'Private Key','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->pk),'cols'=>Form::textarea_width($o->service->plugin()->pk))); ?> - service->plugin()->cert,array('label'=>'Public Certificate','placeholder'=>'Public Certificate','style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->cert),'cols'=>Form::textarea_width($o->service->plugin()->cert))); ?> +set('data',['field'=>'plugin[csr]','value'=>$o->service->plugin()->csr,'text'=>'CSR']); + echo View::factory('field/textarea')->set('data',['field'=>'plugin[pk]','value'=>$o->service->plugin()->pk,'text'=>'Private Key']); + echo View::factory('field/textarea')->set('data',['field'=>'plugin[cert]','value'=>$o->service->plugin()->cert,'text'=>'Public Certificate']); +?>
diff --git a/modules/task/classes/Model/Task.php b/modules/task/classes/Model/Task.php index 77d7dc98..6ace2524 100644 --- a/modules/task/classes/Model/Task.php +++ b/modules/task/classes/Model/Task.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Task extends ORM_OSB { +class Model_Task extends ORM { protected $_display_filters = array( 'date_run'=>array( array('Site::Datetime',array(':value')), diff --git a/modules/task/classes/Model/Task/Log.php b/modules/task/classes/Model/Task/Log.php index 15c0fc84..6908a84c 100644 --- a/modules/task/classes/Model/Task/Log.php +++ b/modules/task/classes/Model/Task/Log.php @@ -9,7 +9,7 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Task_Log extends ORM_OSB { +class Model_Task_Log extends ORM { protected $_sorting = array( 'id'=>'DESC', ); diff --git a/modules/tax/classes/Model/Invoice/Item/Tax.php b/modules/tax/classes/Model/Invoice/Item/Tax.php index b8de5243..e40ccc3c 100644 --- a/modules/tax/classes/Model/Invoice/Item/Tax.php +++ b/modules/tax/classes/Model/Invoice/Item/Tax.php @@ -9,6 +9,6 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Invoice_Item_Tax extends ORM_OSB { +class Model_Invoice_Item_Tax extends ORM { } ?> diff --git a/modules/tax/classes/Model/Tax.php b/modules/tax/classes/Model/Tax.php index 19adab47..32a7199e 100644 --- a/modules/tax/classes/Model/Tax.php +++ b/modules/tax/classes/Model/Tax.php @@ -9,6 +9,6 @@ * @copyright (c) 2009-2013 Open Source Billing * @license http://dev.osbill.net/license.html */ -class Model_Tax extends ORM_OSB { +class Model_Tax extends ORM { } ?>