diff --git a/CHANGELOG.md b/CHANGELOG.md index 3324713cc..fd2b3dc3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ This file documents all notable changes made to ITFlow. ### Upgrading -Update from Maintenance > Update — Queue Update hands the job to cron, which updates the files and applies this release's five database changes (3.6.6 to 3.7.1) in the same pass. They add four tables for RMM providers and their alerts, a setting for device actions and one for API keys in the address, and a column marking the emails the mail queue clears once sent, and change nothing that is there. Nothing else is required. This release has four security fixes - see Security. +Update from Maintenance > Update — Queue Update hands the job to cron, which updates the files and applies this release's six database changes (3.6.6 to 3.7.2) in the same pass. They add four tables for RMM providers and their alerts, a setting for device actions and one for API keys in the address, a column marking the emails the mail queue clears once sent, and a column and a table for agent banners, and change nothing that is there. Nothing else is required. This release has four security fixes - see Security. ### Security @@ -68,6 +68,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u - Reports: every report exports as a PDF that looks like the page - Export > PDF. It has the dark bar with the report's name and dates, your company and who printed it, the figures along the top, and each section as you see it: the charts and the map, the tables with their colours, badges and bold, and the notes under them. Tables come out with all their rows rather than the first few. Client Review makes a PDF to hand a client at a business review. The PDF is in the light colours of paper even when you use dark mode, on Letter paper in the US and Canada and A4 elsewhere, and on its side when a table is wide. Export still has each table as a CSV. - Reports: Tax Package, under Finance, gathers what your accountant asks for at year end for one tax year - profit and loss by category a quarter at a time, the sales tax charged at each rate on payments received and on invoices sent, each account's balance at the start and end of the year, the invoices unpaid at year end, for a US company the vendors paid enough to need a 1099 (with what was paid by card apart), the mileage, and the expenses with no receipt. The year starts in January, or in the month you pick - April in the UK, New Zealand and India, July in Australia and March in South Africa to start with. Download package makes one ZIP: the page as a PDF, each table as a CSV, every payment, expense, invoice and trip of the year as spreadsheets that add up to the summary, and every expense's receipt, named by date, vendor and amount. - Tickets: checking off a task, or marking it not done, no longer reloads the page and sends you back to the top - the list, the count and the Resolve button update where you are, so you can work down a long list. The "Completed Task" note shows in the conversation the next time the page loads. +- Banners: a note your team sees along the top of their pages - for one client, such as "On credit hold - no work without approval", or for every client. A client's shows on its pages, and on its tickets, invoices, quotes, recurring invoices and projects however they're opened. Anyone who can edit a client adds one from New Banner in the client's ⋮ menu, which lists its banners below to change, archive or delete. Admins add them for every client, and see them all, in Admin > Agent Banners. Each is a Notice, Heads up or Urgent, and shows between its start and end like a portal announcement. Anyone can hide a Notice or Heads up until it's changed; an Urgent one is big and red, first on the page, and can't be hidden. Clients never see banners. ### Bug Fixes @@ -132,6 +133,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u - Reports: `tax_package` in `reportCatalog()` (Finance, `module_financial`, `accounting`) and `agent/reports/tax_package.php`. `?start=` is the month the tax year starts (by `company_country` from `TAX_PACKAGE_START` when not given), `?year=` the year it starts in, `?rate=` the mileage rate and `?over=` the 1099 threshold (a US company with a January year; 600 before 2026, 2,000 from). The figures come from `reportIncomeByCategory()`, `reportExpensesByCategory()`, `taxReportSales()` on both bases, `taxReportPurchases()` and `accountBalanceSql()`; what was owed on an invoice at year end is `taxPackageOwedSql()`, which takes an invoice marked Paid that no payment covers as settled. Download package (`?export=package`) calls `reportPdfStart()` with a sender, so the page is drawn and made a PDF as usual and `taxPackageSend()` then builds the ZIP in `uploads/tmp` (removed when the request ends): the summary, the page's tables through the new `reportCsvData()` (what `reportCsv()` now sends), the Income, Expenses, Invoices and Trips registers, and `Receipts/` from `expenseReceiptPath()`. `reportPdfStart(callable $send = null)` can be called more than once, `reportPdfRequested()` is true for `pdf` and `package`, and `reportTable()` takes `pdf_whole` => false to keep its `limit` in a PDF. In report PDFs a table wider than the page now wraps only its text columns, down to their longest word, so figures stay on one line. - `sendQueueEmail()` (`cron/mail_queue.php`) puts a calendar file in the message as its own `text/calendar` part (`$mail->Ical`) only for a meeting - `METHOD:REQUEST` or `CANCEL` with an `ORGANIZER` and an `ATTENDEE` - and attaches anything else as `invite.ics`. `createiCalStrCancel()` has neither, so a ticket's cancellation now goes as an attachment like its `PUBLISH` booking: Exchange Online makes the part into a meeting as it takes the message, and refused one with nobody in it. A PHPMailer exception from `send()` is thrown again with the SMTP server's last reply added (`getSMTPInstance()->getError()`), so `email_error` keeps it. - `agent/ticket.php`: a link marked `data-task-toggle` (a task's checkbox, and Mark incomplete) is followed with `fetch` instead of navigating. The post handler is unchanged: its redirect back to the ticket is the answer, and its `table#tasks` rows, `.ticket-task-count` and `[data-ticket-resolve]` button (both forms of Resolve carry it) replace the page's own, with its flash toast. Only the latest click's answer is used; the rows are replaced inside the tbody so SortableJS reordering keeps working; a link that lands elsewhere goes there, and one that can't be reached is followed as before. +- Banners: `functions/agent_banner.php`. They are kept in `portal_announcements` with the new `announcement_audience` (`portal` or `agents`), sharing `PORTAL_ANNOUNCEMENT_TONES`, `portalAnnouncementState()`, `portalAnnouncementBodyHtml()` and the form, moved to `includes/announcement_form.php` (with `$announcement_for_agents`, and `$announcement_client_fixed` for one client's). `portalAnnouncementFromPost()` and `portalAnnouncementSetSql()` moved from `admin/post/portal_announcement.php` to `functions/portal.php` as `announcementFromPost()` and `announcementSetSql()`, and `portalAnnouncementsFor()` and Admin > Client portal read only the `portal` ones (`portalAnnouncementsOnlySql()`). `agentBannersHtml($client_id)` draws them, each once a page, from `includes/inc_alert_feedback.php` with the page's `$client_id`; `ticket.php`, `invoice.php`, `quote.php`, `recurring_invoice.php` and `project.php` opened without `client_id` set `$agent_banners_later` and call it with the record's client. `agent/post/agent_banner.php` has `add_agent_banner`, `edit_agent_banner`, `archive_agent_banner`, `restore_agent_banner`, `delete_agent_banner` and `hide_agent_banner` (a 204, sent by the close button), checked with `agentBannerCanEdit()` - an admin, or `module_client` at 2 with access to the client for a client's. The windows are `agent/modals/agent_banner/`, used by `admin/agent_banners.php` too. Database 3.7.2: `portal_announcements.announcement_audience` and `announcement_dismissals` (announcement, user, when); a dismissal hides a banner while it is newer than `announcement_updated_at`, and never one in `danger`. Nothing shows until the update has run (`agentBannersReady()`). ## [26.11.8] diff --git a/admin/agent_banners.php b/admin/agent_banners.php new file mode 100644 index 000000000..f13a4cbb1 --- /dev/null +++ b/admin/agent_banners.php @@ -0,0 +1,214 @@ + Agent Banners - every banner along the top of agents' pages (functions/agent_banner.php): + * those for every client, made here, and those for one client, made here or from the client's + * ⋮ menu. Each row shows how loud it is, where it stands (showing, scheduled, ended), who it is + * for and when it shows. Current holds what isn't archived; Archived what is. Search looks in + * the title and message; the client filter picks every client's or one client's. The handlers + * are agent/post/agent_banner.php and the windows agent/modals/agent_banner/, shared with the + * client's menu. + */ + +// Default Column Sortby Filter +$sort = "starts"; +$order = "DESC"; + +require_once "includes/inc_all_admin.php"; + +$views = [ + '' => ['label' => 'Current', 'icon' => 'fa-bullhorn', 'where' => 'announcement_archived_at IS NULL', 'title' => 'Showing, still to come, or ended and not archived'], + 'archived' => ['label' => 'Archived', 'icon' => 'fa-archive', 'where' => 'announcement_archived_at IS NOT NULL', 'title' => 'Nobody sees them'], +]; +$show = (string) ($_GET['show'] ?? ''); +$show = isset($views[$show]) ? $show : ''; +$show_archived = $show === 'archived'; + +// Who it is for: any, every client (0), or one client +$client_filter = (string) ($_GET['client'] ?? ''); +$client_filter = $client_filter === 'every' ? 'every' : (intval($client_filter) > 0 ? (string) intval($client_filter) : ''); + +// Only these sort - an unknown column would take the page down +$sortable_columns = [ + 'announcement_title' => "announcement_title $order", + 'client_name' => "announcement_client_id > 0 $order, client_name $order", + 'starts' => "COALESCE(announcement_starts_at, announcement_created_at) $order", + 'ends' => "announcement_ends_at IS NULL $order, announcement_ends_at $order", +]; +if (!isset($sortable_columns[$sort])) { + $sort = 'starts'; +} + +$filters = "announcement_audience = 'agents' AND (announcement_title LIKE '%$q%' OR announcement_body LIKE '%$q%')"; +if ($client_filter === 'every') { + $filters .= " AND announcement_client_id = 0"; +} elseif ($client_filter !== '') { + $filters .= " AND announcement_client_id = " . intval($client_filter); +} + +$ready = agentBannersReady(); +$num_rows = [0]; +$banners = []; +$view_counts = ['' => 0, 'archived' => 0]; +if ($ready) { + $sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS announcement_id, announcement_title, announcement_body, announcement_tone, announcement_client_id, + announcement_starts_at, announcement_ends_at, announcement_created_at, announcement_archived_at, client_name, user_name + FROM portal_announcements + LEFT JOIN clients ON client_id = announcement_client_id + LEFT JOIN users ON user_id = announcement_created_by + WHERE $filters AND {$views[$show]['where']} + ORDER BY {$sortable_columns[$sort]}, announcement_id DESC + LIMIT $record_from, $record_to"); + $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); + while ($row = mysqli_fetch_assoc($sql)) { + $banners[] = $row; + } + $counts = mysqli_fetch_row(mysqli_query($mysqli, "SELECT COALESCE(SUM(announcement_archived_at IS NULL), 0), COALESCE(SUM(announcement_archived_at IS NOT NULL), 0) + FROM portal_announcements LEFT JOIN clients ON client_id = announcement_client_id WHERE $filters")); + $view_counts = ['' => intval($counts[0]), 'archived' => intval($counts[1])]; +} + +$state_badges = ['showing' => 'text-bg-success', 'scheduled' => 'text-bg-info', 'ended' => 'text-bg-secondary', 'archived' => 'text-bg-secondary']; +$sort_link = function ($column, $label) use ($url_query_strings_sort, $sort, $disp, $order_icon) { + return '' + . $label . ($sort === $column ? " $order_icon" : '') . ''; +}; +$pill_url = function ($view) use ($client_filter) { + return '?' . http_build_query(array_filter(['q' => $_GET['q'] ?? '', 'client' => $client_filter, 'show' => $view])); +}; +$add_url = '/agent/modals/agent_banner/agent_banner_add.php'; +$csrf = $_SESSION['csrf_token']; + +?> + +
Along the top of agents' pages - for every client on every page, or for one client on its pages and its tickets, invoices, quotes and projects. Agents who can edit a client add its banners from its ⋮ menu. Clients don't see them; for a note on the client portal, use announcements.
+ + +| = $sort_link('announcement_title', 'Banner') ?> | += $sort_link('client_name', 'For') ?> | += $sort_link('starts', 'From') ?> | += $sort_link('ends', 'Until') ?> | ++ |
|---|---|---|---|---|
|
+
+
+
+
+ = $title ?>
+ = $state['label'] ?>
+ = escapeHtml(PORTAL_ANNOUNCEMENT_TONES[$tone_key]['label']) ?>
+
+ = escapeHtml($preview) ?>
+ Posted by = escapeHtml($row['user_name'] ?: 'someone') ?>
+
+ = $for_html ?>
+ = escapeHtml("From $from, " . lcfirst($until)) ?>
+ |
+ = $for_html ?> | += escapeHtml($from) ?> | += escapeHtml($until) ?> | +
+
+
+
+
+ |
+
Agent Banners
+ +