$t) { $count_sql[] = "COALESCE(SUM({$t['where']}), 0) AS `$key`"; } $counts = array_map('intval', mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT " . implode(', ', $count_sql) . " $from"))); $total = $counts[$tab]; $pages = max(1, (int) ceil($total / $per_page)); $page = min($page, $pages); $offset = ($page - 1) * $per_page; $tickets = mysqli_query($mysqli, "SELECT " . portalTicketColumnsSql() . ", contact_name, category_name $from AND {$tabs[$tab]['where']} ORDER BY " . ($tab === 'closed' ? 'tickets.ticket_closed_at' : 'COALESCE(tickets.ticket_updated_at, tickets.ticket_created_at)') . " DESC, tickets.ticket_id DESC LIMIT $per_page OFFSET $offset"); /** This page's address with some of its settings changed. */ function ticketsUrl(array $changes) { global $tab, $scope, $q, $sees_all; $params = array_merge(['tab' => $tab, 'scope' => $sees_all && $scope === 'mine' ? 'mine' : null, 'q' => $q !== '' ? $q : null], $changes); if (($params['tab'] ?? '') === 'open') { unset($params['tab']); } $params = array_filter($params, function ($v) { return $v !== null && $v !== ''; }); return 'tickets.php' . ($params ? '?' . http_build_query($params) : ''); } $empty_titles = [ 'open' => ['No open tickets', 'Nothing is being worked on right now.', 'fa-check'], 'you' => ['Nothing waiting on you', 'When we need something from you, the ticket shows here.', 'fa-check'], 'resolved' => ['Nothing to confirm', 'Tickets we have resolved wait here for you to close or reopen.', 'fa-check'], 'closed' => ['No closed tickets', '', 'fa-check-circle'], 'all' => ['No tickets yet', 'Something not working? Raise a ticket and we will pick it up.', 'fa-life-ring'], ]; ?>
= $scope === 'all' ? 'Everyone at ' . escapeHtml($session_client_name) : 'The ones you raised' ?>