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,
|
2013-10-10 13:08:02 +00:00
|
|
|
'listexpiring'=>TRUE,
|
|
|
|
'listinvoicesoon'=>TRUE,
|
2013-06-04 11:50:41 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a list of services
|
|
|
|
*/
|
|
|
|
public function action_list() {
|
2016-07-29 01:19:30 +00:00
|
|
|
$this->meta->title = 'Customer Services';
|
|
|
|
|
2013-06-04 11:50:41 +00:00
|
|
|
Block::factory()
|
|
|
|
->title('Customer Services')
|
2016-07-29 13:04:34 +00:00
|
|
|
->title_icon($this->icon)
|
|
|
|
->body(View::factory('service/reseller/list')->set('o',ORM::factory('Service')->where_authorised($this->ao)->find_all()));
|
2013-06-04 11:50:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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-10-10 13:08:02 +00:00
|
|
|
foreach (ORM::factory('Account')->where_active()->where_authorised($this->ao,'id')->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-17 12:47:44 +00:00
|
|
|
if (! $so->service_billing->checkout_id)
|
2013-06-04 11:50:41 +00:00
|
|
|
array_push($svs,$so);
|
|
|
|
|
|
|
|
if ($svs)
|
|
|
|
Block::factory()
|
|
|
|
->title('Services that should be auto-billed')
|
2016-07-29 13:04:34 +00:00
|
|
|
->title_icon($this->icon)
|
|
|
|
->body(View::factory('service/reseller/list')->set('o',$svs));
|
2013-06-04 11:50:41 +00:00
|
|
|
|
|
|
|
foreach (ORM::factory('Checkout')->find_all() as $co) {
|
|
|
|
$svs = array();
|
|
|
|
|
2014-05-20 11:49:52 +00:00
|
|
|
foreach ($co->service->where('service.account_id','IN',$this->ao->RTM->customers($this->ao->RTM))->find_all() as $so)
|
|
|
|
array_push($svs,$so);
|
2013-06-04 11:50:41 +00:00
|
|
|
|
|
|
|
if ($svs)
|
|
|
|
Block::factory()
|
|
|
|
->title($co->name)
|
2016-07-29 13:04:34 +00:00
|
|
|
->title_icon('fa fa-bank')
|
2013-06-04 11:50:41 +00:00
|
|
|
->body(Table::factory()
|
|
|
|
->jssort($co->id)
|
|
|
|
->data($svs)
|
|
|
|
->columns(array(
|
|
|
|
'id'=>'ID',
|
2016-08-03 04:00:51 +00:00
|
|
|
'name()'=>'Service',
|
2013-06-04 11:50:41 +00:00
|
|
|
'recur_schedule'=>'Billing',
|
|
|
|
'price(TRUE,TRUE)'=>'Price',
|
2016-07-29 13:04:34 +00:00
|
|
|
'account->refnum()'=>'Cust ID',
|
2013-06-04 11:50:41 +00:00
|
|
|
'account->name()'=>'Customer',
|
|
|
|
'date_next_invoice'=>'Next Invoice',
|
|
|
|
'due(TRUE)'=>'Due Invoices',
|
2014-03-04 05:17:01 +00:00
|
|
|
'service_billing->display("checkout_amount")'=>'Auto Pay',
|
2013-06-04 11:50:41 +00:00
|
|
|
))
|
|
|
|
->prepend(array(
|
|
|
|
'id'=>array('url'=>URL::link('user','service/view/')),
|
|
|
|
))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2013-10-10 13:08:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a list of expring services
|
|
|
|
*/
|
|
|
|
public function action_listexpiring() {
|
|
|
|
Block::factory()
|
|
|
|
->title('Customer Services Expiring')
|
2016-07-29 13:04:34 +00:00
|
|
|
->title_icon($this->icon)
|
|
|
|
->body(View::factory('service/reseller/list')->set('o',ORM::factory('Service')->where_authorised($this->ao)->list_expiring()));
|
2013-10-10 13:08:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a list of expring services
|
|
|
|
*/
|
|
|
|
public function action_listinvoicesoon() {
|
|
|
|
Block::factory()
|
|
|
|
->title('Customer Services soon to be Invoiced')
|
2016-07-29 13:04:34 +00:00
|
|
|
->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)));
|
2013-10-10 13:08:02 +00:00
|
|
|
}
|
2013-06-04 11:50:41 +00:00
|
|
|
}
|
|
|
|
?>
|