-
Notifications
You must be signed in to change notification settings - Fork 0
/
view-staff.php
393 lines (301 loc) · 10 KB
/
view-staff.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
<?php require 'core/init.php' ?>
<body>
<div id="wrapper">
<?php
if ($privilege== "normal"){
include 'widget/header-normal.php';
}else if ($privilege=="supervisor"){
include 'widget/header-supervisor.php';
}else if ($privilege=="admin"){
include 'widget/header-admin.php';
}
?>
<div id="page-wrapper">
<div class="row">
<h1>View Staff</h1>
<div id="col-xs-3">
<?php
if (isset($_GET['status'])==true){
if ($_GET['status']=="success"){
echo '<div class="alert alert-success">Successfully edit information</div>';
}else {
echo '<div class="alert alert-danger">Failed to edit information</div>';
}
}
?>
<?php
if(isset($_POST['gobtn'])==TRUE){
if($_POST['searchoption']=="SearchID"){
$query= mysql_query("SELECT *
FROM employees
WHERE ( Privilege ='normal' OR Privilege ='supervisor') AND Employees_ID LIKE '%$_POST[search]%' AND Employee_Status='active'");
}else{
$query= mysql_query("SELECT *
FROM employees
WHERE ( Privilege ='normal' OR Privilege ='supervisor' ) AND FullName LIKE '%$_POST[search]%' AND Employee_Status='active'");
}
}else{
$query= mysql_query("SELECT *
FROM employees
WHERE (Privilege ='normal' OR Privilege ='supervisor') AND Employee_Status='active' ORDER BY Privilege DESC, Employees_ID ASC");
}
if(isset($_GET['id'])==false){
?> <form method ="post" action="" class="form-inline" role="form">
<input type="search" name ="search" class="form-control" placeholder="Search">
<input type="submit" name="gobtn" id="button" value="GO" class="form-control">
<div class="radio" >
<label>
<input type="radio" name="searchoption" id="optionsRadios1" value="SearchID" checked>
Search From ID
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="searchoption" id="optionsRadios2" value="SearchName">
Search From Name
</label>
</div>
<?php
if(mysql_num_rows($query)==0){
echo '<div class="alert alert-danger"><p>No search result found</p></div>';
}else{
echo '
<div class="list-group">';
while($result=mysql_fetch_assoc($query)){
$file = "picture/".$result['Employees_ID'].".jpg";
if (file_exists($file)==true){
$pict = $result['Employees_ID'];
}else{
$pict = "no-pict";
}
echo "<a href='view-staff.php?id=".$result['Employees_ID']."' class='list-group-item'><table class='table'>
<tr><th colspan='2'>ID : (".$result['Employees_ID'].")</th><th colspan='2'>Privilege: ".$result['Privilege']."</th></tr>
<tr><td rowspan='3'><img src='picture/".$pict.".jpg' width='90' height='120' ></td><td>".$result['FullName']."</td><td>Email:".$result['Email']."</td><td>Gender:".$result['Gender']."</td></tr>
<tr><td>Address:".$result['Address']."</td><td>Salary: RM ".$result['Salary']."</td><td>Recruiment Date:".$result['Recruitment_Date']."</td></tr>
<tr><td>Contact No: ".$result['Contact_No']."</td><td>Experience:".$result['Experience']." years</td><td>Department:".getdepartmentname(getdepartmentID($result['Employees_ID']))."</td></tr></table></a>";
}
echo '</div>';
}
}else{
?><div id="col-xs-2">
<table class="table">
<tr>
<th>Employees ID :</th>
<th><?php
$ID =getuserdetails($_GET['id'],'Employees_ID');
echo $ID;
?>
</th>
<td>
<form action='Admin-editStaff.php' method='POST' class="form-inline">
<input type ='submit' class='form-control' name='edit' value='Edit Profile'>
<input type= 'hidden' name='userid' value='<?php echo $_GET['id']; ?>'>
</form>
</td>
<td>
<form action='deactive-staff.php' onclick="return confirm('Are you sure you want to deactive this user ?');" method='POST' class="form-inline">
<input type ='submit' class='form-control' name='Deactive' value='Deactive User'>
<input type= 'hidden' name='userid' value='<?php echo $_GET['id']; ?>'>
</form>
</td>
</tr>
<tr>
<td rowspan= '4'>
<?php
$file = "picture/".$_GET['id'].".jpg";
if (file_exists($file)==true){
$pict = $_GET['id'];
}else{
$pict = "no-pict";
}
?>
<img class="img-thumbnail" src="picture/<?php
echo $pict;
?>.jpg" width="200" height="300" >
</td>
<td><b>Name :</b> <?php
$name =getuserdetails ($_GET['id'], 'FullName');
echo $name;
?>
</td>
<td><b>Identification Card:</b>
<?php
$IC =getuserdetails($_GET['id'],'Identification_Card');
echo $IC;
?>
</td>
<td><b>Address :</b>
<?php
$address =getuserdetails ($_GET['id'], "Address");
echo $address;
?>
</td>
</tr>
<tr>
<td><b>Contact No:</b>
<?php $contact =getuserdetails ($_GET['id'], "Contact_No");
echo $contact;?>
</td>
<td><b>Email :</b>
<?php
$email =getuserdetails($_GET['id'],'Email');
echo $email;
?>
</td>
<td><b>Salary :</b> RM
<?php $salary =getuserdetails($_GET['id'],'Salary');
echo $salary;
?>
</td>
</tr>
<tr>
<td><b>Experience :</b>
<?php
$exp=getuserdetails($_GET['id'],'Experience');
echo $exp;?> Years
</td>
<td><b>Gender :</b>
<?php
$gender=getuserdetails($_GET['id'],'Gender');
echo $gender;
?>
</td>
<td><b>Recruitment Date :</b>
<?php
$recrdate=getuserdetails($_GET['id'],'Recruitment_Date');
echo $recrdate;
?>
</td>
</tr>
<tr>
<td><b>Department :</b>
<?php
$depart=getdepartmentname (getdepartmentID($_GET['id']));
echo $depart;
?>
</td>
<td><b>Privilege :</b>
<?php
$depart=getuserdetails ($_GET['id'], "Privilege");
echo $depart;
?>
</td>
</tr>
</table>
</div>
<h2>Login Details </h2>
<table class="table">
<?php
$query4= mysql_query("SELECT * FROM login WHERE Employee_ID = '$_GET[id]'");
$username = mysql_result ($query4, 0, 'UserName');
$password = mysql_result ($query4, 0, 'Password');
echo '<form> <tr><td>Username:<input type="text" value="'.$username.'" readonly class="form-control"></td><td>Password:<input type="password" value="'.$password.'" readonly class="form-control"></td></tr></form>';
?>
</table>
<?php
$userid= $_GET['id'];
if(getuserdetails ($_GET['id'], "Privilege")=="supervisor"){
include 'widget/leave-status.php';
echo '<br/><br/><br/><br/><br/><br/><br/><br/><br/>';
include 'widget/training-status.php';
}else{
$userids= $_GET['id'];
$userid= $_GET['id'];
echo '<h2>Appraisals</h2>';
include 'widget/performances.php';
echo '<h2>Warning / Merit</h2>';
$query= mysql_query ("SELECT * FROM assessment INNER JOIN employees_assessment ON assessment.assessment_ID = employees_assessment.assessment_ID WHERE
employees_assessment.Employees_ID = '$userids'");
while ($result= mysql_fetch_assoc ($query)){
if ($result['Assessment_type']== "warning"){
echo '<div class="alert alert-danger"> Warning: ';
}else{
echo '<div class="alert alert-success"> Merit:';
}
echo "".$result['Description']."</div>";
}
?>
<h2>Leave Status</h2>
<table class="table table-hover">
<tr>
<th>Duration
</th>
<th>Starting Date
</th>
<th>Reason
</th>
<th>Status
</th>
<label><?php
$query = mysql_query("SELECT *
FROM employees_leave
INNER JOIN leaves ON leaves.Leaves_ID = employees_leave.Leave_ID
WHERE employees_leave.Employees_ID ='$userid'");
while($result= mysql_fetch_assoc($query)){
$empleave_id = $result['EmpLeave_ID'];
$query2 = mysql_query ("SELECT Approval, Approve_By FROM leave_track WHERE EmpLeave_ID = '$empleave_id'");
if(mysql_num_rows($query2)>0){
if (mysql_result($query2, 0, 'Approval') == "Approve"){
$status = "Approve";
}else{
$status = "Not Approve";
}
}else{
$status ="Pending Approval";
}
echo "<tr><td>". $result['Duration']." Days</td> <td>". $result['Starting_Date']."</td><td>". $result['Reason']."</td><td>".$status."</td></tr>" ;
}
?></label>
</table>
<h2>Training Status</h2>
<table class="table table-hover">
<tr>
<th>Apply Date
</th>
<th>Traing Title
</th>
<th>Duration
</th>
<th>Trainer
</th>
<th>Status
</th>
<th>Result
</th>
</tr>
<?php
$query = mysql_query("SELECT *
FROM employees_training
INNER JOIN training_programs ON training_programs.Program_ID = employees_training.Program_ID
WHERE employees_training.Employees_ID ='$userid'");
while($result= mysql_fetch_assoc($query)){
$empTraining_id = $result['EmpTraining_ID'];
$query2 = mysql_query ("SELECT Approval, Supervisor_ID FROM training_track WHERE EmpTraining_ID = '$empTraining_id'");
$query3 = mysql_query ("SELECT Score FROM training_result WHERE EmpTraining_ID = '$empTraining_id'");
if(mysql_num_rows($query2)>0){
if (mysql_result($query2, 0, 'Approval') == "Approve"){
$status = "Approve";
}else{
$status = "Not Approve";
}
}else{
$status ="Pending Approval";
}
if(mysql_num_rows($query3)>0){
$score = mysql_result($query3,0, 'Score');
}else{
$score = "N/A";
}
echo "<tr><td>". $result['Apply_Date']."</td> <td>". $result['Title']."</td><td>". $result['Duration']."</td><td>".$result['Trainer']."</td><td>".$status."</td><td>".$score."/100</td></tr>" ;
}
}
?>
</table>
<?php }
?>
</div>
</div>
</div>
</div>
</body>
</html>