query( "select {chatgroup}.groupid as groupid, vclocalname " . "from {chatgroup} order by vclocalname", NULL, array('return_rows' => Database::RETURN_ALL_ROWS) ); $groupName = array(); foreach ($groups as $group) { $groupName[$group['groupid']] = $group['vclocalname']; } $page['groupName'] = $groupName; $values = array( ':query' => "%{$escapedQuery}%", ':kind_user' => $kind_user, ':kind_agent' => $kind_agent ); $searchConditions = array(); if ($searchType == 'message' || $searchType == 'all') { $searchConditions[] = "({chatmessage}.tmessage LIKE :query" . ($searchInSystemMessages?'':" AND ({chatmessage}.ikind = :kind_user OR {chatmessage}.ikind = :kind_agent)") . ")"; } if ($searchType == 'operator' || $searchType == 'all') { $searchConditions[] = "({chatthread}.agentName LIKE :query)"; } if ($searchType == 'visitor' || $searchType == 'all') { $searchConditions[] = "({chatthread}.userName LIKE :query)"; $searchConditions[] = "({chatthread}.remote LIKE :query)"; } select_with_pagintation("DISTINCT unix_timestamp({chatthread}.dtmcreated) as created, " . "unix_timestamp({chatthread}.dtmmodified) as modified, {chatthread}.threadid, " . "{chatthread}.remote, {chatthread}.agentName, {chatthread}.userName, groupid, " . "messageCount as size", "{chatthread}, {chatmessage}", array( "{chatmessage}.threadid = {chatthread}.threadid", "(" . implode(' or ', $searchConditions) . ")" ), "order by created DESC", "DISTINCT {chatthread}.dtmcreated", $values); $page['formq'] = topage($query); } else { setup_empty_pagination(); } $page['formtype'] = $searchType; $page['forminsystemmessages'] = $searchInSystemMessages; prepare_menu($operator); start_html_output(); require('../view/thread_search.php'); ?>