copy() ->values_flat('ticket_id') ->filter(array('user_id' => $user->getId())) ->union($tickets->copy() ->values_flat('ticket_id') ->filter(array('thread__collaborators__user_id' => $user->getId())) , false); } elseif ($org) { $filter = $tickets->copy() ->values_flat('ticket_id') ->filter(array('user__org' => $org)); } // Apply filter $tickets->filter(array('ticket_id__in' => $filter)); // Apply staff visibility if (!$thisstaff->hasPerm(SearchBackend::PERM_EVERYTHING)) $tickets->filter($thisstaff->getTicketsVisibility()); $tickets->constrain(array('lock' => array( 'lock__expire__gt' => SqlFunction::NOW()))); // Group by ticket_id. $tickets->distinct('ticket_id'); // Save the query to the session for exporting $queue = sprintf(':%s:tickets', $user ? 'U' : 'O'); $_SESSION[$queue] = $tickets; // Apply pagination $total = $tickets->count(); $page = ($_GET['p'] && is_numeric($_GET['p'])) ? $_GET['p'] : 1; $pageNav = new Pagenate($total, $page, PAGE_LIMIT); $pageNav->setURL(($user ? 'users.php' : 'orgs.php'), $args); $tickets = $pageNav->paginate($tickets); $tickets->annotate(array( 'collab_count' => SqlAggregate::COUNT('thread__collaborators', true), 'attachment_count' => SqlAggregate::COUNT(SqlCase::N() ->when(new SqlField('thread__entries__attachments__inline'), null) ->otherwise(new SqlField('thread__entries__attachments')), true ), 'thread_count' => SqlAggregate::COUNT(SqlCase::N() ->when( new Q(array('thread__entries__flags__hasbit'=>ThreadEntry::FLAG_HIDDEN)), null) ->otherwise(new SqlField('thread__entries__id')), true ), )); $tickets->values('staff_id', 'staff__firstname', 'staff__lastname', 'team__name', 'team_id', 'lock__lock_id', 'lock__staff_id', 'isoverdue', 'status_id', 'status__name', 'status__state', 'number', 'cdata__subject', 'ticket_id', 'source', 'dept_id', 'dept__name', 'user_id', 'user__default_email__address', 'user__name', 'lastupdate'); $tickets->order_by('-created'); TicketForm::ensureDynamicDataView(); // Fetch the results ?>
'.$pageNav->showing().''; } else { echo sprintf(__('%s does not have any tickets'), $user? __('User') : __('Organization')); } ?>

one()->getField('subject'); $user_id = $user ? $user->getId() : 0; foreach($tickets as $T) { $flag=null; if ($T['lock__lock_id'] && $T['lock__staff_id'] != $thisstaff->getId()) $flag='locked'; elseif ($T['isoverdue']) $flag='overdue'; $assigned=''; if ($T['staff_id']) $assigned = new AgentsName(array( 'first' => $T['staff__firstname'], 'last' => $T['staff__lastname'] )); elseif ($T['team_id']) $assigned = Team::getLocalById($T['team_id'], 'name', $T['team__name']); else $assigned=' '; $status = TicketStatus::getLocalById($T['status_id'], 'value', $T['status__name']); $tid = $T['number']; $subject = $subject_field->display($subject_field->to_php($T['cdata__subject'])); $threadcount = $T['thread_count']; ?>
 
> '; ?> '; if ($threadcount > 1) { ?> '; if ($T['collab_count']) echo ''; ?> > <>
0) { echo '
'; echo __('Page').':'.$pageNav->getPageLinks('tickets', '#tickets').' '; echo sprintf('%s', $user ? 'users' : 'orgs', $user ? $user->getId() : $org->getId(), 'queue-export', __('Export')); echo '
'; } ?>