forked from samuelgilbertuk/absencetrackingsystem
/
adminCompanyRoles.php
119 lines (104 loc) · 3.84 KB
/
adminCompanyRoles.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
<?php
include 'sessionmanagement.php';
if (!$isAdministrator)
{
header('Location: index.php');
exit();
}
if (isset($_POST["submit"])) {
ClearStatus();
$role = CreateCompanyRole($_POST["roleName"], $_POST["minStaff"]);
}
if (isset($_POST["amend"])) {
ClearStatus();
$url = "Location:editcompanyrole.php?roleID=".$_POST["amend"];
header($url);
}
if (isset($_POST["delete"])) {
ClearStatus();
DeleteCompanyRole($_POST["delete"]);
}
function DisplayCompanyRolesTableBody()
{
$roles = RetrieveCompanyRoles();
if ($roles <> NULL)
{
foreach ($roles as $role)
{
echo "<tr>";
echo "<td>".$role[COMP_ROLE_NAME]."</td>";
echo "<td>".$role[COMP_ROLE_MIN_STAFF]."</td>";
echo "<td>";
echo '<button class="btn btn-success" type="submit"'.
'name="amend"'.
'value="'.$role[COMP_ROLE_ID].'">'.
'Amend</button></td>';
echo '<td> <button class="btn btn-danger" type="submit"'.
'name="delete"'.
'value="'.$role[COMP_ROLE_ID].'">'.
'Delete</button></td>';
echo '</tr>';
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<meta charset="UTF-8">
<title>Admin Company Roles</title>
</head>
<body>
<?php include 'navbar.php'; ?>
<div class="row col-md-4 col-md-offset-4 text-center">
<form method="post">
<h1>Create New Company Role</h1>
<div class="input-group" for="roleName">
<span class="input-group-addon">Company Role Name </span>
<input type="text" class="form-control"
placeholder="Enter name" name="roleName"
id="roleName">
</div>
<br/>
<label for="minStaff">Minimum Staff Level</label>
<input type="range" class="form-control" name="minStaff" min="0"
max="30" value="1" step="1"
oninput="updateMinStaff(value)" id="minStaff" />
<output for="minStaff" id="staffNumber">1</output>
<input class="btn btn-success btn-block" type="submit"
name="submit" id="submit" value="Add Role"/>
</form>
</div>
<div class="row col-md-8 col-md-offset-2 text-center">
<br/><br/>
<h1>Current Company Roles</h1>
<form method="post">
<table class="table table-hover table-bordered table-condensed">
<thead>
<tr>
<th>Role Name</th>
<th>Minimum Staffing Level</th>
<th>Amend</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<?php DisplayCompanyRolesTableBody(); ?>
</tbody>
</table>
</form>
</div>
<script>
function updateMinStaff(level)
{
document.querySelector('#staffNumber').value = level;
}
</script>
</body>
</html>