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

Add ability to filter by unassigned on advanced search.

parent 4b184bf5
Branches
Tags
No related merge requests found
...@@ -124,16 +124,18 @@ class TicketsAjaxAPI extends AjaxController { ...@@ -124,16 +124,18 @@ class TicketsAjaxAPI extends AjaxController {
} }
//Assignee //Assignee
if($_REQUEST['assignee'] && strcasecmp($_REQUEST['status'], 'closed')) { if(isset($_REQUEST['assignee']) && strcasecmp($_REQUEST['status'], 'closed')) {
$id=preg_replace("/[^0-9]/", "", $_REQUEST['assignee']); $id=preg_replace("/[^0-9]/", "", $_REQUEST['assignee']);
$assignee = $_REQUEST['assignee']; $assignee = $_REQUEST['assignee'];
$where.= ' AND ( '; $where.= ' AND ( ( ticket.status="open" ';
if($assignee[0]=='t') if($assignee[0]=='t')
$where.=' (ticket.team_id='.db_input($id). ' AND ticket.status="open") '; $where.=' AND ticket.team_id='.db_input($id);
elseif($assignee[0]=='s') elseif($assignee[0]=='s')
$where.=' (ticket.staff_id='.db_input($id). ' AND ticket.status="open") '; $where.=' AND ticket.staff_id='.db_input($id);
else elseif(is_numeric($id))
$where.=' (ticket.staff_id='.db_input($id). ' AND ticket.status="open") '; $where.=' AND ticket.staff_id='.db_input($id);
$where.=')';
if($_REQUEST['staffId'] && !$_REQUEST['status']) //Assigned TO + Closed By if($_REQUEST['staffId'] && !$_REQUEST['status']) //Assigned TO + Closed By
$where.= ' OR (ticket.staff_id='.db_input($_REQUEST['staffId']). ' AND ticket.status="closed") '; $where.= ' OR (ticket.staff_id='.db_input($_REQUEST['staffId']). ' AND ticket.status="closed") ';
......
...@@ -50,7 +50,7 @@ switch(strtolower($_REQUEST['status'])){ //Status is overloaded ...@@ -50,7 +50,7 @@ switch(strtolower($_REQUEST['status'])){ //Status is overloaded
break; break;
default: default:
if(!$search) if(!$search)
$status='open'; $_REQUEST['status']=$status='open';
} }
$qwhere =''; $qwhere ='';
...@@ -144,19 +144,21 @@ if($search): ...@@ -144,19 +144,21 @@ if($search):
} }
//Assignee //Assignee
if($_REQUEST['assignee'] && strcasecmp($_REQUEST['status'], 'closed')) { if(isset($_REQUEST['assignee']) && strcasecmp($_REQUEST['status'], 'closed')) {
$id=preg_replace("/[^0-9]/", "", $_REQUEST['assignee']); $id=preg_replace("/[^0-9]/", "", $_REQUEST['assignee']);
$assignee = $_REQUEST['assignee']; $assignee = $_REQUEST['assignee'];
$qstr.='&assignee='.urlencode($_REQUEST['assignee']); $qstr.='&assignee='.urlencode($_REQUEST['assignee']);
$qwhere.= ' AND ( '; $qwhere.= ' AND (
( ticket.status="open" ';
if($assignee[0]=='t') if($assignee[0]=='t')
$qwhere.=' (ticket.team_id='.db_input($id). ' AND ticket.status="open") '; $qwhere.=' AND ticket.team_id='.db_input($id);
elseif($assignee[0]=='s') elseif($assignee[0]=='s')
$qwhere.=' (ticket.staff_id='.db_input($id). ' AND ticket.status="open") '; $qwhere.=' AND ticket.staff_id='.db_input($id);
else elseif(is_numeric($id))
$qwhere.=' (ticket.staff_id='.db_input($id). ' AND ticket.status="open") '; $qwhere.=' AND ticket.staff_id='.db_input($id);
$qwhere.=' ) ';
if($_REQUEST['staffId'] && !$_REQUEST['status']) { //Assigned TO + Closed By if($_REQUEST['staffId'] && !$_REQUEST['status']) { //Assigned TO + Closed By
$qwhere.= ' OR (ticket.staff_id='.db_input($_REQUEST['staffId']). ' AND ticket.status="closed") '; $qwhere.= ' OR (ticket.staff_id='.db_input($_REQUEST['staffId']). ' AND ticket.status="closed") ';
...@@ -579,7 +581,9 @@ $negorder=$order=='DESC'?'ASC':'DESC'; //Negate the sorting.. ...@@ -579,7 +581,9 @@ $negorder=$order=='DESC'?'ASC':'DESC'; //Negate the sorting..
<fieldset class="owner"> <fieldset class="owner">
<label for="assignee">Assigned To:</label> <label for="assignee">Assigned To:</label>
<select id="assignee" name="assignee"> <select id="assignee" name="assignee">
<option value="0">&mdash; Anyone &mdash;</option> <option value="">&mdash; Anyone &mdash;</option>
<option value="0">&mdash; Unassigned &mdash;</option>
<option value="<?php echo $thisstaff->getId(); ?>">Me</option>
<?php <?php
if(($users=Staff::getStaffMembers())) { if(($users=Staff::getStaffMembers())) {
echo '<OPTGROUP label="Staff Members ('.count($users).')">'; echo '<OPTGROUP label="Staff Members ('.count($users).')">';
...@@ -603,6 +607,7 @@ $negorder=$order=='DESC'?'ASC':'DESC'; //Negate the sorting.. ...@@ -603,6 +607,7 @@ $negorder=$order=='DESC'?'ASC':'DESC'; //Negate the sorting..
<label for="staffId">Closed By:</label> <label for="staffId">Closed By:</label>
<select id="staffId" name="staffId"> <select id="staffId" name="staffId">
<option value="0">&mdash; Anyone &mdash;</option> <option value="0">&mdash; Anyone &mdash;</option>
<option value="<?php echo $thisstaff->getId(); ?>">Me</option>
<?php <?php
if(($users=Staff::getStaffMembers())) { if(($users=Staff::getStaffMembers())) {
foreach($users as $id => $name) foreach($users as $id => $name)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment