blob: 0cf775bf3bbc0f73b1f968288700f78037a1e3b5 [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001<?php
2require_once("core.php");
3security::checkType(security::ADMIN);
4
5if (!security::checkParams("POST", [
6 ["id", security::PARAM_NEMPTY]
7])) {
8 security::go("users.php?msg=unexpected");
9
10}
11$id = (int)$_POST["id"];
12
13$day = schedules::getDay($id);
14
15if ($day === false) {
16 security::go("users.php?msg=unexpected");
17}
18
19$dates = ["beginswork", "endswork", "beginsbreakfast", "endsbreakfast", "beginslunch", "endslunch"];
20$time = [];
21foreach ($dates as $date) {
22 if (isset($_POST[$date]) && !empty($_POST[$date])) {
23 if (!security::checkParam($_POST[$date], security::PARAM_ISTIME)) {
24 security::go("schedule.php?id=".$day["schedule"]."&msg=unexpected");
25 }
26 $time[$date] = schedules::time2sec($_POST[$date]);
27 } else {
28 $time[$date] = 0;
29 }
30}
31
32$status = schedules::checkAddDayGeneric($time["beginswork"], $time["endswork"], $time["beginsbreakfast"], $time["endsbreakfast"], $time["beginslunch"], $time["endslunch"]);
33
34if ($status != 0) {
35 security::go("schedule.php?id=".$day["schedule"]."&msg=errorcheck".(int)$status);
36}
37
38if (schedules::editDay($id, $time["beginswork"], $time["endswork"], $time["beginsbreakfast"], $time["endsbreakfast"], $time["beginslunch"], $time["endslunch"])) {
39 security::go("schedule.php?id=".$day["schedule"]."&msg=modified");
40} else {
41 security::go("schedule.php?id=".$day["schedule"]."&msg=unexpected");
42}