Skip to content

Commit

Permalink
Add ability to filter by unassigned on advanced search.
Browse files Browse the repository at this point in the history
  • Loading branch information
protich committed Feb 22, 2013
1 parent 4b184bf commit 1f1dd03
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
14 changes: 8 additions & 6 deletions include/ajax.tickets.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,18 @@ function search() {
}

//Assignee
if($_REQUEST['assignee'] && strcasecmp($_REQUEST['status'], 'closed')) {
if(isset($_REQUEST['assignee']) && strcasecmp($_REQUEST['status'], 'closed')) {
$id=preg_replace("/[^0-9]/", "", $_REQUEST['assignee']);
$assignee = $_REQUEST['assignee'];
$where.= ' AND ( ';
$where.= ' AND ( ( ticket.status="open" ';
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')
$where.=' (ticket.staff_id='.db_input($id). ' AND ticket.status="open") ';
else
$where.=' (ticket.staff_id='.db_input($id). ' AND ticket.status="open") ';
$where.=' AND ticket.staff_id='.db_input($id);
elseif(is_numeric($id))
$where.=' AND ticket.staff_id='.db_input($id);

$where.=')';

if($_REQUEST['staffId'] && !$_REQUEST['status']) //Assigned TO + Closed By
$where.= ' OR (ticket.staff_id='.db_input($_REQUEST['staffId']). ' AND ticket.status="closed") ';
Expand Down
21 changes: 13 additions & 8 deletions include/staff/tickets.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
break;
default:
if(!$search)
$status='open';
$_REQUEST['status']=$status='open';
}

$qwhere ='';
Expand Down Expand Up @@ -144,19 +144,21 @@
}

//Assignee
if($_REQUEST['assignee'] && strcasecmp($_REQUEST['status'], 'closed')) {
if(isset($_REQUEST['assignee']) && strcasecmp($_REQUEST['status'], 'closed')) {
$id=preg_replace("/[^0-9]/", "", $_REQUEST['assignee']);
$assignee = $_REQUEST['assignee'];
$qstr.='&assignee='.urlencode($_REQUEST['assignee']);
$qwhere.= ' AND ( ';
$qwhere.= ' AND (
( ticket.status="open" ';

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')
$qwhere.=' (ticket.staff_id='.db_input($id). ' AND ticket.status="open") ';
else
$qwhere.=' (ticket.staff_id='.db_input($id). ' AND ticket.status="open") ';
$qwhere.=' AND ticket.staff_id='.db_input($id);
elseif(is_numeric($id))
$qwhere.=' AND ticket.staff_id='.db_input($id);

$qwhere.=' ) ';

if($_REQUEST['staffId'] && !$_REQUEST['status']) { //Assigned TO + Closed By
$qwhere.= ' OR (ticket.staff_id='.db_input($_REQUEST['staffId']). ' AND ticket.status="closed") ';
Expand Down Expand Up @@ -579,7 +581,9 @@
<fieldset class="owner">
<label for="assignee">Assigned To:</label>
<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
if(($users=Staff::getStaffMembers())) {
echo '<OPTGROUP label="Staff Members ('.count($users).')">';
Expand All @@ -603,6 +607,7 @@
<label for="staffId">Closed By:</label>
<select id="staffId" name="staffId">
<option value="0">&mdash; Anyone &mdash;</option>
<option value="<?php echo $thisstaff->getId(); ?>">Me</option>
<?php
if(($users=Staff::getStaffMembers())) {
foreach($users as $id => $name)
Expand Down

0 comments on commit 1f1dd03

Please sign in to comment.