diff --git a/application/classes/Controller/Reseller/Welcome.php b/application/classes/Controller/Reseller/Welcome.php index 15a5394e..f7899fcb 100644 --- a/application/classes/Controller/Reseller/Welcome.php +++ b/application/classes/Controller/Reseller/Welcome.php @@ -94,7 +94,7 @@ class Controller_Reseller_Welcome extends Controller_Welcome { 'date_payment'=>'Pay Date', 'account->accnum()'=>'Num', 'account->name()'=>'Account', - 'account->status'=>'Active', + 'account->display("status")'=>'Active', 'total(TRUE)'=>'Total', 'balance(TRUE)'=>'Balance', )) diff --git a/modules/adsl/classes/Model/Service/Plugin/Adsl.php b/modules/adsl/classes/Model/Service/Plugin/Adsl.php index 2a590a8a..91eeb904 100644 --- a/modules/adsl/classes/Model/Service/Plugin/Adsl.php +++ b/modules/adsl/classes/Model/Service/Plugin/Adsl.php @@ -32,15 +32,6 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin { ); // Required abstract functions - public function admin_update() { - return View::factory('service/admin/adsl/update') - ->set('mediapath',Route::get('default/media')) - ->set('so',$this); - } - - /** - * When does this service expire - */ public function expire() { // @todo This should work out if the invoices are currently due, then the expire is the invoice date, otherwise the next invoice date. return NULL; @@ -50,6 +41,33 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin { return $this->service_number; } + public function admin_update() { + Script::factory() + ->type('stdin') + ->data(' +$(document).ready(function() { + $("#service_connect_date_label").datepicker({ + autoclose : true, + startDate : now, + format : "dd-M-yyyy", + todayBtn : true, + }).on("hide",function(ev) { + $("input[id=service_connect_date]").val(ev.date.valueOf()/1000); + }); + $("#service_contract_date_label").datepicker({ + autoclose : true, + startDate : now, + format : "dd-M-yyyy", + todayBtn : true, + }).on("hide",function(ev) { + $("input[id=service_contract_date]").val(ev.date.valueOf()/1000); + }); +}); + '); + + return parent::admin_update(); + } + public function product() { if ($this->provided_adsl_plan_id) return $this->adsl_plan; diff --git a/modules/adsl/views/service/admin/adsl/update.php b/modules/adsl/views/service/admin/adsl/update.php deleted file mode 100644 index 5be29853..00000000 --- a/modules/adsl/views/service/admin/adsl/update.php +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Plugin Details
Service Numberservice_number); ?>
Service Addressservice_address); ?>
Service Connect Date - service_connect_date,array('id'=>'service_connect_date')); ?> - uri(array('file'=>'img/calendar.png')),array('alt'=>_('Calendar'),'style'=>'cursor: pointer;')), - array('title'=>'Click to popup a dialog to select a date graphically','onclick'=>"dateSelector('service_connect_date')")); ?> - -
Service Contract Date - service_contract_date,array('id'=>'service_contract_date')); ?> - uri(array('file'=>'img/calendar.png')),array('alt'=>_('Calendar'),'style'=>'cursor: pointer;')), - array('title'=>'Click to popup a dialog to select a date graphically','onclick'=>"dateSelector('service_contract_date')")); ?> - -
Service Usernameservice_username); ?>
Service Passwordservice_password); ?>
Service IP Addressipaddress); ?>
diff --git a/modules/adsl/views/service/admin/plugin/adsl/edit.php b/modules/adsl/views/service/admin/plugin/adsl/edit.php new file mode 100644 index 00000000..a47de888 --- /dev/null +++ b/modules/adsl/views/service/admin/plugin/adsl/edit.php @@ -0,0 +1,45 @@ +
+
+ service_number,array('class'=>'span2','label'=>'Service Number','placeholder'=>'Service Number')); ?> +
+
+ +
+
+ service_address,array('class'=>'span6','label'=>'Service Address','placeholder'=>'Service Address')); ?> +
+
+ +
+
+ display('service_connect_date'),array('class'=>'span2','label'=>'Service Connected','add-on'=>'','disabled')); ?> +
+ + service_connect_date,array('id'=>'service_connect_date')); ?> +
+ +
+
+ display('service_contract_date'),array('class'=>'span2','label'=>'Contract Start Date','add-on'=>'','disabled')); ?> +
+ + service_contract_date,array('id'=>'service_contract_date')); ?> +
+ +
+
+ service_username,array('class'=>'span6','label'=>'Service Username','placeholder'=>'Service Username')); ?> +
+
+ +
+
+ service_password,array('class'=>'span6','label'=>'Service Password','placeholder'=>'Service Password')); ?> +
+
+ +
+
+ ipaddress,array('class'=>'span6','label'=>'Service IP Address','placeholder'=>'Service IP Address')); ?> +
+
diff --git a/modules/charge/classes/Controller/Reseller/Charge.php b/modules/charge/classes/Controller/Reseller/Charge.php index b9465adf..3c5a0f41 100644 --- a/modules/charge/classes/Controller/Reseller/Charge.php +++ b/modules/charge/classes/Controller/Reseller/Charge.php @@ -81,7 +81,7 @@ $(document).ready(function() { $("#date_charge_label").datepicker({ autoclose : true, endDate : now, - format : "dd-mm-yyyy", + format : "dd-M-yyyy", todayBtn : true, }).on("hide",function(ev) { $("input[name=date_charge]").val(ev.date.valueOf()/1000); @@ -152,7 +152,7 @@ $(document).ready(function() { ->columns(array( 'id'=>'ID', 'date_charge'=>'Date', - 'processed(TRUE)'=>'Processed', + 'processed'=>'Processed', 'invoice_item->invoice_id'=>'Invoice', 'sweep_type'=>'Sweep', 'quantity'=>'Quantity', diff --git a/modules/lnApp b/modules/lnApp index 45cadf09..c014a4ce 160000 --- a/modules/lnApp +++ b/modules/lnApp @@ -1 +1 @@ -Subproject commit 45cadf09454eede07c4c75238231bed8967a6848 +Subproject commit c014a4cec843a37c14cb77b2d453909b8ca6494e diff --git a/modules/service/classes/Controller/Admin/Service.php b/modules/service/classes/Controller/Admin/Service.php index 0f4a13a5..6c7fe3cf 100644 --- a/modules/service/classes/Controller/Admin/Service.php +++ b/modules/service/classes/Controller/Admin/Service.php @@ -115,50 +115,95 @@ class Controller_Admin_Service extends Controller_Service { } public function action_update() { - $id = $this->request->param('id'); + list($id,$output) = Table::page(__METHOD__); + $so = ORM::factory('Service',$id); if (! $so->loaded()) HTTP::redirect('welcome/index'); if ($_POST) { - if (isset($_POST['plugin']) AND $_POST['plugin']) - if (! $so->plugin()->values($_POST['plugin'])->update()->saved()) - throw new Kohana_Exception('Failed to save updates to plugin data for record :record',array(':record'=>$so->id())); + // Entry updated + if (isset($_POST['plugin']) AND $_POST['plugin']) { + $p = $so->plugin(); - if (! $so->values($_POST)->update()->saved()) - throw new Kohana_Exception('Failed to save updates to service data for record :record',array(':record'=>$so->id())); + if ($p->values($_POST['plugin'])->changed() AND $p->check()) { + try { + $p->values($_POST['plugin'])->save(); + SystemMessage::factory() + ->title('Record PLUGIN updated') + ->type('success') + ->body(_('Your Charge record has been recorded/updated.')); + + } catch (ORM_Validation_Exception $e) { + $errors = $e->errors('models'); + + SystemMessage::factory() + ->title('Record PLUGIN NOT updated') + ->type('error') + ->body(join('
',array_values($errors))); + + $so->reload(); + } + } + } + + if ($so->values($_POST)->changed() AND $so->check()) { + try { + $so->values($_POST)->save(); + SystemMessage::factory() + ->title('Record updated') + ->type('success') + ->body(_('Your Charge record has been recorded/updated.')); + + } catch (ORM_Validation_Exception $e) { + $errors = $e->errors('models'); + + SystemMessage::factory() + ->title('Record NOT updated') + ->type('error') + ->body(join('
',array_values($errors))); + + $so->reload(); + } + } } - Block::add(array( - 'title'=>sprintf('%s %s:%s',_('Update Service'),$so->id(),$so->name()), - 'body'=>View::factory($this->viewpath()) - ->set('so',$so) - ->set('mediapath',Route::get('default/media')) - ->set('plugin_form',$so->admin_update()), - )); + 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(' +var nowTemp = new Date(); +var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0); + +$(document).ready(function() { + $("#date_next_invoice_label").datepicker({ + autoclose : true, + startDate : now, + format : "dd-M-yyyy", + todayBtn : true, + }).on("hide",function(ev) { + $("input[name=date_next_invoicel]").val(ev.date.valueOf()/1000); + }); +}); + '); + + Block::factory() + ->type('form-horizontal') + ->title(sprintf('%s: %s %s',_('Update Service'),$id,$so->name())) + ->title_icon('icon-wrench') + ->body(View::factory('service/admin/edit') + ->set('o',$so) + ->set('plugin_form',$so->admin_update()) + ); - // @todo Investigate a better way of preparing for jscalendar - Script::add(array( - 'type'=>'file', - 'data'=>'js/dhtml.calendar.js', - )); - Script::add(array( - 'type'=>'file', - 'data'=>'js/dhtml.calendar-setup.js', - )); - Script::add(array( - 'type'=>'file', - 'data'=>'js/dhtml.calendar-en.js', - )); - Script::add(array( - 'type'=>'file', - 'data'=>'js/dhtml.date_selector.js', - )); - Style::add(array( - 'type'=>'file', - 'data'=>'css/dhtml.calendar.css', - )); } public function action_view() { @@ -173,8 +218,8 @@ class Controller_Admin_Service extends Controller_Service { $doutput = $loutput = ''; - $loutput .= View::factory($this->viewpath()) - ->set('so',$so); + $loutput .= View::factory('service/admin/view') + ->set('o',$so); // Validate the transactions $bt = NULL; @@ -241,7 +286,7 @@ class Controller_Admin_Service extends Controller_Service { )); $output .= View::factory('service/user/view') - ->set('so',$so); + ->set('o',$so); Block::add(array( 'title'=>sprintf('%s: %s',$so->id(),$so->service_name()), diff --git a/modules/service/classes/Model/Service/Plugin.php b/modules/service/classes/Model/Service/Plugin.php index 9fcb4390..1e1572c0 100644 --- a/modules/service/classes/Model/Service/Plugin.php +++ b/modules/service/classes/Model/Service/Plugin.php @@ -13,11 +13,6 @@ abstract class Model_Service_Plugin extends ORM_OSB { // Reset any sorting that may be defined in our parent protected $_sorting = array(); - /** - * Form info for admins to update - */ - abstract public function admin_update(); - /** * Our service name as defined in the DB */ @@ -46,6 +41,14 @@ abstract class Model_Service_Plugin extends ORM_OSB { abstract public function username_value(); abstract public function password_value(); + /** + * Form info for admins to update + */ + public function admin_update() { + return View::factory(sprintf('service/admin/plugin/%s/edit',$this->plugin())) + ->set('o',$this); + } + public function manage_button() { if (! $this->service->status OR $this->service->expiring()) return FALSE; @@ -76,6 +79,10 @@ function() { $("form[id=id_"+t[0]+"_"+t[1]+"]").submit(); }); return TRUE; } + protected function plugin() { + return strtolower(preg_replace('/(.*)_([a-zA-Z]+)$/',"$2",get_class($this))); + } + /** * Get specific service details for use in other modules * For Example: Invoice diff --git a/modules/service/views/service/admin/edit.php b/modules/service/views/service/admin/edit.php new file mode 100644 index 00000000..91980d32 --- /dev/null +++ b/modules/service/views/service/admin/edit.php @@ -0,0 +1,48 @@ +
+
+
+ Update Service + +
+
+ status,FALSE,array('label'=>'Active','class'=>'span1')); ?> +
+
+ +
+
+ recur_schedule,FALSE,array('label'=>'Billing Period','required'));?> +
+
+ +
+
+ display('date_next_invoice'),array('class'=>'span2','label'=>'Date Last Invoice','add-on'=>'','disabled')); ?> +
+ + date_next_invoice); ?> +
+ +
+
+ taxable,FALSE,array('label'=>'Taxable','class'=>'span1')); ?> +
+
+ +
+
+ suspend_billing,FALSE,array('label'=>'Suspend Billing','class'=>'span1')); ?> +
+
+ + + +
+
+ + +
+
+
+
+
diff --git a/modules/service/views/service/admin/update.php b/modules/service/views/service/admin/update.php deleted file mode 100644 index 951edfaa..00000000 --- a/modules/service/views/service/admin/update.php +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Service Activestatus); ?>
Queuedisplay('queue'); ?>
Billing Periodproduct,$so->recur_schedule);?>
Date Last Invoicedisplay('date_last_invoice'); ?>
Date Next Invoice - date_next_invoice,array('id'=>'date_next_invoice')); ?> - uri(array('file'=>'img/calendar.png')),array('alt'=>_('Calendar'),'style'=>'cursor: pointer;')), - array('title'=>'Click to popup a dialog to select a date graphically','onclick'=>"dateSelector('date_next_invoice')")); ?> - -
Taxabletaxable); ?>
Suspend Billingsuspend_billing); ?>
- '.$plugin_form; } ?> - -
-'form_button')); ?> - diff --git a/modules/ssl/classes/Model/Service/Plugin/Ssl.php b/modules/ssl/classes/Model/Service/Plugin/Ssl.php index 1c954dad..1db5a578 100644 --- a/modules/ssl/classes/Model/Service/Plugin/Ssl.php +++ b/modules/ssl/classes/Model/Service/Plugin/Ssl.php @@ -104,13 +104,6 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin { } } - // @todo This needs to be validated for this model - public function admin_update() { - return View::factory('service/admin/plugin/ssl/update') - ->set('mediapath',Route::get('default/media')) - ->set('o',$this); - } - public function download_button() { if (! $this->service->status OR ! preg_match('/client/',$this->service->product->plugin()->extensions) OR $this->valid_to() < time()) return ''; diff --git a/modules/ssl/views/service/admin/plugin/ssl/edit.php b/modules/ssl/views/service/admin/plugin/ssl/edit.php new file mode 100644 index 00000000..e203a691 --- /dev/null +++ b/modules/ssl/views/service/admin/plugin/ssl/edit.php @@ -0,0 +1,17 @@ +
+
+ service->plugin()->csr,array('class'=>'span6','label'=>'CSR','placeholder'=>'CSR','nowysihtml'=>TRUE,'style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->csr))); ?> +
+
+ +
+
+ service->plugin()->pk,array('class'=>'span6','label'=>'Private Key','placeholder'=>'Private Key','nowysihtml'=>TRUE,'style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->pk))); ?> +
+
+ +
+
+ service->plugin()->cert,array('class'=>'span6','label'=>'Public Certificate','placeholder'=>'Public Certificate','nowysihtml'=>TRUE,'style'=>'font-family: monospace;','rows'=>Form::textarea_rows($o->service->plugin()->cert))); ?> +
+
diff --git a/modules/ssl/views/service/admin/plugin/ssl/update.php b/modules/ssl/views/service/admin/plugin/ssl/update.php deleted file mode 100644 index fe47ed19..00000000 --- a/modules/ssl/views/service/admin/plugin/ssl/update.php +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - -
CSRservice->plugin()->csr,array('cols'=>64,'rows'=>13,'nowysihtml'=>TRUE)); ?>
PKservice->plugin()->pk,array('cols'=>64,'rows'=>13,'nowysihtml'=>TRUE)); ?>
Certservice->plugin()->cert,array('cols'=>64,'rows'=>13,'nowysihtml'=>TRUE)); ?>