- Edited
This Mod essentially replicates the Search functionality that is already present in 1.7st for the e-mail field for the Full name field. I have some pretty picky co-workers and they wanted to be able to search by first and last name! ( our email format is FLastname@domain.com, so the email field search wasn't cutting it... )
In any case I've documented my changes below for those of you who want to MOD your files manually. I've commented all my changes with my initials - "RJS" to make searching for Modded section of code just a bit easier.
And as always you can find the already MODDED Files in the .zip Folder attached as well.
include\staff\ticket-open.inc.php
Search for "Full Name:" and Make the following changes....
<input type="text" size="50" name="name" id="name" class="typeahead" value="<?php echo $info; ?>" autocomplete="off" autocorrect="off" autocapitalize="off"> RJS
scp\js\scp.js
Add the Following function...
/* Name Typeahead user lookup - RJS */
$('#name.typeahead').typeahead({
source: function (typeahead, query) {
if(query.length > 1) {
$.ajax({
url: "ajax.php/names?q="+query,
dataType: 'json',
success: function (data) {
typeahead.process(data);
}
});
}
},
onselect: function (obj) {
var fObj=$('#name.typeahead').closest('form');
if(obj.email)
$('#email', fObj).val(obj.email);
if(obj.pcname)
$('#pcname', fObj).val(obj.pcname);
if(obj.phone)
$('#phone', fObj).val(obj.phone);
},
property: "name"
});
scp\ajax.php
After Line 55 Add....
url_get('^/names$', array('ajax.names.php', 'search')), //RJS
Create The following File - include\ajax.names.php
<?php
/*********************************************************************
ajax.names.php
AJAX interface for user names(based on submitted tickets)
XXX: osTicket doesn't support user accounts at the moment.
Peter Rotich <peter@osticket.com>
Copyright (c) 2006-2013 osTicket
http://www.osticket.com
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
vim: expandtab sw=4 ts=4 sts=4:
Updated for Full Name Search by: Rionoskae
**********************************************************************/
if(!defined('INCLUDE_DIR')) die('403');
include_once(INCLUDE_DIR.'class.ticket.php');
class UsersAjaxAPI extends AjaxController {
/* Search by Full Name - RJS */
function search() {
if(!isset($_REQUEST)) {
Http:(400, 'Query argument is required');
}
$limit = isset($_REQUEST) ? (int) $_REQUEST;
$users=array();
$sql='SELECT DISTINCT name, pcname, phone, email'
.' FROM '.TICKET_TABLE
.' WHERE name LIKE \'%'.db_input(strtolower($_REQUEST), false).'%\' '
.' ORDER BY created DESC'
.' LIMIT '.$limit;
if(($res=db_query($sql)) && db_num_rows($res)){
while(list($name,$pcname,$phone,$email)=db_fetch_row($res)) {
$names = array('name'=>$name, 'pcname'=>$pcname, 'phone'=>$phone, 'email'=>$email, 'info'=>"$email - $name - $pcname - $phone");
}
}
return $this->json_encode($names);
}
}?>
~Cheers
--------------------------------------------------------------------------------------------------------------
Check out My (1.7 Setup & MODS Guide)