Feriefridage not decimal
This commit is contained in:
parent
e0d2ab12d3
commit
36e09e7cc6
3 changed files with 46 additions and 14 deletions
10
api.php
10
api.php
|
|
@ -297,7 +297,11 @@ function save_settings(PDO $db, array $settings): void
|
|||
|
||||
foreach ($allowed as $key) {
|
||||
if (array_key_exists($key, $settings)) {
|
||||
$stmt->execute([':key' => $key, ':value' => (string)$settings[$key]]);
|
||||
$value = $settings[$key];
|
||||
if ($key === 'feriefridage_per_year' && floor((float)$value) !== (float)$value) {
|
||||
fail('Feriefridage/year must be a whole number', 400);
|
||||
}
|
||||
$stmt->execute([':key' => $key, ':value' => (string)$value]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -352,6 +356,10 @@ function save_feriefridage_override(PDO $db, int $year, int $month, mixed $value
|
|||
return;
|
||||
}
|
||||
|
||||
if (floor((float)$value) !== (float)$value) {
|
||||
fail('Feriefridage must be whole days', 400);
|
||||
}
|
||||
|
||||
$stmt = $db->prepare('INSERT INTO monthly_feriefridage_overrides (year, month, feriefridage_days)
|
||||
VALUES (:year, :month, :value)
|
||||
ON CONFLICT(year, month) DO UPDATE SET feriefridage_days = excluded.feriefridage_days');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue