Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame^] | 1 | <?php |
| 2 | require_once("core.php"); |
| 3 | security::checkType(security::ADMIN); |
| 4 | |
| 5 | if (!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 | |
| 15 | if ($day === false) { |
| 16 | security::go("users.php?msg=unexpected"); |
| 17 | } |
| 18 | |
| 19 | $dates = ["beginswork", "endswork", "beginsbreakfast", "endsbreakfast", "beginslunch", "endslunch"]; |
| 20 | $time = []; |
| 21 | foreach ($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 | |
| 34 | if ($status != 0) { |
| 35 | security::go("schedule.php?id=".$day["schedule"]."&msg=errorcheck".(int)$status); |
| 36 | } |
| 37 | |
| 38 | if (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 | } |