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("scheduletemplates.php?msg=unexpected"); |
| 9 | } |
| 10 | |
| 11 | $id = (int)$_POST["id"]; |
| 12 | |
| 13 | $day = schedules::getTemplateDay($id); |
| 14 | |
| 15 | if ($day === false) { |
| 16 | security::go("scheduletemplates.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("scheduletemplate.php?id=".$day["template"]."&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("scheduletemplate.php?id=".$day["template"]."&msg=errorcheck".(int)$status); |
| 36 | } |
| 37 | |
| 38 | if (schedules::editTemplateDay($id, $time["beginswork"], $time["endswork"], $time["beginsbreakfast"], $time["endsbreakfast"], $time["beginslunch"], $time["endslunch"])) { |
| 39 | security::go("scheduletemplate.php?id=".$day["template"]."&msg=modified"); |
| 40 | } else { |
| 41 | security::go("scheduletemplate.php?id=".$day["template"]."&msg=unexpected"); |
| 42 | } |