From 362a6dcfd2c132c0bca41d133eecde5d269182cd Mon Sep 17 00:00:00 2001 From: johnnyq Date: Sat, 10 Oct 2026 13:49:47 -0400 Subject: [PATCH] Client side nav: coloured initials and client name under an All clients link, aligned with the menu, click to switch clients --- agent/ajax.php | 17 +++- agent/clients.php | 9 +- agent/includes/client_side_nav.php | 52 ++++++++++- agent/includes/inc_all_client.php | 3 +- css/itflow_custom.css | 98 ++++++++++++++++++++- functions/format.php | 15 ++++ js/client_switcher.js | 137 +++++++++++++++++++++++++++++ 7 files changed, 315 insertions(+), 16 deletions(-) create mode 100644 js/client_switcher.js diff --git a/agent/ajax.php b/agent/ajax.php index 89f544cd1..760562999 100644 --- a/agent/ajax.php +++ b/agent/ajax.php @@ -364,22 +364,33 @@ if (isset($_GET['share_generate_link'])) { /* * Returns sorted list of active clients */ +/* + * Every active client this agent can open, most recently opened first - the + * client switcher in the client side nav (js/client_switcher.js) loads it once + * and filters it as you type. Names are raw; the script renders them as text. + */ if (isset($_GET['get_active_clients'])) { enforceUserPermission('module_client'); $client_sql = mysqli_query( $mysqli, - "SELECT client_id, client_name FROM clients + "SELECT client_id, client_name, client_abbreviation FROM clients WHERE client_archived_at IS NULL " . clientScopeSql('clients.client_id') . " ORDER BY client_accessed_at DESC" ); + $response = ['clients' => []]; while ($row = mysqli_fetch_assoc($client_sql)) { - $response['clients'][] = $row; + $response['clients'][] = [ + 'client_id' => intval($row['client_id']), + 'client_name' => $row['client_name'], + 'client_initials' => clientInitials($row['client_abbreviation'], $row['client_name']), + 'client_tone' => clientInitialsTone($row['client_id']), + ]; } - echo json_encode($response); + echo json_encode($response, JSON_INVALID_UTF8_SUBSTITUTE); } /* diff --git a/agent/clients.php b/agent/clients.php index 9674f4369..61d6749e2 100644 --- a/agent/clients.php +++ b/agent/clients.php @@ -268,9 +268,6 @@ $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COALESCE(SUM(client_lead $total_clients = intval($row['clients']); $total_leads = intval($row['leads']); -// Initials tile colours - picked by id, so a client keeps its colour from page to page -$avatar_tones = ['primary', 'success', 'info', 'warning', 'secondary']; - ?>
@@ -479,10 +476,8 @@ $avatar_tones = ['primary', 'success', 'info', 'warning', 'secondary']; $client_currency_code = escapeHtml($row['client_currency_code'] ?: $session_company_currency); $client_rate = floatval($row['client_rate']); - // Initials tile: the client's own abbreviation when it has one - $client_abbreviation = trim($row['client_abbreviation']) ?: shortenClientName($row['client_name']); - $client_initials = escapeHtml(mb_strtoupper(mb_substr($client_abbreviation, 0, 3))); - $client_tone = $avatar_tones[$client_id % count($avatar_tones)]; + $client_initials = escapeHtml(clientInitials($row['client_abbreviation'], $row['client_name'])); + $client_tone = clientInitialsTone($client_id); $contact_id = intval($row['contact_id']); $contact_name = escapeHtml($row['contact_name']); diff --git a/agent/includes/client_side_nav.php b/agent/includes/client_side_nav.php index 654282467..7a69f8197 100644 --- a/agent/includes/client_side_nav.php +++ b/agent/includes/client_side_nav.php @@ -2,21 +2,67 @@