isValid()) die('Access Denied'); $settings = &$_SESSION['client:Q']; // Unpack search, filter, and sort requests if (isset($_REQUEST['clear'])) $settings = array(); if (isset($_REQUEST['keywords'])) { $settings['keywords'] = $_REQUEST['keywords']; } if (isset($_REQUEST['topic_id'])) { $settings['topic_id'] = $_REQUEST['topic_id']; } if (isset($_REQUEST['status'])) { $settings['status'] = $_REQUEST['status']; } $org_tickets = $thisclient->canSeeOrgTickets(); if ($settings['keywords']) { // Don't show stat counts for searches $openTickets = $closedTickets = -1; } elseif ($settings['topic_id']) { $openTickets = $thisclient->getNumTopicTicketsInState($settings['topic_id'], 'open', $org_tickets); $closedTickets = $thisclient->getNumTopicTicketsInState($settings['topic_id'], 'closed', $org_tickets); } else { $openTickets = $thisclient->getNumOpenTickets($org_tickets); $closedTickets = $thisclient->getNumClosedTickets($org_tickets); } $tickets = Ticket::objects(); $qs = array(); $status=null; $sortOptions=array('id'=>'number', 'subject'=>'cdata__subject', 'status'=>'status__name', 'dept'=>'dept__name','date'=>'created'); $orderWays=array('DESC'=>'-','ASC'=>''); //Sorting options... $order_by=$order=null; $sort=($_REQUEST['sort'] && $sortOptions[strtolower($_REQUEST['sort'])])?strtolower($_REQUEST['sort']):'date'; if($sort && $sortOptions[$sort]) $order_by =$sortOptions[$sort]; $order_by=$order_by ?: $sortOptions['date']; if ($_REQUEST['order'] && !is_null($orderWays[strtoupper($_REQUEST['order'])])) $order = $orderWays[strtoupper($_REQUEST['order'])]; else $order = $orderWays['DESC']; $x=$sort.'_sort'; $$x=' class="'.strtolower($_REQUEST['order'] ?: 'desc').'" '; $basic_filter = Ticket::objects(); if ($settings['topic_id']) { $basic_filter = $basic_filter->filter(array('topic_id' => $settings['topic_id'])); } if ($settings['status']) $status = strtolower($settings['status']); switch ($status) { default: $status = 'open'; case 'open': case 'closed': $results_type = ($status == 'closed') ? __('Closed Tickets') : __('Open Tickets'); $basic_filter->filter(array('status__state' => $status)); break; } // Add visibility constraints — use a union query to use multiple indexes, // use UNION without "ALL" (false as second parameter to union()) to imply // unique values $visibility = $basic_filter->copy() ->values_flat('ticket_id') ->filter(array('user_id' => $thisclient->getId())); // Add visibility of Tickets where the User is a Collaborator if enabled if ($cfg->collaboratorTicketsVisibility()) $visibility = $visibility ->union($basic_filter->copy() ->values_flat('ticket_id') ->filter(array('thread__collaborators__user_id' => $thisclient->getId())) , false); if ($thisclient->canSeeOrgTickets()) { $visibility = $visibility->union( $basic_filter->copy()->values_flat('ticket_id') ->filter(array('user__org_id' => $thisclient->getOrgId())) , false); } // Perform basic search if ($settings['keywords']) { $q = trim($settings['keywords']); if (is_numeric($q)) { $tickets->filter(array('number__startswith'=>$q)); } elseif (strlen($q) > 2) { //Deep search! // Use the search engine to perform the search $tickets = $ost->searcher->find($q, $tickets); } } $tickets->distinct('ticket_id'); TicketForm::ensureDynamicDataView(); $total=$visibility->count(); $page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; $pageNav=new Pagenate($total, $page, PAGE_LIMIT); $qstr = '&'. Http::build_query($qs); $qs += array('sort' => $_REQUEST['sort'], 'order' => $_REQUEST['order']); $pageNav->setURL('tickets.php', $qs); $tickets->filter(array('ticket_id__in' => $visibility)); $pageNav->paginate($tickets); $showing =$total ? $pageNav->showing() : ""; if(!$results_type) { $results_type=ucfirst($status).' '.__('Tickets'); } $showing.=($status)?(' '.$results_type):' '.__('All Tickets'); if($search) $showing=__('Search Results').": $showing"; $negorder=$order=='-'?'ASC':'DESC'; //Negate the sorting $tickets->order_by($order.$order_by); $tickets->values( 'ticket_id', 'number', 'created', 'isanswered', 'source', 'status_id', 'status__state', 'status__name', 'cdata__subject', 'dept_id', 'dept__name', 'dept__ispublic', 'user__default_email__address', 'user_id' ); ?>

0) echo sprintf(' (%d)', $openTickets); ?>   |   0) echo sprintf(' (%d)', $closedTickets); ?>

one()->getField('subject'); $defaultDept=Dept::getDefaultDeptName(); //Default public dept. if ($tickets->exists(true)) { foreach ($tickets as $T) { $dept = $T['dept__ispublic'] ? Dept::getLocalById($T['dept_id'], 'name', $T['dept__name']) : $defaultDept; $subject = $subject_field->display( $subject_field->to_php($T['cdata__subject']) ?: $T['cdata__subject'] ); $status = TicketStatus::getLocalById($T['status_id'], 'value', $T['status__name']); if (false) // XXX: Reimplement attachment count support $subject.='   '; $ticketNumber=$T['number']; if($T['isanswered'] && !strcasecmp($T['status__state'], 'open')) { $subject="$subject"; $ticketNumber="$ticketNumber"; } $thisclient->getId() != $T['user_id'] ? $isCollab = true : $isCollab = false; ?> '; } ?>
         
'.__('Your query did not match any records').'
 '.__('Page').':'.$pageNav->getPageLinks().' '; } ?>