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) ?> |
|