diff --git a/CHANGELOG.md b/CHANGELOG.md index 8df50a942..099d1d655 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -188,6 +188,8 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u - Projects: a project has a Timeline - its booked tickets as bars in time, from its start to its due date, with now marked. A booking that is past and still open shows in amber, and two of the same agent's at the same time are flagged. Its open tickets with no booking are listed under it, with Book. - Pickers: long lists of clients, contacts, vendors, categories, locations, assets, technicians, projects, accounts and products start with the last five you picked in a field like it, under Recent, above All. Typing searches everything as before. - Archived: Tools > Archived lists what was archived lately - clients, contacts, locations, vendors, assets, credentials, documents, files, domains, certificates, networks, racks, services, licenses, projects and products - newest first, with who archived each one, to restore one or several at once. The last 30 days to start with, or pick another time, a kind or a client. +- Client portal: one Search box in the top bar looks through the client's tickets - their subject, number and what was said on them - the documents you share with them and your Help articles at once, the first eight of each with See all. Nothing found offers Ask us, and a search with no Help article goes on the Knowledge Base's Not found list. +- Client portal: a ticket says when to expect your first reply - We'll reply by and the time, from its SLA - until you reply, while it isn't on hold and the time is still ahead. New ticket says how soon you reply to each priority, beside the priority and under What happens next. Without SLAs nothing is promised. - Tickets: a ticket shows what its client owes on invoices past their due date, beside the client's name, to agents who can see invoices - with how many and how late the oldest is. It opens their overdue invoices. - Invoices: a draft left more than a week says so on the invoices list, under its status, and Drafts left a week picks them out - In drafts counts them too. The nightly notice about drafts says how many have been left that long, and opens them. - Contacts and assets: an email already on another contact - now when changing a contact too - and a serial number or MAC address already on another asset are named as they're typed, with who or which, and where. @@ -389,6 +391,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u - Projects: `projectTimeline($project, $tickets, $first_day)` in `functions/project.php` - bars, ticks by day, week or month, the now / start / due markers and same-agent clashes - for the Timeline tab on `agent/project.php`. - Pickers: `js/itflow_select.js` keeps the last five values picked (`RECENT_KEEP`) per kind in `localStorage` (`itflow.recent.`) - the kind from the select's name (`RECENT_NAMES`) or `data-recent`, `data-recent="false"` to leave one out, single selects only - and draws them first under Recent, the rest under All, while nothing is typed in a list of `SEARCH_FROM` (9) options or more. - Archived: `agent/archived.php` and `functions/archived.php` - `archivedKinds()` (table, columns, read module, audit log type), `archivedKindsFor($level)`, `archivedUnionSql()` (one `UNION ALL`, client-scoped, to sort and page), `archivedBy()` (the latest Archive in the audit log), `archivedUrl()`, `archivedCanRestore()` and `archivedRestore()`. Restore on a row uses each kind's own `restore_*` handler; `bulk_restore_archived` (`agent/post/archived.php`) takes `archived_items[]` as `kind:id`. +- Client portal: `client/search.php` (tickets by `portalTicketScopeSql()` with their non-internal replies, documents behind the same check as `portalItGate()`, articles by `kbClientSql()`, `kbSearchMissSave()` when Help finds nothing), from `.itflow-portal-search` in `client/includes/header.php`. `portalReplyTimes()` (each priority's response target from `getTicketSlaId()`) and `portalTicketReplyBy($ticket_id)` (`ticket_response_due_at` while there is no `ticket_first_response_at`, the status doesn't pause the SLA and the time is ahead) in `client/functions.php`. ## [26.11.8] diff --git a/client/functions.php b/client/functions.php index 57d6f7867..669da3f85 100644 --- a/client/functions.php +++ b/client/functions.php @@ -325,6 +325,51 @@ function portalTicketColumnsSql() { ticket_statuses.ticket_status_name, ticket_statuses.ticket_status_pauses_sla, " . ticketLastSpokeSql() . " AS ticket_last_spoke"; } +/* + * When to expect a reply - from the SLA, as the new-ticket email already + * promises it (ticketEmailSla()). Nothing when no SLA with a response target + * applies, so a company without SLAs promises nothing. + */ + +/** How soon a new ticket of each priority hears back - [priority => 'within 4 business hours'], for the priorities with a response target. */ +function portalReplyTimes() { + global $mysqli, $session_client_id; + static $times = null; + if ($times !== null) { + return $times; + } + $times = []; + foreach (['Low', 'Medium', 'High', 'Urgent'] as $priority) { + $sla_id = intval(getTicketSlaId($session_client_id, $priority)); + $minutes = $sla_id ? intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT sla_response_minutes FROM slas WHERE sla_id = $sla_id"))[0] ?? 0) : 0; + if ($minutes > 0) { + $times[$priority] = 'within ' . formatSlaMinutes($minutes); + } + } + return $times; +} + +/* + * When this ticket's first reply is due - ['by' => the time, 'within' => '4 business hours'] - + * while it is open, not on hold, not yet answered and that time is still ahead. Else null: once + * we have replied, or the time has passed, the portal promises nothing more. + */ +function portalTicketReplyBy($ticket_id) { + global $mysqli; + $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT ticket_first_response_at, ticket_response_due_at, ticket_resolved_at, ticket_closed_at, + ticket_status_pauses_sla, sla_response_minutes + FROM tickets + LEFT JOIN slas ON sla_id = ticket_sla_id + LEFT JOIN ticket_statuses ON ticket_status_id = ticket_status + WHERE ticket_id = " . intval($ticket_id) . " AND ticket_sla_id > 0 LIMIT 1")); + if (!$row || !empty($row['ticket_first_response_at']) || !empty($row['ticket_resolved_at']) || !empty($row['ticket_closed_at']) + || intval($row['ticket_status_pauses_sla'] ?? 0) === 1 || empty($row['ticket_response_due_at']) + || strtotime($row['ticket_response_due_at']) <= time() || intval($row['sla_response_minutes']) <= 0) { + return null; + } + return ['by' => $row['ticket_response_due_at'], 'within' => formatSlaMinutes(intval($row['sla_response_minutes']))]; +} + /** Whether what the editor sent says nothing - only tags, spaces and non-breaking spaces, and no picture. */ function portalHtmlIsEmpty($html) { $html = (string) $html; diff --git a/client/includes/header.php b/client/includes/header.php index 5193e9db2..16d50ad2a 100644 --- a/client/includes/header.php +++ b/client/includes/header.php @@ -151,7 +151,15 @@ $portal_contact_name = (string) ($contact['contact_name'] ?? '');
- New ticket + + + + New ticket
+
diff --git a/client/includes/ticket_next_steps.php b/client/includes/ticket_next_steps.php index 88ac18b6f..3cbb88601 100644 --- a/client/includes/ticket_next_steps.php +++ b/client/includes/ticket_next_steps.php @@ -1,7 +1,8 @@ Answer us by replying to the email or on the ticket - whichever is easier.
  • When it is done we mark it resolved, and you close it - or reopen it if it is not.
  • + +
    +

    How soon we reply

    +
      + $within) { ?> +
    • + +
    +

    Stopping everyone? Call us as well:

    diff --git a/client/search.php b/client/search.php new file mode 100644 index 000000000..7ffe63dc3 --- /dev/null +++ b/client/search.php @@ -0,0 +1,176 @@ + 'Tickets', 'icon' => 'fa-life-ring', 'total' => $total, 'rows' => $rows, 'all' => 'tickets.php?' . http_build_query(['tab' => 'all', 'q' => $q])]; + + // Documents shared with them - for those who see the company's IT + if ($can_documents) { + $where = "document_client_id = $session_client_id AND document_client_visible = 1 AND document_archived_at IS NULL + AND (document_name LIKE '%$q_sql%' OR document_description LIKE '%$q_sql%' OR document_content_raw LIKE '%$q_sql%')"; + $total = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FROM documents WHERE $where"))[0]); + $rows = []; + if ($total) { + $sql = mysqli_query($mysqli, "SELECT document_id, document_name, document_description, document_created_at, document_updated_at, folder_name, + (SELECT file_ext FROM document_files JOIN files ON files.file_id = document_files.file_id WHERE document_files.document_id = documents.document_id ORDER BY files.file_id LIMIT 1) AS file_ext + FROM documents LEFT JOIN folders ON folder_id = document_folder_id AND folder_client_id = $session_client_id + WHERE $where ORDER BY (document_name LIKE '%$q_sql%') DESC, COALESCE(document_updated_at, document_created_at) DESC LIMIT $limit"); + while ($row = mysqli_fetch_assoc($sql)) { + $rows[] = $row; + } + } + $sections['documents'] = ['label' => 'Documents', 'icon' => 'fa-folder-open', 'total' => $total, 'rows' => $rows, 'all' => 'documents.php?' . http_build_query(['q' => $q])]; + } + + // Help - the articles shared with them + if ($can_help) { + $where = kbClientSql($session_client_id) . " AND (kb_article_title LIKE '%$q_sql%' OR kb_article_summary LIKE '%$q_sql%' OR MATCH(kb_article_content_raw) AGAINST ('$q_sql'))"; + $total = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FROM kb_articles WHERE $where"))[0]); + $rows = []; + if ($total) { + $sql = mysqli_query($mysqli, "SELECT kb_article_id, kb_article_title, kb_article_summary, kb_article_content, kb_article_created_at, kb_article_updated_at, category_name, category_icon + FROM kb_articles LEFT JOIN categories ON category_id = kb_article_category_id AND kb_article_category_id > 0 + WHERE $where ORDER BY (kb_article_title LIKE '%$q_sql%') DESC, MATCH(kb_article_content_raw) AGAINST ('$q_sql') DESC, kb_article_title ASC LIMIT $limit"); + while ($row = mysqli_fetch_assoc($sql)) { + $rows[] = $row; + } + } elseif (!portalViewingAs()) { + // Nothing in Help - on the Knowledge Base's Not found list, as a search in Help is + kbSearchMissSave($q, 'portal', $session_client_id); + } + $sections['help'] = ['label' => 'Help', 'icon' => 'fa-book', 'total' => $total, 'rows' => $rows, 'all' => 'kb.php?' . http_build_query(['q' => $q])]; + } +} + +$found = array_sum(array_column($sections, 'total')); +?> + +
    +
    +

    Search

    +

    +
    + +
    + + +
    + 'What are you looking for?', 'text' => 'Type a word or a ticket number - it looks through your tickets and what was said on them' . ($can_documents ? ', your documents' : '') . ($can_help ? ' and our Help articles' : '') . '.', 'icon' => 'fa-search', 'filtered' => false]) ?> +
    + +
    + 'Nothing found', 'text' => 'Nothing mentions “' . escapeHtml($q) . '”. Try another word - or ask us.', 'icon' => 'fa-search', 'filtered' => false, + 'actions' => [['label' => 'Ask us', 'href' => portalAskUrl($q), 'icon' => 'fa-plus']]]) ?> +
    + + $section) { + if (!$section['total']) { + continue; + } ?> +
    +
    +

    + count($section['rows'])) { ?> + See all + +
    + +
    + + + + diff --git a/client/ticket.php b/client/ticket.php index c794b48b1..a3e90b850 100644 --- a/client/ticket.php +++ b/client/ticket.php @@ -118,6 +118,9 @@ $at = $closed ? 3 : ($resolved ? 2 : ($state['key'] === 'new' ? 0 : 1)); $requester = (string) ($ticket['contact_name'] ?? ''); $requester_photo = $ticket['contact_photo'] ? "/uploads/clients/$session_client_id/" . $ticket['contact_photo'] : ''; $agent_name = (string) ($ticket['user_name'] ?? ''); + +// When our first reply is due, from the SLA - while one is still to come +$reply_by = portalTicketReplyBy($ticket_id); ?> Tickets @@ -147,6 +150,12 @@ $agent_name = (string) ($ticket['user_name'] ?? '');
  • + +

    + + We'll reply by - within of when it was raised. +

    + diff --git a/client/ticket_add.php b/client/ticket_add.php index 9322aed2a..db925a5a6 100644 --- a/client/ticket_add.php +++ b/client/ticket_add.php @@ -46,6 +46,9 @@ $priorities = [ ]; $company = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT company_phone, company_phone_country_code FROM companies WHERE company_id = 1")); + +// How soon each priority hears back, from the SLAs - in the priority list and What happens next +$reply_times = portalReplyTimes(); ?> @@ -214,7 +217,7 @@ $company = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT company_phone, compa
    diff --git a/css/itflow_custom.css b/css/itflow_custom.css index b059bd81d..a5b127f9e 100644 --- a/css/itflow_custom.css +++ b/css/itflow_custom.css @@ -7805,6 +7805,24 @@ a.itflow-billing-stat:hover { align-items: center; gap: .15rem; } +/* The search box in the portal's top bar (client/search.php) */ +.itflow-portal-search { + width: 14rem; +} +/* When the first reply is due, under where a ticket has got to (client/ticket.php) */ +.itflow-portal-expect { + display: flex; + align-items: baseline; + gap: .5rem; + margin: 1rem 0 0; + padding-top: .85rem; + border-top: 1px solid var(--bs-border-color-translucent); + font-size: .875rem; + color: var(--bs-secondary-color); +} +.itflow-portal-expect strong { + color: var(--bs-emphasis-color); +} .itflow-portal-nav-link { display: inline-flex; align-items: center;