More Standardisation work.

This commit is contained in:
Deon George
2016-08-03 14:00:51 +10:00
parent 85f08bbb0a
commit 5f84d2c14f
38 changed files with 276 additions and 100 deletions

View File

@@ -83,7 +83,7 @@ class Company {
return ($x=Kohana::find_file(sprintf('media/site/%s',$this->site()),$path,$suffix)) ? $x : Kohana::find_file('media',$path,$suffix);
}
public function name() {
public function name($variable=NULL) {
return $this->so->site_details('name');
}

View File

@@ -57,7 +57,7 @@ class Controller_Login extends lnApp_Controller_Login {
'SITE_NAME'=>Company::instance()->name(),
'TOKEN'=>$mmto->token,
'TOKEN_EXPIRE_MIN'=>$token_expire,
'USER_NAME'=>sprintf('%s %s',$mmto->account->first_name,$mmto->account->last_name),
'USER_NAME'=>$mmto->account->namesub(),
);
$et->send();

View File

@@ -21,12 +21,12 @@ class Controller_User_Search extends Controller_Search {
$result = array();
if (isset($_REQUEST['term']) AND trim($_REQUEST['term'])) {
$result = Arr::merge($result,ORM::factory('Account')->list_autocomplete($_REQUEST['term'],'url','id',array('ACC %s: %s'=>array('id','name(TRUE)')),array(),array('urlprefix'=>URL::link('reseller','account/view/'))));
$result = Arr::merge($result,ORM::factory('Service')->list_autocomplete($_REQUEST['term'],'url','id',array('SVC %s: %s'=>array('id','service_name()')),array(),array('urlprefix'=>URL::link('user','service/view/'))));
$result = Arr::merge($result,ORM::factory('Invoice')->list_autocomplete($_REQUEST['term'],'url','id',array('INV %s: %s'=>array('id','account->name(TRUE)')),array(),array('urlprefix'=>URL::link('user','invoice/view/'))));
$result = Arr::merge($result,ORM::factory('Account')->list_autocomplete($_REQUEST['term'],'url','id',array('ACC %s: %s'=>array('id','name()')),array(),array('urlprefix'=>URL::link('reseller','account/view/'))));
$result = Arr::merge($result,ORM::factory('Service')->list_autocomplete($_REQUEST['term'],'url','id',array('SVC %s: %s'=>array('id','name()')),array(),array('urlprefix'=>URL::link('user','service/view/'))));
$result = Arr::merge($result,ORM::factory('Invoice')->list_autocomplete($_REQUEST['term'],'url','id',array('INV %s: %s'=>array('id','account->name()')),array(),array('urlprefix'=>URL::link('user','invoice/view/'))));
foreach (array('Service_Plugin_Adsl','Service_Plugin_Domain','Service_Plugin_Host') as $o)
$result = Arr::merge($result,ORM::factory($o)->list_autocomplete($_REQUEST['term'],'url','service_id',array('SVC %s: %s'=>array('service_id','service_name()')),array(),array('urlprefix'=>URL::link('user','service/view/'))));
$result = Arr::merge($result,ORM::factory($o)->list_autocomplete($_REQUEST['term'],'url','service_id',array('SVC %s: %s'=>array('service_id','service->name()')),array(),array('urlprefix'=>URL::link('user','service/view/'))));
}
$this->response->headers('Content-Type','application/json');

View File

@@ -21,12 +21,15 @@ class Model_Account extends lnApp_Model_Account {
);
protected $_has_one = array(
'country'=>array('foreign_key'=>'id'),
'currency'=>array('foreign_key'=>'id'),
'language'=>array('foreign_key'=>'id'),
'RTM'=>array('far_key'=>'id'),
);
protected $_belongs_to = array(
'country'=>array(),
'currency'=>array(),
'language'=>array(),
);
protected $_display_filters = array(
'date_orig'=>array(
array('Site::Date',array(':value')),
@@ -39,6 +42,22 @@ class Model_Account extends lnApp_Model_Account {
),
);
/** REQUIRED ABSTRACT METHODS **/
/**
* Returns the company name if it exists, otherwise the persons name
*/
public function name($variable=NULL) {
return $this->isCompany() ? $this->company : $this->namesub();
}
/*
* Returns the persons name
*/
public function namesub($variable=NULL) {
return trim(sprintf('%s %s',$this->first_name,$this->last_name));
}
/** OTHER METHODS **/
public function activated() {
@@ -85,15 +104,15 @@ class Model_Account extends lnApp_Model_Account {
return ($this->RTM->loaded() AND is_null($this->RTM->parent_id));
}
public function isReseller() {
return $this->RTM->loaded();
/**
* Is this account a company account
*/
public function isCompany() {
return strlen($this->company) > 0;
}
/**
* Return an account name
*/
public function name($withcompany=FALSE) {
return trim(sprintf('%s %s',$this->first_name,$this->last_name).(($withcompany AND $this->company) ? sprintf(' (%s)',$this->company) : ''));
public function isReseller() {
return $this->RTM->loaded();
}
/**
@@ -111,7 +130,7 @@ class Model_Account extends lnApp_Model_Account {
/**
* Search for accounts matching a term
*/
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=NULL) {
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=array()) {
$ao = Auth::instance()->get_user();
$this->clear();
@@ -147,7 +166,7 @@ class Model_Account extends lnApp_Model_Account {
// Restrict results to authorised accounts
array_push($limit,array('id','IN',$ao->RTM->customers($ao->RTM)));
return parent::list_autocomplete($term,$index,$value,$label,$limit,$options);
return parent::list_autocomplete($term,$index,$value,$label,$limit,array_merge($options,array('parentbypass'=>TRUE)));
}
}
?>

View File

@@ -148,11 +148,29 @@ abstract class ORM extends lnApp_ORM {
/**
* Name value return for the record
*
* @param $variable to enable further processing to determine name, eg: language
*/
public function name() {
public function name($variable=NULL) {
return sprintf('Unknown [%s]',$this->id);
}
/**
* Sub-Name value return for the record
*
* @param $variable to enable further processing to determine name, eg: language
*/
public function namesub($variable=NULL) {
return sprintf('Unknown [%s]',$this->id);
}
/**
* A reference number relating to the object
*/
public function refnum($short=FALSE) {
return ($short ? '' : 'x').sprintf('%06s',$this->id);
}
/**
* Set the site ID attribute for each row update
*/

View File

@@ -11,21 +11,7 @@
*/
class StaticList_ItemType extends StaticList {
protected function _table() {
return array(
0=>_('Product/Service Charge'), // Line Charge Topic on Invoice, eg: Service Name
1=>_('Hardware'),
2=>_('Service Relocation Fee'),
3=>_('Service Change Fee'),
4=>_('Service Connection Fee'),
5=>_('Excess Usage'), // Excess Service Item, of item 0
6=>_('Service Cancellation Fee'),
7=>_('Extra Product/Service Charge'), // Service Billing in advance
8=>_('Product Addition'), // Additional Product Customisation
124=>_('Late Payment Fee'),
125=>_('Payment Fee'), // Payment processing fee
126=>_('Other'),
127=>_('Rounding'),
);
return ORM::factory('Invoice_Item')->_types();
}
public static function get($value) {