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)

[AutoComplete For all User Info Fields! MOD.zip](https://forum.osticket.com/assets/files/migrated/b/3aa197f578a1abae0aa48116bb8f55e.zip)

19 days later

Add to the Client Side

Great MOD. Thanks for the code. I actually modified it just to use the name and email address of the client. Do you know how I can use this on the client side?

7 days later

There is similar functionality built into the (LDAP MOD) that provides autofill for the client side.

Thanks for the MOD. It saved me a bunch of work. I used it on 1.7RC5, and the changes were minimal to make it work. :) I also copied/changed a few things, now we can search by phone number as well.

Thanks Again

AutoFillPhone.jpg

2 months later
Write a Reply...