forked from samuelgilbertuk/absencetrackingsystem
/
editEmployee.php
168 lines (141 loc) · 5.59 KB
/
editEmployee.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
<?php
include 'sessionmanagement.php';
if ($_GET["ID"] <> NULL)
{
$Employee = RetrieveEmployeeByID($_GET["ID"]);
}
if (isset($_POST["cancel"])) {
ClearStatus();
$url = "Location:adminEmployeeTable.php";
header($url);
}
if (isset($_POST["update"])) {
ClearStatus();
unset($Employee);
$Employee[EMP_ID] = $_GET["ID"];
$Employee[EMP_NAME] = $_POST["empName"];
$Employee[EMP_EMAIL] = $_POST["eMail"];
$Employee[EMP_DATEJOINED] = $_POST["dateJoin"];
$Employee[EMP_LEAVE_ENTITLEMENT]= $_POST["annualLeave"];
$Employee[EMP_COMPANY_ROLE] = $_POST["companyRole"];
$Employee[EMP_ADMIN_PERM] = '0';
if (isset($_POST['isAdmin']))
{
if ($_POST["isAdmin"] == 'on')
{
$Employee[EMP_ADMIN_PERM] = '1';
}
}
$Employee[EMP_MANAGER_PERM] = '0';
if (isset($_POST['isManager']))
{
if ($_POST["isManager"] == 'on')
{
$Employee[EMP_MANAGER_PERM] = '1';
}
}
$result = UpdateEmployee($Employee);
if ($result)
{
$url = "Location:adminEmployeeTable.php";
header($url);
}
}
function GenerateCompanyRoleSelect()
{
$roles = RetrieveCompanyRoles();
if ($roles <> NULL)
{
echo '<select class="form-control" name="companyRole">';
foreach ($roles as $role)
{
if ($role[COMP_ROLE_ID]== $Employee[EMP_COMPANY_ROLE])
{
echo '<option selected="selected" value="'.$role[COMP_ROLE_ID].
'">'.$role[COMP_ROLE_NAME].'</option>';
}
else
{
echo '<option value="'.$role[COMP_ROLE_ID].'">'.
$role[COMP_ROLE_NAME].'</option>';
}
}
}
echo '</select>';
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Admin Employees</title>
<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>
</head>
<body>
<?php include 'navbar.php'; ?>
<form class="signUp"method="post">
<div class="row">
<div class="col-md-4 col-md-offset-4 text-center">
<h1> Edit Employee </h1>
<div class="input-group" for="empName">
<span class="input-group-addon">
<span class="glyphicon glyphicon-user"></span>
</span>
<input type="text" class="form-control" placeholder="Name"
name="empName" id="empName"
value="<?php echo $Employee[EMP_NAME]; ?>">
</div>
<div class="input-group" for="eMail">
<span class="input-group-addon">
<span class="glyphicon glyphicon-envelope"></span>
</span>
<input type="text" class="form-control" placeholder="Email"
name="eMail" id="eMail"
value="<?php echo $Employee[EMP_EMAIL]; ?>">
</div>
<div class="input-group" for=dateJoin">
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
<input type="date" class="form-control" name="dateJoin"
id="dateJoin" placeholder="Date Joined"
value="<?php echo $Employee[EMP_DATEJOINED]; ?>">
</div>
<br />
<label for="annualLeave">Annual Leave Entitlement</label>
<input type="range" name="annualLeave" min="10" max="28"
value="<?php echo $Employee[EMP_LEAVE_ENTITLEMENT]; ?>"
step="1" oninput="updateAnnualLeave(value)" id="annualLeave" />
<output for="minStaff" id="Leave">
<?php echo $Employee[EMP_LEAVE_ENTITLEMENT]; ?></output>
<br />
<label for="companyRole">Company Role</label>
<?php GenerateCompanyRoleSelect(); ?>
<br/>
<label for="isAdmin"> Is Administrator</label>
<input type="checkbox" name="isAdmin" id="isAdmin"
<?php if ($Employee[EMP_ADMIN_PERM] == 1) echo "checked"; ?>/>
<label for="isManager"> Is Manager</label>
<input type="checkbox" name="isManager" id="isManager"
<?php if ($Employee[EMP_MANAGER_PERM] == 1) echo "checked"; ?>/>
<br /><br/>
<input class="btn btn-success btn-block" type="submit" name="update"
id="submit" value="Edit Employee"/>
<input class="btn btn-danger btn-block" type="submit" name="cancel"
id="cancel" value="Cancel Changes"/>
<script>
function updateAnnualLeave(level)
{
document.querySelector('#Leave').value = level;
}
</script>
</div>
</div>
</form>
</body>
</html>