blob: deded14f2b2c6728de9a6f7785e1fa9478ced5c4 [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 ["type", security::PARAM_ISINT],
7 ["worker", security::PARAM_ISINT],
8 ["firstday", security::PARAM_ISDATE],
9 ["lastday", security::PARAM_ISDATE],
10 ["day", security::PARAM_ISARRAY],
11 ["daytype", security::PARAM_ISARRAY]
12])) {
13 security::go(visual::getContinueUrl("incidents.php", "empty", "POST"));
14}
15
16$type = (int)$_POST["type"];
17$worker = (int)$_POST["worker"];
18$details = ((isset($_POST["details"]) && is_string($_POST["details"])) ? $_POST["details"] : "");
19$firstday = $_POST["firstday"];
20$lastday = $_POST["lastday"];
21$days = $_POST["day"];
22$typeDays = $_POST["daytype"];
23
24if (isset($_POST["allday"]) && $_POST["allday"] == 1) {
25 $begins = incidents::STARTOFDAY;
26 $ends = incidents::ENDOFDAY;
27} else {
28 if (!security::checkParams("POST", [
29 ["begins", security::PARAM_ISTIME],
30 ["ends", security::PARAM_ISTIME]
31 ])) {
32 security::go(visual::getContinueUrl("incidents.php", "empty", "POST"));
33 }
34
35 $begins = schedules::time2sec($_POST["begins"]);
36 $ends = schedules::time2sec($_POST["ends"]);
37}
38
39if (recurringIncidents::add($worker, $type, $details, $firstday, $lastday, $begins, $ends, "ME", $typeDays, $days)) security::go(visual::getContinueUrl("incidents.php", "addedrecurring", "POST"));
40else security::go(visual::getContinueUrl("incidents.php", "unexpectedrecurring", "POST"));