blob: e7482abf7e4ae8b77089cf0f2c6625026a826b1f [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001<?php
2require_once("core.php");
3security::checkType(security::HYPERADMIN);
4
5$advancedMode = (isset($_POST["advanced"]) && $_POST["advanced"] == "1");
6
7if (!$advancedMode) {
8 if (!security::checkParams("POST", [
9 ["day", security::PARAM_ISDATE],
10 ["workers", security::PARAM_ISARRAY]
11 ])) {
12 security::go("manuallygenerateregistry.php?msg=empty");
13 }
14
15 $day = new DateTime($_POST["day"]);
16 $time = $day->getTimestamp();
17
18 $logId = -1;
19 $status = registry::generateNow($time, $logId, true, people::userData("id"), $_POST["workers"]);
20
21 security::go("manuallygenerateregistry.php?".($logId == -1 ? "msg=generatederr" : "")."&logId=".$logId);
22} else {
23 if (!security::checkParams("POST", [
24 ["begins", security::PARAM_ISDATE],
25 ["ends", security::PARAM_ISDATE],
26 ["workers", security::PARAM_ISARRAY]
27 ])) {
28 security::go("manuallygenerateregistry.php?msg=empty");
29 }
30
31 $executedBy = people::userData("id");
32
33 $current = new DateTime($_POST["begins"]);
34 $ends = new DateTime($_POST["ends"]);
35 $interval = new DateInterval("P1D");
36 while ($current->diff($ends)->invert === 0) {
37 $logId = 0;
38 registry::generateNow($current->getTimestamp(), $logId, true, $executedBy, $_POST["workers"]);
39
40 $current->add($interval);
41 }
42
43 security::go("manuallygenerateregistry.php?msg=done");
44}