Added Account list, DB changes for account
This commit is contained in:
parent
84145ac24f
commit
8f56da789e
@ -226,7 +226,7 @@ class Auth_OSB extends Auth_ORM {
|
||||
}
|
||||
|
||||
// If the passwords match, perform a login
|
||||
if ($user->status AND $user->has_any('group',ORM::factory('group',array('name'=>'Registered Users'))->list_childgrps(TRUE)) AND $user->password === $password)
|
||||
if ($user->active AND $user->has_any('group',ORM::factory('group',array('name'=>'Registered Users'))->list_childgrps(TRUE)) AND $user->password === $password)
|
||||
{
|
||||
if ($remember === TRUE)
|
||||
{
|
||||
|
@ -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',
|
||||
)),
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
44
application/classes/controller/affiliate/account.php
Normal file
44
application/classes/controller/affiliate/account.php
Normal 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',
|
||||
)),
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
@ -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);
|
||||
|
@ -24,15 +24,15 @@ class Model_Account extends Model_Auth_UserDefault {
|
||||
);
|
||||
|
||||
protected $_display_filters = array(
|
||||
'active'=>array(
|
||||
array('StaticList_YesNo::display',array(':value')),
|
||||
),
|
||||
'date_orig'=>array(
|
||||
array('Config::date',array(':value')),
|
||||
),
|
||||
'date_last'=>array(
|
||||
array('Config::date',array(':value')),
|
||||
),
|
||||
'status'=>array(
|
||||
array('StaticList_YesNo::display',array(':value')),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
@ -49,6 +49,15 @@ class Model_Account extends Model_Auth_UserDefault {
|
||||
return sprintf('%s-%04s',Config::siteid(TRUE),$this->id);
|
||||
}
|
||||
|
||||
public function sortkey($withcompany=FALSE) {
|
||||
$sk = '';
|
||||
|
||||
if ($withcompany AND $this->company)
|
||||
$sk .= $this->company.' ';
|
||||
|
||||
return $sk.sprintf('%s %s',$this->last_name,$this->first_name);
|
||||
}
|
||||
|
||||
public function title($name) {
|
||||
return StaticList_Title::form($name,$this->title);
|
||||
}
|
||||
@ -124,6 +133,28 @@ class Model_Account extends Model_Auth_UserDefault {
|
||||
return $alo->saved();
|
||||
}
|
||||
|
||||
private function _active() {
|
||||
return $this->where('active','=',TRUE);
|
||||
}
|
||||
|
||||
public function list_active() {
|
||||
return $this->_active()->order_by('company,last_name,first_name')->find_all();
|
||||
}
|
||||
|
||||
public function list_affiliates() {
|
||||
$return = array();
|
||||
|
||||
foreach ($this->list_services() as $so)
|
||||
if (! isset($return[$so->affiliate_id]))
|
||||
$return[$so->affiliate_id] = $so->affiliate;
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function count_services($active=TRUE,$afid=NULL) {
|
||||
return count($this->list_services($active,$afid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for accounts matching a term
|
||||
*/
|
||||
@ -167,5 +198,14 @@ class Model_Account extends Model_Auth_UserDefault {
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function list_services($active=TRUE,$afid=NULL) {
|
||||
$svs = $this->service->where('active','=',$active);
|
||||
|
||||
if ($afid)
|
||||
$svs->where('affiliate_id','=',$afid);
|
||||
|
||||
return $svs->find_all();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -208,5 +208,13 @@ abstract class ORMOSB extends ORM {
|
||||
|
||||
return empty($mc[$key]) ? '' : $mc[$key];
|
||||
}
|
||||
|
||||
protected function _active() {
|
||||
return $this->where('active','=',TRUE);
|
||||
}
|
||||
|
||||
public function list_active() {
|
||||
return $this->_active()->find_all();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user