Skip to content
Snippets Groups Projects
Commit 2385efa6 authored by Peter Rotich's avatar Peter Rotich
Browse files

Add user search - typeahead

parent b3be36eb
No related branches found
No related tags found
No related merge requests found
......@@ -43,7 +43,7 @@ class UsersAjaxAPI extends AjaxController {
}
}
return $this->encode($users);
return $this->json_encode($users);
}
}
......
......@@ -22,7 +22,8 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
Email Address:
</td>
<td>
<input type="text" size="30" name="email" value="<?php echo $info['email']; ?>">
<input type="text" size="30" name="email" id="email" class="typeahead" value="<?php echo $info['email']; ?>"
autocomplete="off" autocorrect="off" autocapitalize="off">
&nbsp;<span class="error">*&nbsp;<?php echo $errors['email']; ?></span>
<?php
if($cfg->notifyONNewStaffTicket()) { ?>
......@@ -37,7 +38,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
Full Name:
</td>
<td>
<input type="text" size="30" name="name" value="<?php echo $info['name']; ?>">
<input type="text" size="30" name="name" id="name" value="<?php echo $info['name']; ?>">
&nbsp;<span class="error">*&nbsp;<?php echo $errors['name']; ?></span>
</td>
</tr>
......@@ -46,9 +47,9 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
Phone Number:
</td>
<td>
<input type="text" size="18" name="phone" value="<?php echo $info['phone']; ?>">
<input type="text" size="18" name="phone" id="phone" value="<?php echo $info['phone']; ?>">
&nbsp;<span class="error">&nbsp;<?php echo $errors['phone']; ?></span>
Ext <input type="text" size="5" name="phone_ext" value="<?php echo $info['phone_ext']; ?>">
Ext <input type="text" size="5" name="phone_ext" id="phone_ext" value="<?php echo $info['phone_ext']; ?>">
&nbsp;<span class="error">&nbsp;<?php echo $errors['phone_ext']; ?></span>
</td>
</tr>
......
......@@ -199,7 +199,7 @@ $(document).ready(function(){
}
/* Typeahead init */
$('#ticket-search').typeahead({
$('#basic-ticket-search').typeahead({
source: function (typeahead, query) {
$.ajax({
url: "ajax.php/tickets?q="+query,
......@@ -210,9 +210,31 @@ $(document).ready(function(){
});
},
onselect: function (obj) {
$('#ticket-search').closest('form').submit();
$('#basic-ticket-search').val(obj.id); /*overwriting email*/
$('#basic-ticket-search').closest('form').submit();
},
property: "value"
});
$('#email.typeahead').typeahead({
source: function (typeahead, query) {
if(query.length > 2) {
$.ajax({
url: "ajax.php/users?q="+query,
dataType: 'json',
success: function (data) {
typeahead.process(data);
}
});
}
},
onselect: function (obj) {
var fObj=$('#email.typeahead').closest('form');
if(obj.name)
$('#name', fObj).val(obj.name);
},
property: "email"
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment