-
Notifications
You must be signed in to change notification settings - Fork 2
/
EmployeeReportListController.php
57 lines (49 loc) · 1.32 KB
/
EmployeeReportListController.php
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
<?php
namespace app\controllers\employee;
use app\core\Controller;
use app\core\Request;
use app\models\ReportListModel;
use app\stores\EmployeeStore;
class EmployeeReportListController extends Controller
{
const login = 'Location: /login';
private function validate(): void
{
// checking whether the user is logged into the server
if ($_SESSION['userType'] != 'staff') {
header(self::login);
}
}
public function load(Request $request): void
{
$this->validate();
if ($request->isGet()) {
if ($_SESSION['userType'] == 'staff') {
$this -> render("employee/reports.php");
} else {
header(self::login);
}
} else {
header(self::login);
}
}
public function getAllReports(): array
{
$model = new ReportListModel();
// creating an array of all reports
return $model->getAllReports();
}
public function sortBySeen($list): array
{
$seen = array();
$unseen = array();
foreach ($list as $report) {
if ($report->is_employee_noticed) {
$seen[] = $report;
} else {
$unseen[] = $report;
}
}
return array_merge($seen, $unseen);
}
}