Client side nav: coloured initials and client name under an All clients link, aligned with the menu, click to switch clients

This commit is contained in:
johnnyq
2026-10-10 13:49:47 -04:00
parent 4728797432
commit 362a6dcfd2
7 changed files with 315 additions and 16 deletions

View File

@@ -330,6 +330,21 @@ function shortenClientName($client) {
return strtoupper(substr($shortened, 0, 3));
}
/**
* Up to three letters for a client's initials tile - their abbreviation when
* they have one, otherwise one made from the name. Raw: escape at output.
*/
function clientInitials($abbreviation, $name) {
$source = trim((string) $abbreviation) ?: shortenClientName((string) $name);
return mb_strtoupper(mb_substr($source, 0, 3));
}
/** The colour of a client's initials tile, picked by id so it is the same on every page. */
function clientInitialsTone($client_id) {
$tones = ['primary', 'success', 'info', 'warning', 'secondary'];
return $tones[intval($client_id) % count($tones)];
}
function roundUpToNearestMultiple($n, $increment = 1000) {
return (int) ($increment * ceil($n / $increment));