-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemployeeTargetsAccomplishmentpip.php
More file actions
454 lines (337 loc) · 12.8 KB
/
Copy pathemployeeTargetsAccomplishmentpip.php
File metadata and controls
454 lines (337 loc) · 12.8 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
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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
<?php
include "home.php";
?>
<script>
$(function() {
$( "#dateOfBirth" ).datepicker({
appendText:"(yy-mm-dd)",
changeMonth:true,
changeYear:true,
yearRange:"c-80:c+0",
dateFormat:"yy-mm-dd"
});
$( ".dateElement" ).datepicker({
appendText:"(yy-mm-dd)",
changeMonth:true,
changeYear:true,
yearRange:"c-35:c+0",
dateFormat:"yy-mm-dd"
});
});
</script>
<script type="text/javascript">
$(function() {
$(".tablelist tr:nth-child(even)").addClass("striped");
$(".tablelist tr:nth-child(odd)").addClass("nostriped");
});
$(document).ready(function () {
$('#dtBasicExample').DataTable();
$('.dataTables_length').addClass('bs-select');
});
</script>
<style type="text/css">
body,td {
font-size: 10pt;
}
table.tablelist {
/*background-color: black;*/
border: 1px black solid;
border-collapse: collapse;
}
th {
border: 1px outset silver;
background-color: grey;
color: white;
}
tr.nostriped {
background-color: white;
margin: 1px;
}
tr.striped {
/*background-color: #f09320;*/
background-color: whitesmoke;;
}
td {
padding: 1px 8px;
}
.normal {
font-weight: normal;
}
</style>
<script>
function uncheckrestrictided() {
document.getElementById("restrictided").checked = false;
}
function uncheckunrestricted() {
document.getElementById("unrestricted").checked = false;
}
function uncheckmedical() {
document.getElementById("medical").checked = false;
}
function unchecknonmedical() {
document.getElementById("nonmedical").checked = false;
}
</script>
<?php
include("connect.php");
$userId=$_SESSION['hruseridsession'];
$reqList=mysqli_query($conn,"SELECT *,(select GROUP_CONCAT(firstname,' ',lastname) from users u where u.userid = t.employee_id) as employee FROM hr_pip_ap_targets t where t.employee_id='$userId' group by t.employee_id,t.fy");
if(mysqli_num_rows($reqList)) {
print("<table><tr>");
while($row=mysqli_fetch_array($reqList)){
$fy=$row['FY'];
$employee=$row['employee'];
$employeeid=$row['employee_id'];
print("<td>
<form action='employeeCheckAllAppraisals.php' method='post'>
<input type='hidden' name='fy' value='$fy'>
<input type='hidden' name='employeeid' value='$employeeid'>
<input type='submit' name='showselected' value='$fy' class='hrbutton'>");
print("</form>
</td>");
}
print("</tr></table>");
}else {
print("<br>targets not yet recorded");
}
?>
<h1>EMPLOYEE SELF-ASSESSMENT ON Performance Improvement Plan (PIP) <br/><br/> <b><i>ISUZUMA MIKORERE RY'INYONGERA UMUKOZI YIKORERA KU GITI CYE</i></b><h1>
<br/>
<?php
if(isset($_POST['perfomanceconfirm'])){
include("connect.php");
include 'createEmail.php';
$employee_id=$_POST['employee_id'];
$fy=$_POST['fy'];
$confirm=$_POST['confirm'];
$tscore="";
$totalscore=mysqli_query($conn,"SELECT ((((SELECT (SUM(score)/(count(target_id)*5))*60 as scoredintarget FROM hr_pip_ap_targets where employee_id='$employee_id' and FY='$fy' and (accomplished='Fully Accomplished' or accomplished='Partially Accomplished') and score is not null) + (SELECT (SUM(score)/25)*40 as scoredinconduct FROM hr_performance_ap_conduct where employee_id='$employee_id' and FY='$fy' and score is not null))/100)*5) as totalscore");
if(mysqli_num_rows($totalscore)) {
$rowscore=mysqli_fetch_array($totalscore);
$tscore=$rowscore['totalscore'];
$tscore=round($tscore,0);
}
if($tscore!="" && $tscore!=null) {
$insertconfirmationOfEmployee=mysqli_query($conn,"insert into hr_performance_ap (FY,employee_id,score,employee_accept,employee_accept_date) values('$fy','$employee_id','$tscore','$confirm',now())");
$reqError=mysqli_error($conn);
if($reqError==null || $reqError=="") {
$receivers=mysqli_query($conn,"select email from users where userid in (select supervisor from users where userid='$employee_id')");
$names= $_SESSION['firstnamesession']." ".$_SESSION['lastnamesession'];
$subject="CONFIRMATION OF PA from your Supervisee ";
$message="We would like to notify you that your Supervisee(<b>".$names."</b>) confirm a performance appraisal."."<br/><br/> <font color=red><strong> Please approve this PA and set the new targets for the upcoming(New) fiscal year.</strong></font>";
while($rowrec=mysqli_fetch_array($receivers)){
$receverEmail=$rowrec['email'];
sendEmail($receverEmail,$subject,$message);
}
if($confirm=="DENIED") {
$receivers=mysqli_query($conn,"select email from users where role like '%hradmin%'");
$names= $_SESSION['firstnamesession']." ".$_SESSION['lastnamesession'];
$subject="Denial OF PA";
$message="We would like to notify you that the employee(<b>".$names."</b>) denied a performance appraisal (".$fy.").";
while($rowrec=mysqli_fetch_array($receivers)){
$receverEmail=$rowrec['email'];
sendEmail($receverEmail,$subject,$message);
}
}
print("
<script>
alert('Thank you for this confirmation');
</script>");
}
}
}
?>
<?php
if(isset($_POST['edit'])){
include("connect.php");
$target_id=$_POST['target_id'];
$userId=$_SESSION['hruseridsession'];
$targetq=mysqli_query($conn,"SELECT * FROM hr_pip_ap_targets where target_id='$target_id' and supervisor_id='$userId'");
$row=mysqli_fetch_array($targetq);
$target_id= $row['target_id'];
$date_submited=$row['date_submited'];
$FY=$row['FY'];
$employee_id=$row['employee_id'];
$supervisor_id=$row['supervisor_id'];
$target=$row['target'];
$indicator=$row['indicator'];
$timing=$row['timing'];
$comment=$row['comments'];
print("
<form action='showtargets.php' method='post'>
<table class='tablelist'><thead>
<tr> <th>PLANNED ACTIVITIES/TARGETS</th>
<th>PERFORMANCE INDICATORS</th>
<th>TIMING OF THE ACTIVITY PER SET TARGET</th>
<th>COMMENTS / OBSERVATIONS</th>
</tr> </thead>
<tr>
<td><input type='hidden' name='target_id' value='$target_id'><input type='hidden' name='fy' value='$FY'><input type='hidden' name='employee_id' value='$employee_id'>
<textarea name=target size=10 rows=4 cols=30>$target</textarea></td>
<td><textarea name=indicator size=10 rows=4 cols=30>$indicator</textarea></td>
<td><input type=text name=timing size=10 value='$timing' ></td>
<td><textarea name=comment size=10 rows=4 cols=30>$comment</textarea></td>
</tr>
</table>
<div style='text-align: center;'><input type='submit' name='edittarget' value='Save' class='hrbutton'></div>
</form>
");
}
?>
<?php
if(isset($_POST['edittarget'])){
include("connect.php");
$target_id=$_POST['target_id'];
$fy=$_POST['fy'];
$employee_id=$_POST['employee_id'];
$target=$_POST['target'];
$indicator=$_POST['indicator'];
$timing=$_POST['timing'];
$comment=$_POST['comment'];
$updateTargetquery=mysqli_query($conn,"update hr_pip_ap_targets set target='$target',indicator='$indicator', timing='$timing', comments='$comment' where target_id='$target_id'");
showRequest($fy,$employee_id);
}
?>
<!-- Delete procurement request item -->
<?php
if(isset($_POST['accomplished'])){
include("connect.php");
$target_id=$_POST['target_id'];
$employee_id=$_POST['employee_id'];
$accomplishedOption=$_POST['accomplishedOption'];
$fy=$_POST['fy'];
$deleteRequestitemquery=mysqli_query($conn,"update hr_pip_ap_targets set accomplished='$accomplishedOption' where target_id='$target_id'");
//showRequest($fy,$employee_id);
}
?>
<?php
if(isset($_POST['accept'])){
include("connect.php");
$target_id=$_POST['target_id'];
$employee_id=$_POST['employee_id'];
$fy=$_POST['fy'];
$deleteRequestitemquery=mysqli_query($conn,"update hr_pip_ap_targets set employee_accept='YES' where target_id='$target_id'");
//showRequest($fy,$employee_id);
}
?>
<!-- Add notices -->
<?php
if(isset($_POST['saveChallenges'])){
include("connect.php");
include 'createEmail.php';
$fy=$_POST['fy'];
$employee_id=$_POST['employee_id'];
$supervisor_id=$_POST['supervisor_id'];
$challenges=$_POST['challenges'];
$overcome=mysqli_real_escape_string($conn,$_POST['overcome']);
$insertchallengeError="";
$insertovercomeError="";
foreach ($challenges as &$challengevalue) {
$challenge=mysqli_real_escape_string($conn,$challengevalue);
$addChallenge=mysqli_query($conn,"insert into hr_performance_ap_challenges(FY,employee_id,challenge,recorded_date) values('$fy','$employee_id','$challenge',now())");
$reqError=mysqli_error($conn);
if($reqError!==null && $reqError!=="") {
$insertchallengeError=$reqError;
}
}
$addOvercome=mysqli_query($conn,"insert into hr_performance_ap_challenges_overcome(FY,employee_id,overcome,recorded_date) values('$fy','$employee_id','$overcome',now())");
$reqError=mysqli_error($conn);
if($reqError!==null && $reqError!=="") {
$insertovercomeError=$reqError;
}
// Star Email
if($insertchallengeError=="" && $insertovercomeError=="") {
$names=$_SESSION['firstnamesession']." ".$_SESSION['lastnamesession'];
$receivers=mysqli_query($conn,"select distinct email from users where userid='$supervisor_id'");
$subject="Challenges have been submitted by your Supervisee ";
$message="We would like to notify you that, ".$names.", submitted challenges in the performance appraisal process of".$fy;
while($rowrec=mysqli_fetch_array($receivers)){
$receverEmail=$rowrec['email'];
sendEmail($receverEmail,$subject,$message);
}
}
// End Email
}
?>
<!-- List targerts -->
<?php
include("connect.php");
$employeeid=$_SESSION['hruseridsession'];
$fy="FY". (date('y'));
$supervisor_id="";
$allowChange=0;
$checkAppraisalwindow=mysqli_query($conn,"select * from hr_performance_ap_window where startdate<=now() and enddate>=now()");
if(mysqli_num_rows($checkAppraisalwindow)) {
$allowChange=1;
}
$targetsList=mysqli_query($conn,"SELECT * FROM hr_pip_ap_targets where employee_id='$employeeid' and FY='$fy' order by target_id");
if(mysqli_num_rows($targetsList)) {
print("<h5>ACCOMPLISHMENTS: $fy</h5>");
print("<div style='text-align: left;margin-left: 80px'>What were the set targets and the level of accomplishments in the last fiscal year?<br />
<b><i>Ni iyihe mihigo wabashije kwesa muri uyu mwaka twasoje wa $fy ?</i></b>
<br /><br />");
print("<center><table width='100%' class='tablelist'><thead><tr>
<th>PLANNED ACTIVITIES/TARGETS <br /> <b><i>GAHUNDA Y’IBIKORWA BY’UMUKOZI</i></b></th>
<th>PERFORMANCE INDICATORS<br /> <b><i>IBIPIMO FATIZO BY’IBIKORWA</i></b></th>
<th>TIMING OF THE ACTIVITY PER SET TARGET <br /> <b><i>IGIHE IGIKORWA KIZAKORERWAMO</i></b></th>
<th>COMMENTS / OBSERVATIONS <br /> <b><i>ICYONGERWAHO</i></b></th>
<th>DATE CREATED<br /> <b><i>ITARIKI YINJIRIJWEHO</i></b></th>
<th>SCORE<br /> <b><i>AMANOTA</i></b></th>
<th>Accepted?<br /> <b><i>WARAYEMEYE?</i></b></th>
<th>Accomplished?<br /> <b><i>WARAYIRANGIJE?</i></b></th>
</tr></thead>");
while($row1=mysqli_fetch_array($targetsList)){
$target_id= $row1['target_id'];
$date_submited=$row1['date_submited'];
$FY=$row1['FY'];
$employee_id=$row1['employee_id'];
$supervisor_id=$row1['supervisor_id'];
$target=$row1['target'];
$indicator=$row1['indicator'];
$timing=$row1['timing'];
$comments=$row1['comments'];
$accomplished=$row1['accomplished'];
$score=$row1['score'];
$employee_accept=$row1['employee_accept'];
print("
<tr>
<td>$target</td>
<td>$indicator</td>
<td>$timing</td>
<td>$comments</td>
<td>$date_submited</td>
<td>$score</td><td>");
if(strlen($employee_accept)==0){
print("<form action='employeeTargetsAccomplishmentpip.php' method='post'>
<input type='hidden' name='target_id' value='$target_id'><input type='hidden' name='fy' value='$FY'><input type='hidden' name='employee_id' value='$employee_id'>
");
print("<input type='submit' name='accept' value='Accept' class='hrbutton'></form>");
}else {
print("$employee_accept");
}
print("
</td><td>");
if(strlen($accomplished)==0 && strlen($employee_accept)!=0 && $allowChange==1){
print("<form action='employeeTargetsAccomplishmentpip.php' method='post'>
<input type='hidden' name='target_id' value='$target_id'><input type='hidden' name='fy' value='$FY'><input type='hidden' name='employee_id' value='$employee_id'>
<select name='accomplishedOption'>
<option value='Fully Accomplished'>Fully Accomplished</option>
<option value='Partially Accomplished'>Partially Accomplished</option>
<option value='Not Accomplished'>Not Accomplished</option>
</select>
");
print("<input type='submit' name='accomplished' value='Confirm' class='hrbutton'></form>");
}else {
print("$accomplished");
}
print("</td></tr>");
}
print("</center></table></div><br><br>");
}else {
print("<div style='text-align: left;margin-left: 80px'>Waiting for Supervisor to set targets for $fy or HR did not send you to PIP ............. <br /><br />");
}
print("</div>");
?>
<!-- </div> -->
</body>
</html>