From be50f92fe8b382fe1cb01940b5759fd0fdd81ee3 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Fri, 13 Nov 2026 02:25:09 -0500 Subject: [PATCH] Rebuild Admin > SLAs on the standard list pattern: the SLAs are a searchable, sortable, paged list with Active and Archived views and the settings forms beside it, and each SLA shows its targets in business time with the hours typed under it, the priorities it is the default for and what uses it (open tickets, contracts and contract templates); closure days become views of the same list, coming up and past, searched by name, date, month or weekday, and Add US Holidays is a window that says how many of each year are already in; the SLA window takes targets as hours and minutes and refuses a missing name, a missing response target or a resolution target shorter than the response target; archiving says what stops getting the SLA and an archived default is shown as archived; Default SLA by priority uses the select picker, Business hours and alerts has day buttons and warns when cron is not running, and an On tickets now strip links to the tickets close to or past a target; fix business hours that end before they start being accepted and running the SLA clocks around the clock, keep the warning percent within 1 to 99, word the save messages as tickets not yet closed, and fix the backslash shown after saving an SLA with an apostrophe in its name; add slaBusinessDayMinutes, formatSlaClockMinutes and slaTargetMinutes to functions/sla.php; no database change --- CHANGELOG.md | 15 + admin/modals/sla/holiday_add.php | 22 +- admin/modals/sla/holiday_generate.php | 65 +++ admin/modals/sla/sla_add.php | 43 +- admin/modals/sla/sla_edit.php | 67 +-- admin/modals/sla/sla_form.php | 77 +++ admin/post/sla.php | 91 ++- admin/sla.php | 809 ++++++++++++++++++-------- functions/sla.php | 42 ++ 9 files changed, 888 insertions(+), 343 deletions(-) create mode 100644 admin/modals/sla/holiday_generate.php create mode 100644 admin/modals/sla/sla_form.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 18974b64a..efa3c24a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,11 +24,18 @@ Update from Maintenance > Update — Queue Update hands the job to cron and it a - Cron: a job's menu has Run now, Change the schedule, Turn off - which asks first - and Copy the command to run it, which copies the command that runs that one job on the server, where it shows what it does as it goes. The list sorts by its headings, and starts in the order the day runs: the every-minute jobs, then the nightly ones by time. - Cron: beside the page, At a glance has whether cron is running, when it last ran, how many jobs are on and off, any that failed, what runs next, and the time zone the schedules are in. Turn cron off, which stops every job at once for a restored backup or a test copy, asks first and says what stops. - Update, Backup and Cron: a page that is keeping itself up to date no longer reloads under you. It waits while a window or a menu is open, while you are typing in a field, and while you have text selected to copy. +- SLAs: Admin > SLAs is rebuilt as a list like every other - it searches, sorts by its headings and has pages - with the settings beside it instead of stacked under it. Each SLA shows what its targets come to in business time as well as the hours typed: with a 9 to 5 day, 48 hours reads 6 business days, with 48 hours under it. It also shows the priorities it is the default for, and what uses it - open tickets, contracts and contract templates. +- SLAs: a target is typed as hours and minutes, not as a count of minutes, and the window says what a day's worth comes to with your business hours. An SLA with no name or no response target, or with a resolution target shorter than its response target, is refused with the reason. +- SLAs: archiving an SLA says first what stops getting it - the priorities it is the default for and the contracts that give it - and that tickets already on it keep their targets. A priority whose default has been archived says so, where it used to read None. +- SLAs: holidays and closure days are views of the same list, coming up and past, searched by name, date, month or day of the week. Each shows its date and how far off it is, and one that falls on a day you're shut anyway says so. Add US holidays opens a window that says how many of each year's are already in and offers the first year with some to add. Removing a day asks first, and says what changes. +- SLAs: beside the list, Default SLA by priority uses the select picker, with each SLA's targets under its name. Business hours and alerts has the business days as buttons, the hours, when to warn and who else to email, and says when cron isn't running, as no warning goes out without it. On tickets now counts the open tickets with an SLA, those close to a target and those that missed one, each a link to the tickets. ### Bug Fixes - Backups: the list showed only the newest 100. Older backups were still on the server, taking up room, with no way to download or delete them from the page. Every backup can now be reached. - Backups: the window for exporting the master key said the key "is not written anywhere". An encrypted copy is filed with the other backups; the window now says so, and that every agent is notified of the export. +- SLAs: business hours saved with the day ending before it starts were accepted, and SLA clocks then ran around the clock without saying so - a 4-hour target given late on a Friday came due that evening. They are now refused, with how to set cover around the clock. A warning percent outside 1 to 99 is kept within it. +- SLAs: the message after saving an SLA with an apostrophe in its name showed a backslash in it. ### Developer Updates @@ -53,6 +60,14 @@ Update from Maintenance > Update — Queue Update hands the job to cron and it a - `admin/post/cron.php`: the messages follow the buttons - "Cron turned off.", "Mail Queue turned on." - where they said "Cron disabled." and "Cron job enabled."; `enable_cron_job` and `disable_cron_job` load the registry for the job's label. The audit log's wording is unchanged. - `js/auto_reload.js` holds its reload while `.modal.show`, `.dropdown-menu.show` or `.swal2-container` is on the page, while an `input`, `textarea` or `select` has focus, or while there is a selection, and looks again every two seconds. Before, the Backup page could reload away the Change the time window, or what was being typed into its retention boxes, while a backup was being made. - Hooks for tests and scripts: `data-cron-state` on the hero, `data-cron-jobs` with `data-cron-job`, `data-cron-status` and `data-cron-enabled` on each job's ``, `data-cron-run`, `data-cron-edit`, `data-cron-off` and `data-cron-on` in its menu, `data-cron-reason`, `data-cron-error` and `data-cron-dismiss` under it, `data-cron-glance`, `data-cron-command`, `data-cron-switch` (`on` or `off`), `data-cron-busy` and `data-cron-recovered`. +- `admin/sla.php` is rewritten on the standard list plumbing, as `admin/tax_rates.php` is laid out: the list with `SQL_CALC_FOUND_ROWS`, `includes/filter_footer.php` and `$empty_state`, and two form cards beside it. `show` picks the view - none for the SLAs in use, `archived`, `days` (closure days from today on) or `past` - and each side has its own default sort, sortable columns (`sla_name`, `sla_response_minutes`, `sla_resolution_minutes`, `tickets`; `holiday_date`, `holiday_name`), search and counts; a view's link keeps the search only on its own side. The closure days were a table with no paging under the settings. No CSS or JavaScript is added, and there is no database change. +- What uses an SLA: open tickets by a subquery on `TICKET_OPEN_SQL`, and the contracts and contract templates that name it for a priority, counted in PHP where `contractsReady()`. On tickets now uses `dashboardSlaBreachedSql()` and the ticket list's own at-risk rule, so each count is the list its link opens (`/agent/tickets.php?sla=breached`, `?sla=at_risk`). +- `functions/sla.php` gains `slaBusinessDayMinutes()` (0 when the clocks run around the clock, by `addBusinessMinutes()`'s own test), `formatSlaClockMinutes()` ("48 hours", "1 hour 30 minutes" - beside `formatSlaMinutes()`, which says what that is in business days) and `slaTargetMinutes($hours, $minutes)`. +- `admin/modals/sla/`: `sla_add.php` and `sla_edit.php` share the new `sla_form.php`, which posts `response_hours` and `response_minutes`, `resolution_hours` and `resolution_minutes`; `holiday_generate.php` is new, in place of the year box in the card's header; `holiday_add.php` is tidied. `add_sla` and `edit_sla` (`admin/post/sla.php`) add hours to minutes, so a caller that sends only `response_minutes` and `resolution_minutes` as totals gets what it did before. +- `admin/post/sla.php`: `add_sla` and `edit_sla` check the name and targets first; `edit_sla_settings` takes the hours as HH:MM, refuses a day that ends before it starts when any day is picked, and keeps `warning_percent` within 1 to 99; the messages count tickets properly and say which ("1 ticket not yet closed", "80 tickets not yet closed" - a save works out again every ticket still to close, resolved ones included, which can be more than the open tickets a row counts), use the name as typed, and `generate_holidays` says when every one was already in. What is saved, the restamping of open tickets and the audit log are unchanged. +- Removing a closure day is a `button.confirm-link` in its form (`js/confirm_modal.js`) in place of an inline `onsubmit="return confirm()"`, and Archive carries its own `data-confirm-*` text. +- Found and left alone: `slaMinutesText()` (`functions/contract.php`), which words an SLA on contracts and in the contract form, calls 2880 minutes "2 days" where the clock and `formatSlaMinutes()` make it 6 business days of a 9 to 5 day. +- Hooks for tests and scripts: `data-sla-view` on each view's link, `data-sla-list` with `data-sla-id` on each row, `data-sla-default-for`, `data-sla-archive` and `data-sla-restore`; `data-sla-days` with `data-sla-day` (the date) on each row; `data-sla-new`, `data-sla-new-day` and `data-sla-us-holidays`; `data-sla-default` (the priority) on each default's select, `data-sla-closures`, `data-sla-alerts-stopped` and `data-sla-now`. ## [26.11.7] diff --git a/admin/modals/sla/holiday_add.php b/admin/modals/sla/holiday_add.php index 83672257b..689258e66 100644 --- a/admin/modals/sla/holiday_add.php +++ b/admin/modals/sla/holiday_add.php @@ -1,5 +1,14 @@ @@ -12,24 +21,23 @@ ob_start(); -