-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathemployee_panel.php
177 lines (145 loc) · 5.8 KB
/
employee_panel.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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<!DOCTYPE HTML>
<html>
<head>
<title>Lista zamówień</title>
<link href="/images/dot_ico/zamowienia.ico" rel="icon" type="image/x-icon" />
<style>
body {
background-color: rgba(0, 0, 0, 0.90) !important;
color: white !important;
}
table tr td {
color: white !important;
}
.center {
color: white !important;
text-align: center;
}
.absolute {
width: 80%;
max-width: 800px;
position: absolute;
margin-left: auto;
margin-right: auto;
margin-top: 20px;
left: 0;
right: 0;
text-align: center;
}
.tableUnderline {
border-bottom: solid 4px !important;
}
.table>tbody>tr>td {
vertical-align: middle;
}
</style>
<link rel="stylesheet" href="styles.css">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
</head>
<body>
<nav class="navbar navbar-expand-xxl navbar-dark">
<div class="adminNav">
<a class="navbar-brand" href="index.php"><img id="logoImg" src="images/logo.jpg" alt="Logo"></a>
<a class="navbar-brand logomen" href="index.php">Restau<span class="fast-flicker">racja</span> u <span class="flicker">Mentzena</span></a>
</div>
</nav>
<div class='absolute'>
<?php
session_start();
if (isset($_SESSION['general_message'])) {
echo $_SESSION['general_message'];
unset($_SESSION['general_message']);
}
?>
</div>
</body>
</html>
<?php
require_once("paths.php");
require_once($pSharedFunctions);
$dbConnected = true;
if (isset($_SESSION['user_permission']) && ($_SESSION['user_permission'] == "admin" || $_SESSION['user_permission'] == "employee")) {
try {
require_once "$pDbConnection";
} catch (Exception $e) {
$_SESSION['general_message'] = ErrorMessageGenerator("Błąd podczas łączenia z bazą danych");
$_SESSION['general_message'] .= ErrorMessageGenerator($e);
$dbConnected = false;
}
if ($dbConnected) {
require_once "print_table_functions.php";
// Zamówienia w trakcie realizacji
$queryProducts = generateProductsQuery(" WHERE od.Status = 'W trakcie realizacji' ");
try {
$sth = $dbh->query($queryProducts);
} catch (Exception $e) {
$_SESSION['general_message'] = ErrorMessageGenerator("Błąd podczas wykonywania zapytania do bazy danych");
$_SESSION['general_message'] .= ErrorMessageGenerator($e);
}
$queryDetails = generateDetailsQuery(" WHERE od.Status = 'W trakcie realizacji' ");
try {
$sthDetails = $dbh->query($queryDetails);
} catch (Exception $e) {
$_SESSION['general_message'] = ErrorMessageGenerator("Błąd podczas wykonywania zapytania trzeciego do bazy danych");
$_SESSION['general_message'] .= ErrorMessageGenerator($e);
}
// Używane do rowspana w tabeli
$queryCount = "SELECT idOrders, count(*) AS count FROM orders GROUP BY idOrders";
try {
$sthCount = $dbh->query($queryCount);
} catch (Exception $e) {
$_SESSION['general_message'] = ErrorMessageGenerator("Błąd podczas wykonywania zapytania drugiego do bazy danych");
$_SESSION['general_message'] .= ErrorMessageGenerator($e);
}
echo "<h1 style='text-align: center; margin-top: 13vh;'>Zamówienia w trakcie realizacji</h1>";
// Count jest robiony tylko raz ale używany we wszystkich tabelach do rowspana
$arrCount = $sthCount->fetchAll();
$arrData = $sth->fetchAll();
printTable($arrData, $arrCount, $sthDetails, "employee_panel.php", true, "Zrealizowano", true, "Anulowano");
// Zamówienia w trakcie realizacji koniec
// Zamówienia zrealizowane
$queryProducts = generateProductsQuery(" WHERE od.Status = 'Zrealizowano' ");
try {
$sth = $dbh->query($queryProducts);
} catch (Exception $e) {
$_SESSION['general_message'] = ErrorMessageGenerator("Błąd podczas wykonywania zapytania do bazy danych");
$_SESSION['general_message'] .= ErrorMessageGenerator($e);
}
$queryDetails = generateDetailsQuery(" WHERE od.Status = 'Zrealizowano' ");
try {
$sthDetails = $dbh->query($queryDetails);
} catch (Exception $e) {
$_SESSION['general_message'] = ErrorMessageGenerator("Błąd podczas wykonywania zapytania trzeciego do bazy danych");
$_SESSION['general_message'] .= ErrorMessageGenerator($e);
}
echo "<h1 style='text-align: center;'>Zamówienia zrealizowane</h1>";
$arrData = $sth->fetchAll();
printTable($arrData, $arrCount, $sthDetails);
// Zamówienia zrealizowane koniec
// Zamówienia anulowane
$queryProducts = generateProductsQuery(" WHERE od.Status = 'Anulowano' ");
try {
$sth = $dbh->query($queryProducts);
} catch (Exception $e) {
$_SESSION['general_message'] = ErrorMessageGenerator("Błąd podczas wykonywania zapytania do bazy danych");
$_SESSION['general_message'] .= ErrorMessageGenerator($e);
}
$queryDetails = generateDetailsQuery(" WHERE od.Status = 'Anulowano' ");
try {
$sthDetails = $dbh->query($queryDetails);
} catch (Exception $e) {
$_SESSION['general_message'] = ErrorMessageGenerator("Błąd podczas wykonywania zapytania trzeciego do bazy danych");
$_SESSION['general_message'] .= ErrorMessageGenerator($e);
}
echo "<h1 style='text-align: center;'>Zamówienia anulowane</h1>";
$arrData = $sth->fetchAll();
printTable($arrData, $arrCount, $sthDetails);
// Zamówienia anulowane koniec
} else {
header("Location: $pHome");
}
} else {
header("Location: $pHome");
}
?>