2013-04-04 22:42:29 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class provides Reseller Account management
|
|
|
|
*
|
|
|
|
* @package OSB
|
|
|
|
* @category Controllers/Reseller
|
|
|
|
* @author Deon George
|
|
|
|
* @copyright (c) 2009-2013 Open Source Billing
|
|
|
|
* @license http://dev.osbill.net/license.html
|
|
|
|
*/
|
|
|
|
class Controller_Reseller_Account extends Controller_Account {
|
|
|
|
protected $secure_actions = array(
|
|
|
|
'ajaxlist'=>TRUE,
|
|
|
|
'list'=>TRUE,
|
|
|
|
'listlog'=>TRUE,
|
2013-05-28 13:10:12 +00:00
|
|
|
'view'=>TRUE,
|
2013-04-04 22:42:29 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used by AJAX calls to find accounts
|
|
|
|
* @note list_autocomplete() will limit to authorised accounts
|
|
|
|
*/
|
|
|
|
public function action_ajaxlist() {
|
2013-04-05 12:50:08 +00:00
|
|
|
$result = array();
|
2013-04-04 22:42:29 +00:00
|
|
|
|
|
|
|
if (isset($_REQUEST['term']) AND trim($_REQUEST['term']))
|
2013-04-05 12:50:08 +00:00
|
|
|
$result += ORM::factory('Account')->list_autocomplete($_REQUEST['term']);
|
2013-04-04 22:42:29 +00:00
|
|
|
|
|
|
|
$this->auto_render = FALSE;
|
|
|
|
$this->response->headers('Content-Type','application/json');
|
2013-04-05 12:50:08 +00:00
|
|
|
$this->response->body(json_encode(array_values($result)));
|
2013-04-04 22:42:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a list of accounts
|
|
|
|
*/
|
|
|
|
public function action_list() {
|
|
|
|
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'),
|
|
|
|
25,
|
|
|
|
array(
|
|
|
|
'id'=>array('label'=>'ID','url'=>URL::link('reseller','invoice/list/')),
|
|
|
|
'accnum()'=>array('label'=>'Num'),
|
|
|
|
'name(TRUE)'=>array('label'=>'Account'),
|
|
|
|
'email'=>array('label'=>'Email'),
|
|
|
|
'invoices_due_total(NULL,TRUE)'=>array('label'=>'Invoices','class'=>'right'),
|
|
|
|
'services_count(TRUE)'=>array('label'=>'Services','class'=>'right'),
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'page'=>TRUE,
|
|
|
|
'type'=>'select',
|
|
|
|
'form'=>URL::link('reseller','invoice/list'),
|
|
|
|
)),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a list of account logins
|
|
|
|
*/
|
|
|
|
public function action_listlog() {
|
|
|
|
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'),
|
|
|
|
25,
|
|
|
|
array(
|
|
|
|
'id'=>array('label'=>'ID'),
|
|
|
|
'date_orig'=>array('label'=>'Date'),
|
|
|
|
'account->name()'=>array('label'=>'Account'),
|
|
|
|
'ip'=>array('label'=>'IP Address'),
|
|
|
|
'details'=>array('label'=>'Details'),
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'page'=>TRUE,
|
|
|
|
)),
|
|
|
|
));
|
|
|
|
}
|
2013-05-28 13:10:12 +00:00
|
|
|
|
|
|
|
public function action_view() {
|
|
|
|
$ao = ORM::factory('Account',$this->request->param('id'));
|
|
|
|
if (! $ao->loaded() OR ! $ao->status)
|
|
|
|
HTTP::redirect(URL::link('reseller','welcome'));
|
|
|
|
|
|
|
|
Block::factory()
|
|
|
|
->title(sprintf('Active Service for Account: %s',$ao->accnum()))
|
|
|
|
->title_icon('icon-info-sign')
|
|
|
|
->span(6)
|
|
|
|
->body(Table::factory()
|
|
|
|
->data($ao->service->list_active())
|
|
|
|
->jssort('service')
|
|
|
|
->columns(array(
|
|
|
|
'id'=>'ID',
|
|
|
|
'service_name()'=>'Service',
|
|
|
|
))
|
|
|
|
->prepend(array(
|
|
|
|
'id'=>array('url'=>URL::link('user','service/view/')),
|
|
|
|
))
|
|
|
|
);
|
|
|
|
|
|
|
|
Block::factory()
|
|
|
|
->title(sprintf('Invoices Due Account: %s (%s)',$ao->accnum(),$ao->invoice->list_due_total(TRUE)))
|
|
|
|
->title_icon('icon-info-sign')
|
|
|
|
->span(6)
|
|
|
|
->body(Table::factory()
|
|
|
|
->data($ao->invoice->list_due())
|
|
|
|
->columns(array(
|
|
|
|
'id'=>'ID',
|
|
|
|
'due_date'=>'Date Due',
|
|
|
|
'total(TRUE)'=>'Invoice Total',
|
|
|
|
'due(TRUE)'=>'Amount Due',
|
|
|
|
))
|
|
|
|
->prepend(array(
|
|
|
|
'id'=>array('url'=>URL::link('user','invoice/view/')),
|
|
|
|
))
|
|
|
|
);
|
|
|
|
|
|
|
|
Block::factory()
|
|
|
|
->title(sprintf('Services Expiring for Account: %s',$ao->accnum()))
|
|
|
|
->title_icon('icon-info-sign')
|
|
|
|
->span(6)
|
|
|
|
->body(Table::factory()
|
|
|
|
->data($ao->service->list_expiring())
|
|
|
|
->columns(array(
|
|
|
|
'id'=>'ID',
|
|
|
|
'service_name()'=>'Service',
|
|
|
|
'expire(TRUE)'=>'Date',
|
|
|
|
))
|
|
|
|
->prepend(array(
|
|
|
|
'id'=>array('url'=>URL::link('user','service/view/')),
|
|
|
|
))
|
|
|
|
);
|
|
|
|
}
|
2013-04-04 22:42:29 +00:00
|
|
|
}
|
|
|
|
?>
|