-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_maint.php
More file actions
253 lines (223 loc) · 9.04 KB
/
Copy pathuser_maint.php
File metadata and controls
253 lines (223 loc) · 9.04 KB
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
<?php
// $Header: /cvsroot/tsheet/timesheet.php/user_maint.php,v 1.7 2005/02/03 09:15:44 vexil Exp $
// Authenticate
require("class.AuthenticationManager.php");
require("class.CommandMenu.php");
if (!$authenticationManager->isLoggedIn() || !$authenticationManager->hasClearance(CLEARANCE_ADMINISTRATOR)) {
Header('Location: login.php?clearanceRequired=Administrator');
exit;
}
// Connect to database.
$dbh = dbConnect();
//define the command menu
include("timesheet_menu.inc");
?>
<head><title>User Management Page</title>
<?php
include ("header.inc");
?>
<script type="text/javascript">
function deleteUser(uid, username) {
//get confirmation
if (confirm("Note: It is recommended that users be marked INACTIVE rather than deleted.\nDeleting user '" + username + "' will also remove all related project and task assignments.\n\tClicking OK will DELETE this user!")) {
document.userForm.action.value = "delete";
document.userForm.uid.value = uid;
document.userForm.username.value = username;
document.userForm.submit();
}
}
function editUser(uid, firstName, lastName, username, emailAddress, password, isAdministrator, isManager, isActive) {
document.userForm.uid.value = uid;
document.userForm.first_name.value = firstName;
document.userForm.last_name.value = lastName;
document.userForm.username.value = username;
document.userForm.email_address.value = emailAddress;
document.userForm.password.value = password;
document.userForm.checkAdmin.checked = isAdministrator;
document.userForm.isAdministrator.value = document.userForm.checkAdmin.checked=='1' ? true : false;
document.userForm.checkManager.checked = isManager;
document.userForm.isManager.value = document.userForm.checkManager.checked=='1' ? true : false;
document.userForm.checkActive.checked = isActive;
document.userForm.isActive.value = document.userForm.checkActive.checked=='1' ? true : false;
onCheckClearance();
document.location.href = "#AddEdit";
}
function addUser() {
//validation
if (document.userForm.username.value == "")
alert("You must enter a username that the user will log on with.");
else if (document.userForm.password.value == "")
alert("You must enter a password that the user will log on with.");
else {
document.userForm.action.value = "addupdate";
document.userForm.submit();
}
}
function goClone() {
var cloneTo = document.userForm.username.value;
var location = "user_clone.php";
if(cloneTo.length > 0)
location+="?cloneTo=" + cloneTo;
window.location.href=location;
}
function onCheckClearance() {
document.userForm.isAdministrator.value =
document.userForm.checkAdmin.checked;
document.userForm.isManager.value =
document.userForm.checkManager.checked;
}
function onCheckActive() {
document.userForm.isActive.value =
document.userForm.checkActive.checked;
}
</script>
</head>
<body <?php include ("body.inc"); ?> >
<?php
include ("banner.inc");
?>
<form action="user_action.php" name="userForm" method="post">
<input type="hidden" name="action" value="" />
<input type="hidden" name="uid" value="" />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" class="face_padding_cell">
<!-- include the timesheet face up until the heading start section -->
<?php include("timesheet_face_part_1.inc"); ?>
<table width="100%" border="0">
<tr>
<td align="left" nowrap class="outer_table_heading">
Employees/Contractors:
</td>
<td align="right" nowrap >
<a href="javascript:goClone()">Copy Projects/Tasks between users</a></td>
</td>
</tr>
</table>
<!-- include the timesheet face up until the heading start section -->
<?php include("timesheet_face_part_2.inc"); ?>
<table width="100%" align="center" border="0" cellpadding="0" cellspacing="0" class="outer_table">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table_body">
<tr class="inner_table_head">
<td class="inner_table_column_heading">First Name</td>
<td class="inner_table_column_heading">Last Name</td>
<td align="center" class="inner_table_column_heading">Active</td>
<td class="inner_table_column_heading">Access</td>
<td class="inner_table_column_heading">Login Username</td>
<td class="inner_table_column_heading">Email Address</td>
<td class="inner_table_column_heading"><i>Actions</i></td>
</tr>
<?php
list($qh,$num) = dbQuery("SELECT * FROM $USER_TABLE WHERE username!='guest' ORDER BY status desc, last_name, first_name");
while ($data = dbResult($qh)) {
$firstNameField = empty($data["first_name"]) ? " ": $data["first_name"];
$lastNameField = empty($data["last_name"]) ? " ": $data["last_name"];
$usernameField = empty($data["username"]) ? " ": $data["username"];
$isActive = ($data["status"]=='ACTIVE');
$emailAddressField = empty($data["email_address"]) ? " ": $data["email_address"];
$isAdministrator = ($data["level"] >= 10);
$isManager = ($data["level"] >= 5);
print "<tr>\n";
print "<td class=\"calendar_cell_middle\">$firstNameField</td>";
print "<td class=\"calendar_cell_middle\">$lastNameField</td>";
if ($isActive)
print "<td align=\"center\" class=\"calendar_cell_middle\"><img src=\"images/green-check-mark.gif\" height=\"12\" border=\"0\" alt=\"\" /></td>";
else
print "<td align=\"center\" class=\"calendar_cell_middle\"><img src=\"images/red-x.gif\" height=\"12\" border=\"0\" alt=\"\" /></td>";
if ($isAdministrator)
print "<td class=\"calendar_cell_middle\"><span class=\"calendar_total_value_weekly\">Admin</span></td>";
else if ($isManager)
print "<td style=\"color:blue; font-weight:bold;\" class=\"calendar_cell_middle\">Manager</td>";
else
print "<td class=\"calendar_cell_middle\">Basic</td>";
print "<td class=\"calendar_cell_middle\">$usernameField</td>";
print "<td class=\"calendar_cell_middle\">$emailAddressField</td>";
print "<td class=\"calendar_cell_disabled_right\">";
print " <a href=\"javascript:deleteUser('$data[uid]', '$data[username]')\">Delete</a>, \n";
print " <a href=\"javascript:editUser('$data[uid]', '$data[first_name]', '$data[last_name]', '$data[username]', '$data[email_address]', '$data[password]', '$isAdministrator', '$isManager', '$isActive')\">Edit</a>\n";
print "</td>\n";
print "</tr>\n";
}
?>
</table>
</td>
</tr>
</table>
<!-- include the timesheet face up until the end -->
<?php include("timesheet_face_part_3.inc"); ?>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" class="face_padding_cell">
<!-- include the timesheet face up until the heading start section -->
<?php include("timesheet_face_part_1.inc"); ?>
<table width="100%" border="0">
<tr>
<td align="left" nowrap class="outer_table_heading">
<a name="AddEdit"> Add/Update Employee/Contractor:</a>
</td>
<td align="right" nowrap >
<a href="javascript:goClone()">Copy Projects/Tasks between users</a></td>
</td>
</tr>
</table>
<!-- include the timesheet face up until the heading start section -->
<?php include("timesheet_face_part_2.inc"); ?>
<table width="100%" align="center" border="0" cellpadding="0" cellspacing="0" class="outer_table">
<tr>
<td>
<table width="100%" border="0" class="table_body">
<tr>
<td>First name:<br><input size="20" name="first_name" style="width: 100%;"></td>
<td>Last name:<br><input size="20" name="last_name" style="width: 100%;"></td>
<td>Login username:<br /><input size="15" name="username" style="width: 100%;" /></td>
<td>Email address:<br /><input size="35" name="email_address" style="width: 100%;" /></td>
<td>Password:<br /><input type="password" size="20" name="password" style="width: 100%;" AUTOCOMPLETE="OFF" /></td>
</tr>
<tr>
<td colspan="2" align="left">
<input type="checkbox" name="checkAdmin" id="checkAdmin" value="" onclick="onCheckClearance();" />This user is an administrator
<input type="hidden" name="isAdministrator" id="isAdministrator" value="false" />
</td>
<td colspan="2" align="left">
<input type="checkbox" name="checkManager" id="checkManager" value="" onclick="onCheckClearance();" />This user is a project manager
<input type="hidden" name="isManager" id="isManager" value="false" />
</td>
<td align="left">
<input type="checkbox" name="checkActive" id="checkActive" value="" onclick="onCheckActive();" />is Active
<input type="hidden" name="isActive" id="isActive" value="false" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width="100%" border="0" class="table_bottom_panel">
<tr>
<td align="center">
<input type="button" name="addupdate" value="Add/Update Employee/Contractor" onclick="javascript:addUser()" class="bottom_panel_button" />
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- include the timesheet face up until the end -->
<?php include("timesheet_face_part_3.inc"); ?>
</td>
</tr>
</table>
</form>
<?php
include ("footer.inc");
?>
</body>
</HTML>
<?php
// vim:ai:ts=4:sw=4
?>