-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRTCCViewInspectionsCollection.php
456 lines (426 loc) · 19.8 KB
/
RTCCViewInspectionsCollection.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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
<?php
try
{
$host = "localhost"; //server name
$dbUsername = "root";
$dbPassword = "";
$dbname = "inspectionslist";
//Creating connection to database
$conn = new mysqli($host, $dbUsername, $dbPassword, $dbname);
//Checking connection
if (mysqli_connect_error())
{
die('Connect Error('.mysqli_connect_error().')'.mysqli_connect_error());
}
else
{
//echo "Connected successfully";
}
}
catch(Exception $e)
{
echo "ERROR.";
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Inspection Collection</title>
<!--link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous"-->
<link rel = "stylesheet" href = "Template.css">
<!--Give webpage a favicon icon-->
<link rel = "icon" type = "image/x-icon" href = "Favicon Images/favicon.ico">
<!--Icons Link-->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@48,700,1,-25" />
<style>
table
{
border-collapse: collapse;
}
table tr:hover
{
background-color: #ccc;
border: 1px solid #ccc;
}
button
{
font-family: 'League Spartan';
width: 100%;
height: 100%;
border: 5px solid rgb(52, 51, 51);
background-color: #FFD500;
padding: 20px;
color: rgb(52, 51, 51);
text-align: center;
cursor:pointer;
}
button:hover
{
border: 5px solid #FFD500;
background-color: rgb(52, 51, 51);
padding: 20px;
color: #FFD500;
font-weight: bold;
}
button:active
{
border: 5px solid rgb(52, 51, 51);
background-color: #FFD500;
padding: 20px;
color: rgb(52, 51, 51);
}
.material-icons
{
color: rgb(52, 51, 51);
font-size: 60px;
transition-property: color;
}
button:hover .material-icons
{
color: #FFD500;
font-size: 70px;
}
button:active .material-icons
{
color: rgb(52, 51, 51);
font-size: 70px;
}
.BackButton
{
margin: 1%;
position: absolute;
width:max-content;
height: max-content;
border-radius: 50%;
color: rgb(0, 0, 0);
background-color: #ED1C24;
border: 5px solid black;
}
.BackButton .material-symbols-rounded
{
color:rgb(0, 0, 0);
font-size: 40px;
}
.BackButton:hover
{
position:absolute;
background-color: #ED1C24;
border: 5px solid black;
}
.BackButton:hover .material-symbols-rounded
{
color:rgb(0, 0, 0);
font-size: 50px;
}
.BackButton:active
{
background-color: rgb(172, 10, 10);
}
tbody tr td
{
font-size: 12px;
font-weight: lighter;
}
.Circle
{
text-align: center;
margin-left: auto;
margin-right: auto;
width: 10px;
height: 10px;
border-radius: 20px;
background-color: grey;
padding: 5px;
}
#GreenCircle
{
background-color: green;
}
#YellowCircle
{
background-color: #e1ec14;
}
#OrangeCircle
{
background-color: #f37221;
}
#RedCircle
{
background-color: #ED1C24;
}
td select
{
margin-left: auto;
margin-right: auto;
text-align: center;
width: 100%;
}
#SubmitButton
{
background-color: #FBCE07;
}
#SubmitButton:hover
{
background-color: #ED1C24;
color: black;
border: 5px solid black;
}
#TLNameSelection, #LocationSelection, #ComplianceStatusSelection, #ActionStatusSelection
{
visibility: hidden;
}
#CategoryTable:hover tr
{
background-color: white;
border: none;
}
td input
{
width: 100%;
height: 30%;
}
</style>
<script>
function DisplaySelection()
{
var x0 = document.getElementById("TLName");
var x1 = document.getElementById("TLNameSelection");
if (x0.checked == true)
{
x1.style.visibility = 'visible';
}
else
{
x1.style.visibility = 'hidden';
}
x0 = document.getElementById("Location");
x1 = document.getElementById("LocationSelection");
if (x0.checked == true)
{
x1.style.visibility = 'visible';
}
else
{
x1.style.visibility = 'hidden';
}
x0 = document.getElementById("ComplianceStatus");
x1 = document.getElementById("ComplianceStatusSelection");
if (x0.checked == true)
{
x1.style.visibility = 'visible';
}
else
{
x1.style.visibility = 'hidden';
}
x0 = document.getElementById("ActionStatus");
x1 = document.getElementById("ActionStatusSelection");
if (x0.checked == true)
{
x1.style.visibility = 'visible';
}
else
{
x1.style.visibility = 'hidden';
}
}
</script>
</head>
<body>
<button type = "button" class = "BackButton" onclick = "document.location = 'SelectFunctionsRTCC.html'">
<i class="material-symbols-rounded">reply</i>
</button>
<div class = "Heading" style = "font-size: 60px; display: block; padding-top: 3%; padding-bottom: 3%;">INSPECTIONS COLLECTION</div>
<form action = "" method = "POST">
<table id = "CategoryTable">
<thead>
<th colspan = "5">Select Category To View By</th>
</thead>
<tbody>
<tr>
<td>
<input type = "checkbox" id = "TLName" name = "TLName" onclick = "DisplaySelection()">
<label for = "TLName">TL Name</label>
</td>
<td>
<input type = "checkbox" id = "Location" name = "Location" onclick = "DisplaySelection()">
<label for = "Location">Location</label>
</td>
<td>
<input type = "checkbox" id = "ComplianceStatus" name = "ComplianceStatus" onclick = "DisplaySelection()">
<label for = "ComplianceStatus">Compliance Status</label>
</td>
<td>
<input type = "checkbox" id = "ActionStatus" name = "ActionStatus" onclick = "DisplaySelection()">
<label for = "ActionStatus">Action</label>
</td>
<td>
<button type = "submit" id = "SubmitButton" name = "SubmitButton">
FILTER
</button>
</td>
</tr>
<tr>
<td id = "TLNameSelection">
<input type = "text" id = "SelectTLName" name = "SelectTLName" placeholder = "Enter TL Name (NOTE: case-sensitive field).">
</td>
<td id = "LocationSelection">
<select id = "SelectLocation" name = "SelectLocation" div class = "Input">
<option></option>
<option value = "KMR">KMR</option>
<option value = "DHP">DHP</option>
<option value = "VHR">VHR</option>
<option value = "BHK">BHK</option>
<option value = "MCH">MCH</option>
<option value = "MHK">MHK</option>
<option value = "CKL">CKL</option>
<option value = "TJB">TJB</option>
<option value = "SKP">SKP</option>
<option value = "SWL">SWL</option>
<option value = "SSH">SSH</option>
<option value = "QUETTA">QUETTA</option>
</select>
</td>
<td id = "ComplianceStatusSelection">
<select id = "SelectComplianceStatus" name = "SelectComplianceStatus" div class = "Input">
<option></option>
<option value = "Fit">Fit</option>
<option value = "Delayable Concerns">Delayable Concerns</option>
<option value = "Previous Concerns Not Rectified">Previous Concerns Not Rectified</option>
<option value = "Critical">Critical</option>
</select>
</td>
<td id = "ActionStatusSelection">
<select id = "SelectActionStatus" name = "SelectActionStatus" div class = "Input">
<option></option>
<option value = "Allow">Allow</option>
<option value = "Allow With Warning">Allow With Warning</option>
<option value = "Refuse Loading">Refuse Loading</option>
</select>
</td>
</tr>
</tbody>
</table>
</form>
<br/>
<?php
$SELECT = "SELECT * FROM inspectionscollection";
if (isset($_POST['SubmitButton']))
{
$WHERE = " WHERE ";
if (!empty($_POST['SelectTLName']))
{
$WHERE .= "TLName = '" . $_POST['SelectTLName'] . "'";
}
if (!empty($_POST['SelectLocation']))
{
if ($WHERE != " WHERE ")
{
$WHERE .= " AND ";
}
$WHERE .= "Location = '" . $_POST['SelectLocation'] . "'";
}
if (!empty($_POST['SelectComplianceStatus']))
{
if ($WHERE != " WHERE ")
{
$WHERE .= " AND ";
}
$WHERE .= "ComplianceStatus = '" . $_POST['SelectComplianceStatus'] . "'";
}
if (!empty($_POST['SelectActionStatus']))
{
if ($WHERE != " WHERE ")
{
$WHERE .= " AND ";
}
$WHERE .= "ActionStatus = '" . $_POST['SelectActionStatus'] . "'";
}
if ($WHERE != " WHERE ")
{
$SELECT .= $WHERE;
}
}
$AllDatabaseData = mysqli_query($conn, $SELECT);
$NoOfRowsInDatabase = mysqli_num_rows($AllDatabaseData);
if ($NoOfRowsInDatabase > 0)
{
echo "<table style = 'text-align: center; margin-left: auto; margin-right: auto;'>";
echo "<thead>";
echo "<tr style = 'background-color: #FBCE07; border: none;'>";
echo "<th>DATE & TIME</th>";
echo "<th>LOCATION</th>";
echo "<th>TL NAME</th>";
echo "<th>INSPECTION SUMMARY</th>";
echo "<th>IMAGES</th>";
echo "<th>COMPLIANCE STATUS</th>";
echo "<th>ACTION</th>";
echo "<th>NOTIFIED PARTIES</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
//Printing all rows in the database
while ($DatabaseEntry = mysqli_fetch_assoc($AllDatabaseData))
{
echo "<tr>";
echo "<td>" . $DatabaseEntry['DateAndTime'] . "</td>";
echo "<td>" . $DatabaseEntry['Location'] . "</td>";
echo "<td>" . $DatabaseEntry['TLName'] . "</td>";
echo nl2br("<td>" . $DatabaseEntry['InspectionSummary'] . "</td>");
echo "<td>" . $DatabaseEntry['Images'] . "</td>";
$ComplianceStatusString = $DatabaseEntry['ComplianceStatus'];
if ($ComplianceStatusString == "Fit")
{
echo "<td><div class = 'Circle' id = 'GreenCircle'></div><br>" . $DatabaseEntry['ComplianceStatus'] . "</td>";
}
else if ($ComplianceStatusString == "Delayable Concerns")
{
echo "<td><div class = 'Circle' id = 'YellowCircle'></div><br>" . $DatabaseEntry['ComplianceStatus'] . "</td>";
}
else if ($ComplianceStatusString == "Previous Concerns Not Rectified")
{
echo "<td><div class = 'Circle' id = 'OrangeCircle'></div><br>" . $DatabaseEntry['ComplianceStatus'] . "</td>";
}
else if ($ComplianceStatusString == "Critical")
{
echo "<td><div class = 'Circle' id = 'RedCircle'></div><br>" . $DatabaseEntry['ComplianceStatus'] . "</td>";
}
else
{
echo "<td><div class = 'Circle'></div><br>" . $DatabaseEntry['ComplianceStatus'] . "</td>";
}
$ActionStatusString = $DatabaseEntry['ActionStatus'];
if ($ActionStatusString == "Allow")
{
echo "<td><div class = 'Circle' id = 'GreenCircle'></div><br>" . $DatabaseEntry['ActionStatus'] . "</td>";
}
else if ($ActionStatusString == "Allow With Warning")
{
echo "<td><div class = 'Circle' id = 'YellowCircle'></div><br>" . $DatabaseEntry['ActionStatus'] . "</td>";
}
else if ($ActionStatusString == "Refuse Loading")
{
echo "<td><div class = 'Circle' id = 'RedCircle'></div><br>" . $DatabaseEntry['ActionStatus'] . "</td>";
}
else
{
echo "<td><div class = 'Circle'></div><br>" . $DatabaseEntry['ActionStatus'] . "</td>";
}
echo nl2br("<td>" . $DatabaseEntry['Notify'] . "</td>");
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
}
else
{
echo "0 entries in database.";
}
$conn->close(); //Closing established connections
?>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>
</body>
</html>