Removed the use of TemplateDefault::filter()
This commit is contained in:
parent
66ea9babf4
commit
114ac8eb38
@ -36,47 +36,44 @@ class Controller_Reseller_Account extends Controller_Account {
|
|||||||
* Show a list of accounts
|
* Show a list of accounts
|
||||||
*/
|
*/
|
||||||
public function action_list() {
|
public function action_list() {
|
||||||
Block::add(array(
|
Block::factory()
|
||||||
'title'=>_('Customer List'),
|
->title(_('Customer List'))
|
||||||
'body'=>Table::display(
|
->title_icon('icon-th-list')
|
||||||
$this->filter(ORM::factory('Account')->list_active(),$this->ao->RTM->customers($this->ao->RTM),'id','sortkey(TRUE)'),
|
->body(Table::factory()
|
||||||
25,
|
->data(ORM::factory('Account')->where('id','IN',$this->ao->RTM->customers($this->ao->RTM))->find_all())
|
||||||
array(
|
->jssort('customer')
|
||||||
'id'=>array('label'=>'ID','url'=>URL::link('reseller','invoice/list/')),
|
->columns(array(
|
||||||
'accnum()'=>array('label'=>'Num'),
|
'id'=>'ID',
|
||||||
'name(TRUE)'=>array('label'=>'Account'),
|
'accnum()'=>'Num',
|
||||||
'email'=>array('label'=>'Email'),
|
'name(TRUE)'=>'Account',
|
||||||
'invoices_due_total(NULL,TRUE)'=>array('label'=>'Invoices','class'=>'right'),
|
'email'=>'Email',
|
||||||
'services_count(TRUE)'=>array('label'=>'Services','class'=>'right'),
|
'invoices_due_total(NULL,TRUE)'=>'Invoices',
|
||||||
),
|
'services_count(TRUE)'=>'Services',
|
||||||
array(
|
))
|
||||||
'page'=>TRUE,
|
->prepend(array(
|
||||||
'type'=>'select',
|
'id'=>array('url'=>URL::link('reseller','account/view/')),
|
||||||
'form'=>URL::link('reseller','invoice/list'),
|
))
|
||||||
)),
|
);
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a list of account logins
|
* Show a list of account logins
|
||||||
*/
|
*/
|
||||||
public function action_listlog() {
|
public function action_listlog() {
|
||||||
Block::add(array(
|
Block::factory()
|
||||||
'title'=>_('Account Login Log'),
|
->title(_('Customer Login Activity'))
|
||||||
'body'=>Table::display(
|
->title_icon('icon-eye-open')
|
||||||
$this->filter(ORM::factory('Account_Log')->find_all(),$this->ao->RTM->customers($this->ao->RTM),'account_id'),
|
->body(Table::factory()
|
||||||
25,
|
->data(ORM::factory('Account_Log')->where('account_id','IN',$this->ao->RTM->customers($this->ao->RTM))->find_all())
|
||||||
array(
|
->page_items(25)
|
||||||
'id'=>array('label'=>'ID'),
|
->columns(array(
|
||||||
'date_orig'=>array('label'=>'Date'),
|
'id'=>'ID',
|
||||||
'account->name()'=>array('label'=>'Account'),
|
'date_orig'=>'Date',
|
||||||
'ip'=>array('label'=>'IP Address'),
|
'account->name()'=>'Account',
|
||||||
'details'=>array('label'=>'Details'),
|
'ip'=>'IP Address',
|
||||||
),
|
'details'=>'Details',
|
||||||
array(
|
))
|
||||||
'page'=>TRUE,
|
);
|
||||||
)),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function action_view() {
|
public function action_view() {
|
||||||
|
@ -50,27 +50,6 @@ class Controller_TemplateDefault extends lnApp_Controller_TemplateDefault {
|
|||||||
parent::after();
|
parent::after();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This will filter a search query to only return those accounts for a reseller
|
|
||||||
*
|
|
||||||
* @param $o Our ORM Object that we are searching on
|
|
||||||
* @param $fl Our array of items that we must return
|
|
||||||
* @param $flid The ID that must be in the $fl
|
|
||||||
* @param $sort Sort the results
|
|
||||||
*/
|
|
||||||
protected function filter($o,array $fl,$flid,$sort=NULL) {
|
|
||||||
$result = array();
|
|
||||||
|
|
||||||
foreach ($o as $x)
|
|
||||||
if (! is_null($flid) AND isset($x->$flid) AND in_array($x->$flid,$fl))
|
|
||||||
array_push($result,$x);
|
|
||||||
|
|
||||||
if ($sort)
|
|
||||||
Sort::MAsort($result,$sort);
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setup(array $config_items=array()) {
|
protected function setup(array $config_items=array()) {
|
||||||
$module = Request::current()->controller();
|
$module = Request::current()->controller();
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class Controller_Reseller_Service_Adsl extends Controller_Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function action_list() {
|
public function action_list() {
|
||||||
$svs = $this->filter(ORM::factory('Service')->list_byplugin('ADSL'),$this->ao->RTM->customers($this->ao->RTM),'account_id','name()');
|
$svs = ORM::factory('Service')->where('account_id','IN',$this->ao->RTM->customers($this->ao->RTM))->list_byplugin('ADSL');
|
||||||
|
|
||||||
$data = $this->consoltraffic($svs,time());
|
$data = $this->consoltraffic($svs,time());
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ class Controller_Reseller_Service_Domain extends Controller_Service {
|
|||||||
->title('Domain License Services')
|
->title('Domain License Services')
|
||||||
->title_icon('icon-th-list')
|
->title_icon('icon-th-list')
|
||||||
->body(Table::factory()
|
->body(Table::factory()
|
||||||
->jssort('adsl')
|
->jssort('domain')
|
||||||
->data($this->filter(ORM::factory('Service')->list_byplugin('DOMAIN'),$this->ao->RTM->customers($this->ao->RTM),'account_id','name()'))
|
->data(ORM::factory('Service')->where('account_id','IN',$this->ao->RTM->customers($this->ao->RTM))->list_byplugin('DOMAIN'))
|
||||||
->columns(array(
|
->columns(array(
|
||||||
'id'=>'ID',
|
'id'=>'ID',
|
||||||
'name()'=>'Service',
|
'name()'=>'Service',
|
||||||
|
@ -19,8 +19,8 @@ class Controller_Reseller_Service_Host extends Controller_Service {
|
|||||||
->title('Hosting Services')
|
->title('Hosting Services')
|
||||||
->title_icon('icon-th-list')
|
->title_icon('icon-th-list')
|
||||||
->body(Table::factory()
|
->body(Table::factory()
|
||||||
->jssort('adsl')
|
->jssort('host')
|
||||||
->data($this->filter(ORM::factory('Service')->list_byplugin('HOST'),$this->ao->RTM->customers($this->ao->RTM),'account_id','name()'))
|
->data(ORM::factory('Service')->where('account_id','IN',$this->ao->RTM->customers($this->ao->RTM))->list_byplugin('HOST'))
|
||||||
->columns(array(
|
->columns(array(
|
||||||
'id'=>'ID',
|
'id'=>'ID',
|
||||||
'name()'=>'Service',
|
'name()'=>'Service',
|
@ -10,22 +10,31 @@
|
|||||||
* @license http://dev.osbill.net/license.html
|
* @license http://dev.osbill.net/license.html
|
||||||
*/
|
*/
|
||||||
class Controller_Reseller_Invoice extends Controller_Invoice {
|
class Controller_Reseller_Invoice extends Controller_Invoice {
|
||||||
|
protected $secure_actions = array(
|
||||||
|
'list'=>TRUE,
|
||||||
|
);
|
||||||
|
|
||||||
public function action_list() {
|
public function action_list() {
|
||||||
list($id,$output) = Table::page(__METHOD__);
|
Block::factory()
|
||||||
|
->title('Customer Invoices')
|
||||||
$ao = ORM::factory('Account',$id);
|
->title_icon('icon-th-list')
|
||||||
|
->body(Table::factory()
|
||||||
if (! $ao->loaded() OR ! Auth::instance()->authorised($ao))
|
->jssort('invoices')
|
||||||
throw HTTP_Exception::factory(403,'Unauthorised or doesnt exist?');
|
->data(ORM::factory('Invoice')->where('account_id','IN',$this->ao->RTM->customers($this->ao->RTM))->where_active()->find_all())
|
||||||
|
->page_items(25)
|
||||||
Block::add(array(
|
->columns(array(
|
||||||
'body'=>$output,
|
'id'=>'ID',
|
||||||
));
|
'date_orig'=>'Date Created',
|
||||||
|
'due_date'=>'Date Due',
|
||||||
$this->ao = $ao;
|
'total(TRUE)'=>'Total',
|
||||||
|
'due(TRUE)'=>'Due',
|
||||||
// @todo Our pagination is broken if we select multiple accounts, and those accounts have multiple invoices.
|
'account->accnum()'=>'Cust ID',
|
||||||
return parent::action_list();
|
'account->name()'=>'Customer',
|
||||||
|
))
|
||||||
|
->prepend(array(
|
||||||
|
'id'=>array('url'=>URL::link('user','invoice/view/')),
|
||||||
|
))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -25,7 +25,7 @@ class Controller_Reseller_Service extends Controller_Service {
|
|||||||
->title_icon('icon-th-list')
|
->title_icon('icon-th-list')
|
||||||
->body(Table::factory()
|
->body(Table::factory()
|
||||||
->jssort('services')
|
->jssort('services')
|
||||||
->data($this->filter(ORM::factory('Service')->find_all(),$this->ao->RTM->customers($this->ao->RTM),'account_id'))
|
->data(ORM::factory('Service')->where('account_id','IN',$this->ao->RTM->customers($this->ao->RTM))->find_all())
|
||||||
->columns(array(
|
->columns(array(
|
||||||
'id'=>'ID',
|
'id'=>'ID',
|
||||||
'service_name()'=>'Service',
|
'service_name()'=>'Service',
|
||||||
@ -49,9 +49,9 @@ class Controller_Reseller_Service extends Controller_Service {
|
|||||||
// @todo This needs to be configurable
|
// @todo This needs to be configurable
|
||||||
$go = ORM::factory('Group',array('name'=>'Personal'));
|
$go = ORM::factory('Group',array('name'=>'Personal'));
|
||||||
|
|
||||||
foreach (ORM::factory('Account')->list_active() as $ao)
|
foreach (ORM::factory('Account')->where_active()->where('id','IN',$this->ao->RTM->customers($this->ao->RTM))->find_all() as $ao)
|
||||||
if ($ao->has_any('group',array($go)))
|
if ($ao->has_any('group',array($go)))
|
||||||
foreach ($this->filter($ao->service->list_active(),$this->ao->RTM->customers($this->ao->RTM),'account_id') as $so)
|
foreach ($ao->service->list_active() as $so)
|
||||||
if (! $so->service_billing->checkout_plugin_id)
|
if (! $so->service_billing->checkout_plugin_id)
|
||||||
array_push($svs,$so);
|
array_push($svs,$so);
|
||||||
|
|
||||||
@ -80,8 +80,8 @@ class Controller_Reseller_Service extends Controller_Service {
|
|||||||
foreach (ORM::factory('Checkout')->find_all() as $co) {
|
foreach (ORM::factory('Checkout')->find_all() as $co) {
|
||||||
$svs = array();
|
$svs = array();
|
||||||
|
|
||||||
foreach ($co->account->find_all() as $ao)
|
foreach ($co->account->where('account.id','IN',$this->ao->RTM->customers($this->ao->RTM))->find_all() as $ao)
|
||||||
foreach ($this->filter($ao->service->list_active(),$this->ao->RTM->customers($this->ao->RTM),'account_id') as $so)
|
foreach ($ao->service->list_active() as $so)
|
||||||
if ($so->service_billing->checkout_plugin_id == $co->id)
|
if ($so->service_billing->checkout_plugin_id == $co->id)
|
||||||
array_push($svs,$so);
|
array_push($svs,$so);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user