-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompletedSchedule.php
More file actions
59 lines (50 loc) · 1.53 KB
/
CompletedSchedule.php
File metadata and controls
59 lines (50 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* Created by PhpStorm.
* User: User
* Date: 11/4/18
* Time: 1:32 PM
*/
const PAGE_TYPE = "index";
require "Head.php";
$isNextWeek = $_GET["Next"];
$monday = new DateTime("Monday " . ($isNextWeek ? "next" : "this") . " week");
echo "
<div class='mb-5'>
<h1>" . ($isNextWeek ? "Next Week's" : "Current") . " Schedule</h1>
<p>You are viewing the schedule for the week beginning <b>{$monday->format("F j")}</b>.</p>
<a href='?" . ($isNextWeek ? "" : "Next=1") . "' class='btn btn-primary'>
" . ($isNextWeek ? "Current" : "Next Week's") . " Schedule
</a>
</div><!-- /.text-right -->
";
if ($_GET["action"] === "editEmployeesSchedule") {
$shifts = $_GET["shiftID"];
$employees = $_GET["employeeID"];
for($i = 0; $i < count($shifts); $i++){
$timeBlock = TimeBlock::getByID($shifts[$i]);
$week = $timeBlock->getWeek();
$startDate = $week->getStartDate();
$week->removeTimeBlock($timeBlock);
$employeeID = $employees[$i];
$week = $employeeID
? Employee::getByID($employeeID)->getScheduleFor($startDate)
: Week::getUnassignedShiftsContainer($startDate);
$week->addTimeBlock($timeBlock);
$week->sync();
}
Util::redir("CompletedSchedule.php");
}
(new ScheduleView(array_merge(
array_map(
function (Employee $e): Week {
global $monday;
return $e->getScheduleFor($monday);
},
Employee::getAll()
),
[ Week::getUnassignedShiftsContainer($monday) ]
)))
->echo(Session::getLoggedInUser()->getStaffType() == StaffType::EMPLOYER);
?>
<?php require "Foot.php"; ?>