-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.php
More file actions
632 lines (546 loc) · 19.7 KB
/
settings.php
File metadata and controls
632 lines (546 loc) · 19.7 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
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
<?php
include "home.php";
?>
<?php
// $role=$_SESSION['hrrolesession'];
// if(strpos($role,"hrsadmin") == false){
// session_destroy();
// exit();
// }
?>
<script>
$(function() {
$( "#startDate" ).datepicker({
appendText:"(yy-mm-dd)",
changeMonth:true,
changeYear:true,
yearRange:"c-0:c+1",
dateFormat:"yy-mm-dd"
});
$( "#endDate" ).datepicker({
appendText:"(yy-mm-dd)",
changeMonth:true,
changeYear:true,
yearRange:"c-0:c+1",
dateFormat:"yy-mm-dd"
});
$( ".dateElement" ).datepicker({
appendText:"(yy-mm-dd)",
changeMonth:true,
changeYear:true,
yearRange:"c-35:c+0",
dateFormat:"yy-mm-dd"
});
});
$("#indiv").click(function(){
$("#impo").toggle();
});
</script>
<script>
$(document).ready(function(){
//$("#impo").hide();
$("#indiv").click(function(){
$("#impo").show();
$("#all"). prop("checked", false);
});
$("#all").click(function(){
$("#indiv"). prop("checked", false);
$('#impo option:first').prop('selected',true);
$("#impo").hide();
});
$("#days").click(function(){
for(var c=0,e=0,d=new Date($("#startDate").val()),a=(new Date($("#endDate").val())-d)/864E5;0<=a;a--)
{
var b=new Date(d);
b.setDate(b.getDate()+a);
1==Math.ceil(b.getDay()%6/6)?c++:e++
}
$("#days").val(c);
});
});
</script>
<style>
.tableFixHead { overflow-y: auto; height: 100px; }
.tableFixHead thead th { position: sticky; top: 0; }
</style>
<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>
<style>
</style>
<h1>Settings<h2>
<br/>
<form action="settings.php" method="post">
<fieldset>
<legend>Reset Performance Appraisal</legend>
<table>
<tr>
<td>Employee:</td>
<td><select name="employee">
<option value="" selected="">-- Select employee--</option> <?php
include("connect.php");
$employeesqueryActive=mysqli_query($conn,"select userid,concat(lastname,' ',firstname) as empName from users where active='YES' order by lastname");
if(mysqli_num_rows($employeesqueryActive)) {
while($row=mysqli_fetch_array($employeesqueryActive)){
$mployeeId=$row['userid'];
$mployeeName=$row['empName'];
print("<option value='$mployeeId'>$mployeeName</option>");
}
}
?></select></td>
</tr>
<tr>
<td>FY:</td>
<td><select name="fy">
<option value="" selected="">-- Select FY--</option> <?php
include("connect.php");
$fys=mysqli_query($conn,"select distinct FY from hr_performance_ap_targets order by FY");
if(mysqli_num_rows($fys)) {
while($row=mysqli_fetch_array($fys)){
$name=$row['FY'];
print("<option value='$name'>$name</option>");
}
}
?></select></td>
</tr>
<tr>
<td>To which level </td>
<td><select name="level">
<option value="confirmations">CONFIRMATIONS</option>
<option value="devplan">EMPLOYEE DEVELOPMENT PLAN</option>
<option value="conducts">EMPLOYEE CONDUCT</option>
<option value="chalengeAndStrengths">EMPLOYEE STRENGTHS AND CHALLENGES</option>
<option value="chalenges">CHALLENGES</option>
<option value="targets">TARGETS</option>
</select></td>
</tr>
</table>
</fieldset>
<br />
<div style="text-align: center;">
<input type='submit' value='Reset PA' onclick="this.disabled=true; this.value='Please wait...'; document.getElementById('resetpaid').click();" class='hrbutton'>
<input type='submit' name='resetpa' value='Reset PA' id='resetpaid' style='display:none;' class='hrbutton'>
</div>
</form>
<form action="settings.php" method="post">
<fieldset>
<legend>Set appraisal window</legend>
<table>
<tr>
<td>Start Date: </td>
<td><input type="text" name="startDate" id="startDate"></td>
</tr>
<tr>
<td>End Date: </td>
<td><input type="text" name="endDate" id="endDate"></td>
</tr>
</table>
</fieldset>
<br />
<div style="text-align: center;">
<input type='submit' value='Set Window' onclick="this.disabled=true; this.value='Please wait...'; document.getElementById('requestid').click();" class='hrbutton'>
<input type='submit' name='save' value='Set Window' id='requestid' style='display:none;' class='hrbutton'>
</div>
</form>
<!-- Reset PA -->
<?php
include "connect.php";
if(isset($_POST['resetpa'])){
include 'createEmail.php';
$employeeid=$_POST['employee'];
$fy=$_POST['fy'];
$level=$_POST['level'];
if($level==="targets") {
$updatetarges=mysqli_query($conn,"update hr_performance_ap_targets set accomplished=null,score=null,scorecomment=null where employee_id='$employeeid' and fy='$fy'");
$deletechallenge=mysqli_query($conn,"delete from hr_performance_ap_challenges where employee_id='$employeeid' and fy='$fy'");
$deletechallengeovercome=mysqli_query($conn,"delete from hr_performance_ap_challenges_overcome where employee_id='$employeeid' and fy='$fy'");
$deletechallengeandstrength=mysqli_query($conn,"delete from hr_performance_ap_strength_challenges_overcome where employee_id='$employeeid' and fy='$fy'");
$deleteconducts=mysqli_query($conn,"delete from hr_performance_ap_conduct where employee_id='$employeeid' and fy='$fy'");
$deletedevplan=mysqli_query($conn,"delete from hr_performance_ap_dev_plan where employee_id='$employeeid' and fy='$fy'");
$deleteconfirmations=mysqli_query($conn,"delete from hr_performance_ap where employee_id='$employeeid' and fy='$fy'");
}
if($level==="chalenges") {
$deletechallenge=mysqli_query($conn,"delete from hr_performance_ap_challenges where employee_id='$employeeid' and fy='$fy'");
$deletechallengeovercome=mysqli_query($conn,"delete from hr_performance_ap_challenges_overcome where employee_id='$employeeid' and fy='$fy'");
$deletechallengeandstrength=mysqli_query($conn,"delete from hr_performance_ap_strength_challenges_overcome where employee_id='$employeeid' and fy='$fy'");
$deleteconducts=mysqli_query($conn,"delete from hr_performance_ap_conduct where employee_id='$employeeid' and fy='$fy'");
$deletedevplan=mysqli_query($conn,"delete from hr_performance_ap_dev_plan where employee_id='$employeeid' and fy='$fy'");
$deleteconfirmations=mysqli_query($conn,"delete from hr_performance_ap where employee_id='$employeeid' and fy='$fy'");
}
if($level==="chalengeAndStrengths") {
$deletechallengeandstrength=mysqli_query($conn,"delete from hr_performance_ap_strength_challenges_overcome where employee_id='$employeeid' and fy='$fy'");
$deleteconducts=mysqli_query($conn,"delete from hr_performance_ap_conduct where employee_id='$employeeid' and fy='$fy'");
$deletedevplan=mysqli_query($conn,"delete from hr_performance_ap_dev_plan where employee_id='$employeeid' and fy='$fy'");
$deleteconfirmations=mysqli_query($conn,"delete from hr_performance_ap where employee_id='$employeeid' and fy='$fy'");
}
if($level==="conducts") {
$deleteconducts=mysqli_query($conn,"delete from hr_performance_ap_conduct where employee_id='$employeeid' and fy='$fy'");
$deletedevplan=mysqli_query($conn,"delete from hr_performance_ap_dev_plan where employee_id='$employeeid' and fy='$fy'");
$deleteconfirmations=mysqli_query($conn,"delete from hr_performance_ap where employee_id='$employeeid' and fy='$fy'");
}
if($level==="devplan") {
$deletedevplan=mysqli_query($conn,"delete from hr_performance_ap_dev_plan where employee_id='$employeeid' and fy='$fy'");
$deleteconfirmations=mysqli_query($conn,"delete from hr_performance_ap where employee_id='$employeeid' and fy='$fy'");
}
if($level==="confirmations") {
$deleteconfirmations=mysqli_query($conn,"delete from hr_performance_ap where employee_id='$employeeid' and fy='$fy'");
}
$reqError=mysqli_error($conn);
if(($reqError==null || $reqError=="")) {
$receivers=mysqli_query($conn,"select email from users where userid='$employeeid'");
$names= $_SESSION['firstnamesession']." ".$_SESSION['lastnamesession'];
$subject="Reset on your Appraisal of $fy";
$message="We would like to notify you that <b>".$names."</b> did reset on your appraisal of $fy to the level of $level . ";
while($rowrec=mysqli_fetch_array($receivers)){
$receverEmail=$rowrec['email'];
sendEmail($receverEmail,$subject,$message);
}
$receiversSupervisor=mysqli_query($conn,"select email,(select concat(lastname,' ',firstname) from users where userid='$employeeid') as empName from users where userid in (select supervisor from users where userid='$employeeid')");
$rowrecsup=mysqli_fetch_array($receiversSupervisor);
$receversupEmail=$rowrecsup['email'];
$empName=$rowrecsup['empName'];
$subject="Reset of Appraisal of your supervisee";
$message="We would like to notify you that <b>".$names."</b> did reset on the appraisal of $fy to the level of $level . Please seat with $empName for correction";
sendEmail($receversupEmail,$subject,$message);
print("
<script>
alert('Performance Appraisal reset is done');
</script>
");
}
}
?>
<!-- End reset PA -->
<?php
include "connect.php";
if(isset($_POST['save'])){
include 'createEmail.php';
$employeeid=$_SESSION['hruseridsession'];
$startDate=$_POST['startDate'];
$endDate=$_POST['endDate'];
$startDate=$startDate." 00:00:00";
$endDate=$endDate." 23:59:59";
$requesteddate=date("Y-m-d");
$changeappraisalwindow=mysqli_query($conn,"update hr_performance_ap_window set startdate='$startDate',enddate='$endDate'");
$reqError=mysqli_error($conn);
if(($reqError==null || $reqError=="")) {
$receivers=mysqli_query($conn,"select email from users where active='YES'");
$names= $_SESSION['firstnamesession']." ".$_SESSION['lastnamesession'];
$subject="Notification on Appraisal window";
$message="We would like to notify you that <b>".$names."</b> has updated the appraisal window (from: <b>".$startDate."</b> to: <b>".$endDate."</b> ). You can <b>start</b> or <b>update</b> the performance appraisal for you or for your supervisee based on the mentioned start date and end date";
while($rowrec=mysqli_fetch_array($receivers)){
$receverEmail=$rowrec['email'];
sendEmail($receverEmail,$subject,$message);
}
print("
<script>
alert('Window is changed successfully');
</script>
");
}
}
?>
<!-- Window -->
<?php
include "connect.php";
$employeeid=$_SESSION['hruseridsession'];
$window=mysqli_query($conn,"select * from hr_performance_ap_window");
if(mysqli_num_rows($window)) {
print("<br /><fieldset>
<legend>Performance appraisal window</legend>
<table width='100%' class='tablelist' id='dynamic_field'><thead>
<tr>
<th>Start Date</th>
<th>End Date</th>
</tr></thead>");
while($row=mysqli_fetch_array($window)){
$start_date=$row['startdate'];
$end_date=$row['enddate'];
print("<tr>
<td>$start_date</td>
<td>$end_date</td>
</tr>");
}
print("</table></fieldset>");
}
?>
<br/>
<form action="settings.php" method="post">
<fieldset>
<legend>Clean All Permission days</legend>
<div style="text-align: center;">
<input type='submit' value='Make them Zero' onclick="this.disabled=true; this.value='Please wait...'; document.getElementById('cleanid').click();" class='hrbutton'>
<input type='submit' name='cleanpermissions' value='Make them Zero' id='cleanid' style='display:none;' class='hrbutton deletebtn'>
</div>
</fieldset>
</form>
<?php
include "connect.php";
if(isset($_POST['cleanpermissions'])){
include 'createEmail.php';
$employeeid=$_SESSION['hruseridsession'];
$cleanpermission=mysqli_query($conn,"update hr_employee_leave_days set number_of_days='0' where leave_type='Permission'");
$reqError=mysqli_error($conn);
if(($reqError==null || $reqError=="")) {
print("
<script>
alert('All Permission days are all cleaned');
</script>
");
}
}
?>
<!-- Save outstanding leave -->
<?php
include "connect.php";
if(isset($_POST['saveoutstanding'])){
include 'createEmail.php';
$creator=$_SESSION['hruseridsession'];
$fy=$_POST['fy'];
$leave_type=$_POST['leavetype'];
$startDate=$startDate." 00:00:00";
$endDate=$endDate." 23:59:59";
$requesteddate=date("Y-m-d");
$employeeleaveschecks=mysqli_query($conn,"select * from hr_outstanding_leave where leave_type='$leave_type' and fy='$fy' ");
if(mysqli_num_rows($employeeleaveschecks) == 0) {
$employeeleaves=mysqli_query($conn,"select number_of_days,employee_id from hr_employee_leave_days where leave_type='$leave_type'");
if(mysqli_num_rows($employeeleaves)) {
while($row=mysqli_fetch_array($employeeleaves)){
$employee_id=$row['employee_id'];
$number_of_days=$row['number_of_days'];
$saveoutstanding=mysqli_query($conn,"INSERT INTO hr_outstanding_leave (employee_id, fy, leave_type, days, date_created, creator) VALUES('$employee_id','$fy','$leave_type','$number_of_days',now(),'$creator')");
print(mysqli_error($saveoutstanding));
}
print("
<script>
alert('Outstanding $leave_type in $fy is saved');
</script>
");
}
}else {
print("
<script>
alert('This Outstanding of $leave_type in $fy exist');
</script>
");
}
}
?>
<!-- allow or stop allocations -->
<?php
if(isset($_POST['confirm'])){
include "connect.php";
$creator=$_SESSION['hruseridsession'];
$employee=$_POST['employee'];
$lleaveAllocationAllowed=$_POST['leaveAllocationAllowed'];
$allowStopAllocation=mysqli_query($conn,"update users set leaveAllocationAllowed='$lleaveAllocationAllowed' where userid='$employee'");
print("
<script>
alert('Information is updated');
</script>
");
}
?>
<!-- Swap supervisors -->
<?php
if(isset($_POST['changesup'])){
include "connect.php";
$creator=$_SESSION['hruseridsession'];
$currsup=$_POST['currsup'];
$newsup=$_POST['newsup'];
$allowStopAllocation=mysqli_query($conn,"update users set supervisor='$newsup' where supervisor='$currsup'");
print("
<script>
alert('Information is updated');
</script>
");
}
?>
<form action="settings.php" method="post">
<fieldset>
<legend>SAVE OUTSTANDING LEAVE</legend>
<table>
<tr>
<td>FY:</td>
<td><select name="fy">
<option value="" selected="">-- Select FY--</option> <?php
include("connect.php");
$employeeLeaveTypes=mysqli_query($conn,"select distinct fy from hr_employee_leave_allocation order by fy");
if(mysqli_num_rows($employeeLeaveTypes)) {
while($row=mysqli_fetch_array($employeeLeaveTypes)){
$name=$row['fy'];
print("<option value='$name'>$name</option>");
}
}
?></select></td>
</tr>
<tr>
<td>LEAVE TYPE: </td>
<td><select name="leavetype">
<option value="" selected="">-- Select leave type--</option> <?php
include("connect.php");
$employeeLeaveTypes=mysqli_query($conn,"select name from hr_employee_leave_type order by name");
if(mysqli_num_rows($employeeLeaveTypes)) {
while($row=mysqli_fetch_array($employeeLeaveTypes)){
$name=$row['name'];
print("<option value='$name'>$name</option>");
}
}
?></select></td>
</tr>
</table>
</fieldset>
<br />
<div style="text-align: center;">
<input type='submit' value='Save Outstanding' onclick="this.disabled=true; this.value='Please wait...'; document.getElementById('saveoutstandingid').click();" class='hrbutton'>
<input type='submit' name='saveoutstanding' value='Save Outstanding' id='saveoutstandingid' style='display:none;' class='hrbutton'>
</div>
</form>
<form action="settings.php" method="post">
<fieldset>
<legend>SEND EMPLOYEE TO PIP</legend>
<table>
<tr>
<td>Employee: </td>
<td><select name="employee"><option value="" selected="">-- Select employee--</option> <?php
include("connect.php");
$employeesqueryActive=mysqli_query($conn,"select userid,concat(lastname,' ',firstname) as empName from users where userid in (SELECT employee_id FROM hr_performance_ap where employee_accept='DENIED' or score<=2) order by lastname");
if(mysqli_num_rows($employeesqueryActive)) {
while($row=mysqli_fetch_array($employeesqueryActive)){
$mployeeId=$row['userid'];
$mployeeName=$row['empName'];
print("<option value='$mployeeId'>$mployeeName</option>");
}
}
?></select></td>
</tr>
<tr>
<td>FY:</td>
<td><select name="fy">
<option value="" selected="">-- Select FY--</option> <?php
include("connect.php");
$fy=mysqli_query($conn,"select distinct FY from hr_performance_ap order by FY");
if(mysqli_num_rows($fy)) {
while($row=mysqli_fetch_array($fy)){
$name=$row['FY'];
print("<option value='$name'>$name</option>");
}
}
?></select></td>
</tr>
</table>
</fieldset>
<br />
<div style="text-align: center;">
<input type='submit' value='Send to PIP' onclick="this.disabled=true; this.value='Please wait...'; document.getElementById('sendTopipid').click();" class='hrbutton'>
<input type='submit' name='sendtopip' value='Send to PIP' id='sendTopipid' style='display:none;' class='hrbutton'>
</div>
</form>
<form action="settings.php" method="post">
<fieldset>
<legend>STOP/ALLOW ALLOCATIONS ON EMPLOYEE</legend>
<table>
<tr>
<td>Employee: </td>
<td><select name="employee"><option value="" selected="">-- Select employee--</option> <?php
include("connect.php");
$employeesqueryActive=mysqli_query($conn,"select userid,concat(lastname,' ',firstname) as empName from users where active='YES' order by lastname");
if(mysqli_num_rows($employeesqueryActive)) {
while($row=mysqli_fetch_array($employeesqueryActive)){
$mployeeId=$row['userid'];
$mployeeName=$row['empName'];
print("<option value='$mployeeId'>$mployeeName</option>");
}
}
?></select></td>
</tr>
<tr>
<td>IS ALLOCATION ACCEPTED?</td>
<td><select name="leaveAllocationAllowed">
<option value="YES">YES</option>
<option value='NO'>NO</option></select></td>
</tr>
</table>
</fieldset>
<br />
<div style="text-align: center;">
<input type='submit' value='CONFIRM' onclick="this.disabled=true; this.value='Please wait...'; document.getElementById('confirmid').click();" class='hrbutton'>
<input type='submit' name='confirm' value='CONFIRM' id='confirmid' style='display:none;' class='hrbutton'>
</div>
</form>
<form action="settings.php" method="post">
<fieldset>
<legend>Change Supervisor once</legend>
<table>
<tr>
<td>Current Supervisor: </td>
<td><select name="currsup"><option value="" selected="">-- Select Supervisor--</option> <?php
include("connect.php");
$employeesqueryActive=mysqli_query($conn,"select userid,concat(lastname,' ',firstname) as empName from users where active='YES' and role like '%supervisor%' order by lastname");
if(mysqli_num_rows($employeesqueryActive)) {
while($row=mysqli_fetch_array($employeesqueryActive)){
$mployeeId=$row['userid'];
$mployeeName=$row['empName'];
print("<option value='$mployeeId'>$mployeeName</option>");
}
}
?></select></td>
</tr>
<tr>
<td>New Supervisor: </td>
<td><select name="newsup"><option value="" selected="">-- Select Supervisor--</option> <?php
include("connect.php");
$employeesqueryActive=mysqli_query($conn,"select userid,concat(lastname,' ',firstname) as empName from users where active='YES' and role like '%supervisor%' order by lastname");
if(mysqli_num_rows($employeesqueryActive)) {
while($row=mysqli_fetch_array($employeesqueryActive)){
$mployeeId=$row['userid'];
$mployeeName=$row['empName'];
print("<option value='$mployeeId'>$mployeeName</option>");
}
}
?></select></td>
</tr>
</table>
</fieldset>
<br />
<div style="text-align: center;">
<input type='submit' value='CHANGE SUP.' onclick="this.disabled=true; this.value='Please wait...'; document.getElementById('changesupid').click();" class='hrbutton'>
<input type='submit' name='changesup' value='CHANGE SUP' id='changesupid' style='display:none;' class='hrbutton'>
</div>
</form>