From 1e6f25f148cb3330d035edc51f61fd1bb9581dfd Mon Sep 17 00:00:00 2001 From: Naomi Date: Mon, 24 Jan 2011 18:44:28 -0500 Subject: [PATCH] adding autocomplete from backend source to add shows. --- .zfproject.xml | 4 ++++ application/controllers/UserController.php | 8 ++++++++ application/models/Users.php | 8 +++++--- application/views/scripts/user/get-hosts.phtml | 1 + public/js/airtime/schedule/add-show.js | 18 ++++++++++-------- 5 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 application/views/scripts/user/get-hosts.phtml diff --git a/.zfproject.xml b/.zfproject.xml index 182da779d..bc8f59d24 100644 --- a/.zfproject.xml +++ b/.zfproject.xml @@ -72,6 +72,7 @@ + @@ -254,6 +255,9 @@ + + + diff --git a/application/controllers/UserController.php b/application/controllers/UserController.php index f255dd600..ba3b7ddfa 100644 --- a/application/controllers/UserController.php +++ b/application/controllers/UserController.php @@ -30,7 +30,15 @@ class UserController extends Zend_Controller_Action $this->view->form = $form; } + public function getHostsAction() + { + $this->view->hosts = User::getHosts(); + } + + } + + diff --git a/application/models/Users.php b/application/models/Users.php index 198bda1f6..0d25bbb16 100644 --- a/application/models/Users.php +++ b/application/models/Users.php @@ -39,14 +39,13 @@ class User { } - public static function getUsers($type=NULL) { + public static function getUsers($type=NULL, $search=NULL) { global $CC_DBC; $sql; - $sql_gen = "SELECT id, login, type FROM cc_subjs "; + $sql_gen = "SELECT id, login FROM cc_subjs "; $sql = $sql_gen; - if(!is_null($type)){ @@ -62,6 +61,9 @@ class User { $sql = $sql_gen ." WHERE ". $sql_type; } + if(!is_null($search)) { + $like = "login ILIKE '{$search}'"; + } $sql = $sql . " ORDER BY login"; diff --git a/application/views/scripts/user/get-hosts.phtml b/application/views/scripts/user/get-hosts.phtml new file mode 100644 index 000000000..1bee582a8 --- /dev/null +++ b/application/views/scripts/user/get-hosts.phtml @@ -0,0 +1 @@ +

View script for controller User and script/action name getHosts
\ No newline at end of file diff --git a/public/js/airtime/schedule/add-show.js b/public/js/airtime/schedule/add-show.js index df3bb43e5..9e132427b 100644 --- a/public/js/airtime/schedule/add-show.js +++ b/public/js/airtime/schedule/add-show.js @@ -42,6 +42,12 @@ function autoSelect(event, ui) { event.preventDefault(); } +function findHosts(request, callback) { + var search = request.term; + + +} + function setAddShowEvents() { var start, end; @@ -53,14 +59,10 @@ function setAddShowEvents() { createDateInput(start, startDpSelect); createDateInput(end, endDpSelect); - //var auto = json.hosts.map(function(el) { - // return {value: el.id, label: el.login}; - //}); - - //dialog.find("#add_show_hosts_autocomplete").autocomplete({ - // source: auto, - // select: autoSelect - //}); + $("#add_show_hosts_autocomplete").autocomplete({ + source: findHosts, + select: autoSelect + }); $("#schedule-show-style input").ColorPicker({ onSubmit: function(hsb, hex, rgb, el) {