104 lines
3.0 KiB
PHP
104 lines
3.0 KiB
PHP
<?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,
|
|
'listexpiring'=>TRUE,
|
|
'listinvoicesoon'=>TRUE,
|
|
);
|
|
|
|
/**
|
|
* Show a list of services
|
|
*/
|
|
public function action_list() {
|
|
$this->meta->title = 'Customer Services';
|
|
|
|
Block::factory()
|
|
->title('Customer Services')
|
|
->title_icon($this->icon)
|
|
->body(View::factory('service/reseller/list')->set('o',ORM::factory('Service')->where_authorised($this->ao)->find_all()));
|
|
}
|
|
|
|
/**
|
|
* 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')->where_active()->where_authorised($this->ao,'id')->find_all() as $ao)
|
|
if ($ao->has_any('group',array($go)))
|
|
foreach ($ao->service->list_active() as $so)
|
|
if (! $so->service_billing->checkout_id)
|
|
array_push($svs,$so);
|
|
|
|
if ($svs)
|
|
Block::factory()
|
|
->title('Services that should be auto-billed')
|
|
->title_icon($this->icon)
|
|
->body(View::factory('service/reseller/list')->set('o',$svs));
|
|
|
|
foreach (ORM::factory('Checkout')->find_all() as $co) {
|
|
$svs = array();
|
|
|
|
foreach ($co->service->where('service.account_id','IN',$this->ao->RTM->customers($this->ao->RTM))->find_all() as $so)
|
|
array_push($svs,$so);
|
|
|
|
if ($svs)
|
|
Block::factory()
|
|
->title($co->name)
|
|
->title_icon('fa fa-bank')
|
|
->body(Table::factory()
|
|
->jssort($co->id)
|
|
->data($svs)
|
|
->columns(array(
|
|
'id'=>'ID',
|
|
'service_name()'=>'Service',
|
|
'recur_schedule'=>'Billing',
|
|
'price(TRUE,TRUE)'=>'Price',
|
|
'account->refnum()'=>'Cust ID',
|
|
'account->name()'=>'Customer',
|
|
'date_next_invoice'=>'Next Invoice',
|
|
'due(TRUE)'=>'Due Invoices',
|
|
'service_billing->display("checkout_amount")'=>'Auto Pay',
|
|
))
|
|
->prepend(array(
|
|
'id'=>array('url'=>URL::link('user','service/view/')),
|
|
))
|
|
);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Show a list of expring services
|
|
*/
|
|
public function action_listexpiring() {
|
|
Block::factory()
|
|
->title('Customer Services Expiring')
|
|
->title_icon($this->icon)
|
|
->body(View::factory('service/reseller/list')->set('o',ORM::factory('Service')->where_authorised($this->ao)->list_expiring()));
|
|
}
|
|
|
|
/**
|
|
* Show a list of expring services
|
|
*/
|
|
public function action_listinvoicesoon() {
|
|
Block::factory()
|
|
->title('Customer Services soon to be Invoiced')
|
|
->title_icon($this->icon)
|
|
->body(View::factory('service/reseller/list')->set('o',ORM::factory('Service')->where_authorised($this->ao)->list_invoicesoon(ORM::factory('Invoice')->config('GEN_SOON_DAYS')+30)));
|
|
}
|
|
}
|
|
?>
|