This repository was archived by the owner on Nov 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDisplaySeverities.php
99 lines (91 loc) · 4.04 KB
/
DisplaySeverities.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
<?php
include('session.php');
include('SQLFunctions.php');
$table = 'severity';
$title = "SVBX - Display Severities";
include('filestart.php');
$link = f_sqlConnect();
if(!f_tableExists($link, $table, DB_NAME)) {
die('<br>Destination table does not exist: '.$table);
}
$sql = "SELECT severityID, severityName, severityDescrip, lastUpdated, updatedBy FROM $table ORDER BY SeverityID";
$sql1 = "SELECT COUNT(*) FROM $table";
if($result = mysqli_query($link,$sql1)) {
echo"
<header class='container page-header'>
<h1 class='page-title'>Severity Types</h1><br />";
if (!empty($_SESSION['errorMsg']) || !empty($_SESSION['successMsg'])) {
list($msgKey, $color) = empty($_SESSION['errorMsg'])
? ['successMsg', 'green'] : ['errorMsg', 'yellow'];
echo "
<div class='bg-$color thin-grey-border pad'>
<p>{$_SESSION[$msgKey]}</p>
</div>";
unset($_SESSION[$msgKey]);
}
echo
"
<table class='sumtable'>
<tr class='sumtr'>
<td class='sumtd'>Severity Types in Database: </td>";
while ($row = mysqli_fetch_array($result)) {
echo "<td class='sumtd'>{$row[0]}</td>";
}
echo "</table><br></header>";
}
if($result = mysqli_query($link,$sql)) {
echo"
<div class='container main-content'>
<table class='table'>
<tr class='usertr'>
<th class='userth'>Severity ID</th>
<th class='userth'>Severity</th>
<th class='userth'>Description</th>";
if(!isset($_SESSION['userID']))
{
echo "</tr>";
} else {
echo "
<th class='userth'>Last updated</th>
<th class='userth'>Updated by</th>
<th class='userth'>Edit</th>";
if($role >= 40) {
echo "
<th class='userth'>Delete</th>";
}
echo "
</tr>";
}
while ($row = mysqli_fetch_array($result)) {
echo" <tr class='usertr'>
<td style='text-align:center' class='usertd'>{$row[0]}</td>
<td class='usertd'>{$row[1]}</td>
<td class='usertd'>{$row[2]}</td>";
if(!isset($_SESSION['userID']))
{
echo "</tr>";
} else {
echo "
<td class='usertd'>{$row[3]}</td>
<td class='usertd'>{$row[4]}</td>
<td class='usertd'><form action='UpdateSeverity.php' method='POST' onsubmit=''/>
<input type='hidden' name='q' value='".$row[0]."'/><input type='submit' value='Update'></form></td>";
if($role >= 40) {
echo "
<td class='usertd'><form action='DeleteSeverity.php' method='POST' onsubmit='' onsubmit='' onclick='return confirm(`do you want to delete severity {$row[1]}`)'/>
<button type='Submit' name='q' value='".$row[0]."'><i class='typcn typcn-times'></i></button></form></td>";
}
echo "</tr>";
}
}
echo "</table></div>";
}
mysqli_free_result($result);
if(mysqli_error($link)) {
echo '<br>Error: ' .mysqli_error($link);
} else //echo '<br>Success';
mysqli_close($link);
?>
<?php include 'fileend.php';?>
</Body>
</HTML>