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

Merge branch 'feature/basic-search-revisisted' into develop

parents c11868ce 2d261af2
No related branches found
No related tags found
No related merge requests found
......@@ -22,37 +22,43 @@ class TicketsAjaxAPI extends AjaxController {
function search() {
if(!is_numeric($_REQUEST['q']))
return self::searchByEmail();
$limit = isset($_REQUEST['limit']) ? (int) $_REQUEST['limit']:25;
$items=array();
$tickets=array();
$sql='SELECT DISTINCT ticketID, email'
.' FROM '.TICKET_TABLE;
$emailSearch=false;
if(is_numeric($_REQUEST['q']))
$sql.=' WHERE ticketID LIKE \''.db_input($_REQUEST['q'], false).'%\'';
else {
$emailSearch=true;
$sql.=' WHERE email LIKE \'%'.db_input(strtolower($_REQUEST['q']), false).'%\' ';
.' FROM '.TICKET_TABLE
.' WHERE ticketID LIKE \''.db_input($_REQUEST['q'], false).'%\''
.' ORDER BY created LIMIT '.$limit;
if(($res=db_query($sql)) && db_num_rows($res)) {
while(list($id, $email)=db_fetch_row($res))
$tickets[] = array('id'=>$id, 'email'=>$email, 'value'=>$id, 'info'=>"$id - $email");
}
$sql.=' ORDER BY created LIMIT '.$limit;
return $this->json_encode($tickets);
}
function searchByEmail() {
$limit = isset($_REQUEST['limit']) ? (int) $_REQUEST['limit']:25;
$tickets=array();
$sql='SELECT email, count(ticket_id) as tickets '
.' FROM '.TICKET_TABLE
.' WHERE email LIKE \'%'.db_input(strtolower($_REQUEST['q']), false).'%\' '
.' GROUP BY email '
.' ORDER BY created LIMIT '.$limit;
if(($res=db_query($sql)) && db_num_rows($res)) {
while(list($id,$email,$name)=db_fetch_row($res)) {
if($emailSearch) {
$info = "$email - $id";
$value = $email;
} else {
$info = "$id -$email";
$value = $id;
}
$items[] = array('id'=>$id, 'email'=>$email, 'value'=>$value, 'info'=>$info);
}
while(list($email, $count)=db_fetch_row($res))
$tickets[] = array('email'=>$email, 'value'=>$email, 'info'=>"$email ($count)");
}
return $this->json_encode($items);
return $this->json_encode($tickets);
}
function acquireLock($tid) {
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<?php
if(defined('AUTO_REFRESH') && is_numeric(AUTO_REFRESH_RATE) && AUTO_REFRESH_RATE>0){ //Refresh rate
echo '<meta http-equiv="refresh" content="'.AUTO_REFRESH_RATE.'" />';
}
?>
<title>osTicket Staff Control Panel</title>
<!--[if IE]>
<style type="text/css">
......
......@@ -210,7 +210,6 @@ $(document).ready(function(){
});
},
onselect: function (obj) {
$('#basic-ticket-search').val(obj.id); /*overwriting email*/
$('#basic-ticket-search').closest('form').submit();
},
property: "value"
......
......@@ -456,7 +456,7 @@ if($ticket) {
$inc = 'ticket-view.inc.php';
if($_REQUEST['a']=='edit' && $thisstaff->canEditTickets())
$inc = 'ticket-edit.inc.php';
}else {
} else {
$inc = 'tickets.inc.php';
if($_REQUEST['a']=='open' && $thisstaff->canCreateTickets())
$inc = 'ticket-open.inc.php';
......@@ -470,8 +470,14 @@ if($ticket) {
elseif (!Export::saveTickets($query, "tickets-$ts.csv", 'csv'))
$errors['err'] = 'Internal error: Unable to dump query results';
}
elseif(!$_POST && $_REQUEST['a']!='search' && ($min=$thisstaff->getRefreshRate()))
define('AUTO_REFRESH',1); //set refresh rate if the user has it configured
//Clear active submenu on search with no status
if($_REQUEST['a']=='search' && !$_REQUEST['status'])
$nav->setActiveSubMenu(-1);
//set refresh rate if the user has it configured
if(!$_POST && $_REQUEST['a']!='search' && ($min=$thisstaff->getRefreshRate()))
define('AUTO_REFRESH', $min*60);
}
require_once(STAFFINC_DIR.'header.inc.php');
......
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