Added Account list, DB changes for account

This commit is contained in:
Deon George
2012-07-30 17:47:28 +10:00
parent 84145ac24f
commit 8f56da789e
6 changed files with 158 additions and 32 deletions

View File

@@ -13,31 +13,10 @@
class Controller_Admin_Account extends Controller_TemplateDefault_Admin {
protected $secure_actions = array(
'autocomplete'=>FALSE, // @todo To Change
'list'=>TRUE,
'listlog'=>TRUE,
);
/**
* Show a list of account logins
*/
public function action_listlog() {
Block::add(array(
'title'=>_('Account Login Log'),
'body'=>Table::display(
ORM::factory('account_log')->order_by('id','DESC')->find_all(),
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,
)),
));
}
public function action_autocomplete() {
$return = array();
@@ -61,7 +40,7 @@ class Controller_Admin_Account extends Controller_TemplateDefault_Admin {
}
// @todo The results should be limited so that users dont see what they shouldnt.
foreach ($a->find_all() as $ao)
foreach ($a->find_all() as $ao)
array_push($return,array(
'id'=>$ao->id,
'label'=>sprintf('%s (%s)',$ao->name(),$ao->email),
@@ -69,8 +48,55 @@ class Controller_Admin_Account extends Controller_TemplateDefault_Admin {
));
$this->auto_render = FALSE;
$this->response->headers('Content-Type','application/json');
$this->response->body(json_encode($return));
$this->response->headers('Content-Type','application/json');
$this->response->body(json_encode($return));
}
/**
* Show a list of account logins
*/
public function action_listlog() {
Block::add(array(
'title'=>_('Account Login Log'),
'body'=>Table::display(
ORM::factory('account_log')->order_by('id','DESC')->find_all(),
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,
)),
));
}
/**
* Show a list of accounts
*/
public function action_list() {
Block::add(array(
'title'=>_('Customer List'),
'body'=>Table::display(
ORM::factory('account')->list_active(),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/account/view/'),
'accnum()'=>array('label'=>'Num'),
'name(TRUE)'=>array('label'=>'Account'),
'email'=>array('label'=>'Email'),
'invoices_due_total(NULL,TRUE)'=>array('label'=>'Invoices','class'=>'right'),
'count_services(TRUE,NULL)'=>array('label'=>'Services','class'=>'right'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>'user/account/view',
)),
));
}
}
?>

View File

@@ -0,0 +1,44 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Affiliate Account functions
*
* @package OSB
* @subpackage Account
* @category Controllers/Affiliate
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_Affiliate_Account extends Controller_TemplateDefault_Affiliate {
protected $secure_actions = array(
'list'=>TRUE,
);
/**
* 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->affiliate->id,'sortkey(TRUE)');
25,
array(
'id'=>array('label'=>'ID','url'=>'user/account/view/'),
'accnum()'=>array('label'=>'Num'),
'name(TRUE)'=>array('label'=>'Account'),
'email'=>array('label'=>'Email'),
'invoices_due_total(NULL,TRUE)'=>array('label'=>'Invoices','class'=>'right'),
'count_services(TRUE,'.$this->ao->affiliate->id.')'=>array('label'=>'Services','class'=>'right'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>'user/account/view',
)),
));
}
}
?>

View File

@@ -17,9 +17,17 @@ class Controller_TemplateDefault_Affiliate extends Controller_TemplateDefault_Us
protected function filter($o,$af,$sort='account->name()',$afid='affiliate_id') {
$result = array();
foreach ($o as $x)
if ($x->$afid == $af)
array_push($result,$x);
foreach ($o as $x) {
if (isset($x->$afid)) {
if ($x->$afid == $af)
array_push($result,$x);
} elseif (method_exists($x,'list_affiliates')) {
if (in_array($af,$x->list_affiliates()))
array_push($result,$x);
}
}
if ($sort)
Sort::MAsort($result,$sort);