2013-10-10 02:44:53 +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(
|
|
|
|
'list'=>TRUE,
|
|
|
|
'listlog'=>TRUE,
|
2013-05-28 13:10:12 +00:00
|
|
|
'view'=>TRUE,
|
2013-10-10 02:44:53 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a list of accounts
|
|
|
|
*/
|
|
|
|
public function action_list() {
|
2013-06-10 11:48:06 +00:00
|
|
|
Block::factory()
|
|
|
|
->title(_('Customer List'))
|
|
|
|
->title_icon('icon-th-list')
|
|
|
|
->body(Table::factory()
|
2013-10-09 05:43:41 +00:00
|
|
|
->data(ORM::factory('Account')->where_authorised($this->ao,'id')->find_all())
|
2013-06-10 11:48:06 +00:00
|
|
|
->jssort('customer')
|
|
|
|
->columns(array(
|
|
|
|
'id'=>'ID',
|
2013-11-08 11:02:32 +00:00
|
|
|
'status'=>'Active',
|
2013-06-10 11:48:06 +00:00
|
|
|
'accnum()'=>'Num',
|
|
|
|
'name(TRUE)'=>'Account',
|
|
|
|
'email'=>'Email',
|
|
|
|
'invoices_due_total(NULL,TRUE)'=>'Invoices',
|
|
|
|
'services_count(TRUE)'=>'Services',
|
|
|
|
))
|
|
|
|
->prepend(array(
|
|
|
|
'id'=>array('url'=>URL::link('reseller','account/view/')),
|
|
|
|
))
|
|
|
|
);
|
2013-10-10 02:44:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a list of account logins
|
|
|
|
*/
|
|
|
|
public function action_listlog() {
|
2013-06-10 11:48:06 +00:00
|
|
|
Block::factory()
|
|
|
|
->title(_('Customer Login Activity'))
|
|
|
|
->title_icon('icon-eye-open')
|
|
|
|
->body(Table::factory()
|
2013-10-09 05:43:41 +00:00
|
|
|
->data(ORM::factory('Account_Log')->where_authorised($this->ao)->find_all())
|
2013-06-10 11:48:06 +00:00
|
|
|
->page_items(25)
|
|
|
|
->columns(array(
|
|
|
|
'id'=>'ID',
|
|
|
|
'date_orig'=>'Date',
|
|
|
|
'account->name()'=>'Account',
|
|
|
|
'ip'=>'IP Address',
|
|
|
|
'details'=>'Details',
|
|
|
|
))
|
|
|
|
);
|
2013-10-10 02:44:53 +00:00
|
|
|
}
|
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())
|
2013-06-10 11:48:06 +00:00
|
|
|
->columns(array(
|
|
|
|
'id'=>'ID',
|
|
|
|
'service_name()'=>'Service',
|
|
|
|
))
|
|
|
|
->prepend(array(
|
|
|
|
'id'=>array('url'=>URL::link('user','service/view/')),
|
|
|
|
))
|
2013-05-28 13:10:12 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
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())
|
2013-06-10 11:48:06 +00:00
|
|
|
->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/')),
|
|
|
|
))
|
2013-05-28 13:10:12 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
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())
|
2013-06-10 11:48:06 +00:00
|
|
|
->columns(array(
|
|
|
|
'id'=>'ID',
|
|
|
|
'service_name()'=>'Service',
|
|
|
|
'expire(TRUE)'=>'Date',
|
|
|
|
))
|
|
|
|
->prepend(array(
|
|
|
|
'id'=>array('url'=>URL::link('user','service/view/')),
|
|
|
|
))
|
2013-05-28 13:10:12 +00:00
|
|
|
);
|
2013-06-13 13:35:19 +00:00
|
|
|
|
|
|
|
$i = Invoice::instance();
|
|
|
|
foreach ($ao->service->list_active() as $io)
|
|
|
|
if (! $io->suspend_billing)
|
|
|
|
$i->add_service($io);
|
|
|
|
|
|
|
|
Block::factory()
|
|
|
|
->title(sprintf('Next Invoice Items for Account: %s',$ao->accnum()))
|
|
|
|
->title_icon('icon-info-sign')
|
|
|
|
->span(6)
|
2013-09-06 05:39:56 +00:00
|
|
|
->body($i->render('html','body',array('noid'=>TRUE)));
|
2013-05-28 13:10:12 +00:00
|
|
|
}
|
2013-10-10 02:44:53 +00:00
|
|
|
}
|
|
|
|
?>
|