Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 1 | <?php |
| 2 | require_once("core.php"); |
| 3 | security::checkType(security::HYPERADMIN); |
| 4 | |
| 5 | $advancedMode = (isset($_POST["advanced"]) && $_POST["advanced"] == "1"); |
| 6 | |
| 7 | if (!$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 | } |