display client notes in client list
Some checks failed
PHPUnit / test (push) Has been cancelled

This commit is contained in:
2026-07-17 17:33:48 +02:00
parent f90d5db40a
commit fc23f7a619
4 changed files with 71 additions and 5 deletions

View File

@ -24,9 +24,16 @@ case 'GET':
$archiveFilter = 'active';
}
[$clause, $params] = rbac_client_filter($tokenRec, 'cl', $archiveFilter);
$noteSelect = qdb_table_exists($pdo, 'client_followup_note')
? 'n.note AS note'
: "'' AS note";
$noteJoin = qdb_table_exists($pdo, 'client_followup_note')
? 'LEFT JOIN client_followup_note n ON n.clientCode = cl.clientCode'
: '';
$stmt = $pdo->prepare(
"SELECT cl.clientCode, cl.coachID, cl.archived, cl.archivedAt,
co.username AS coachUsername,
$noteSelect,
CASE WHEN EXISTS (
SELECT 1 FROM completed_questionnaire cq WHERE cq.clientCode = cl.clientCode
) OR EXISTS (
@ -34,6 +41,7 @@ case 'GET':
) THEN 1 ELSE 0 END AS hasResponseData
FROM client cl
LEFT JOIN coach co ON co.coachID = cl.coachID
$noteJoin
WHERE $clause
ORDER BY cl.archived ASC, hasResponseData DESC, cl.clientCode ASC"
);
@ -44,6 +52,7 @@ case 'GET':
require_once __DIR__ . '/../lib/submissions.php';
$scoringSummary = qdb_clients_scoring_summary_for_list($pdo, $tokenRec);
foreach ($clients as &$client) {
$client['note'] = (string)($client['note'] ?? '');
$client['scoringProfiles'] = qdb_client_scoring_dots_for_client(
$client['clientCode'],
$scoringSummary