Added Payment, other minor fixes

This commit is contained in:
Deon George
2011-12-20 16:46:10 +11:00
parent c8fd44f844
commit a40ce27a16
31 changed files with 452 additions and 1280 deletions

View File

@@ -39,7 +39,7 @@ class Model_Account extends Model_Auth_UserDefault {
*/
public function name($withcompany=FALSE) {
if ($withcompany)
return sprintf('%s %s (%s)',$this->first_name,$this->last_name,$this->company);
return sprintf('%s %s%s',$this->first_name,$this->last_name,$this->company ? sprintf(' (%s)',$this->company) : '');
else
return sprintf('%s %s',$this->first_name,$this->last_name);
}
@@ -121,11 +121,55 @@ class Model_Account extends Model_Auth_UserDefault {
// Log the logout
$alo = ORM::factory('account_log');
$alo->account_id = $this->id;
$alo->ip = $_SERVER['REMOTE_ADDR'];
$alo->ip = Request::$client_ip;
$alo->details = $message;
$alo->save();
return $alo->saved();
}
/**
* Search for accounts matching a term
*/
public function list_autocomplete($term,$index='id') {
$return = array();
$this->clear();
$value = 'name(TRUE)';
// Build our where clause
// First Name, Last name
if (preg_match('/\ /',$term)) {
list($fn,$ln) = explode(' ',$term,2);
$this->where_open()
->where('first_name','like','%'.$fn.'%')
->and_where('last_name','like','%'.$ln.'%')
->where_close()
->or_where('company','like','%'.$term.'%');
} elseif (is_numeric($term)) {
$this->where('id','like','%'.$term.'%');
} elseif (preg_match('/\@/',$term)) {
$this->where('email','like','%'.$term.'%');
$value = 'email';
} else {
$this->where('company','like','%'.$term.'%')
->or_where('first_name','like','%'.$term.'%')
->or_where('last_name','like','%'.$term.'%')
->or_where('email','like','%'.$term.'%');
}
// @todo This should limit the results so that users dont see other users services.
foreach ($this->find_all() as $o)
$return[$o->$index] = array(
'value'=>$o->$index,
'label'=>sprintf('ACC %s: %s',$o->id,Table::resolve($o,$value)),
);
return $return;
}
}
?>