2013-06-04 11:50:41 +00:00
|
|
|
<?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')
|
2013-06-10 11:48:06 +00:00
|
|
|
->data(ORM::factory('Service')->where('account_id','IN',$this->ao->RTM->customers($this->ao->RTM))->find_all())
|
2013-06-04 11:50:41 +00:00
|
|
|
->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'));
|
|
|
|
|
2013-06-10 11:48:06 +00:00
|
|
|
foreach (ORM::factory('Account')->where_active()->where('id','IN',$this->ao->RTM->customers($this->ao->RTM))->find_all() as $ao)
|
2013-06-04 11:50:41 +00:00
|
|
|
if ($ao->has_any('group',array($go)))
|
2013-06-10 11:48:06 +00:00
|
|
|
foreach ($ao->service->list_active() as $so)
|
2013-06-04 11:50:41 +00:00
|
|
|
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();
|
|
|
|
|
2013-06-10 11:48:06 +00:00
|
|
|
foreach ($co->account->where('account.id','IN',$this->ao->RTM->customers($this->ao->RTM))->find_all() as $ao)
|
|
|
|
foreach ($ao->service->list_active() as $so)
|
2013-06-04 11:50:41 +00:00
|
|
|
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/')),
|
|
|
|
))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|