. */ /** * @brief Script used by an Ajax autocompleter object to get the contacts data (from users or contacts) * * @file autocomplete_contacts.php * @author Claire Figueras * @date $date$ * @version $Revision$ * @ingroup indexing_searching_mlb */ require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php"); $req = new request(); $req->connect(); if(empty($_REQUEST['table'])) { exit(); } $table = $_REQUEST['table']; if($table == 'users') { $select = array(); $select[$_SESSION['tablename']['users']]= array('lastname', 'firstname', 'user_id'); $where = " (lower(lastname) like lower('%".$req->protect_string_db($_REQUEST['Input'])."%') " ."or lower(firstname) like lower('%".$req->protect_string_db($_REQUEST['Input'])."%') " ."or user_id like '%".$req->protect_string_db($_REQUEST['Input'])."%') and (status = 'OK' or status = 'ABS') and enabled = 'Y'"; $other = 'order by lastname, firstname'; $res = $req->select($select, $where, $other, $_SESSION['config']['databasetype'], 31,false,"","","", false); echo ""; } elseif($table == 'contacts') { $select = array(); $select[$_SESSION['tablename']['contacts']]= array('is_corporate_person','society', 'lastname', 'firstname', 'contact_id'); $where = " (lower(lastname) like lower('%".$req->protect_string_db($_REQUEST['Input'])."%') " //."or lower(firstname) like lower('%".$req->protect_string_db($_REQUEST['Input'])."%') " ."or lower(society) like lower('%".$req->protect_string_db($_REQUEST['Input'])."%')) "; $where .= " and (user_id = '' or user_id is null or user_id = '".$req->protect_string_db($_SESSION['user']['UserId'])."' ) and enabled = 'Y'"; $other = 'order by society, lastname, firstname'; $res = $req->select($select, $where, $other, $_SESSION['config']['databasetype'], 31,false,"","","", false); echo ""; }