added API endpoint to fetch clients assigned to the authenticated coach
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
* GET (no params) -> ordered questionnaire list with conditions
|
||||
* GET ?id=<questionnaireID> -> single questionnaire in app JSON format
|
||||
* GET ?translations=1 -> all translations merged across all tables
|
||||
* GET ?clients=1 -> list of clients assigned to the authenticated coach
|
||||
* POST -> submit interview answers for a client (coach / supervisor / admin)
|
||||
*/
|
||||
|
||||
@ -158,8 +159,27 @@ if ($method !== 'GET') {
|
||||
|
||||
[$pdo, $tmpDb, $lockFp] = qdb_open(false);
|
||||
|
||||
$qnID = $_GET['id'] ?? '';
|
||||
$qnID = $_GET['id'] ?? '';
|
||||
$translations = $_GET['translations'] ?? '';
|
||||
$fetchClients = $_GET['clients'] ?? '';
|
||||
|
||||
if ($fetchClients) {
|
||||
require_role(['coach'], $tokenRec);
|
||||
|
||||
$coachID = $tokenRec['entityID'] ?? '';
|
||||
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT clientCode
|
||||
FROM client
|
||||
WHERE coachID = :cid
|
||||
ORDER BY clientCode
|
||||
");
|
||||
$stmt->execute([':cid' => $coachID]);
|
||||
$clients = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
qdb_discard($tmpDb, $lockFp);
|
||||
json_success(['coachID' => $coachID, 'clients' => $clients]);
|
||||
}
|
||||
|
||||
if ($translations) {
|
||||
$result = [];
|
||||
|
||||
Reference in New Issue
Block a user