Minor fixes to statement, services and internal things

Many misc updates
This commit is contained in:
Deon George
2011-10-14 16:44:12 +11:00
parent 7876a16413
commit 56c11507f4
71 changed files with 2192 additions and 677 deletions

View File

@@ -12,6 +12,7 @@
*/
class Controller_Admin_Account extends Controller_TemplateDefault_Admin {
protected $secure_actions = array(
'autocomplete'=>FALSE, // @todo To Change
'listlog'=>TRUE,
);
@@ -36,5 +37,40 @@ class Controller_Admin_Account extends Controller_TemplateDefault_Admin {
)),
));
}
public function action_autocomplete() {
$return = array();
$a = ORM::factory('account')->where('status','=',1);
if (isset($_REQUEST['term']) AND trim($_REQUEST['term'])) {
$t = $_REQUEST['term'];
// @todo - Implement different search criteria, eg: @ by email, space for first/last, etc
if (FALSE) {
// All search
} else {
$a = $a
->where_open()
->where('first_name','like','%'.$t.'%')
->or_where('last_name','like','%'.$t.'%')
->or_where('company','like','%'.$t.'%')
->or_where('email','like','%'.$t.'%')
->where_close();
}
}
// @todo The results should be limited so that users dont see what they shouldnt.
foreach ($a->find_all() as $ao)
array_push($return,array(
'id'=>$ao->id,
'label'=>sprintf('%s (%s)',$ao->name(),$ao->email),
'value'=>$ao->id,
));
$this->auto_render = FALSE;
$this->response->headers('Content-Type','application/json');
$this->response->body(json_encode($return));
}
}
?>