blob: d91254ff781f6001765aa30f0310b7aed49748e6 [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 ["worker", security::PARAM_NEMPTY]
7])) {
8 security::go("users.php?msg=unexpected");
9}
10
11$w = workers::get((int)$_POST["worker"]);
12
13if ($w === false) {
14 security::go("users.php?msg=unexpected");
15}
16
17if (!security::checkParams("POST", [
18 ["begins", security::PARAM_ISDATE],
19 ["ends", security::PARAM_ISDATE]
20])) {
21 security::go("userschedule.php?id=".(int)$w["person"]."&msg=empty");
22}
23
24$begins = $_POST["begins"];
25$ends = $_POST["ends"];
26
27$status = schedules::add($w["id"], $begins, $ends);
28
29switch ($status) {
30 case 0:
31 $id = mysqli_insert_id($con);
32 security::go("schedule.php?id=".(int)$id."&msg=added");
33 break;
34
35 case 1:
36 security::go("userschedule.php?id=".(int)$w["person"]."&msg=overlaps");
37 break;
38
39 case 3:
40 security::go("userschedule.php?id=".(int)$w["person"]."&msg=order");
41 break;
42
43 default:
44 security::go("userschedule.php?id=".(int)$w["person"]."&msg=unexpected");
45 break;
46}