'That ticket no longer exists.']); exit; } $client_id = intval($ticket['ticket_client_id']); if ($client_id) { enforceClientAccess(); } $purifier_config = HTMLPurifier_Config::createDefault(); $purifier_config->set('Cache.DefinitionImpl', null); $purifier_config->set('URI.AllowedSchemes', ['data' => true, 'src' => true, 'http' => true, 'https' => true]); $purifier = new HTMLPurifier($purifier_config); $reference = escapeHtml(ticketReference($ticket)); $url = escapeHtml(ticketUrl($ticket_id, $client_id)); $is_open = ticketIsOpen($ticket); $is_closed = !empty($ticket['ticket_closed_at']); $can_edit = ticketCan(2) && !$is_closed; $ticket_tags_display = tagPills('ticket', $ticket_id, tagsForRecord('ticket', $ticket_id), $client_id ? "tickets.php?client_id=$client_id&" : 'tickets.php?', $can_edit); $mine = intval($ticket['ticket_assigned_to']) === intval($session_user_id); $move = ticketWhoseMove($ticket); $sla = ticketSlaState($ticket); $due = ticketDueState($ticket); $also_open = $is_open ? ticketAlsoOpen($ticket['ticket_contact_id'], $ticket['ticket_asset_id'], $ticket_id, 5) : []; $also_open_shares = array_values(array_unique(array_merge([], ...array_column($also_open, 'shares')))); $also_open_shares = count($also_open_shares) > 1 ? 'contact or asset' : ($also_open_shares[0] ?? 'contact'); $tasks = ticketTaskCounts([$ticket_id])[$ticket_id] ?? null; $replies = []; $sql_replies = mysqli_query($mysqli, "SELECT ticket_reply_id, ticket_reply, ticket_reply_type, ticket_reply_created_at, ticket_reply_by, user_name, contact_name FROM ticket_replies LEFT JOIN users ON ticket_reply_type <> 'Client' AND ticket_reply_by = user_id LEFT JOIN contacts ON ticket_reply_type = 'Client' AND ticket_reply_by = contact_id WHERE ticket_reply_ticket_id = $ticket_id AND ticket_reply_archived_at IS NULL ORDER BY ticket_reply_id DESC LIMIT 3"); while ($row = mysqli_fetch_assoc($sql_replies)) { $replies[] = $row; } $reply_count = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FROM ticket_replies WHERE ticket_reply_ticket_id = $ticket_id AND ticket_reply_archived_at IS NULL"))[0]); $open_tasks = []; if ($tasks && $tasks[0] < $tasks[1]) { $sql_tasks = mysqli_query($mysqli, "SELECT task_name FROM tasks WHERE task_ticket_id = $ticket_id AND task_completed_at IS NULL ORDER BY task_order, task_id LIMIT 5"); while ($row = mysqli_fetch_assoc($sql_tasks)) { $open_tasks[] = $row['task_name']; } } $move_text = ['us' => ['fa-reply text-primary', 'Needs a reply from us'], 'client' => ['fa-hourglass-half', 'With the client - we replied last'], 'parked' => ['fa-pause', 'Parked - the SLA clock is paused in this status']][$move] ?? null; // Each as it reads, and as it is dialled - the extension after a pause $phones = []; if (!empty($ticket['contact_phone'])) { $extension = preg_replace('/[^0-9]/', '', (string) $ticket['contact_extension']); $phones[] = [formatPhoneNumber($ticket['contact_phone'], $ticket['contact_phone_country_code']) . ($ticket['contact_extension'] ? ' x' . $ticket['contact_extension'] : ''), phoneDialNumber($ticket['contact_phone'], $ticket['contact_phone_country_code']) . ($extension !== '' ? ",$extension" : '')]; } if (!empty($ticket['contact_mobile'])) { $phones[] = [formatPhoneNumber($ticket['contact_mobile'], $ticket['contact_mobile_country_code']), phoneDialNumber($ticket['contact_mobile'], $ticket['contact_mobile_country_code'])]; } ob_start(); ?>