Rework service, change module_method configuration
This commit is contained in:
@@ -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]<br/>',$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) {
|
||||
|
@@ -1,287 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides Affiliate Service functions
|
||||
*
|
||||
* @package Service
|
||||
* @category Controllers/Affiliate
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate {
|
||||
protected $secure_actions = array(
|
||||
'list'=>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'),
|
||||
)),
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
112
modules/service/classes/Controller/Reseller/Service.php
Normal file
112
modules/service/classes/Controller/Reseller/Service.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides Reseller Service functions
|
||||
*
|
||||
* @package Service
|
||||
* @category Controllers/Reseller
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Reseller_Service extends Controller_Service {
|
||||
protected $secure_actions = array(
|
||||
'list'=>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/')),
|
||||
))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@@ -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);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user