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
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
|
<?php include_once '../include/DBConnect.php'; include_once 'CheckFollowUpAction.php';
#### Lesson State #### //state , 1 = Normal class , 2 = Make up class , 3 = Need make up // 4 = cancel , 5 = Had make up
class General {
public static function fields() { return array( 'id', 'createby', 'createdate', 'lastupby', 'lastupdate', ); }
public static function genderOptions() { return array( 1 => 'Male', 2 => 'Female', ); }
}
class Leave {
public static function Type() { return array( 1 => 'Annual Leave', 2 => 'Marriage Leave', 3 => 'Maternity Leave', 4 => 'No Pay Leave', 5 => 'Sick Leave' ); }
// public static function duration(){ // return array( // 1 => 'Whole day', // 2 => 'Morning', // 3 => 'Afternoon' // ); // }
public static function Status() { return array( 0 => 'Pending', 1 => 'Approved' ); }
}
$genderOptions = General::genderOptions(); $leaveType = Leave::Type(); $leaveStatus = Leave::Status(); //$leaveDuration = Leave::duration();
date_default_timezone_set("Hongkong"); $today = date("Y-m-d"); $todaytime = date(" G:i"); $LID = ""; $CurrentAction = "Insert"; $SubmitFormWithoutWarning = 'true'; $Leave_Assistant = new LeaveAssistant($dbh); $isEditBlock = FALSE;
if ($_GET) { //Get leave_id and action if (isset($_GET['leave_id']) && isset($_GET['action'])) { $LID = $_GET['leave_id']; $CurrentAction = $_GET['action']; //var_dump($CurrentAction); $SubmitFormWithoutWarning = 'false'; } $query = "SELECT createby,createdate,staff_id,reason_id,start_date,end_date,is_approved FROM `leave_app` WHERE `leave_id` = '$LID' and deleted = 0"; $result = $dbh->prepare($query); $result->execute(); while ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) { //var_dump($ResultSet); $get_createby = $ResultSet['createby']; $get_createdate = substr($ResultSet['createdate'], 0, 10); $get_staff_id = $ResultSet['staff_id']; $get_leave_reason = $ResultSet['reason_id']; $get_SDateTime = date_create($ResultSet['start_date']); $get_EDateTime = date_create($ResultSet['end_date']); $get_leave_status = $ResultSet['is_approved']; } }
if ($_POST) { $actived = 1; $deleted = 0; $Previous_Leave_Lesson_Record = array(); $Sdate = $_POST['SDate']; $Stime = $_POST['STime']; $SdateTime = $Sdate . ' ' . $Stime; //var_dump($SdateTime);
$Edate = $_POST['EDate']; $Etime = $_POST['ETime']; $EdateTime = $Edate . ' ' . $Etime; //var_dump($EdateTime); //Delete current record from leave_app table if ($LID != "" && $CurrentAction == "Edit") { ################################## #### Undo All related lesson #### //$query = "SELECT `lesson_id` FROM `leave_lesson` WHERE `leave_id` = '$LID'"; $query = "select `lesson_id`,`leave_lesson_id` from `leave_lesson` where `leave_id`='$LID' and `lesson_id` not in (SELECT `lesson_id` FROM `lesson`l WHERE (concat(l.`date`,' ',l.`start_time`) >= '$SdateTime' OR concat(l.`date`,' ',l.`end_time`) >='$SdateTime') AND (concat(l.`date`,' ',l.`start_time`) <= '$EdateTime' OR concat(l.`date`,' ',l.`end_time`) <='$EdateTime') and l.`actived`=1 and l.`deleted`=0)"; $result = $dbh->prepare($query); $result->execute(); $Related_Lesson_IDs = $result->fetchAll(); // while ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) { foreach ($Related_Lesson_IDs as $RLID) { $UpdateLesson_ID = $RLID['lesson_id']; $UpdateLeaveLesson_id = $RLID['leave_lesson_id']; $Leave_Assistant->undoOneLesson($UpdateLesson_ID); //set to be delete $Leave_Assistant->DeleteLeaveLessonRecord($UpdateLeaveLesson_id); } #### Final Checking of attendance, after delete leave record #### foreach ($Related_Lesson_IDs as $RLID) { $checking_lesson_id = $RLID['lesson_id']; ## Update attendance(state = 1) where student have not leave record ## $Leave_Assistant->UpdateLessonStateNoOtherLeave($checking_lesson_id);
## UpDate staff attendance record ## $query = "UPDATE `lesson_attendance` SET `attendance`=1 WHERE `staff_id` >0 and `actived`=1 and `deleted`=0 and `lesson_id`='$checking_lesson_id' and `staff_id`='$get_staff_id'"; $sth = $dbh->prepare($query); $sth->execute(); } ########################################### #### Deleted the previous Leave Record #### $query = "UPDATE `leave_app` SET `deleted`= '1' WHERE `leave_id` = '$LID'"; $sth = $dbh->prepare($query); $sth->execute(); }
$input_by = $_POST['input_by']; $input_date = date("Y-m-d G:i:s");
$SID = $_POST['staff_name']; $stuID = -1;
$leave_reason = $_POST['leave_type']; //approved or pendding $leave_status = $_POST['leave_status']; //0; $approved_by = -1; $remarks = "";
$query = "INSERT INTO `leave_app`( `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `staff_id`, `stu_linking_id`, `start_date`, `end_date`, `reason_id`, `approve_by`, `is_approved`, `remarks`) VALUES ('$input_by','$input_date','$input_by','$input_date','$actived','$deleted','$SID','$stuID','$SdateTime','$EdateTime','$leave_reason','$approved_by','$leave_status','$remarks')"; $sth = $dbh->prepare($query); if ($SID != "") $sth->execute();
$Current_Leave_Record_ID = ""; $get_leave_app_start_date = ""; $get_leave_app_end_date = ""; $query = "Select `leave_id`,`start_date`,`end_date` from `leave_app` where `createdate`='$input_date' and `lastupdate`='$input_date' and `actived`='$actived' and `deleted`='$deleted' and `staff_id`='$SID' and `stu_linking_id`='$stuID' and `start_date`='$SdateTime' and `end_date`='$EdateTime' and `reason_id`='$leave_reason' and `approve_by`='$approved_by' and `is_approved`='$leave_status' and `remarks`='$remarks' "; $result = $dbh->prepare($query); $result->execute(); while ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) { //var_dump($ResultSet['leave_id']); $Current_Leave_Record_ID = $ResultSet['leave_id']; $get_leave_app_start_date = $ResultSet['start_date']; $get_leave_app_end_date = $ResultSet['end_date']; }
// check ,insert and update related record
$currentProcess_lesson_id = -1; // $query = "select l.start_time,l.end_time,l.date,e.event_code ,l.room_id,l.lesson_id,la.attend_id from lesson l,event_lesson el,event e ,lesson_attendance la where la.actived=1 and la.deleted=0 and l.lesson_id = la.lesson_id and // l.lesson_id in ( SELECT lesson_id FROM `lesson_attendance` WHERE `staff_id`='$SID' and `date`>= '$Sdate' and `date`<= '$Edate' ) and el.lesson_id = l.lesson_id and el.event_id in (select event_id from event // where actived=1 and deleted =0) and e.event_id = el.event_id and (('$Stime' <= l.start_time AND '$Etime' >= l.start_time ) OR ('$Stime' <= l.end_time AND '$Etime' >= l.end_time ) OR ('$Stime' >= l.start_time AND '$Etime'<= l.end_time))"; $query = "SELECT l.`lesson_id`,la.`attend_id` FROM `lesson`as l,`lesson_attendance` as la WHERE (concat(l.`date`,' ',l.`start_time`) >= '$get_leave_app_start_date' OR concat(l.`date`,' ',l.`end_time`) >='$get_leave_app_start_date') AND (concat(l.`date`,' ',l.`start_time`) <= '$get_leave_app_end_date' OR concat(l.`date`,' ',l.`end_time`) <='$get_leave_app_end_date') and la.lesson_id in(select `lesson_id` from `lesson_attendance` where `staff_id`='$SID' and `deleted`=0 and `actived`=1) and la.`actived`=1 and la.`deleted` = 0 and l.`lesson_id`= la.`lesson_id`"; if ($LID != "" && $CurrentAction == "Edit") { $query .= " and l.`lesson_id` not in (select `lesson_id` from `leave_lesson` where `leave_id`='$LID' and `actived`=1 and `deleted`=0)"; } $result = $dbh->prepare($query); $result->execute(); while ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) { $Make_up_lesson_id = 0; $Leave_lesson_id = $ResultSet['lesson_id']; //var_dump($Leave_lesson_id); //var_dump($currentProcess_lesson_id);
$update_lesson_attendance_id = $ResultSet['attend_id']; //Update related student lesson_attendance record $query = "UPDATE `lesson_attendance` SET `state` = 3 WHERE `attend_id` = '$update_lesson_attendance_id' and `stu_linking_id` >0"; $sth = $dbh->prepare($query); $sth->execute();
//Update related staff lesson_attendance record $query = "UPDATE `lesson_attendance` SET `state` = 6, `attendance` = 0 WHERE `attend_id` = '$update_lesson_attendance_id' and `staff_id` >0"; $sth = $dbh->prepare($query); $sth->execute();
if ($currentProcess_lesson_id != $Leave_lesson_id) { $query = "INSERT INTO `leave_lesson`(`leave_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `lesson_id`) VALUES ('$Current_Leave_Record_ID','$input_by','$input_date','$input_by','$input_date','$actived','$deleted','$Leave_lesson_id')"; $sth = $dbh->prepare($query); $sth->execute();
$query = "UPDATE `lesson` SET `lesson_leave_status`= 1 WHERE `lesson_id` = '$Leave_lesson_id'"; $sth = $dbh->prepare($query); $sth->execute(); $currentProcess_lesson_id = $Leave_lesson_id; } }
if ($LID != "" && $CurrentAction == "Edit") { //echo "reinsert leave_lesson: ".$LID; $query = "SELECT `lesson_id` FROM `leave_lesson` WHERE `actived`=1 and `deleted`=0 and `leave_id`='$LID'"; $result = $dbh->prepare($query); $result->execute(); $Previous_Leave_Lesson_Record = $result->fetchAll(PDO::FETCH_ASSOC); //var_dump($Previous_Leave_Lesson_Record); foreach ($Previous_Leave_Lesson_Record as $PLLR) { $Previous_Leave_Lesson_ID = $PLLR['lesson_id']; $query = "INSERT INTO `leave_lesson`(`leave_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `lesson_id`) VALUES ('$Current_Leave_Record_ID','$input_by','$input_date','$input_by','$input_date','$actived','$deleted','$Previous_Leave_Lesson_ID')"; $sth = $dbh->prepare($query); $sth->execute(); } }
$result = ($_GET) ? "Update data successful." : "Insert data successful"; echo "<script>alert('" . $result . "');</script>"; echo "<script>location.href = 'LeaveIndex.php';</script>"; } ?>
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <?php require_once '../include/head.php'; ?> <?php require_once '../include/checkuser.php'; ?> <?php require_once '../include/Nav_bar.php'; ?> <script> var Sdate = null, Edate = null, date; var SubmitForm = <?= $SubmitFormWithoutWarning ?>; var WarningText = "</br>the <b>action</b> of related record done before <b>will undo</b>"; $(function() { $('div input').height(20); //fix size for input box //$('#SDate_id').datetimepicker({pickTime: false, startDate: new Date()}); //$('#EDate_id').datetimepicker({pickTime: false, startDate: new Date()}); $('.date-picker').datetimepicker({pickTime: false, startDate: new Date()}); //$('.time-picker').datetimepicker({pickDate: false}); $('.time-picker').timepicker({'timeFormat': 'H:i', 'step': 5, 'minTime': '6:00', 'maxTime': '22:00'}); //$('.timepicker_end').timepicker({ 'timeFormat': 'H:i','step': 5,'minTime':'6:00','maxTime': '22:00' }); // $('#SDate').val('<?= $today . $todaytime ?>'); //Generate by system // $('#EDate').val('<?= $today . $todaytime ?>'); //Generate by system $("#myselect").select2({ placeholder: "Staff Code", minimumInputLength: 1, allowClear: true }); $("#myselect2").select2({ placeholder: "Staff Name | Code", minimumInputLength: 0, allowClear: true }); var date; $('#SDate_id').datetimepicker().on('changeDate', function(ev) { Sdate = $('#SDate').val(); date = new Date($('#SDate').val()); //alert(date); $('#EDate_id').datetimepicker('setStartDate', date); if ($('#EDate').val() === "") { $('#EDate_id').datetimepicker('setDate', date); $('#EDate_id').datetimepicker('show'); } $('#SDate_id').datetimepicker('hide'); $('#EDate_id').datetimepicker('remove'); }); $('#EDate_id').datetimepicker().on('changeDate', function(ev) { Edate = $('#EDate').val(); date = new Date($('#EDate').val()); //alert($('#SDate').val()); $('#SDate_id').datetimepicker('setEndDate', date); if ($('#SDate').val() === "") { $('#SDate_id').datetimepicker('setDate', date); $('#SDate_id').datetimepicker('show'); } $('#EDate_id').datetimepicker('hide'); }); $("#Staff_Leave_Form").validate({ submitHandler: function(form) { //alert(SubmitForm); if (SubmitForm === false) { bootbox.dialog('<b>Are you sure to Edit this records?</b><br><br><b>Note:</b> If you edit this record, ' + WarningText, [ { 'label': 'Save', 'class': 'btn-danger', 'callback': function() { SubmitForm = true; document.getElementById('Save').click(); } }, { 'label': 'Cancel', 'class': 'btn' } ]); } if (SubmitForm === true) { $('#Save').button('loading'); $(form).ajaxSubmit(); } } }); });
function limit_time(e) { var clearValue = false; if ($('#SDate').val() === "") { document.getElementById("SDate").focus(); $('#SDate_id').datetimepicker('show'); clearValue = true; } else if ($('#EDate').val() === "") { document.getElementById("EDate").focus(); $('#EDate_id').datetimepicker('show'); clearValue = true; } else { if ($('#SDate').val() === $('#EDate').val()) { if (e === document.getElementById('STime')) { var arr = $(e).val(); $('#ETime').timepicker('option', {disableTimeRanges: [['6:00', arr]]}); } else if (e === document.getElementById('ETime')) { var arr = $(e).val(); $('#STime').timepicker('option', {disableTimeRanges: [[arr, '22:01']]}); } } } if (clearValue === true) { if (e === document.getElementById('STime')) { $('#STime').val(""); } else if (e === document.getElementById('ETime')) { $('#ETime').val(""); } } }
<?php if ($_GET) { ?> $(function() { //$('#myselect').select2().select2('val', '<?= $get_staff_id ?>'); $('#myselect2').select2().select2('val', '<?= $get_staff_id ?>'); $('#leave_type').val('<?= $get_leave_reason ?>'); $('#SDate').val('<?= date_format($get_SDateTime, 'Y-m-d') ?>'); $('#EDate').val('<?= date_format($get_EDateTime, 'Y-m-d') ?>'); $('#leave_status').val(<?= $get_leave_status ?>); $('#leave_status_display').val('<?= $get_leave_status ?>') $('#delete_btn').click(function() { bootbox.dialog('<b>Are you sure to Delete this records?</b><br><br><b>Note:</b> If you delete this record, ' + WarningText, [ { 'label': 'Delete', 'class': 'btn-danger', 'callback': function() { DeleteID = <?= $LID ?>; Target = 0; $.ajax({ url: 'delete/delete.php', //This is the current doc type: "POST", data: {Data: DeleteID, Target: Target}, success: function(data) { var obj = $.parseJSON(data); location.href = 'LeaveIndex.php'; //reload this page }
}); } }, { 'label': 'Cancel', 'class': 'btn' } ]); }); }); <?php } ?>
function UndoButtonUnavailable(isMakeUpChain, isInvoiceGened, isPayrollGened, isUsedByOtherLeave) { var content = ""; if (isMakeUpChain!=="") content += "<br> - Having another make up lesson "+isMakeUpChain+" arranged for this lesson"; if (isInvoiceGened) content += "<br> - Student in this lesson have generated invoice"; if (isPayrollGened) content += "<br> - Teacher in this lesson have generated payroll"; if (isUsedByOtherLeave) content += "<br> - This make up lesson have other leave application"; bootbox.dialog('<b>Sorry, The Edit and Delete Button is Unavailable now</b><br><br><b>The reason is:</b>' + content, [ { 'label': 'OK', 'class': 'btn' }, { 'label': 'Cancel', 'class': 'btn' } ]); return false; } </script> </head> <body> <div class="text-right"> <ul class="breadcrumb"> <!--<li><a href="#">Master</a> <span class="divider">></span></li>--> <!-- <li><a href="index.php">Staff</a> <span class="divider">></span></li>--> <li class="active">Leave Application</li> </ul> </div>
<div class="container-fluid pathways-container"> <!--<a class="btn pull-right" <?= ($name != "") ? 'href="historyfrom.php?root_id=' . $RootID . '&action=Insert"' : 'disabled="disabled"' ?> ><i class="icon-plus"></i>Add</a>--> <h2>Staff Application</h2>
<form class="form-horizontal" action="" method="post" id="Staff_Leave_Form" > <div class="control-group"> <?php $attribute = 'input_by'; $label = 'Input By'; ?> <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label> <div class="controls form-inline"> <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="required" value="<?= $_GET ? $get_createby : $_SESSION['MIS_login']['username'] ?>" placeholder="<?= $label ?>" maxlength="200" disabled /> <input type="hidden" id="<?= $attribute ?>" name="<?= $attribute ?>" class="required" value="<?= $_GET ? $get_createby : $_SESSION['MIS_login']['username'] ?>" maxlength="200" <?= $CurrentAction == "View" ? "disabled" : "" ?> /> </div> </div> <div class="control-group"> <?php $attribute = 'input_date'; $label = 'Input Date'; ?> <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label> <div class="controls form-inline"> <div class="input-append date-picker"> <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="dateISO" value="<?= $_GET ? $get_createdate : $today ?>" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" disabled /> <input type="hidden" id="<?= $attribute ?>" name="<?= $attribute ?>" class="dateISO" value="<?= $_GET ? $get_createdate : $today ?>" data-format="yyyy-MM-dd" maxlength="200" <?= $CurrentAction == "View" ? "disabled" : "" ?> /> <!--<span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>--> </div> </div> </div> <!-- <div class="control-group"> <?php $attribute = 'staff_code'; $label = 'Staff Code'; ?> <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label> <div class="controls form-inline"> <select id="myselect" name="<?= $attribute ?>" id="<?= $attribute ?>" style="width:300px"> <option value=""></option> <?php $query = 'SELECT CONCAT( last_name, " ", first_name, "(", ch_name, ")" ) AS name,root_id,staff_code FROM staff WHERE deleted =0 GROUP BY name'; $result = $dbh->prepare($query); $result->execute(); while ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) { ?> <option value="<?= $ResultSet['root_id'] ?>" id="S<?= $ResultSet['root_id'] ?>" ><?= $ResultSet['staff_code'] ?></option> <?php } ?> </select> </div> </div>--> <div class="control-group"> <?php $attribute = 'staff_name'; $label = 'Staff Name | Code'; ?> <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label> <div class="controls form-inline"> <!-- Store the Root ID here, and pass to $_Post after submited --> <input type="hidden" id="TempRootID" name="TempRootID" value="0" /> <select id="myselect2" name="<?= $attribute ?>" id="<?= $attribute ?>" style="width:300px" required <?= $CurrentAction == "View" ? "disabled" : "" ?> > <option value=""></option> <?php $query = 'SELECT CONCAT( last_name, " ", first_name, "(", ch_name, ")" ) AS name,root_id,staff_code FROM staff WHERE deleted =0 GROUP BY name'; $result = $dbh->prepare($query); $result->execute(); while ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) { ?> <option value="<?= $ResultSet['root_id'] ?>" id="S<?= $ResultSet['root_id'] ?>" ><?= $ResultSet['name'] . ' | ' . $ResultSet['staff_code'] ?></option> <?php } ?> </select> <?php $attribute = 'zh_name'; $label = '中文姓名'; ?> <!--<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="" value="" placeholder="<?= $label ?>" maxlength="200" />--> </div> </div> <div class="control-group"> <?php $attribute = 'leave_type'; $label = 'Leave Type'; ?> <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label> <div class="controls form-inline"> <select id="<?= $attribute ?>" name="<?= $attribute ?>" class="" placeholder="<?= $label ?>" <?= $CurrentAction == "View" ? "disabled" : "" ?> > <!--<option value=""></option>--> <?php foreach ($leaveType as $leaveValue => $leaveLabel) { ?> <option value="<?= $leaveValue ?>"><?= $leaveLabel ?></option> <?php } ?> </select> </div> </div> <div class="control-group"> <?php $attribute = 'SDate'; $label = 'Start Date'; ?> <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label> <div class="controls form-inline"> <div class="input-append date-picker" id="SDate_id"> <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="dateISO" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" value="<?= $_GET ? date_format($get_SDateTime, 'Y-m-d') : '' ?>" required <?= $CurrentAction == "View" ? "disabled" : "" ?> /> <?php if ($CurrentAction != "View") { ?> <span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span> <?php } ?> </div> <?php $attribute = 'EDate'; $label = 'End Date'; ?> <label class="control-label" style="float:none;" for="<?= $attribute ?>" ><?= $label ?></label> <div class="input-append date-picker" id="EDate_id"> <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" style="margin-left:20px" class="dateISO" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" value="<?= $_GET ? date_format($get_EDateTime, 'Y-m-d') : '' ?>" required <?= $CurrentAction == "View" ? "disabled" : "" ?> /> <?php if ($CurrentAction != "View") { ?> <span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span> <?php } ?> </div>
</div> </div> <div class="control-group"> <?php $attribute = 'STime'; $label = 'Start Time'; ?> <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label> <div class="controls form-inline"> <!--<div class="input-append time-picker" id="STime_id">--> <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="time-picker" data-format="hh:mm" placeholder="<?= $label ?>" maxlength="200" onchange="limit_time(this);" value="<?= $_GET ? date_format($get_SDateTime, 'G:i') : '' ?>" required <?= $CurrentAction == "View" ? "disabled" : "" ?> /> <!--<span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>--> <!--</div>-->
<?php $attribute = 'ETime'; $label = 'End Time'; ?> <label class="control-label" style="float:none" for="<?= $attribute ?>" ><?= $label ?></label> <!--<div class="input-append time-picker" id="ETime_id">--> <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" style="margin-left:20px" class="time-picker" data-format="hh:mm" placeholder="<?= $label ?>" maxlength="200" onchange="limit_time(this);" value="<?= $_GET ? date_format($get_EDateTime, 'G:i') : '' ?>" required <?= $CurrentAction == "View" ? "disabled" : "" ?> /> <!-- <span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>--> <!--</div>--> </div> </div> <input type="hidden" name="leave_status" id="leave_status" value="0" /> <?php if ($CurrentAction == "View") { ?> <div class="control-group"> <?php $attribute = 'leave_status_display'; $label = 'Leave Status'; ?> <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label> <div class="controls form-inline"> <select id="<?= $attribute ?>" name="<?= $attribute ?>" class="" placeholder="<?= $label ?>" <?= $CurrentAction == "View" ? "disabled" : "" ?> > <option value=""></option> <?php foreach ($leaveStatus as $lsValue => $lsLabel) { ?> <option value="<?= $lsValue ?>"><?= $lsLabel ?></option> <?php } ?> </select> </div> </div> <?php } ?> <!-- <div class="control-group"> <?php $attribute = 'leave_duration'; $label = 'Leave Duration'; ?> <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label> <div class="controls form-inline"> <select id="<?= $attribute ?>" name="<?= $attribute ?>" class="" placeholder="<?= $label ?>"> <option value=""></option> <?php foreach ($leaveDuration as $ldValue => $ldLabel) { ?> <option value="<?= $ldValue ?>"><?= $ldLabel ?></option> <?php } ?> </select> </div> </div>--> <!-- <div class="control-group"> <?php $attribute = 'leave_status'; $label = 'Leave Status'; ?> <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label> <div class="controls form-inline"> <select id="<?= $attribute ?>" name="<?= $attribute ?>" class="" placeholder="<?= $label ?>"> <option value=""></option> <?php foreach ($leaveStatus as $lsValue => $lsLabel) { ?> <option value="<?= $lsValue ?>"><?= $lsLabel ?></option> <?php } ?> </select> </div> </div>--> <hr> <?php if ($CurrentAction == "View") { $query = "SELECT l.start_time, l.end_time, l.date, e.event_code, e.event_id, l.room_id, l.lesson_id ,l.lesson_leave_status FROM lesson l, event_lesson el, event e, lesson_attendance la , leave_lesson ll WHERE la.actived =1 AND la.deleted =0 AND l.lesson_id = la.lesson_id AND l.lesson_id = ll.lesson_id AND ll.deleted = '0' and ll.leave_id = '$LID' and la.staff_id = '$get_staff_id' AND el.lesson_id = l.lesson_id AND el.event_id IN ( SELECT event_id FROM event WHERE actived =1 AND deleted =0 ) AND e.event_id = el.event_id"; $result = $dbh->prepare($query); $result->execute(); $staffs_Leave_Lesson_Record = $result->fetchAll(); ?> <table class="table table-striped table-bordered table-hover table-condensed" style="width:100%" > <thead> <tr> <th style="width:10%" >Date</th> <th style="width:10%" >Time</th> <th style="width:10%" >Program</th> <th style="width:10%" >Subject</th> </tr> </thead> <tbody> <?php foreach ($staffs_Leave_Lesson_Record as $SLLRecord) { //var_dump($SLLRecord); $current_lesson_id = $SLLRecord['lesson_id']; $isButtonAvailable = $Leave_Assistant->isUndoButtonAvailable($current_lesson_id); if ($isButtonAvailable['available'] == FALSE) { $isEditBlock = TRUE; $onclickListener = "UndoButtonUnavailable('" . $isButtonAvailable['isLessonInMakeUpChain'] . "','" . $isButtonAvailable['isLessonInvoiceGened'] . "','" . $isButtonAvailable['isLessonPayrollGened'] . "','" . $isButtonAvailable['isMakeUpLessonUsed'] . "')"; } ?> <tr> <td> <?php print '<b>' . $SLLRecord['date'] . '</b>'; ?> </td> <td> <?php $get_Stime = date_create($SLLRecord['start_time']); $get_Etime = date_create($SLLRecord['end_time']); print date_format($get_Stime, 'H:i') . '-' . date_format($get_Etime, 'H:i') ?> </td> <td> <?php print $SLLRecord['event_code'] ?> </td> <td> <?php print $SLLRecord['room_id'] ?> </td> <!-- <td> </td> <td> </td>--> </tr> <?php } ?> </tbody> </table> <?php } if ($CurrentAction != "View") { ?> <button class="btn btn-danger" data-loading-text="Loading..." id="Save" >Save</button> <?php if ($CurrentAction == "Edit") { print '<button class="btn btn-danger" style="margin-left:5px" id="delete_btn" type="button" onclick="deleteRecord()">Delete</button>'; } } else {
if ($isEditBlock == TRUE) { ?> <button class="btn btn-danger" style="margin-left:5px" id="" type="button" onclick="return <?= $onclickListener ?>" >Edit</button> <?php } else { print '<a href="Staff_App_Form.php?leave_id=' . $LID . '&action=Edit" class="btn btn-danger" >Edit</a>'; } } ?> <button class="btn btn-danger" type="button" onclick="history.back();" >Back</button> </form> </div> </body> </html>
|