diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php index ab44bd3e3e0ac39343c5425ccec2f612d90f4445..f9151951c1f3880f40121905ed26bb01f1f23fe9 100644 --- a/include/ajax.tickets.php +++ b/include/ajax.tickets.php @@ -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) { diff --git a/include/staff/header.inc.php b/include/staff/header.inc.php index 0fabe6585d42dbcdcc6f5b1e769fb145f01cc356..58d4f28dcdf77cbe3fa184e8a4979982b01de0fe 100644 --- a/include/staff/header.inc.php +++ b/include/staff/header.inc.php @@ -1,7 +1,12 @@ <!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"> diff --git a/scp/js/scp.js b/scp/js/scp.js index 08da6525eef13c66bfbfd9136a9961fdfebadcda..7a9e0e218d1da97b3ec4b2860f307dd1c1769d1f 100644 --- a/scp/js/scp.js +++ b/scp/js/scp.js @@ -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" diff --git a/scp/tickets.php b/scp/tickets.php index 9fb1e9cf7f0612e8f600af2e911ae58e02f2c9f9..d41e527779ef9f76a59eb973e337af03aaca6ddd 100644 --- a/scp/tickets.php +++ b/scp/tickets.php @@ -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');