feat: suivre la température pendant les tournées

This commit is contained in:
Alexandre NOEL 2026-09-15 15:43:00 +02:00
commit d35434c522
15 changed files with 129 additions and 23 deletions

View file

@ -139,6 +139,18 @@ final class CareRoundsController
$value = (string) ($_POST[$field] ?? $opts[0]);
$values[$field] = in_array($value, $opts, true) ? $value : $opts[0];
}
$temperatureInput = str_replace(',', '.', trim((string) ($_POST['temperature_c'] ?? '')));
if (!is_numeric($temperatureInput)) {
http_response_code(400);
echo h(t('care.invalid_temperature'));
return;
}
$temperature = (float) $temperatureInput;
if ($temperature < 30 || $temperature > 45) {
http_response_code(400);
echo h(t('care.invalid_temperature'));
return;
}
$db->prepare(
'UPDATE care_rounds SET performed_by_user_id=COALESCE(performed_by_user_id,:user) WHERE id=:id',
)->execute([':user' => Auth::id(), ':id' => $roundId]);
@ -220,7 +232,7 @@ final class CareRoundsController
$db->beginTransaction();
try {
$stmt = $db->prepare(
"INSERT INTO care_round_observations(round_id,animal_id,food,water,urine,stool,general_state,comment,alert_signature) VALUES(:round,:animal,:food,:water,:urine,:stool,:general,:comment,:signature) ON CONFLICT(round_id,animal_id) DO UPDATE SET food=excluded.food,water=excluded.water,urine=excluded.urine,stool=excluded.stool,general_state=excluded.general_state,comment=excluded.comment,alert_signature=excluded.alert_signature,checked_at=datetime('now')",
"INSERT INTO care_round_observations(round_id,animal_id,food,water,urine,stool,general_state,temperature_c,comment,alert_signature) VALUES(:round,:animal,:food,:water,:urine,:stool,:general,:temperature,:comment,:signature) ON CONFLICT(round_id,animal_id) DO UPDATE SET food=excluded.food,water=excluded.water,urine=excluded.urine,stool=excluded.stool,general_state=excluded.general_state,temperature_c=excluded.temperature_c,comment=excluded.comment,alert_signature=excluded.alert_signature,checked_at=datetime('now')",
);
$stmt->execute([
':round' => $roundId,
@ -230,6 +242,7 @@ final class CareRoundsController
':urine' => $values['urine'],
':stool' => $values['stool'],
':general' => $values['general_state'],
':temperature' => $temperature,
':comment' => $comment ?: null,
':signature' => $signature,
]);