This commit is contained in:
@ -43,14 +43,15 @@ case 'POST':
|
||||
if ($members === []) {
|
||||
json_error('INVALID_FIELD', 'At least one questionnaire is required', 400);
|
||||
}
|
||||
$processCompleteBands = qdb_parse_process_complete_bands($body['processCompleteBands'] ?? []);
|
||||
try {
|
||||
[$pdo, $tmpDb, $lockFp] = qdb_open_write_or_fail();
|
||||
$profileID = bin2hex(random_bytes(16));
|
||||
$now = time();
|
||||
$pdo->prepare(
|
||||
'INSERT INTO scoring_profile (profileID, name, description, isActive,
|
||||
greenMin, greenMax, yellowMin, yellowMax, redMin, createdAt, updatedAt)
|
||||
VALUES (:id, :name, :desc, :act, :gmin, :gmax, :ymin, :ymax, :rmin, :ca, :ua)'
|
||||
greenMin, greenMax, yellowMin, yellowMax, redMin, processCompleteBands, createdAt, updatedAt)
|
||||
VALUES (:id, :name, :desc, :act, :gmin, :gmax, :ymin, :ymax, :rmin, :pcb, :ca, :ua)'
|
||||
)->execute([
|
||||
':id' => $profileID,
|
||||
':name' => $name,
|
||||
@ -61,6 +62,7 @@ case 'POST':
|
||||
':ymin' => $bands['yellowMin'],
|
||||
':ymax' => $bands['yellowMax'],
|
||||
':rmin' => $bands['redMin'],
|
||||
':pcb' => qdb_encode_process_complete_bands($processCompleteBands),
|
||||
':ca' => $now,
|
||||
':ua' => $now,
|
||||
]);
|
||||
@ -101,10 +103,13 @@ case 'PUT':
|
||||
qdb_discard($tmpDb, $lockFp);
|
||||
json_error('INVALID_FIELD', 'At least one questionnaire is required', 400);
|
||||
}
|
||||
$processCompleteBands = array_key_exists('processCompleteBands', $body)
|
||||
? qdb_parse_process_complete_bands($body['processCompleteBands'])
|
||||
: qdb_row_process_complete_bands($existing);
|
||||
$pdo->prepare(
|
||||
'UPDATE scoring_profile SET name = :name, description = :desc, isActive = :act,
|
||||
greenMin = :gmin, greenMax = :gmax, yellowMin = :ymin, yellowMax = :ymax, redMin = :rmin,
|
||||
updatedAt = :ua WHERE profileID = :id'
|
||||
processCompleteBands = :pcb, updatedAt = :ua WHERE profileID = :id'
|
||||
)->execute([
|
||||
':name' => $name,
|
||||
':desc' => trim($body['description'] ?? $existing['description']),
|
||||
@ -114,6 +119,7 @@ case 'PUT':
|
||||
':ymin' => $bands['yellowMin'],
|
||||
':ymax' => $bands['yellowMax'],
|
||||
':rmin' => $bands['redMin'],
|
||||
':pcb' => qdb_encode_process_complete_bands($processCompleteBands),
|
||||
':ua' => time(),
|
||||
':id' => $profileID,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user