-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployeeList.php
More file actions
156 lines (142 loc) · 3.97 KB
/
EmployeeList.php
File metadata and controls
156 lines (142 loc) · 3.97 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
const PAGE_TYPE = "Employer";
require "Head.php";
$allEmployees = Employee::getAll();
if ($_GET["deleteID"]) {
// delete the employee...
$employee = $allEmployees[$_GET["deleteID"]];
if ($employee) {
$employee->remove();
unset($allEmployees[$_GET["deleteID"]]);
Util::redir("EmployeeList.php");
}
}
if ($_GET["action"] == "edit"){
Employee::getByID($_GET["StaffID"])->applyVals($_GET)->sync();
header("Location: EmployeeList.php");
}
if ($_GET["action"]=="create") {
($_GET["StaffType"] == "Employer" ? new Employer($_GET) : new Employee($_GET))->sync();
Util::redir("EmployeeList.php");
}
echo "
<div class='row'>
<div class='col'>
<h1>All Employees</h1>
</div><!-- /.col -->
<div class='col'>
<div class='form-group d-flex flex-column align-items-end mb-5'>
";
(new Modal)
->buttonClass("primary")
->buttonText("<span class='fas fa-plus'></span> Add Employee")
->title("Add Employee")
->contents("
<div class='form-group'>
<label for='FirstName'>First Name</label>
<input name='FirstName' type='text' class='form-control' id='FirstName' required>
</div>
<div class='form-group'>
<label for='LastName'>Last Name</label>
<input name='LastName' type='text' class='form-control' id='LastName' required>
</div>
<div class='form-group'>
<label for='UserName'>Username</label>
<input name='UserName' type='text' class='form-control' id='UserName' placeholder='Leave blank to auto-generate a username'>
</div>
<input type='hidden' name='action' value='create'>
")
->echo();
echo "
</div><!-- /.form-group -->
</div><!-- /.col -->
</div><!-- /.row -->
<table class='table'>
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
<th></th>
</tr>
</thead>
<tbody>
";
foreach (Employee::getAll() as $employee) {
/*
* $dyn = " "; clears out entries from previous employees
*/
$dyn = "";
foreach ($employee->getSchedules() as $schedule)
$dyn .= "
<tr>
<td>{$schedule->getStartDate()->format("m/d/Y")}-{$schedule->getEndDate()->format("m/d/Y")}</td>
<td>{$schedule->sumTimeBlocks()}</td>
</tr>
";
$pastHourModal = (new Modal)
->title("View Past Hours")
->buttonText("View Past Hours")
->buttonClass("dark")
->contents("
<table class='table'>
<thead>
<tr>
<th>Week</th>
<th>Hours</th>
</tr>
</thead>
<tbody>
$dyn
</tbody>
</table>
");
echo "
<tr>
<td>" . $employee->getFirstName() . "</td>
<td>" . $employee->getLastName() . "</td>
<td>" . $employee->getUsername() . "</td>
<td>";
$monday = new DateTime("Monday next week");
(new Modal)
->title("Availability for {$employee->getFirstName()} {$employee->getLastName()} - week of {$monday->format("M j")}")
->buttonText("View Availability")
->buttonClass("info")
->large()
->noSave()
->contents(
(new ScheduleView($employee->getWeekAvailability($monday)))
->noNames()
->compact()
->render()
)
->echo();
(new Modal)
->title("Edit Employee")
->buttonText("Edit")
->buttonClass("warning")
->contents("
<div class='form-group'>
<label for='FirstName'>First Name</label>
<input name='FirstName' type='text' class='form-control' id='FirstName' value='{$employee->getFirstName()}'>
</div>
<div class='form-group'>
<label for='LastName'>Last Name</label>
<input name='LastName' type='text' class='form-control' id='LastName' value='{$employee->getLastName()}'>
</div>
<input type='hidden' name='action' value='edit'>
<input type='hidden' name='StaffID' value='{$employee->getStaffID()}'>
")
->echo();
$pastHourModal->echo();
echo "
<a href='?deleteID={$employee->getStaffID()}' class='btn btn-danger'>Delete</a>
</td>
</tr>
";
}
echo "
</tbody>
</table>
";
require "Foot.php";