Standardisation work, changed accnum() to refnum()

This commit is contained in:
Deon George
2016-07-29 23:04:34 +10:00
parent e0b45be758
commit 85f08bbb0a
52 changed files with 361 additions and 514 deletions

View File

@@ -10,5 +10,6 @@
* @license http://dev.osbill.net/license.html
*/
class Controller_Account extends Controller_TemplateDefault {
protected $icon = 'fa fa-users';
}
?>

View File

@@ -20,34 +20,24 @@ class Controller_Reseller_Account extends Controller_Account {
* Show a list of accounts
*/
public function action_list() {
$this->meta->title = 'Customer List';
$this->meta->title = 'R|Customer List';
Block::factory()
->title(_('Customer List'))
->title_icon('fa fa-list')
->body(Table::factory()
->data(ORM::factory('Account')->where_authorised($this->ao,'id')->find_all())
->jssort('customer')
->columns(array(
'id'=>'ID',
'status'=>'Active',
'accnum()'=>'Num',
'name(TRUE)'=>'Account',
'email'=>'Email',
'invoices_due_total(NULL,TRUE)'=>'Invoices',
'service->find_all()->count()'=>'Services',
))
->prepend(array(
'id'=>array('url'=>URL::link('reseller','account/view/')),
))
);
->title_icon($this->icon)
->body(View::factory('account/list')->set('o',ORM::factory('Account')->where_authorised($this->ao,'id')->find_all()));
}
/**
* Show a list of account logins
*/
public function action_listlog() {
$this->template->content = View::factory('account/reseller/listlog');
$this->meta->title = 'R|Customer Logins';
Block::factory()
->title(_('Customer List'))
->title_icon('fa fa-eye')
->body(View::factory('account/listlog')->set('o',ORM::factory('Account_Log')->where_authorised($this->ao)->find_all()));
}
public function action_view() {

View File

@@ -19,89 +19,29 @@ class Controller_Reseller_Welcome extends Controller_Welcome {
public function action_index() {
$t = time();
// Show outstanding invoices
$o = ORM::factory('Invoice');
Block::factory()
->title($this->ao->RTM->display('name'))
->body('');
Block::factory()
->title('Invoices Overdue - No Auto Billing')
->title_icon('icon-info-sign')
->title_icon('fa fa-pencil-square-o')
->span(6)
->body(Table::factory()
->data($o->list_overdue_billing($t))
->columns(array(
'id'=>'ID',
'due_date'=>'Due',
'account->accnum()'=>'Num',
'account->name()'=>'Account',
'total(TRUE)'=>'Total',
'due(TRUE)'=>'Due',
))
->prepend(array(
'id'=>array('url'=>URL::link('user','invoice/view/')),
))
);
->body(View::factory('invoice/list')->set('o',ORM::factory('Invoice')->list_overdue_billing($t)));
Block::factory()
->title('Invoices Overdue - Auto Billing')
->title_icon('icon-info-sign')
->title_icon('fa fa-pencil-square-o')
->span(6)
->body(Table::factory()
->data($o->list_overdue_billing($t,TRUE))
->columns(array(
'id'=>'ID',
'due_date'=>'Due',
'account->accnum()'=>'Num',
'account->name()'=>'Account',
'total(TRUE)'=>'Total',
'due(TRUE)'=>'Due',
))
->prepend(array(
'id'=>array('url'=>URL::link('user','invoice/view/')),
))
);
->body(View::factory('invoice/list')->set('o',ORM::factory('Invoice')->list_overdue_billing($t,TRUE)));
Block::factory()
->title('Upcoming Invoices')
->title_icon('icon-info-sign')
->title_icon('fa fa-pencil-square-o')
->span(6)
->body(Table::factory()
->data($o->list_due(time()))
->columns(array(
'id'=>'ID',
'due_date'=>'Due',
'account->accnum()'=>'Num',
'account->name()'=>'Account',
'total(TRUE)'=>'Total',
'due(TRUE)'=>'Due',
))
->prepend(array(
'id'=>array('url'=>URL::link('user','invoice/view/')),
))
);
->body(View::factory('invoice/list')->set('o',ORM::factory('Invoice')->list_due($t)));
Block::factory()
->title('Un-applied payments')
->title_icon('icon-info-sign')
->title_icon('fa fa-money')
->span(6)
->body(Table::factory()
->data(ORM::factory('Payment')->where_authorised()->list_unapplied())
->columns(array(
'id'=>'ID',
'date_payment'=>'Pay Date',
'account->accnum()'=>'Num',
'account->name()'=>'Account',
'account->display("status")'=>'Active',
'total(TRUE)'=>'Total',
'balance(TRUE)'=>'Balance',
))
->prepend(array(
'id'=>array('url'=>URL::link('reseller','payment/view/')),
))
);
->body(View::factory('payment/list')->set('o',ORM::factory('Payment')->where_authorised()->list_unapplied()));
}
/**

View File

@@ -23,7 +23,7 @@ class Controller_User_Account extends Controller_Account {
$this->ao->reload();
Block::factory()
->title(sprintf('Account: %s',$this->ao->accnum()))
->title(sprintf('Account: %s',$this->ao->refnum()))
->title_icon('icon-wrench')
->type('form-horizontal')
->body(View::factory('account/user/edit')->set('o',$this->ao));
@@ -94,7 +94,7 @@ $("#reset").validate({
');
Block::factory()
->title(sprintf('Password Reset: %s',$this->ao->accnum()))
->title(sprintf('Password Reset: %s',$this->ao->refnum()))
->title_icon('icon-cog')
->id('reset')
->type('form-horizontal')

View File

@@ -9,7 +9,7 @@
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Account extends Model_Auth_UserDefault {
class Model_Account extends lnApp_Model_Account {
// Relationships
protected $_has_many = array(
'user_tokens'=>array('model'=>'user_token'),
@@ -39,35 +39,12 @@ class Model_Account extends Model_Auth_UserDefault {
),
);
protected $_form = array('id'=>'id','value'=>'name(TRUE)');
protected $_save_message = TRUE;
/**
* Our account number format
*/
public function accnum() {
return sprintf('%s-%04s',Company::instance()->site(TRUE),$this->id);
}
/** OTHER METHODS **/
public function activated() {
return $this->has('group');
}
/**
* Get the groups that an account belongs to
*/
public function groups() {
$result = array();
foreach ($this->group->where_active()->find_all() as $go)
foreach ($go->list_parentgrps(TRUE) as $cgo)
if (empty($result[$cgo->id]))
$result[$cgo->id] = $cgo;
return $result;
}
/**
* Get a list of all invoices for this account
*/
@@ -77,14 +54,6 @@ class Model_Account extends Model_Auth_UserDefault {
return $processed ? $o->find_all() : $o->where_unprocessed()->find_all();
}
public function isAdmin() {
return ($this->RTM->loaded() AND is_null($this->RTM->parent_id));
}
public function isReseller() {
return $this->RTM->loaded();
}
/**
* Get a list of due invoices for this account
*
@@ -112,36 +81,12 @@ class Model_Account extends Model_Auth_UserDefault {
return $format ? Currency::display($result) : $result;
}
public function log($message) {
// Log a message for this account
$alo = ORM::factory('Account_Log');
$alo->account_id = $this->id;
$alo->ip = Request::$client_ip;
$alo->details = $message;
$alo->save();
return $alo->saved();
public function isAdmin() {
return ($this->RTM->loaded() AND is_null($this->RTM->parent_id));
}
/**
* This function will extract the available methods for this account
* This is used both for menu options and method security
*/
public function methods() {
static $result = array();
// @todo We may want to optimise this with some session caching.
if ($result)
return $result;
foreach ($this->groups() as $go)
foreach ($go->module_method->find_all() as $mmo)
if (empty($result[$mmo->id]))
$result[$mmo->id] = $mmo;
Sort::MAsort($result,array('module->name','menu_display'));
return $result;
public function isReseller() {
return $this->RTM->loaded();
}
/**