diff --git a/application/classes/Controller/Admin/Module.php b/application/classes/Controller/Admin/Module.php
index edaa33c6..ae032d1a 100644
--- a/application/classes/Controller/Admin/Module.php
+++ b/application/classes/Controller/Admin/Module.php
@@ -16,12 +16,45 @@ class Controller_Admin_Module extends Controller_Module {
'list'=>TRUE,
);
+ protected function _classes($dir,$class,$array=NULL,$key='') {
+ $result = array();
+
+ if (is_null($array)) {
+ $array = Kohana::list_files('classes');
+ $array = $array['classes/Controller'];
+ $key = 'classes/Controller';
+ }
+
+ if (! $class)
+ return array_keys($array);
+
+ if (! $dir) {
+ if (! empty($array[$key.'/'.$class]))
+ $result = Arr::merge($result,$this->_classes('','',$array[$key.'/'.$class],$key.'/'.$class));
+
+ if (! empty($array[$key.'/'.$class.'.php']))
+ array_push($result,$key.'/'.$class);
+
+ } else {
+ if (! empty($array[$key.'/'.$dir]))
+ $result = Arr::merge($result,$this->_classes('',$class,$array[$key.'/'.$dir],$key.'/'.$dir));
+
+ if (! empty($array[$key.'/'.$dir.'/'.$class.'.php']))
+ array_push($result,$key.'/'.$dir.'/'.$class);
+ }
+
+ foreach ($result as $k=>$v)
+ $result[$k] = str_replace('.php','',str_replace('/','_',preg_replace('/^classes\//','',$v)));
+
+ return $result;
+ }
+
/**
* Get the list of methods for a class
*/
protected function _methods($class) {
+ $class = Kohana::classname($class);
// Get a list of methods this module has
- $ch = 'Controller_%s';
$methods = $secure_actions = $auth_required = array();
// List of classes where all our methods are, including this one.
@@ -30,20 +63,26 @@ class Controller_Admin_Module extends Controller_Module {
foreach ($classes as $c) {
$x = URL::dir($c);
- $cn = Kohana::classname('Controller_'.($x ? $x.'_'.$class : $class));
+ $cp = $this->_classes($x,$class);
- if (class_exists($cn)) {
- $r = new ReflectionClass($cn);
+ foreach ($cp as $cn)
+ if (class_exists($cn)) {
+ $sc = preg_replace(sprintf('/^Controller_%s%s_?/',$x ? $x.'_' : '',$class),'',$cn);
+ $r = new ReflectionClass($cn);
- $rdp = $r->getDefaultProperties();
- $secure_actions[$cn] = $rdp['secure_actions'];
- $auth_required[$cn] = $rdp['auth_required'];
+ $rdp = $r->getDefaultProperties();
+ $secure_actions[$cn] = $rdp['secure_actions'];
+ $auth_required[$cn] = $rdp['auth_required'];
- foreach ($r->getMethods() as $method) {
- if (preg_match('/^action_/',$method->name))
- array_push($methods,str_replace('action_',strtolower(($x ? $x.'_' : $x)),$method->name));
+ foreach ($r->getMethods() as $method)
+ if (preg_match('/^action_/',$method->name))
+ array_push($methods,
+ str_replace('action_',
+ #strtolower(($x ? $x.'_' : '').($sc ? $sc.'_' : '')),
+ strtolower($x.($sc ? '_'.$sc : '').':'),
+ $method->name)
+ );
}
- }
}
return array('methods'=>$methods,'secure_actions'=>$secure_actions,'auth_required'=>$auth_required);
diff --git a/application/classes/Controller/Reseller/Account.php b/application/classes/Controller/Reseller/Account.php
index 7f33c719..87f7d7cb 100644
--- a/application/classes/Controller/Reseller/Account.php
+++ b/application/classes/Controller/Reseller/Account.php
@@ -39,7 +39,7 @@ class Controller_Reseller_Account extends Controller_Account {
Block::add(array(
'title'=>_('Customer List'),
'body'=>Table::display(
- $this->filter(ORM::factory('Account')->list_active(),$this->ao->RTM->customers($this->ao->RTM),'sortkey(TRUE)','id'),
+ $this->filter(ORM::factory('Account')->list_active(),$this->ao->RTM->customers($this->ao->RTM),'id','sortkey(TRUE)'),
25,
array(
'id'=>array('label'=>'ID','url'=>URL::link('reseller','invoice/list/')),
@@ -64,7 +64,7 @@ class Controller_Reseller_Account extends Controller_Account {
Block::add(array(
'title'=>_('Account Login Log'),
'body'=>Table::display(
- $this->filter(ORM::factory('Account_Log')->find_all(),$this->ao->RTM->customers($this->ao->RTM),NULL,'account_id'),
+ $this->filter(ORM::factory('Account_Log')->find_all(),$this->ao->RTM->customers($this->ao->RTM),'account_id'),
25,
array(
'id'=>array('label'=>'ID'),
diff --git a/application/classes/Controller/TemplateDefault.php b/application/classes/Controller/TemplateDefault.php
index 06fd32c5..c82100cf 100644
--- a/application/classes/Controller/TemplateDefault.php
+++ b/application/classes/Controller/TemplateDefault.php
@@ -52,9 +52,13 @@ class Controller_TemplateDefault extends lnApp_Controller_TemplateDefault {
/**
* This will filter a search query to only return those accounts for a reseller
- * @todo Swap the order of these params and make flid necessary
+ *
+ * @param $o Our ORM Object that we are searching on
+ * @param $fl Our array of items that we must return
+ * @param $flid The ID that must be in the $fl
+ * @param $sort Sort the results
*/
- protected function filter($o,array $fl,$sort=NULL,$flid=NULL) {
+ protected function filter($o,array $fl,$flid,$sort=NULL) {
$result = array();
foreach ($o as $x)
diff --git a/application/classes/Menu.php b/application/classes/Menu.php
index 6c1b44d3..cfea2d05 100644
--- a/application/classes/Menu.php
+++ b/application/classes/Menu.php
@@ -13,17 +13,17 @@ class Menu {
private static function collapse(array $array) {
$result = array();
- foreach ($array as $item) {
- if (isset($result[$item->module->name])) {
- if (! is_array($result[$item->module->name]))
- $result[$item->module->name] = array($result[$item->module->name]);
+ foreach ($array as $mmo) {
+ if (isset($result[$mmo->module->name])) {
+ if (! is_array($result[$mmo->module->name]))
+ $result[$mmo->module->name] = array($result[$mmo->module->name]);
- array_push($result[$item->module->name],$item);
+ array_push($result[$mmo->module->name],$mmo);
continue;
} else {
- $result[$item->module->name] = $item;
+ $result[$mmo->module->name] = $mmo;
}
}
@@ -36,10 +36,10 @@ class Menu {
if (empty(URL::$method_directory[$type]))
return NULL;
- $uo = Auth::instance()->get_user();
+ $ao = Auth::instance()->get_user();
- foreach ($uo->methods() as $mmo)
- if ($mmo->menu_display AND preg_match('/^'.$type.'_/',$mmo->name))
+ foreach ($ao->methods() as $mmo)
+ if ($mmo->menu_display AND $type == $mmo->directory())
if (empty($result[$mmo->id]))
$result[$mmo->id] = $mmo;
diff --git a/application/classes/Model/Account.php b/application/classes/Model/Account.php
index 48c1f031..892b7ffe 100644
--- a/application/classes/Model/Account.php
+++ b/application/classes/Model/Account.php
@@ -123,7 +123,7 @@ class Model_Account extends Model_Auth_UserDefault {
if (empty($result[$mmo->id]))
$result[$mmo->id] = $mmo;
- Sort::MAsort($result,'module->name,name');
+ Sort::MAsort($result,'module->name,menu_display');
return $result;
}
diff --git a/application/classes/Model/Module/Method.php b/application/classes/Model/Module/Method.php
index 79c001e3..14e617b7 100644
--- a/application/classes/Model/Module/Method.php
+++ b/application/classes/Model/Module/Method.php
@@ -31,12 +31,29 @@ class Model_Module_Method extends ORM_OSB {
protected $status;
+ // Temporarily adjust our name
+ // @todo This is temporary until all our method names are colon delimited.
+ protected function _load_values(array $values) {
+ parent::_load_values($values);
+
+ if (substr_count($this->name,'_') == 1 AND ! substr_count($this->name,':'))
+ $this->name = str_replace('_',':',$this->name);
+ elseif (substr_count($this->name,'_') > 1)
+ throw HTTP_Exception::factory(501,'Method :id has double underscore',array(':id'=>$this->id));
+
+ return $this;
+ }
+
+ public function controller_sub() {
+ return substr_count($this->name,'_') ? substr($this->name,($x=strpos($this->name,'_')),strpos($this->name,':')-$x) : '';
+ }
+
public function controller() {
- return Kohana::classname(sprintf('Controller%s_%s',($this->directory() ? '_' : '').$this->directory(),$this->module->name));
+ return Kohana::classname(sprintf('Controller%s_%s',($this->directory() ? '_' : '').$this->directory(),$this->module->name).$this->controller_sub());
}
public function directory() {
- return substr($this->name,0,strpos($this->name,'_'));
+ return substr($this->name,0,substr_count($this->name,'_') ? strpos($this->name,'_') : strpos($this->name,':'));
}
/**
@@ -51,7 +68,7 @@ class Model_Module_Method extends ORM_OSB {
}
public function method() {
- return substr($this->name,strpos($this->name,'_')+1);
+ return substr($this->name,strpos($this->name,':')+1);
}
public function status($status=NULL) {
@@ -62,12 +79,12 @@ class Model_Module_Method extends ORM_OSB {
}
public function url() {
- if (! preg_match('/_/',$this->name))
+ if (! preg_match('/:/',$this->name))
return NULL;
- list($type,$action) = preg_split('/_/',$this->name,2);
+ list($type,$action) = preg_split('/:/',$this->name,2);
- return URL::link($type,$this->module->name.'/'.$action);
+ return URL::link($this->directory(),$this->module->name.$this->controller_sub().'/'.$action);
}
}
?>
diff --git a/application/classes/Request.php b/application/classes/Request.php
index cd3bc653..4120cb62 100644
--- a/application/classes/Request.php
+++ b/application/classes/Request.php
@@ -39,13 +39,18 @@ class Request extends Kohana_Request {
$result = NULL;
- $mo = ORM::factory('Module',array('name'=>$this->_controller));
+ list($c,$x) = substr_count($this->_controller,'_') ? explode('_',$this->_controller,2) : array($this->_controller,'');
+
+ $mo = ORM::factory('Module',array('name'=>$c));
if ($mo->loaded() AND $mo->status) {
- $method = strtolower($this->_directory ? sprintf('%s_%s',$this->_directory,$this->_action) : $this->_action);
+ $method = strtolower($this->_directory ? sprintf('%s:%s',$this->_directory.($x ? '_'.$x : ''),$this->_action) : $this->_action);
// Get the method number
- $mmo = $mo->module_method->where('name','=',$method)->find();
+ $mmo = $mo->module_method
+ ->where('name','=',$method)
+ ->or_where('name','=',str_replace(':','_',$method)) // @todo This is temporary until all our method names have a colon delimiter
+ ->find();
if ($mmo->loaded())
$result = $mmo;
diff --git a/application/views/account/user/edit.php b/application/views/account/user/edit.php
index bde82b3f..507ef24b 100644
--- a/application/views/account/user/edit.php
+++ b/application/views/account/user/edit.php
@@ -57,5 +57,5 @@
-
+
diff --git a/application/views/account/user/resetpassword.php b/application/views/account/user/resetpassword.php
index 856c690d..6e9cbe2e 100644
--- a/application/views/account/user/resetpassword.php
+++ b/application/views/account/user/resetpassword.php
@@ -12,5 +12,5 @@
-
-
+
+
diff --git a/modules/adsl/classes/Controller/Reseller/Service/Adsl.php b/modules/adsl/classes/Controller/Reseller/Service/Adsl.php
new file mode 100644
index 00000000..e2d7ee9e
--- /dev/null
+++ b/modules/adsl/classes/Controller/Reseller/Service/Adsl.php
@@ -0,0 +1,92 @@
+TRUE,
+ );
+
+ private function consoltraffic($svs,$date) {
+ $data = array();
+
+ foreach ($svs as $so) {
+ $c = array();
+ foreach ($so->plugin()->get_traffic_data_monthly($date) as $metric => $ma) {
+ foreach ($ma as $month => $traffic) {
+ // Only count the service once, not for each metric.
+ if (! isset($c[$month])) {
+ if (isset($data['svs'][$month]))
+ $data['svs'][$month] += 1;
+ else
+ $data['svs'][$month] = 1;
+
+ $c[$month] = 1;
+ }
+
+ if (isset($data['data'][$metric][$month]))
+ $data['data'][$metric][$month] += (int)$traffic;
+ else
+ $data['data'][$metric][$month] = (int)$traffic;
+ }
+ }
+ }
+
+ ksort($data['svs']);
+ foreach ($data['data'] as $metric => $details)
+ ksort($data['data'][$metric]);
+
+ return $data;
+ }
+
+ public function action_list() {
+ $svs = $this->filter(ORM::factory('Service')->list_byplugin('ADSL'),$this->ao->RTM->customers($this->ao->RTM),'account_id','name()');
+
+ $data = $this->consoltraffic($svs,time());
+
+ $google = GoogleChart::factory('Legacy')
+ ->type('vertical_bar')
+ ->title(sprintf('ADSL traffic as at %s',date('Y-m-d',strtotime('yesterday'))));
+
+ foreach ($data['data'] as $key => $values)
+ $google->sdata(array('yl'=>$key),array($key=>$values));
+
+ $google->sdata(array('yr'=>'services'),array('services'=>$data['svs']));
+
+ Block::add(array('body'=>(string)$google));
+
+ Block::factory()
+ ->title('ADSL Services')
+ ->title_icon('icon-th-list')
+ ->body(Table::factory()
+ ->jssort('adsl')
+ ->data($svs)
+ ->columns(array(
+ 'id'=>'ID',
+ 'name()'=>'Service',
+ 'plugin()->ipaddress()'=>'IP Address',
+ 'product->plugin()->speed'=>'Speed',
+ 'product->plugin()->allowance()'=>'Allowance',
+ 'plugin()->traffic_thismonth()'=>'This Month',
+ 'plugin()->traffic_lastmonth()'=>'Last Month',
+ 'recur_schedule'=>'Billing',
+ 'price(TRUE,TRUE)'=>'Price',
+ 'account->accnum()'=>'Cust ID',
+ 'account->name()'=>'Customer',
+ 'date_next_invoice'=>'Next Invoice',
+ 'due(TRUE)'=>'Due Invoices',
+ ))
+ ->prepend(array(
+ 'id'=>array('url'=>URL::link('user','service/view/')),
+ ))
+ );
+ }
+}
+?>
diff --git a/modules/adsl/classes/Model/Service/Plugin/Adsl.php b/modules/adsl/classes/Model/Service/Plugin/Adsl.php
index 9c13135b..e017a1bb 100644
--- a/modules/adsl/classes/Model/Service/Plugin/Adsl.php
+++ b/modules/adsl/classes/Model/Service/Plugin/Adsl.php
@@ -59,7 +59,7 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
public function service_view() {
return View::factory('service/user/plugin/adsl/view')
- ->set('so',$this);
+ ->set('o',$this);
}
public function username_value() {
@@ -81,8 +81,10 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
return Config::date($this->service_contract_date);
}
- public function contract_date_end() {
- return Config::date(strtotime(sprintf('+%s months',$this->contract_term),$this->service_contract_date));
+ public function contract_date_end($format=FALSE) {
+ $x = strtotime(sprintf('+%s months',$this->contract_term),$this->service_contract_date);
+
+ return $format ? Config::date($x) : $x;
}
public function hasOffpeak() {
diff --git a/modules/adsl/views/product/plugin/adsl/feature_summary.php b/modules/adsl/views/product/plugin/adsl/feature_summary.php
index 14b55700..59186ea9 100644
--- a/modules/adsl/views/product/plugin/adsl/feature_summary.php
+++ b/modules/adsl/views/product/plugin/adsl/feature_summary.php
@@ -1,28 +1,18 @@
-
-
-
- Speed |
- display('speed'); ?> |
-
-
- |
-
-
- |
- Peak |
- base_down_offpeak OR $po->extra_down_offpeak) { ?>
- Off Peak |
-
-
-
- Included Download Traffic |
-
- base_down_peak/1000; ?> GB |
- base_down_offpeak ? ($po->base_down_offpeak/1000).'GB' : HTML::nbsp(''); ?> |
-
-
- Extra Download Traffic |
- display('extra_down_peak'); ?>/GB |
- extra_down_offpeak ? $po->display('extra_down_offpeak').'/GB' : HTML::nbsp(''); ?> |
-
-
+
diff --git a/modules/adsl/views/service/user/plugin/adsl/view.php b/modules/adsl/views/service/user/plugin/adsl/view.php
index dfb9c162..ebc6f5d8 100644
--- a/modules/adsl/views/service/user/plugin/adsl/view.php
+++ b/modules/adsl/views/service/user/plugin/adsl/view.php
@@ -1,79 +1,60 @@
-
-
-
- Service Details |
-
-
- |
-
-
-
-
-
- Service Number |
- display('service_number'); ?> |
-
-
- Service Address |
- display('service_address'); ?> |
-
-
- Contract Term |
- display('contract_term'); ?> |
-
-
- Connect Date |
- display('service_connect_date'); ?> |
-
-
- Contract End Date |
- contract_date_end(); ?> |
-
-
- Service Username |
- display('service_username'); ?> |
-
-
- Service Password |
- display('service_password'); ?> |
-
-
- Service IP |
- ipaddress(); ?> |
-
- hasOffPeak() AND $so->offpeak_start AND $so->offpeak_end) { ?>
-
- Offpeak Period |
- offpeak_start,$so->offpeak_end); ?> |
-
-
-
- |
-
-
-
- Traffic Used This Month |
- traffic_month(NULL); ?> |
-
-
- Traffic Used Last Month |
- traffic_lastmonth(); ?> |
-
-
- |
-
-
-
-
-
- View Daily Traffic for Month |
- get_traffic_months()),(isset($_POST['month']) ? $_POST['month'] : '')); echo Form::submit('submit',_('Show'),array('class'=>'form_button')); echo Form::close(); ?> |
-
-
- |
-
-
- graph_traffic(isset($_POST['month']) ? $_POST['month'] : ''); ?> |
- table_traffic(isset($_POST['month']) ? $_POST['month'] : ''); ?> |
-
-
+
+
+
+
+
diff --git a/modules/charge/classes/Model/Charge.php b/modules/charge/classes/Model/Charge.php
index 8301484c..73d8b3f8 100644
--- a/modules/charge/classes/Model/Charge.php
+++ b/modules/charge/classes/Model/Charge.php
@@ -12,6 +12,7 @@
class Model_Charge extends ORM_OSB {
// Charge doesnt use the update column
protected $_updated_column = FALSE;
+
protected $_serialize_column = array(
'attributes',
);
@@ -41,5 +42,14 @@ class Model_Charge extends ORM_OSB {
throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type));
}
}
+
+ public function total($format=FALSE) {
+ $result = $this->quantity * $this->amount;
+
+ if ($this->taxable)
+ $result = Tax::add($result);
+
+ return $format ? Currency::display($result) : $result;
+ }
}
?>
diff --git a/modules/domain/classes/Controller/Reseller/Service/Domain.php b/modules/domain/classes/Controller/Reseller/Service/Domain.php
new file mode 100644
index 00000000..ee9ca90e
--- /dev/null
+++ b/modules/domain/classes/Controller/Reseller/Service/Domain.php
@@ -0,0 +1,41 @@
+TRUE,
+ );
+
+ public function action_list() {
+ Block::factory()
+ ->title('Domain License Services')
+ ->title_icon('icon-th-list')
+ ->body(Table::factory()
+ ->jssort('adsl')
+ ->data($this->filter(ORM::factory('Service')->list_byplugin('DOMAIN'),$this->ao->RTM->customers($this->ao->RTM),'account_id','name()'))
+ ->columns(array(
+ 'id'=>'ID',
+ 'name()'=>'Service',
+ 'plugin()->display("domain_expire")'=>'Expire',
+ 'recur_schedule'=>'Billing',
+ 'price(TRUE,TRUE)'=>'Price',
+ 'account->accnum()'=>'Cust ID',
+ 'account->name()'=>'Customer',
+ 'date_next_invoice'=>'Next Invoice',
+ 'due(TRUE)'=>'Due Invoices',
+ ))
+ ->prepend(array(
+ 'id'=>array('url'=>URL::link('user','service/view/')),
+ ))
+ );
+ }
+}
+?>
diff --git a/modules/domain/classes/Model/Service/Plugin/Domain.php b/modules/domain/classes/Model/Service/Plugin/Domain.php
index cbf4e064..a514acd4 100644
--- a/modules/domain/classes/Model/Service/Plugin/Domain.php
+++ b/modules/domain/classes/Model/Service/Plugin/Domain.php
@@ -54,7 +54,7 @@ class Model_Service_Plugin_Domain extends Model_Service_Plugin {
public function service_view() {
return View::factory('service/user/plugin/domain/view')
- ->set('so',$this);
+ ->set('o',$this);
}
public function username_value() {
diff --git a/modules/domain/classes/Service/Domain/PlanetDomain.php b/modules/domain/classes/Service/Domain/PlanetDomain.php
index 685fddc3..26f853eb 100644
--- a/modules/domain/classes/Service/Domain/PlanetDomain.php
+++ b/modules/domain/classes/Service/Domain/PlanetDomain.php
@@ -26,7 +26,7 @@ class Service_Domain_PlanetDomain extends Service_Domain {
$output .= Form::input($this->login_pass_field,substr(md5($spdo->password_value()),0,8),array('type'=>'hidden','id'=>sprintf('p_%s_%s',$spdo->service_id,$t)));
$output .= Form::input('page.next',sprintf('/newdnr/action/dns/getDNSDetails.jsp?domain.name=%s',$d),array('type'=>'hidden'));
$output .= Form::close();
- $output .= Form::button('submit',_('Manage'),array('class'=>'form_button','value'=>sprintf('%s:%s',$spdo->service_id,$t)));
+ $output .= Form::button('submit',_('Manage'),array('class'=>'btn btn-default','value'=>sprintf('%s:%s',$spdo->service_id,$t)));
return $output;
}
diff --git a/modules/domain/classes/Service/Domain/TPP.php b/modules/domain/classes/Service/Domain/TPP.php
index 970873ac..90a96481 100644
--- a/modules/domain/classes/Service/Domain/TPP.php
+++ b/modules/domain/classes/Service/Domain/TPP.php
@@ -26,7 +26,7 @@ class Service_Domain_TPP extends Service_Domain {
$output .= Form::input($this->login_user_field,$spdo->username_value(),array('type'=>'hidden','id'=>sprintf('u_%s_%s',$spdo->service_id,$t)));
$output .= Form::input($this->login_pass_field,substr(md5($spdo->password_value()),0,8),array('type'=>'hidden','id'=>sprintf('p_%s_%s',$spdo->service_id,$t)));
$output .= Form::close();
- $output .= Form::button('submit',_('Manage'),array('class'=>'form_button','value'=>sprintf('%s:%s',$spdo->service_id,$t)));
+ $output .= Form::button('submit',_('Manage'),array('class'=>'btn btn-default','value'=>sprintf('%s:%s',$spdo->service_id,$t)));
return $output;
}
diff --git a/modules/domain/views/service/user/plugin/domain/view.php b/modules/domain/views/service/user/plugin/domain/view.php
index ad7c69fa..77553058 100644
--- a/modules/domain/views/service/user/plugin/domain/view.php
+++ b/modules/domain/views/service/user/plugin/domain/view.php
@@ -1,51 +1,26 @@
-
-
-
- Service Details |
-
-
- |
-
-
-
-
-
- Domain Name |
- name(); ?> |
-
-
- Domain Expire |
- display('domain_expire'); ?> |
-
-
- Domain Primary Name Servers |
- display('registrar_ns'); ?> (Last Sync: display('registrar_lastsync'); ?>) |
-
-
- Domain Auth Password |
- display('registrar_auth_password'); ?> |
-
-
- Domain Type |
- display('registrar_type'); ?> |
-
-
- |
-
-
- manage_button()) { ?>
-
- Manage Registrar |
- |
-
-
- manage_dns_button()) { ?>
-
- Manage DNS |
- |
-
-
-
- |
-
-
+
diff --git a/modules/export/views/export/module/admin/edit.php b/modules/export/views/export/module/admin/edit.php
index a9c8371a..336db3fb 100644
--- a/modules/export/views/export/module/admin/edit.php
+++ b/modules/export/views/export/module/admin/edit.php
@@ -16,5 +16,5 @@
'column_name'=>array('input'=>array('key'=>'display[__VALUE__]','values'=>$o->display)),
)); ?>
-
+
diff --git a/modules/host/classes/Host/Plugin/Cpanel.php b/modules/host/classes/Host/Plugin/Cpanel.php
index 9068e698..f8e84968 100644
--- a/modules/host/classes/Host/Plugin/Cpanel.php
+++ b/modules/host/classes/Host/Plugin/Cpanel.php
@@ -57,7 +57,7 @@ echo __METHOD__;die();
$output .= Form::input($this->login_user_field,$u,array('type'=>'hidden','id'=>sprintf('u_%s_%s',$sid,$t)));
$output .= Form::input($this->login_pass_field,$p,array('type'=>'hidden','id'=>sprintf('p_%s_%s',$sid,$t)));
$output .= Form::close();
- $output .= Form::button('submit',_('Manage'),array('class'=>'form_button','value'=>sprintf('%s:%s',$sid,$t)));
+ $output .= Form::button('submit',_('Manage'),array('class'=>'btn btn-default','value'=>sprintf('%s:%s',$sid,$t)));
return $output;
}
diff --git a/modules/host/classes/Host/Plugin/Plesk.php b/modules/host/classes/Host/Plugin/Plesk.php
index bceea77e..0b8b9665 100644
--- a/modules/host/classes/Host/Plugin/Plesk.php
+++ b/modules/host/classes/Host/Plugin/Plesk.php
@@ -71,7 +71,7 @@ abstract class Host_Plugin_Plesk extends Host_Plugin {
$output .= Form::input($this->login_user_field,$u,array('type'=>'hidden','id'=>sprintf('u_%s_%s',$sid,$t)));
$output .= Form::input($this->login_pass_field,$p,array('type'=>'hidden','id'=>sprintf('p_%s_%s',$sid,$t)));
$output .= Form::close();
- $output .= Form::button('submit',_('Manage'),array('class'=>'form_button','value'=>sprintf('%s:%s',$sid,$t)));
+ $output .= Form::button('submit',_('Manage'),array('class'=>'btn btn-default','value'=>sprintf('%s:%s',$sid,$t),'nocg'=>TRUE));
return $output;
}
diff --git a/modules/host/classes/Model/Service/Plugin/Host.php b/modules/host/classes/Model/Service/Plugin/Host.php
index 8c6c7b0f..f980c2ca 100644
--- a/modules/host/classes/Model/Service/Plugin/Host.php
+++ b/modules/host/classes/Model/Service/Plugin/Host.php
@@ -50,7 +50,7 @@ class Model_Service_Plugin_Host extends Model_Service_Plugin {
public function service_view() {
return View::factory('service/user/plugin/host/view')
- ->set('so',$this);
+ ->set('o',$this);
}
public function username_value() {
diff --git a/modules/host/views/service/user/plugin/host/view.php b/modules/host/views/service/user/plugin/host/view.php
index e03e2152..bf89f6af 100644
--- a/modules/host/views/service/user/plugin/host/view.php
+++ b/modules/host/views/service/user/plugin/host/view.php
@@ -1,33 +1,19 @@
-
-
-
- Service Details |
-
-
- |
-
-
-
-
-
- Domain Name |
- name(); ?> |
-
-
- Hosting Expire |
- display('host_expire'); ?> |
-
-
- |
-
-
- manage_button()) { ?>
-
- Panel Login |
- |
-
-
-
- |
-
-
+
diff --git a/modules/product/views/product/admin/edit.php b/modules/product/views/product/admin/edit.php
index eda7701c..3c598eb1 100644
--- a/modules/product/views/product/admin/edit.php
+++ b/modules/product/views/product/admin/edit.php
@@ -14,7 +14,7 @@
$v) : ?>
- isPriceShown($k),array('label'=>'Price Active','class'=>'span2')); ?>
+ is_price_shown($k),array('label'=>'Price Active','class'=>'span2')); ?>
availPriceGroups() as $g) : ?>
@@ -72,5 +72,5 @@
-
+
diff --git a/modules/product/views/product/category/admin/edit.php b/modules/product/views/product/category/admin/edit.php
index 6a45710e..7e49f1ea 100644
--- a/modules/product/views/product/category/admin/edit.php
+++ b/modules/product/views/product/category/admin/edit.php
@@ -32,5 +32,5 @@
-
+
diff --git a/modules/service/classes/Controller/Admin/Service.php b/modules/service/classes/Controller/Admin/Service.php
index c9441b32..8b9356a2 100644
--- a/modules/service/classes/Controller/Admin/Service.php
+++ b/modules/service/classes/Controller/Admin/Service.php
@@ -9,23 +9,16 @@
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
-class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
- // @todo This "module" menu items should belong in the module dir.
+class Controller_Admin_Service extends Controller_Service {
protected $secure_actions = array(
'ajaxlist'=>TRUE,
'ajaxjson_traffic'=>TRUE,
'adslstat'=>TRUE,
- 'list'=>TRUE,
- 'listbycheckout'=>TRUE,
'listadslbilling'=>TRUE,
- 'listadslservices'=>TRUE,
'listexpiring'=>TRUE,
- 'listdomainservices'=>TRUE,
'listdomainservicesbysupplier'=>TRUE,
'listdomainservicesbydnshost'=>TRUE,
- 'listhostservices'=>TRUE,
'listhostservicesbysupplier'=>TRUE,
- 'listhspaservices'=>TRUE,
'listwebservices'=>TRUE,
'listinvoicesoon'=>TRUE,
'update'=>TRUE,
@@ -63,111 +56,6 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
$this->response->body($google->json());
}
- /**
- * Show a list of services
- */
- public function action_list() {
- $id = $this->request->param('id');
-
- $svs = ORM::factory('Service');
-
- if ($id)
- $svs->where_active()->and_where('account_id','=',$id);
-
- Block::add(array(
- 'title'=>_('Customer Services'),
- 'body'=>Table::display(
- $svs->find_all(),
- 25,
- array(
- 'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
- 'service_name()'=>array('label'=>'Details'),
- 'recur_schedule'=>array('label'=>'Billing'),
- 'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
- 'status'=>array('label'=>'Active'),
- 'account->accnum()'=>array('label'=>'Cust ID'),
- 'account->name()'=>array('label'=>'Customer'),
- ),
- array(
- 'page'=>TRUE,
- 'type'=>'select',
- 'form'=>URL::link('user','service/view'),
- )),
- ));
- }
-
- /**
- * List all services by their default checkout method
- */
- public function action_listbycheckout() {
- $svs = array();
- // @todo This needs to be configurable
- $go = ORM::factory('Group',array('name'=>'Personal'));
-
- foreach (ORM::factory('Account')->list_active() as $ao)
- if ($ao->has_any('group',array($go)))
- foreach ($ao->service->list_active() as $so)
- if (! $so->service_billing->checkout_plugin_id)
- array_push($svs,$so);
-
- if ($svs)
- Block::add(array(
- 'title'=>'Services that should be auto-billed',
- 'body'=>Table::display(
- $svs,
- 25,
- array(
- 'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
- 'service_name()'=>array('label'=>'Details'),
- 'recur_schedule'=>array('label'=>'Billing'),
- 'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
- 'status'=>array('label'=>'Active'),
- 'account->accnum()'=>array('label'=>'Cust ID'),
- 'account->name()'=>array('label'=>'Customer'),
- 'date_next_invoice'=>array('label'=>'Next Invoice'),
- 'account->invoices_due_total(NULL,TRUE)'=>array('label'=>'Due Invoices'),
- ),
- array(
- 'page'=>TRUE,
- 'type'=>'select',
- 'form'=>URL::link('user','service/view'),
- )),
- ));
-
- foreach (ORM::factory('Checkout')->list_active() as $co) {
- $svs = array();
-
- foreach ($co->account->find_all() as $ao)
- foreach ($ao->service->list_active() as $so)
- if ($so->service_billing->checkout_plugin_id == $co->id)
- array_push($svs,$so);
-
- if ($svs)
- Block::add(array(
- 'title'=>$co->name,
- 'body'=>Table::display(
- $svs,
- 25,
- array(
- 'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
- 'service_name()'=>array('label'=>'Details'),
- 'recur_schedule'=>array('label'=>'Billing'),
- 'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
- 'status'=>array('label'=>'Active'),
- 'account->accnum()'=>array('label'=>'Cust ID'),
- 'account->name()'=>array('label'=>'Customer'),
- 'date_next_invoice'=>array('label'=>'Next Invoice'),
- 'account->invoices_due_total(NULL,TRUE)'=>array('label'=>'Due Invoices'),
- ),
- array(
- 'page'=>TRUE,
- 'type'=>'select',
- 'form'=>URL::link('user','service/view'),
- )),
- ));
- }
- }
-
private function consoltraffic($svs,$date) {
$data = array();
@@ -200,51 +88,6 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
return $data;
}
- public function action_listadslservices() {
- $id = $this->request->param('id');
-
- $svs = $list = ORM::factory('Service')->list_bylistgroup('ADSL');
-
- if ($id) {
- $svs = array();
- foreach ($list as $so)
- if ($so->account_id == $id)
- array_push($svs,$so);
- }
-
- $google = GoogleChart::factory('ComboChart')
- ->dataurl(URL::link('admin','service/ajaxjson_traffic',TRUE))
- ->title(sprintf('ADSL traffic as at %s',date('Y-m-d',strtotime('yesterday'))));
-
- Block::add(array('body'=>(string)$google));
-
- Block::add(array(
- 'title'=>_('ADSL Services'),
- 'body'=>Table::display(
- $svs,
- NULL,
- array(
- 'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
- 'name()'=>array('label'=>'Service'),
- 'plugin()->ipaddress()'=>array('label'=>'IP Address'),
- 'product->plugin()->speed'=>array('label'=>'Speed'),
- 'product->plugin()->allowance()'=>array('label'=>'Allowance'),
- 'plugin()->traffic_thismonth()'=>array('label'=>'This Month'),
- 'plugin()->traffic_lastmonth()'=>array('label'=>'Last Month'),
- 'recur_schedule'=>array('label'=>'Billing'),
- 'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
- 'account->accnum()'=>array('label'=>'Cust ID'),
- 'account->name()'=>array('label'=>'Customer'),
- 'date_next_invoice'=>array('label'=>'Next Invoice'),
- 'product->display("status")'=>array('label'=>'Current'),
- ),
- array(
- 'type'=>'select',
- 'form'=>URL::link('user','service/view'),
- )),
- ));
- }
-
/**
* Show a list of services that are expiring or have expired
*/
@@ -271,74 +114,6 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
));
}
- public function action_listhspaservices() {
- $svs = ORM::factory('Service')->list_bylistgroup('HSPA');
- $data = $this->consoltraffic($svs,time());
-
- $google = GoogleChart::factory('Legacy')
- ->type('vertical_bar')
- ->title(sprintf('HSPA traffic as at %s',date('Y-m-d',strtotime('yesterday'))));
-
- foreach ($data['data'] as $key => $values)
- $google->data(array('yl'=>$key),array($key=>$values));
-
- $google->data(array('yr'=>'services'),array('services'=>$data['svs']));
-
- Block::add(array('body'=>(string)$google));
-
- Block::add(array(
- 'title'=>_('HSPA Services'),
- 'body'=>Table::display(
- $svs,
- NULL,
- array(
- 'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
- 'name()'=>array('label'=>'Service'),
- 'plugin()->ipaddress()'=>array('label'=>'IP Address'),
- 'product->plugin()->speed'=>array('label'=>'Speed'),
- 'product->plugin()->allowance()'=>array('label'=>'Allowance'),
- 'plugin()->traffic_thismonth()'=>array('label'=>'This Month'),
- 'plugin()->traffic_lastmonth()'=>array('label'=>'Last Month'),
- 'recur_schedule'=>array('label'=>'Billing'),
- 'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
- 'account->accnum()'=>array('label'=>'Cust ID'),
- 'account->name()'=>array('label'=>'Customer'),
- 'date_next_invoice'=>array('label'=>'Next Invoice'),
- ),
- array(
- 'type'=>'select',
- 'form'=>URL::link('user','service/view'),
- )),
- ));
- }
-
- public function action_listdomainservices() {
- $svs = ORM::factory('Service')->list_bylistgroup('DOMAIN');
- Sort::MAsort($svs,'name()');
-
- Block::add(array(
- 'title'=>_('Domain Names'),
- 'body'=>Table::display(
- $svs,
- 25,
- array(
- 'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
- 'service_name()'=>array('label'=>'Details'),
- 'plugin()->display("domain_expire")'=>array('label'=>'Expire'),
- 'recur_schedule'=>array('label'=>'Billing'),
- 'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
- 'account->accnum()'=>array('label'=>'Cust ID'),
- 'account->name()'=>array('label'=>'Customer'),
- 'display("date_next_invoice")'=>array('label'=>'Next Invoice'),
- ),
- array(
- 'page'=>TRUE,
- 'type'=>'select',
- 'form'=>URL::link('user','service/view'),
- )),
- ));
- }
-
public function action_listdomainservicesbysupplier() {
$svs = ORM::factory('Service')->list_bylistgroup('DOMAIN');
Sort::MAsort($svs,'plugin()->domain_registrar_id,name()');
@@ -402,33 +177,6 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
));
}
- public function action_listhostservices() {
- $svs = ORM::factory('Service')->list_bylistgroup('HOST');
- Sort::MAsort($svs,'name()');
-
- Block::add(array(
- 'title'=>_('Hosting Services'),
- 'body'=>Table::display(
- $svs,
- 25,
- array(
- 'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
- 'service_name()'=>array('label'=>'Details'),
- 'plugin()->display("host_expire")'=>array('label'=>'Expire'),
- 'recur_schedule'=>array('label'=>'Billing'),
- 'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
- 'account->accnum()'=>array('label'=>'Cust ID'),
- 'account->name()'=>array('label'=>'Customer'),
- 'display("date_next_invoice")'=>array('label'=>'Next Invoice'),
- ),
- array(
- 'page'=>TRUE,
- 'type'=>'select',
- 'form'=>URL::link('user','service/view'),
- )),
- ));
- }
-
public function action_listhostservicesbysupplier() {
$svs = ORM::factory('Service')->list_bylistgroup('HOST');
Sort::MAsort($svs,'plugin()->host_server,name()');
@@ -691,7 +439,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
'recur_schedule'=>array('label'=>'Billing'),
'date_next_invoice'=>array('label'=>'Next Invoice'),
'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
- 'charges_new()'=>array('label'=>'Charges','class'=>'right'),
+ 'charges()'=>array('label'=>'Charges','class'=>'right'),
'status'=>array('label'=>'Active'),
'account->accnum()'=>array('label'=>'Cust ID'),
'account->name()'=>array('label'=>'Customer'),
@@ -787,8 +535,6 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
if (is_null($bt))
$bt = $iio->date_start;
-// $doutput .= sprintf('%s: BT is: %s [%s]
',$iio->id,Config::date($bt),$bt);
-
$pdata = Period::details($iio->recurring_schedule,$a ? NULL : $iio->product->price_recurr_weekday,$bt,TRUE);
switch ($iio->recurring_schedule) {
diff --git a/modules/service/classes/Controller/Affiliate/Service.php b/modules/service/classes/Controller/Affiliate/Service.php
deleted file mode 100644
index ec1f793a..00000000
--- a/modules/service/classes/Controller/Affiliate/Service.php
+++ /dev/null
@@ -1,287 +0,0 @@
-TRUE,
- 'listbycheckout'=>TRUE,
- 'listadslservices'=>TRUE,
- 'listdomainservices'=>TRUE,
- 'listhostservices'=>TRUE,
- 'listhspaservices'=>TRUE,
- );
-
- /**
- * Show a list of services
- */
- public function action_list() {
- Block::add(array(
- 'title'=>_('Customer Services'),
- 'body'=>Table::display(
- $this->filter(ORM::factory('Service')->list_active(),$this->ao->RTM->customers($this->ao->RTM),NULL,'account_id'),
- 25,
- array(
- 'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
- 'service_name()'=>array('label'=>'Details'),
- 'recur_schedule'=>array('label'=>'Billing'),
- 'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
- 'status'=>array('label'=>'Active'),
- 'account->accnum()'=>array('label'=>'Cust ID'),
- 'account->name()'=>array('label'=>'Customer'),
- ),
- array(
- 'page'=>TRUE,
- 'type'=>'select',
- 'form'=>URL::link('user','service/view'),
- )),
- ));
- }
-
- /**
- * List all services by their default checkout method
- */
- public function action_listbycheckout() {
- $svs = array();
- // @todo This needs to be configurable
- $go = ORM::factory('Group',array('name'=>'Personal'));
-
- foreach (ORM::factory('Account')->list_active() as $ao)
- if ($ao->has_any('group',array($go)))
- foreach ($this->filter($ao->service->list_active(),$this->ao->RTM->customers($this->ao->RTM),NULL,'account_id') as $so)
- if (! $so->service_billing->checkout_plugin_id)
- array_push($svs,$so);
-
- if ($svs)
- Block::add(array(
- 'title'=>'Services that should be auto-billed',
- 'body'=>Table::display(
- $svs,
- 25,
- array(
- 'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
- 'service_name()'=>array('label'=>'Details'),
- 'recur_schedule'=>array('label'=>'Billing'),
- 'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
- 'status'=>array('label'=>'Active'),
- 'account->accnum()'=>array('label'=>'Cust ID'),
- 'account->name()'=>array('label'=>'Customer'),
- 'date_next_invoice'=>array('label'=>'Next Invoice'),
- 'account->invoices_due_total(NULL,TRUE)'=>array('label'=>'Due Invoices'),
- ),
- array(
- 'page'=>TRUE,
- 'type'=>'select',
- 'form'=>URL::link('user','service/view'),
- )),
- ));
- else
- Block::add(array(
- 'title'=>'Services that should be auto-billed',
- 'body'=>_('None found'),
- ));
-
- foreach (ORM::factory('Checkout')->list_active() as $co) {
- $svs = array();
-
- foreach ($co->account->find_all() as $ao)
- foreach ($this->filter($ao->service->list_active(),$this->ao->RTM->customers($this->ao->RTM),NULL,'account_id') as $so)
- if ($so->service_billing->checkout_plugin_id == $co->id)
- array_push($svs,$so);
-
- if ($svs)
- Block::add(array(
- 'title'=>$co->name,
- 'body'=>Table::display(
- $svs,
- 25,
- array(
- 'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
- 'service_name()'=>array('label'=>'Details'),
- 'recur_schedule'=>array('label'=>'Billing'),
- 'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
- 'status'=>array('label'=>'Active'),
- 'account->accnum()'=>array('label'=>'Cust ID'),
- 'account->name()'=>array('label'=>'Customer'),
- 'date_next_invoice'=>array('label'=>'Next Invoice'),
- 'account->invoices_due_total(NULL,TRUE)'=>array('label'=>'Due Invoices'),
- ),
- array(
- 'page'=>TRUE,
- 'type'=>'select',
- 'form'=>URL::link('user','service/view'),
- )),
- ));
- }
- }
-
- private function consoltraffic($svs,$date) {
- $data = array();
-
- foreach ($svs as $so) {
- $c = array();
- foreach ($so->plugin()->get_traffic_data_monthly($date) as $metric => $ma) {
- foreach ($ma as $month => $traffic) {
- // Only count the service once, not for each metric.
- if (! isset($c[$month])) {
- if (isset($data['svs'][$month]))
- $data['svs'][$month] += 1;
- else
- $data['svs'][$month] = 1;
-
- $c[$month] = 1;
- }
-
- if (isset($data['data'][$metric][$month]))
- $data['data'][$metric][$month] += (int)$traffic;
- else
- $data['data'][$metric][$month] = (int)$traffic;
- }
- }
- }
-
- ksort($data['svs']);
- foreach ($data['data'] as $metric => $details)
- ksort($data['data'][$metric]);
-
- return $data;
- }
-
- public function action_listadslservices() {
- $svs = $this->filter(ORM::factory('Service')->list_bylistgroup('ADSL'),$this->ao->RTM->customers($this->ao->RTM),'name()','account_id');
- $data = $this->consoltraffic($svs,time());
-
- $google = GoogleChart::factory('Legacy')
- ->type('vertical_bar')
- ->title(sprintf('ADSL traffic as at %s',date('Y-m-d',strtotime('yesterday'))));
-
- foreach ($data['data'] as $key => $values)
- $google->sdata(array('yl'=>$key),array($key=>$values));
-
- $google->sdata(array('yr'=>'services'),array('services'=>$data['svs']));
-
- Block::add(array('body'=>(string)$google));
-
- Block::add(array(
- 'title'=>_('ADSL Services'),
- 'body'=>Table::display(
- $svs,
- 50,
- array(
- 'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
- 'name()'=>array('label'=>'Service'),
- 'plugin()->ipaddress()'=>array('label'=>'IP Address'),
- 'product->plugin()->speed'=>array('label'=>'Speed'),
- 'product->plugin()->allowance()'=>array('label'=>'Allowance'),
- 'plugin()->traffic_thismonth()'=>array('label'=>'This Month'),
- 'plugin()->traffic_lastmonth()'=>array('label'=>'Last Month'),
- 'recur_schedule'=>array('label'=>'Billing'),
- 'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
- 'account->accnum()'=>array('label'=>'Cust ID'),
- 'account->name()'=>array('label'=>'Customer'),
- 'date_next_invoice'=>array('label'=>'Next Invoice'),
- ),
- array(
- 'type'=>'select',
- 'form'=>URL::link('user','service/view'),
- )),
- ));
- }
-
- public function action_listhspaservices() {
- $svs = $this->filter(ORM::factory('Service')->list_bylistgroup('HSPA'),$this->ao->RTM->customers($this->ao->RTM),'name()','account_id');
- $data = $this->consoltraffic($svs,time());
-
- $google = GoogleChart::factory('Legacy')
- ->type('vertical_bar')
- ->title(sprintf('HSPA traffic as at %s',date('Y-m-d',strtotime('yesterday'))));
-
- foreach ($data['data'] as $key => $values)
- $google->sdata(array('yl'=>$key),array($key=>$values));
-
- $google->sdata(array('yr'=>'services'),array('services'=>$data['svs']));
-
- Block::add(array('body'=>(string)$google));
-
- Block::add(array(
- 'title'=>_('HSPA Services'),
- 'body'=>Table::display(
- $svs,
- NULL,
- array(
- 'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
- 'name()'=>array('label'=>'Service'),
- 'plugin()->ipaddress()'=>array('label'=>'IP Address'),
- 'product->plugin()->speed'=>array('label'=>'Speed'),
- 'product->plugin()->allowance()'=>array('label'=>'Allowance'),
- 'plugin()->traffic_thismonth()'=>array('label'=>'This Month'),
- 'plugin()->traffic_lastmonth()'=>array('label'=>'Last Month'),
- 'recur_schedule'=>array('label'=>'Billing'),
- 'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
- 'account->accnum()'=>array('label'=>'Cust ID'),
- 'account->name()'=>array('label'=>'Customer'),
- 'date_next_invoice'=>array('label'=>'Next Invoice'),
- ),
- array(
- 'type'=>'select',
- 'form'=>URL::link('user','service/view'),
- )),
- ));
- }
-
- public function action_listdomainservices() {
- Block::add(array(
- 'title'=>_('Domain Names'),
- 'body'=>Table::display(
- $this->filter(ORM::factory('Service')->list_bylistgroup('DOMAIN'),$this->ao->RTM->customers($this->ao->RTM),'name()','account_id'),
- 25,
- array(
- 'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
- 'service_name()'=>array('label'=>'Details'),
- 'plugin()->display("domain_expire")'=>array('label'=>'Expire'),
- 'recur_schedule'=>array('label'=>'Billing'),
- 'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
- 'account->accnum()'=>array('label'=>'Cust ID'),
- 'account->name()'=>array('label'=>'Customer'),
- 'display("date_next_invoice")'=>array('label'=>'Next Invoice'),
- ),
- array(
- 'page'=>TRUE,
- 'type'=>'select',
- 'form'=>URL::link('user','service/view'),
- )),
- ));
- }
-
- public function action_listhostservices() {
- Block::add(array(
- 'title'=>_('Hosting Services'),
- 'body'=>Table::display(
- $this->filter(ORM::factory('Service')->list_bylistgroup('HOST'),$this->ao->RTM->customers($this->ao->RTM),'name()','account_id'),
- 25,
- array(
- 'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
- 'service_name()'=>array('label'=>'Details'),
- 'plugin()->display("host_expire")'=>array('label'=>'Expire'),
- 'recur_schedule'=>array('label'=>'Billing'),
- 'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
- 'account->accnum()'=>array('label'=>'Cust ID'),
- 'account->name()'=>array('label'=>'Customer'),
- 'display("date_next_invoice")'=>array('label'=>'Next Invoice'),
- ),
- array(
- 'page'=>TRUE,
- 'type'=>'select',
- 'form'=>URL::link('user','service/view'),
- )),
- ));
- }
-}
-?>
diff --git a/modules/service/classes/Controller/Reseller/Service.php b/modules/service/classes/Controller/Reseller/Service.php
new file mode 100644
index 00000000..8cd8b11e
--- /dev/null
+++ b/modules/service/classes/Controller/Reseller/Service.php
@@ -0,0 +1,112 @@
+TRUE,
+ 'listbycheckout'=>TRUE,
+ 'listhostservices'=>TRUE,
+ );
+
+ /**
+ * Show a list of services
+ */
+ public function action_list() {
+ Block::factory()
+ ->title('Customer Services')
+ ->title_icon('icon-th-list')
+ ->body(Table::factory()
+ ->jssort('services')
+ ->data($this->filter(ORM::factory('Service')->find_all(),$this->ao->RTM->customers($this->ao->RTM),'account_id'))
+ ->columns(array(
+ 'id'=>'ID',
+ 'service_name()'=>'Service',
+ 'recur_schedule'=>'Billing',
+ 'price(TRUE,TRUE)'=>'Price',
+ 'status(TRUE)'=>'Active',
+ 'account->accnum()'=>'Cust ID',
+ 'account->name()'=>'Customer',
+ ))
+ ->prepend(array(
+ 'id'=>array('url'=>URL::link('user','service/view/')),
+ ))
+ );
+ }
+
+ /**
+ * List all services by their default checkout method
+ */
+ public function action_listbycheckout() {
+ $svs = array();
+ // @todo This needs to be configurable
+ $go = ORM::factory('Group',array('name'=>'Personal'));
+
+ foreach (ORM::factory('Account')->list_active() as $ao)
+ if ($ao->has_any('group',array($go)))
+ foreach ($this->filter($ao->service->list_active(),$this->ao->RTM->customers($this->ao->RTM),'account_id') as $so)
+ if (! $so->service_billing->checkout_plugin_id)
+ array_push($svs,$so);
+
+ if ($svs)
+ Block::factory()
+ ->title('Services that should be auto-billed')
+ ->title_icon('icon-pencil')
+ ->body(Table::factory()
+ ->jssort('services')
+ ->data($svs)
+ ->columns(array(
+ 'id'=>'ID',
+ 'service_name()'=>'Service',
+ 'recur_schedule'=>'Billing',
+ 'price(TRUE,TRUE)'=>'Price',
+ 'account->accnum()'=>'Cust ID',
+ 'account->name()'=>'Customer',
+ 'date_next_invoice'=>'Next Invoice',
+ 'due(TRUE)'=>'Due Invoices',
+ ))
+ ->prepend(array(
+ 'id'=>array('url'=>URL::link('user','service/view/')),
+ ))
+ );
+
+ foreach (ORM::factory('Checkout')->find_all() as $co) {
+ $svs = array();
+
+ foreach ($co->account->find_all() as $ao)
+ foreach ($this->filter($ao->service->list_active(),$this->ao->RTM->customers($this->ao->RTM),'account_id') as $so)
+ if ($so->service_billing->checkout_plugin_id == $co->id)
+ array_push($svs,$so);
+
+ if ($svs)
+ Block::factory()
+ ->title($co->name)
+ ->title_icon('icon-repeat')
+ ->body(Table::factory()
+ ->jssort($co->id)
+ ->data($svs)
+ ->columns(array(
+ 'id'=>'ID',
+ 'service_name()'=>'Service',
+ 'recur_schedule'=>'Billing',
+ 'price(TRUE,TRUE)'=>'Price',
+ 'account->accnum()'=>'Cust ID',
+ 'account->name()'=>'Customer',
+ 'date_next_invoice'=>'Next Invoice',
+ 'due(TRUE)'=>'Due Invoices',
+ ))
+ ->prepend(array(
+ 'id'=>array('url'=>URL::link('user','service/view/')),
+ ))
+ );
+ }
+ }
+}
+?>
diff --git a/modules/service/classes/Controller/User/Service.php b/modules/service/classes/Controller/User/Service.php
index 307ccf5d..b192b276 100644
--- a/modules/service/classes/Controller/User/Service.php
+++ b/modules/service/classes/Controller/User/Service.php
@@ -9,13 +9,16 @@
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
-class Controller_User_Service extends Controller_TemplateDefault_User {
+class Controller_User_Service extends Controller_Service {
protected $secure_actions = array(
'ajaxmanage'=>TRUE,
'list'=>TRUE,
'view'=>TRUE,
);
+ /**
+ * This ajax functions obtains the manage button login/password for this service
+ */
public function action_ajaxmanage() {
$this->auto_render = FALSE;
@@ -36,24 +39,23 @@ class Controller_User_Service extends Controller_TemplateDefault_User {
* Show a list of services
*/
public function action_list() {
- Block::add(array(
- 'title'=>sprintf('%s: %s - %s',_('Services For'),$this->ao->accnum(),$this->ao->name(TRUE)),
- 'body'=>Table::display(
- $this->ao->service->find_all(),
- 25,
- array(
- 'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
- 'service_name()'=>array('label'=>'Details'),
- 'recur_schedule'=>array('label'=>'Billing'),
- 'price(TRUE,TRUE)'=>array('label'=>'Price','class'=>'right'),
- 'status'=>array('label'=>'Active'),
- ),
- array(
- 'page'=>TRUE,
- 'type'=>'select',
- 'form'=>URL::link('user','service/view'),
- )),
- ));
+ Block::factory()
+ ->title(sprintf('Services for Account: %s',$this->ao->accnum()))
+ ->title_icon('icon-th-list')
+ ->body(Table::factory()
+ ->jssort('services')
+ ->data($this->ao->service->find_all())
+ ->columns(array(
+ 'id'=>'ID',
+ 'service_name()'=>'Service',
+ 'recur_schedule'=>'Billing',
+ 'price(TRUE,TRUE)'=>'Price',
+ 'status(TRUE)'=>'Active',
+ ))
+ ->prepend(array(
+ 'id'=>array('url'=>URL::link('user','service/view/')),
+ ))
+ );
}
public function action_view() {
@@ -61,18 +63,16 @@ class Controller_User_Service extends Controller_TemplateDefault_User {
$so = ORM::factory('Service',$id);
- if (! $so->loaded() OR ! Auth::instance()->authorised($so->account)) {
- $this->template->content = 'Unauthorised or doesnt exist?';
- return FALSE;
- }
+ 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');
- $output .= View::factory($this->viewpath())
- ->set('so',$so);
+ $output .= View::factory('service/user/view')
+ ->set('o',$so);
- Block::add(array(
- 'title'=>sprintf('%s: %s',$so->id(),$so->service_name()),
- 'body'=>$output,
- ));
+ Block::factory()
+ ->title(sprintf('%s: %s',$so->id(),$so->service_name()))
+ ->title_icon('icon-list-alt')
+ ->body($output);
}
}
?>
diff --git a/modules/service/classes/Model/Service.php b/modules/service/classes/Model/Service.php
index a14396ee..9b26fdf1 100644
--- a/modules/service/classes/Model/Service.php
+++ b/modules/service/classes/Model/Service.php
@@ -18,6 +18,7 @@ class Model_Service extends ORM_OSB {
'service_billing'=>array('far_key'=>'account_billing_id','foreign_key'=>'id'),
);
protected $_has_many = array(
+ 'charge'=>array('far_key'=>'id'),
'invoice_item'=>array('far_key'=>'id'),
'invoice'=>array('through'=>'invoice_item'),
'service_change'=>array('far_key'=>'id'),
@@ -46,33 +47,27 @@ class Model_Service extends ORM_OSB {
);
/**
- * Return the object of the product plugin
+ * Get the additional charges associated with this service
*/
- public function plugin($type='') {
- if (! $this->product->prod_plugin_file)
- return NULL;
+ public function charges($unprocessed=TRUE,$format=FALSE) {
+ $result = 0;
- $o = ORM::factory(Kohana::classname(sprintf('Service_Plugin_%s',$this->product->prod_plugin_file)),array('service_id'=>$this->id));
+ foreach ($this->charge_list($unprocessed) as $co)
+ $result += $co->total();
- return $type ? $o->$type : $o;
+ return $format ? Currency::display($result) : $result;
}
- /**
- * Display the service number
- */
- public function id() {
- return sprintf('%05s',$this->id);
- }
+ public function charge_list($unprocessed=FALSE) {
+ $x = $this->charge;
- /**
- * Display the service product name
- */
- public function name() {
- return is_null($plugin=$this->plugin()) ? $this->product->title() : $plugin->name();
- }
+ if ($unprocessed)
+ $x->where_open()
+ ->where('processed','IS',NULL)
+ ->or_where('processed','=',FALSE)
+ ->where_close();
- public function pending_change() {
- return count($this->service_change->where_active()->where_open()->and_where('complete','!=',1)->or_where('complete','IS',null)->where_close()->find_all()->as_array());
+ return $x->find_all();
}
/**
@@ -81,7 +76,7 @@ class Model_Service extends ORM_OSB {
public function due($format=FALSE) {
$total = 0;
- foreach ($this->list_invoices(TRUE) as $io)
+ foreach ($this->invoice_list(TRUE) as $io)
$total += $io->due();
return $format ? Currency::display($total) : $total;
@@ -103,10 +98,80 @@ class Model_Service extends ORM_OSB {
/**
* Determine if a service expires in the next $days.
*/
- public function expiring($days) {
+ public function expiring($days=0) {
return time()+$days*86400 > $this->expire();
}
+ /**
+ * Display the service number
+ */
+ public function id() {
+ return sprintf('%05s',$this->id);
+ }
+
+ /**
+ * List invoices for this service
+ */
+ public function invoice_list($due=FALSE) {
+ $result = array();
+
+ $x = $this->invoice->distinct('id');
+
+ // If we only want due invoices, we can speed things up by only looking for unprocessed
+ if ($due)
+ $x->where_unprocessed();
+
+ foreach ($x->find_all() as $io)
+ if (! $due OR $io->due())
+ array_push($result,$io);
+
+ return $result;
+ }
+
+ /**
+ * Display the service product name
+ */
+ public function name() {
+ return is_null($plugin=$this->plugin()) ? $this->product->title() : $plugin->name();
+ }
+
+ /**
+ * Returns TRUE of this service has a planend change
+ */
+ public function pending_change() {
+ return $this->service_change()->loaded() ? TRUE : FALSE;
+ }
+
+ /**
+ * Show the product that this service will be changed to
+ */
+ public function pending_product() {
+ return $this->service_change()->product;
+ }
+
+ /**
+ * Return the object of the product plugin
+ */
+ public function plugin($type='') {
+ if (! $this->product->prod_plugin_file)
+ return NULL;
+
+ $o = ORM::factory(Kohana::classname(sprintf('Service_Plugin_%s',$this->product->prod_plugin_file)),array('service_id'=>$this->id));
+
+ return $type ? $o->$type : $o;
+ }
+
+ public function service_change() {
+ return $this->service_change->where_active()->where_open()->and_where('complete','!=',1)->or_where('complete','IS',null)->where_close()->find();
+ }
+
+ /**
+ * Return a descriptive name for this service
+ */
+ public function service_name() {
+ return is_null($plugin=$this->plugin()) ? $this->name() : $plugin->service_name();
+ }
+
/**
* Return the service charge
*/
@@ -122,32 +187,18 @@ class Model_Service extends ORM_OSB {
return $format ? Currency::display($p) : $p;
}
- public function service_name() {
- return is_null($plugin=$this->plugin()) ? $this->name() : $plugin->service_name();
- }
-
- public function service_view() {
- return is_null($plugin=$this->plugin()) ? HTML::nbsp('') : $plugin->service_view();
- }
-
- /**
- * Display the product feature summary
- */
- public function product_feature_summary() {
- return $this->product->feature_summary();
- }
-
/**
* Render some details for specific calls, eg: invoice
*/
public function details($type) {
+ $plugin = $this->plugin();
+
switch ($type) {
case 'invoice_detail_items':
- if (is_null($plugin = $this->plugin()))
- return array();
- else
- return $plugin->_details($type);
- break;
+ return is_null($plugin) ? array() : $plugin->_details($type);
+
+ case 'service_view':
+ return is_null($plugin) ? HTML::nbsp('') : $plugin->service_view();
default:
throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type));
@@ -170,7 +221,7 @@ class Model_Service extends ORM_OSB {
// @todo To implement
public function charges_new() {
- return 0;
+ return $this->charges();
}
/** LIST FUNCTIONS **/
@@ -198,7 +249,20 @@ class Model_Service extends ORM_OSB {
return parent::list_autocomplete($term,$index,$value,$label,$limit,$options);
}
-
+
+ /**
+ * List all products by their plugin type
+ */
+ public function list_byplugin($plugin) {
+ return $this
+ ->join('product')
+ ->on($this->table_name().'.site_id','=','product.site_id') // @todo This should be automatic
+ ->on($this->table_name().'.product_id','=','product.id')
+ ->where('prod_plugin_file','=',$plugin)
+ ->and_where('service.status','=',TRUE)
+ ->find_all();
+ }
+
public function list_bylistgroup($cat) {
$result = array();
@@ -223,19 +287,6 @@ class Model_Service extends ORM_OSB {
return $result;
}
- /**
- * List invoices for this service
- */
- public function list_invoices($due=FALSE) {
- $result = array();
-
- foreach ($this->invoice->find_all() as $io)
- if (! $due OR $io->due())
- array_push($result,$io);
-
- return $result;
- }
-
/**
* List services that need to be billed.
*
diff --git a/modules/service/views/service/user/view.php b/modules/service/views/service/user/view.php
index b4898d7b..c3464ed6 100644
--- a/modules/service/views/service/user/view.php
+++ b/modules/service/views/service/user/view.php
@@ -1,80 +1,84 @@
-
-
-
-
-
-
-
- Account |
- account->name(),$so->account->accnum()); ?> |
-
-
- Service Active |
- display('status'); ?> |
-
-
- Billing Period |
- display('recur_schedule');?> |
-
-
- Cost |
- price(TRUE,TRUE); if ($so->pending_change()) echo ' *'; ?> |
-
- price) OR ($so->price<=$so->product->price($so->price_group,$so->recur_schedule,'price_base'))) { ?>
-
- Service |
- product_id,$so->product->title()); ?> |
-
-
-
- Date Next Invoice |
- display('date_next_invoice'); ?> |
-
-
- Current Invoices Due |
- account->invoices_due_total()); ?> |
-
- service_billing->loaded()) { ?>
-
- Direct Debit |
- service_billing->checkout->name; ?> |
-
-
-
-
- |
-
-
- product_feature_summary(); ?>
-
- |
-
-
-
-service_view(); ?>
-
-
-
- Invoices for this service |
-
-
- |
-
-
- Number |
- Invoice Date |
- Due Date |
- Total |
- Balance |
-
- invoice->distinct('id')->order_by('id DESC')->find_all() as $io) { ?>
-
- id),HTML::image('media/img/gnome-pdf.png',array('alt'=>_('Download'),'width'=>20))); ?> |
- id),$io->id()); ?> |
- display('date_orig'); ?> |
- display('due_date'); ?> |
- total(TRUE); ?> |
- due(TRUE); ?> |
-
-
-
+
+
+
+ product->feature_summary()) :
+ echo $o->product->feature_summary();
+ endif ?>
+
+
+
+
+ details('service_view'); ?>
+
+
+
+ service_billing->loaded()) : ?>
+
+
+
+ charges()) : ?>
+
+
+
+
+
diff --git a/modules/ssl/classes/Model/Service/Plugin/Ssl.php b/modules/ssl/classes/Model/Service/Plugin/Ssl.php
index bcb5fd4b..ee84d423 100644
--- a/modules/ssl/classes/Model/Service/Plugin/Ssl.php
+++ b/modules/ssl/classes/Model/Service/Plugin/Ssl.php
@@ -78,7 +78,7 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
public function service_view() {
return View::factory('service/user/plugin/ssl/view')
- ->set('so',$this);
+ ->set('o',$this);
}
/**
@@ -110,11 +110,14 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
if (! $this->service->status OR ! preg_match('/client/',$this->service->product->plugin()->extensions) OR $this->valid_to() < time())
return '';
- // @todo Do some password validation
- $output = Form::open(URL::link('user','ssl/download'));
+ $output = Form::open(URL::link('user','ssl/download'),array('class'=>'form-inline'));
$output .= Form::hidden('sid',$this->service->id);
- $output .= _('Choose a password').': '.Form::password('passwd','').'
';
- $output .= Form::submit('download','Download',array('class'=>'form_button'));
+ $output .= '';
+ $output .= Form::password('passwd','',array('label'=>_('Choose a password'),'placeholder'=>'Password','required','nocg'=>TRUE,'pattern'=>'.{6,}','title'=>'Minimum 6 chars'));
+ $output .= Form::button('download','Download',array('class'=>'btn btn-default','nocg'=>TRUE));
+ $output .= '
';
+ $output .= Form::close();
+
return $output;
}
diff --git a/modules/ssl/views/product/plugin/ssl/feature_summary.php b/modules/ssl/views/product/plugin/ssl/feature_summary.php
index c3b8a8a3..a481b080 100644
--- a/modules/ssl/views/product/plugin/ssl/feature_summary.php
+++ b/modules/ssl/views/product/plugin/ssl/feature_summary.php
@@ -1,11 +1,13 @@
-
-
-
- Validity Days |
- display('days'); ?> |
-
-
- Type |
- display('extensions'); ?> |
-
-
+
diff --git a/modules/ssl/views/service/user/plugin/ssl/view.php b/modules/ssl/views/service/user/plugin/ssl/view.php
index 13e26b7c..e45cb007 100644
--- a/modules/ssl/views/service/user/plugin/ssl/view.php
+++ b/modules/ssl/views/service/user/plugin/ssl/view.php
@@ -1,56 +1,41 @@
-
-
-
- Service Details |
-
-
- |
-
-
-
-
-
- Subject |
- dn(); ?> |
-
-
- Issuer |
- issuerdn(); ?> |
-
-
- CA |
- SSL_CA->loaded() ? $so->SSL_CA->subject() : $so->issuer(); ?> |
-
-
- Valid From |
- valid_from(TRUE); ?> |
-
-
- Valid To |
- valid_to(TRUE); ?> |
-
-
- Serial Number |
- serial(); ?> |
-
-
- Version |
- version(); ?> |
-
-
- Hash |
- hash(); ?> |
-
-
- Algorithm |
- algorithm(); ?> |
-
-
- Certificate |
- cert; ?> |
-
-
- |
- download_button(); ?> |
-
-
+
+
+