-
Notifications
You must be signed in to change notification settings - Fork 4
/
allIncidents.php
executable file
·318 lines (262 loc) · 9.71 KB
/
allIncidents.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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>White Stone Support Desk</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="font-awesome/css/font-awesome.css" rel="stylesheet">
<link href="css/animate.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<div id="wrapper">
<!-- COLLAPSABLE SIDE MENU -->
<?php
session_start();
if ($_SESSION['loggedIn'] != true)
{
header('Location: http://www.stenden.protonbytez.com/login.php');
exit;
}
elseif ($_SESSION['auth'] < 1)
{
header('Location: http://www.stenden.protonbytez.com/index.php');
exit;
}
else
{
include 'class/dbConnection.php';
if (isset($_GET['searchText']))
{
$searchString = $_GET['searchText'];
$searchString = 'AND INCIDENT.`Description` LIKE \'%' . $searchString . '%\'';
}
else
{
$searchString = '';
}
$authorisationName = array(
'User',
'Operator',
'Team Leader',
'Security Operator',
'Master'
);
if ($_SESSION['auth'] == 0)
{
$tableName = "USER";
$columnNames = "UserID, UserEmail, UserName, UserSurname";
$whereClause = "UserID";
}
else
{
$tableName = "EMPLOYEE";
$columnNames = "EmployeeID, EmployeeEmail, EmployeeName, EmployeeSurname, Picture";
$whereClause = "EmployeeID";
}
$sqlString = "SELECT $columnNames FROM $tableName WHERE $whereClause =" . $_SESSION['employeeID'];
$result = mysqli_query($DBConnection, $sqlString) OR DIE ('Error: ' . mysqli_errno($DBConnection) . mysqli_error($DBConnection));
$row = mysqli_fetch_assoc($result);
mysqli_free_result($result);
$personalData = array();
if ($_SESSION['auth'] == 0)
{
$personalData = array (
'firstName' => $row['UserName'],
'lastName' => $row['UserSurname'],
'email' => $row['UserEmail'],
'picture' => 'img/user.jpg' //need to fill in a basic picture for an user!
);
}
else
{
$personalData = array (
'firstName' => $row['EmployeeName'],
'lastName' => $row['EmployeeSurname'],
'email' => $row['EmployeeEmail'],
'picture' => $row['Picture']
);
}
}
?>
<!-- COLLAPSABLE SIDE MENU -->
<nav class="navbar-default navbar-static-side" role="navigation">
<div class="sidebar-collapse">
<ul class="nav" id="side-menu">
<!-- NAV BAR TOP -->
<li class="nav-header">
<!-- PROFILE INFORMATION -->
<div class="dropdown profile-element">
<span>
<a href="profile.php"><img alt="image" class="img-circle" src="<?php echo $personalData['picture']; ?>" /></a>
</span>
<a href="profile.php">
<span class="clear">
<span class="block m-t-xs"><strong class="font-bold"><?php echo $personalData['firstName'] . ' ' . $personalData['lastName']; ?></strong></span>
<span class="text-muted text-xs block"><?php echo $authorisationName[$_SESSION['auth']]; ?></span>
</span>
</a>
</div>
<!-- CLOSED NAV BAR LOGO ELEMENT -->
<div class="logo-element">
<a href="profile.php">WS</a>
</div>
</li>
<!-- DASHBOARD -->
<li>
<a href="index.php"><i class="fa fa-th-large"></i><span class="nav-label">Dashboard</span></a>
</li>
<!-- PROFILE DROP DOWN LIST -->
<li>
<a href="#"><i class="fa fa-picture-o"></i></i> <span class="nav-label">Profile</span><span class="fa arrow"></span></a>
<ul class="nav nav-second-level">
<li><a href="profile.php">Profile</a></li>
<li><a href="http://outlook.live.com" target="_blank">Mailbox</a></li>
<li class="divider"></li>
<li><a href="login.php">Log out</a></li>
</ul>
</li>
<?php
if($_SESSION['auth'] == 2 || $_SESSION['auth'] == 4)
{
echo "<!-- GRAPHS LINK -->
<li>
<a href=\"chart.php\"><i class=\"fa fa-bar-chart-o\"></i> <span class=\"nav-label\">Charts</span> </a>
</li>";
}
if($_SESSION['auth'] != 3)
{
echo "<!-- ADD INCIDENT LINK -->
<li>
<a href=\"addIncident.php\"><i class=\"fa fa-edit\"></i> <span class=\"nav-label\">Add Incident</span> </a>
</li>";
}
if($_SESSION['auth'] == 1 || $_SESSION['auth'] == 2 || $_SESSION['auth'] == 4)
{
echo "<!-- ALL INCIDENTS LINK -->
<li class=\"active\">
<a href=\"allIncidents.php\"><i class=\"fa fa-database\"></i> <span class=\"nav-label\">All Incidents</span> </a>
</li>";
}
if($_SESSION['auth'] > 2)
{
echo "<!-- ADD USERS DROP DOWN LIST -->
<li>
<a href=\"#\"><i class=\"fa fa-sitemap\"></i></i> <span class=\"nav-label\">Add User</span><span class=\"fa arrow\"></span></a>
<ul class=\"nav nav-second-level\">
<li><a href=\"addUser.php\">User</a></li>
<li><a href=\"addClient.php\">Client</a></li>
<li><a href=\"addEmployee.php\">Employee</a></li>
</ul>
</li>";
}
?>
</ul>
</div>
</nav>
<div id="page-wrapper" class="gray-bg">
<!-- TOP MENU -->
<?php include "topNav.php"; ?>
<div class="row wrapper border-bottom white-bg page-heading">
<!-- SEARCH BAR -->
<div class="col-lg-9 search-bar-top-padding">
<form method="GET" class="form-horizontal" action="allIncidents.php">
<div class="input-group">
<input type="text" name="searchText" placeholder="Search" class="input-sm form-control">
<span class="input-group-btn">
<button class="search-bar-button btn btn-primary" type="submit"> Search!</button>
</span>
</div>
</form>
</div>
</div>
<div class="wrapper wrapper-content">
<!-- INCIDENTS TABLE -->
<div class="row">
<div class="col-lg-12">
<div class="ibox float-e-margins">
<!-- TABLE DESCRIPTION AND FUNCTION -->
<div class="ibox-title">
<h5>All incidents</h5>
</div>
<!-- TABLE DATA -->
<div class="ibox-content">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>IncidentID</th>
<th>Description</th>
<th>Solution</th>
<th>Type</th>
<th>Status</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<?php
//Added Pagination
$itemsPerPage = 20;
if (isset($_GET['page']))
{
$pageNumber = $_GET['page'] - 1;
}
else
{
$pageNumber = 0;
}
$offset = $itemsPerPage * $pageNumber;
//Select incident records to display
$TableNameIncident = "INCIDENT";
$TableNameStatus = "INCIDENT_STATUS";
$TableNameStatusType = "STATUS";
$TableNameIncidentType = "INCIDENT_TYPE";
$SQLstring = "SELECT `IncidentID`, MAX(`StatusTypeID`) FROM $TableNameStatus GROUP BY `IncidentID` ORDER BY $TableNameStatus.`IncidentID` LIMIT $offset,$itemsPerPage";
$QueryResult = mysqli_query($DBConnection, $SQLstring);
//Display results in a table format
while ($TableRow = mysqli_fetch_assoc($QueryResult))
{
$IncidentID = $TableRow['IncidentID'];
$StatusID = $TableRow['MAX(`StatusTypeID`)'];
$SQLstring = "SELECT $TableNameIncident.`IncidentID`, `Description`, `Solution`, `IncidentTypeName`, `StatusName`, `Date` FROM $TableNameIncident, $TableNameStatus, $TableNameStatusType, $TableNameIncidentType WHERE $TableNameIncident.`IncidentID` = $TableNameStatus.`IncidentID`AND $TableNameStatus.`StatusTypeID` = $TableNameStatusType.`StatusTypeID` AND $TableNameIncident.`IncidentTypeID` = $TableNameIncidentType.`IncidentTypeID` AND $TableNameStatus.`StatusTypeID` = $StatusID AND $TableNameStatus.`IncidentID` = $IncidentID $searchString";
$QueryResultRow = mysqli_query($DBConnection, $SQLstring);
while ($IncidentRow = mysqli_fetch_assoc($QueryResultRow)){
echo "<tr>";
echo "<td>{$IncidentRow['IncidentID']}</td>";
echo "<td>{$IncidentRow['Description']}</td>";
echo "<td>{$IncidentRow['Solution']}</td>";
echo "<td>{$IncidentRow['IncidentTypeName']}</td>";
echo "<td>{$IncidentRow['StatusName']}</td>";
echo "<td>{$IncidentRow['Date']}</td>";
echo "</tr>";
}
}
mysqli_free_result($QueryResult);
mysqli_free_result($QueryResultRow);
?>
</tbody>
</table>
</div>
<!-- Form for the pagination -->
<form method="get" action="allIncidents.php">
<button type="submit" class="btn btn-primary" name="page" value="<?php echo $pageNumber ; ?>">
<i class="fa fa-arrow-left" aria-hidden="true"></i> Back
</button>
<button type="submit" class="btn btn-primary" name="page" value="<?php echo ($pageNumber + 2); ?>">
<i class="fa fa-arrow-right" aria-hidden="true"></i> Next
</button>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- FOOTER WITH COPYRIGHT -->
<?php include "footer.php"; ?>
</div>
</div>
<!-- SCRIPTS -->
<?php include "scripts.php"; ?>
</body>
</html>