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
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
|
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <?php require_once '../include/head.php'; require_once '../include/checkuser.php'; require_once '../include/Nav_bar.php'; include_once '../include/DBConnect.php'; if (isset($_POST['generate1']) && $_POST['generate1'] == 'Generate') { //$root_id = $_POST['root_id']; //this is root id $sch_id = $_POST['sch_id']; $invoice_date = $_POST['invoice_date']; $event_code = $_POST['event_code']; $total_price = $_POST['total_price']; $total_discount = $_POST['total_discount']; $total_amount = $_POST['total_amount']; $funding_type = $_POST['funding_type']; $desc = $_POST['desc'];
$curr_yr = date("Y"); $curr_mon = date("M"); if ($curr_mon < 9) { $curr_yr--; } $curr_yr = substr($curr_yr, 2);
$query_no_of_invocie = "Select count(*) as no_of_invoice from invoice"; $result_no_of_invoice = $dbh->query($query_no_of_invocie); $result_no_of_invoice->setFetchMode(PDO::FETCH_OBJ); $no_of_invoice = $result_no_of_invoice->fetch()->no_of_invoice; $no_of_invoice++; $prog_code = substr($event_code, 0, 2); if ($no_of_invoice < 10) $temp_code = '000'; else if ($no_of_invoice < 100) $temp_code = '00'; else if ($no_of_invoice < 1000) $temp_code = '0'; $invoice_code = "KL" . $prog_code . $curr_yr . $temp_code . $no_of_invoice;
echo "<script>alert('Invoice Code :" . $invoice_code . "')</script>";
$query = "Insert into invoice set invoice_code='$invoice_code',root_id='0',createby=0,createdate=Now(),lastupby=0,lastupdate=Now(),actived=1,deleted=0, school_id='$sch_id',event_code='$event_code',invoice_date='$invoice_date',funding_type='$funding_type',total_original_fee='$total_price', total_discount_fee='$total_discount',total_amount='$total_amount',description='$desc'"; $result = $dbh->query($query); if (!$result) { echo '<script>alert("Error2.1 .")</script>'; } $query_get_invoice_id = "Select Max(invoice_id) as i_id from invoice where school_id='$sch_id' and event_code='$event_code' and deleted=0"; $result_get_invoice_id = $dbh->query($query_get_invoice_id); $result_get_invoice_id->setFetchMode(PDO::FETCH_OBJ); $invoice_id = $result_get_invoice_id->fetch()->i_id; $query3 = "Update invoice set root_id='$invoice_id' where invoice_id='$invoice_id'"; $dbh->query($query3);
if (isset($_POST['activity_id'])) { for ($j = 0; $j < count($_POST['activity_id']); $j++) { $activity_id = $_POST['activity_id'][$j]; //$price = $_POST['price'][$j]; //$discount = $_POST['discount'][$j]; $amount = $_POST['amount'][$j]; $hr = $_POST['hours'][$j]; if (isset($_POST['is_charge'][$j])) $is_charge = 0; else $is_charge = 1; $query1 = "Insert into invoice_line set createby=0,createdate=Now(),lastupby=0,lastupdate=Now(), actived=1,deleted=0,invoice_id='$invoice_id',activity_id='$activity_id',amount='$amount', hour='$hr',subsidy_percent='0',is_charge='$is_charge',remarks=''";
$result1 = $dbh->query($query1); if (!$result1) { echo '<script>alert("Error1 .")</script>'; }
$query2 = "Update activity_stu_list set invoice_gened=1 where activity_id='$activity_id' and deleted=0"; $result2 = $dbh->query($query2); if (!$result2) { echo '<script>alert("Error2 .")</script>'; } } } if (isset($_POST['activity_id'])) { $no_of_act = count($_POST['activity_id']); } else { $no_of_act = 0; } $i = $_POST['i']; $i-=$no_of_act; for ($j = 0; $j < $i; $j++) { $lesson_id = $_POST['lesson_id'][$j]; $j+=$no_of_act; $amount = $_POST['amount'][$j]; $hr = $_POST['hours'][$j]; if (isset($_POST['is_charge'][$j])) { $is_charge = 0; } else { $is_charge = 1; } $query1 = "Insert into invoice_line set createby=0,createdate=Now(),lastupby=0,lastupdate=Now(), actived=1,deleted=0,invoice_id='$invoice_id',lesson_id='$lesson_id',amount='$amount', hour='$hr',subsidy_percent='0',is_charge='$is_charge',remarks=''";
$result1 = $dbh->query($query1); if (!$result1) { echo '<script>alert("Error1 .")</script>'; }
$query2 = "Update lesson_attendance set invoice_gened=1 where lesson_id='$lesson_id' and deleted=0"; $result2 = $dbh->query($query2);
if (!$result2) { echo '<script>alert("Error2 .")</script>'; } $j-=$no_of_act; } echo '<script>alert("Generate invoice successful.")</script>'; echo("<script>location.href ='invoice.php';</script>"); }
if (isset($_POST['generate']) && $_POST['generate'] == 'Generate') { $root_id = $_POST['root_id']; //this is root id $invoice_date = $_POST['invoice_date']; $event_code = $_POST['event_code']; $total_price = $_POST['total_price']; $total_discount = $_POST['total_discount']; $total_amount = $_POST['total_amount']; $funding_type = $_POST['funding_type'];
$curr_yr = date("Y"); $curr_mon = date("M"); if ($curr_mon < 9) { $curr_yr--; } $curr_yr = substr($curr_yr, 2); $query_no_of_invocie = "Select count(*) as no_of_invoice from invoice"; $result_no_of_invoice = $dbh->query($query_no_of_invocie); $result_no_of_invoice->setFetchMode(PDO::FETCH_OBJ); $no_of_invoice = $result_no_of_invoice->fetch()->no_of_invoice; $no_of_invoice++; $prog_code = substr($event_code, 0, 2); if ($no_of_invoice < 10) $temp_code = '000'; else if ($no_of_invoice < 100) $temp_code = '00'; else if ($no_of_invoice < 1000) $temp_code = '0'; $invoice_code = "KL" . $prog_code . $curr_yr . $temp_code . $no_of_invoice;
echo "<script>alert('Invoice Code :" . $invoice_code . "')</script>";
//invoice data $query = "Insert into invoice set invoice_code='$invoice_code',root_id='0',createby=0,createdate=Now(),lastupby=0,lastupdate=Now(),actived=1,deleted=0, stu_linking_id='$root_id',event_code='$event_code',invoice_date='$invoice_date',funding_type='$funding_type',total_original_fee='$total_price', total_discount_fee='$total_discount',total_amount='$total_amount'"; $result = $dbh->query($query); if (!$result) { echo '<script>alert("Error1 .")</script>'; } $query_get_invoice_id = "Select Max(invoice_id) as i_id from invoice where stu_linking_id='$root_id' and event_code='$event_code' and deleted=0"; $result_get_invoice_id = $dbh->query($query_get_invoice_id); $result_get_invoice_id->setFetchMode(PDO::FETCH_OBJ); $invoice_id = $result_get_invoice_id->fetch()->i_id; $query3 = "Update invoice set root_id='$invoice_id' where invoice_id='$invoice_id'"; $dbh->query($query3); //insert invoice here
if (isset($_POST['activity_id'])) { for ($j = 0; $j < count($_POST['activity_id']); $j++) { $activity_id = $_POST['activity_id'][$j]; $fee_type = $_POST['fee_type'][$j]; $price = $_POST['price'][$j]; $attendance = $_POST['attendance'][$j]; $discount = $_POST['discount'][$j]; $amount = $_POST['amount'][$j]; $hr = $_POST['hours'][$j]; if (isset($_POST['is_charge'][$j])) $is_charge = 0; else $is_charge = 1; $type = $_POST['type'][$j]; $type_rate = $_POST['type_rate'][$j]; if ($type == 1) { $query1 = "Insert into invoice_line set createby=0,createdate=Now(),lastupby=0,lastupdate=Now(), actived=1,deleted=0,invoice_id='$invoice_id',activity_id='$activity_id',event_programme_fee_type='$fee_type', discount_type='$type',original_fee='$price',discounted_fee='$discount',amount='$amount', hour='$hr',subsidy_percent='$type_rate',is_charge='$is_charge',remarks=''"; } else { $query1 = "Insert into invoice_line set createby=0,createdate=Now(),lastupby=0,lastupdate=Now(), actived=1,deleted=0,invoice_id='$invoice_id',lesson_id='$lesson_id',event_programme_fee_type='$fee_type', discount_type='$type',original_fee='$price',discounted_fee='$discount',amount='$amount', hour='$hr',subsidy_percent='0',is_charge='$is_charge',remarks=''"; } $result1 = $dbh->query($query1); if (!$result1) { echo '<script>alert("Error1 .")</script>'; } $query2 = "Update activity_stu_list set invoice_gened=1 where activity_id='$activity_id' and stu_linking_id='$root_id'"; $result2 = $dbh->query($query2); if (!$result2) { echo '<script>alert("Error2 .")</script>'; } } } if (isset($_POST['activity_id'])) { $no_of_act = count($_POST['activity_id']); } else { $no_of_act = 0; } $i = $_POST['i']; $i-=$no_of_act; for ($j = 0; $j < $i; $j++) { $lesson_id = $_POST['lesson_id'][$j]; $attendance = $_POST['attendance'][$j]; $fee_type = $_POST['fee_type'][$j]; $j+=$no_of_act; $price = $_POST['price'][$j]; $discount = $_POST['discount'][$j]; $amount = $_POST['amount'][$j]; $hr = $_POST['hours'][$j]; if (isset($_POST['is_charge'][$j])) $is_charge = 0; else $is_charge = 1; $type = $_POST['type'][$j]; $type_rate = $_POST['type_rate'][$j]; if ($type == 1) { $query1 = "Insert into invoice_line set createby=0,createdate=Now(),lastupby=0,lastupdate=Now(), actived=1,deleted=0,invoice_id='$invoice_id',lesson_id='$lesson_id',event_programme_fee_type='$fee_type', discount_type='$type',original_fee='$price',discounted_fee='$discount',amount='$amount', hour='$hr',subsidy_percent='$type_rate',is_charge='$is_charge',remarks=''"; } else { $query1 = "Insert into invoice_line set createby=0,createdate=Now(),lastupby=0,lastupdate=Now(), actived=1,deleted=0,invoice_id='$invoice_id',lesson_id='$lesson_id',event_programme_fee_type='$fee_type', discount_type='$type',original_fee='$price',discounted_fee='$discount',amount='$amount', hour='$hr',subsidy_percent='0',is_charge='$is_charge',remarks=''"; } $result1 = $dbh->query($query1); if (!$result1) { echo '<script>alert("Error1 .")</script>'; } $query2 = "Update lesson_attendance set invoice_gened=1 where lesson_id='$lesson_id' and stu_linking_id='$root_id'"; $result2 = $dbh->query($query2); if (!$result2) { echo '<script>alert("Error2 .")</script>'; } $j-=$no_of_act; } echo '<script>alert("Generate invoice successful.")</script>'; echo("<script>location.href = 'invoice.php';</script>"); } ?> <script> function cal_total() { var i = $('#i').val(); var total_amount = 0; for (var j = 0; j < i; j++) { //var obj=getElementById('lesson_'+j); //if (obj.checked) { var temp_amount = parseFloat($('#amount_' + j).val()); total_amount += temp_amount; //} } $('#total_amount').val(total_amount); } ; function cal_discount() { var i = $('#i').val(); var total_discount = 0; for (var j = 0; j < i; j++) { //var obj=getElementById('lesson_'+j); //if (obj.checked) { var temp_discount = parseFloat($('#discount_' + j).val()); total_discount += temp_discount; //} } $('#total_discount').val(total_discount); } ; $(function() { $('.date-picker').datetimepicker({pickTime: false, format: 'yyyy-MM-dd'}); }); function change_discount(obj) { //alert(obj.id); var target_id = obj.id; var target_i = target_id.split('_')[1];
$.ajax({ type: "POST", url: "ajax_invoice.php", data: { type: $('#type_' + target_i).val(), linking_id: $('#linking_id').val() }, cache: false, success: function(html) { if ($('#type_' + target_i).val() == 1) {//subsidy $('#typerate_' + target_i).val(html); var fee = $('#price_' + target_i).val() * (1 - (html / 100));//fee=amount wrong naming in the very first beginning var discount = $('#price_' + target_i).val() * ((html / 100)); $('#amount_' + target_i).val(fee); $('#discount_' + target_i).val(discount); $('#typerate_' + target_i).attr("readonly", true); cal_total(); cal_discount(); } else { if ($('#type_' + target_i).val() == 2) {//package_discount $('#typerate_' + target_i).val(html); $('#discount_' + target_i).val(html); var fee = $('#price_' + target_i).val() - html; $('#amount_' + target_i).val(fee); $('#typerate_' + target_i).attr("readonly", true); cal_total(); cal_discount(); } } } }); } function in_sch_change_amount(obj) { var target_id = obj.id; var target_i = target_id.split('_')[1]; var fee = $('#temp_' + target_i).val();//fee=amount wrong naming in the very first beginning fee = parseFloat(fee); $('#amount_' + target_i).val(fee); cal_total(); } function not_charge(obj) { var target_id = obj.id; var target_i = target_id.split('_')[1]; if (obj.checked) { $('#typerate_' + target_i).val(0); $('#discount_' + target_i).val(0); $('#amount_' + target_i).val(0); $('#type_' + target_i).attr('disabled', true); cal_total(); cal_discount(); } else { change_discount(obj); $('#type_' + target_i).attr('disabled', false); } } ; function in_school_not_charge(obj) { var target_id = obj.id; var target_i = target_id.split('_')[1]; if (obj.checked) { $('#amount_' + target_i).val(0); cal_total(); } else { in_sch_change_amount(obj); cal_total(); } } ; function funding(obj) { var target_id = obj.id; var target_i = target_id.split('_')[1]; var type_rate = $('#typerate_' + target_i).val(); var price = $('#price_' + target_i).val(); var fee = price - type_rate;//typerate_ $('#discount_' + target_i).val(type_rate); $('#amount_' + target_i).val(fee); cal_total(); cal_discount(); } ; function selected(obj) { var target_id = obj.id; var target_i = target_id.split('_')[1]; if (obj.checked == true) { /*if ($('#is_charge_' + target_i).checked == true) { $('#type_' + target_i).attr('disabled', false); $('#charge_' + target_i).attr('disabled', false); //change_discount(obj); $('#discount_' + target_i).val(0); $('#amount_' + target_i).val(0); cal_total(); cal_discount(); } else {*/ var charge = document.getElementById('charge_' + target_i); $('#type_' + target_i).attr('disabled', false); $('#charge_' + target_i).attr('disabled', false); if (charge.checked==true) { $('#typerate_' + target_i).val(0); $('#discount_' + target_i).val(0); $('#amount_' + target_i).val(0); } else { change_discount(obj); } cal_total(); cal_discount(); //} } else { $('#type_' + target_i).attr('disabled', true); $('#charge_' + target_i).attr('disabled', true); $('#discount_' + target_i).val(0); $('#amount_' + target_i).val(0); cal_total(); cal_discount(); } } $(document).ready(function() { $('#start_date').datetimepicker().on('changeDate', function(ev) { date = new Date($('#start_date_input').val()); $('#end_date').datetimepicker('setStartDate', date); $('#end_date').datetimepicker('setDate', date); $('#end_date').datetimepicker('show'); $('#start_date').datetimepicker('hide'); $('#end_date').datetimepicker('remove'); }); $('#end_date').datetimepicker().on('changeDate', function(ev) { $('#end_date').datetimepicker('hide'); }); }); </script> </head> <body> <!-- line between nav bar and content --> <div class="text-right"> <ul class="breadcrumb"> <li class="active"></li> </ul> </div> <!-- line between nav bar and content --> <div class="container-fluid pathways-container"> <?php if (isset($_POST['select1']) && $_POST['select1'] == "Select") { //in-school invoice $percent = 0; $id = $_POST['id']; $temp_id = explode("|", $id); $sch_id = $temp_id[1]; $event_id = $temp_id[0]; $from_date = $_POST['from_date']; $to_date = $_POST['to_date']; ?> <form action="" method="POST" class="form-inline"> <table border="0" class="table table-striped table-bordered table-hover table-condensed" width="100%"> <?php $query = "Select DATE_FORMAT(l.date, '%W') as weekday,e.event_id,e.event_code,e.school_id,l.lesson_id,l.start_time,l.end_time,l.date,stu.first_name,stu.last_name,stu.linking_id,stu.root_id,stu.New_stu_ID as id,e.programme_fee_type,e.program_id,e.subject_id,e.primary_individual_price,e.primary_group_price,e.secondary_individual_price,e.secondary_group_price, e.primary_package_price,e.secondary_package_price,g.grade,la.attendance ,sch.school_id,sch.sch_name,sch.sch_ch_name,e.program_id,e.subject_id,sub.sub_name,prog.program_name from event as e, lesson_attendance as la,student_grade as sg,grade as g, school as sch,subject as sub,program as prog, student as stu,lesson as l,event_lesson as el where e.event_id=el.event_id and sub.subject_id=e.subject_id and prog.program_id=e.program_id and el.lesson_id=l.lesson_id and l.lesson_id=la.lesson_id and sg.student_grade_id=stu.linking_id and sg.grade_id=g.grade_id and stu.root_id=la.stu_linking_id and sg.student_grade_id=stu.linking_id and sg.grade_id=g.grade_id and sch.school_id=e.school_id and e.deleted=0 and e.actived=1 and la.deleted=0 and la.actived=1 and stu.deleted=0 and stu.actived=1 and l.deleted=0 and l.actived=1 and el.deleted=0 and el.actived=1 and la.invoice_gened=0 and e.event_id='$event_id' and e.school_id='$sch_id' and l.date>='$from_date' and l.date<='$to_date' group by l.lesson_id"; $result = $dbh->query($query); //get invoice data if ($result) { $result->setFetchMode(PDO::FETCH_OBJ); $total_price = 0.0; $total_discount = 0.0; $total_amount = 0.0; $total_hr = 0.0; $i = 0;
while ($row = $result->fetch()) { if ($i == 0) { ?> <tr> <td colspan="6"><center><h3>INVOICE</h3></center></td> </tr> <tr> <td>Bill To:</td> <td colspan="2"> <input type="text" name="bill_to" required="true" value="<?= $row->sch_name ?>" readonly="true"> <input type="hidden" name="sch_id" id="sch_id" value="<?= $row->school_id ?>"> </td> <td>Invoice Date:</td> <td colspan="3"> <div class="input-append date-picker"> <input type="text" name="invoice_date" class="dateISO" required='true'> <span class="add-on"> <i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i> </span> </div> </td> </tr> <tr> <td>Program-Subject</td> <td colspan="2"><input type="text" name="prog_sub" value="<?= $row->program_name . '-' . $row->sub_name ?>" readonly="true"></td> <td>Event Code:</td> <td colspan="3"><input type="text" name="event_code" value="<?= $row->event_code ?>" readonly="true"></td> </tr> <tr> <td colspan="1">Funding Type</td> <td colspan="6"> <select name="funding_type"> <option value="0">No Funding</option> <?php $query_funding = "Select funding_id,funding_type from funding where deleted=0 and actived=1"; $result_funding = $dbh->query($query_funding); $result_funding->setFetchMode(PDO::FETCH_OBJ); while ($row_funding = $result_funding->fetch()) { ?> <option value="<?= $row_funding->funding_id ?>"><?= $row_funding->funding_type ?></option> <?php } ?> </select> </td> </tr> <tr> <th>Date</th> <th>Time from</th> <th>Time to</th> <th>Hour(s)</th> <th>Not Charge?</th> <th>Amount($)</th> </tr> <?php //activity $query_activity = "Select DATE_FORMAT(act.date, '%W') as weekday,e.event_id,act.activity_id,act.start_time,act.end_time,act.payment,act.date from activity as act,activity_stu_list as act_stu,event as e, lesson_attendance as la,student_grade as sg,grade as g, school as sch,subject as sub,program as prog, student as stu,lesson as l,event_lesson as el where act.activity_id=act_stu.activity_id and e.event_id=act.event_id and e.event_id=el.event_id and sub.subject_id=e.subject_id and prog.program_id=e.program_id and el.lesson_id=l.lesson_id and l.lesson_id=la.lesson_id and sg.student_grade_id=stu.linking_id and sg.grade_id=g.grade_id and stu.root_id=la.stu_linking_id and sg.student_grade_id=stu.linking_id and sg.grade_id=g.grade_id and sch.school_id=e.school_id and act.deleted=0 and act.actived=1 and e.deleted=0 and e.actived=1 and la.deleted=0 and la.actived=1 and stu.deleted=0 and stu.actived=1 and l.deleted=0 and l.actived=1 and el.deleted=0 and el.actived=1 and act_stu.invoice_gened=0 and la.invoice_gened=0 and e.event_id='$event_id' and e.school_id='$sch_id' and l.date>='$from_date' and l.date<='$to_date' group by act.activity_id"; $result_activity = $dbh->query($query_activity); $result_activity->setFetchMode(PDO::FETCH_OBJ); while ($row_activity = $result_activity->fetch()) { $query_get_stu = "Select count(*) as no_of_stu from activity_stu_list where activity_id='$row_activity->activity_id'"; $result_get_stu = $dbh->query($query_get_stu); $result_get_stu->setFetchMode(PDO::FETCH_OBJ); $no_of_stu = $result_get_stu->fetch()->no_of_stu; //cal amount and hr
$hour = (round((strtotime($row->end_time) - strtotime($row->start_time)) / 3600, 2)); $price = $no_of_stu * $row_activity->payment * $hour; $amount = $price; $total_price += $price; $total_amount += $amount; $total_hr+=$hour; ?> <tr> <td><input type="hidden" name="activity_id[]" id="activity_<?= $i ?>" value="<?= $row_activity->activity_id ?>" onclick="//selected(this);"> <?= $row_activity->date . '(' . $row_activity->weekday . ')' ?><input type="hidden" name="date[]" value="<?= $row_activity->date ?>"></td> <td><?= $row_activity->start_time ?><input type="hidden" name="start_time[]" value="<?= $row_activity->start_time ?>"></td> <td><?= $row_activity->end_time ?><input type="hidden" name="end_time[]" value="<?= $row_activity->end_time ?>"></td> <td><?= $hour ?><input type="hidden" name="hours[]" value="<?= $hour ?>"></td> <td><input type="checkbox" name="is_charge[]" id="charge_<?= $i ?>" onclick="in_school_not_charge(this);" value="1"></td> <td> <input type="text" name="amount[]" id='amount_<?= $i ?>' value="<?= $amount ?>" readonly="true"> <input type="hidden" name="temp_amount[]" id="temp_<?= $i ?>" value="<?= $amount ?>"> </td> </tr> <?php $i++; } } $query4 = "Select Max(invoice_id) as i from invoice"; $result4 = $dbh->query($query4); $result4->setFetchMode(PDO::FETCH_OBJ); $row4 = $result4->fetch(); $query5 = "Select count(*) as no_of_stu from lesson_attendance where lesson_id ='$row->lesson_id' and deleted=0 and actived=1 group by lesson_id"; $result5 = $dbh->query($query5); $result5->setFetchMode(PDO::FETCH_OBJ); $row5 = $result5->fetch();
$hour = (round((strtotime($row->end_time) - strtotime($row->start_time)) / 3600, 2)); $price = $row->primary_individual_price * $hour; $amount = $price; $total_price += $price; $total_amount += $amount; $total_hr+=$hour; ?> <tr> <td><input type="hidden" name="lesson_id[]" id="lesson_<?= $i ?>" value="<?= $row->lesson_id ?>" checked> <?= $row->date . '(' . $row->weekday . ')' ?><input type="hidden" name="date[]" value="<?= $row->date ?>"></td> <td><?= $row->start_time ?><input type="hidden" name="start_time[]" value="<?= $row->start_time ?>"></td> <td><?= $row->end_time ?><input type="hidden" name="end_time[]" value="<?= $row->end_time ?>"></td> <td><?= $hour ?><input type="hidden" name="hours[]" value="<?= $hour ?>"></td> <td><input type="checkbox" name="is_charge[]" id="charge_<?= $i ?>" onclick="in_school_not_charge(this);" value="1"></td> <td> <input type="text" name="amount[]" id='amount_<?= $i ?>' value="<?= $amount ?>" readonly="true"> <input type="hidden" name="temp_amount[]" id="temp_<?= $i ?>" value="<?= $amount ?>"> </td> </tr> <?php $i++; }//end while loop ?> <tr> <td> </td> <td> </td> <td> Total price:<?= $total_price ?><input type="hidden" name="total_price" value='<?= $total_price ?>'> <input type='hidden' name='total_discount' id='total_discount' value='<?= $total_discount ?>'> </td> <td>Total hours:<input type="text" name="desc" readonly="true" value="<?= $total_hr ?> hour(s)"></td> <td> </td> <td> Total amount:<br><input type='text' name='total_amount' id='total_amount' value='<?= $total_amount ?>' readonly='true'> <input type="hidden" name="i" id="i" value="<?= $i ?>"> </td> </tr> </table> <input type="button" value="Cancel" class="btn" onclick="window.history.go(-1);"/> <input type="submit" name="generate1" value="Generate" class="btn"> </form> <?php }//end result's if } else { if (isset($_POST['select']) && $_POST['select'] == "Select") { $percent = 0; $id = $_POST['id']; $temp_id = explode("|", $id); $stu_id = $temp_id[1]; $event_id = $temp_id[0]; $from_date = $_POST['from_date']; $to_date = $_POST['to_date']; //echo $from_date.' '.$to_date; ?> <form action="" method="POST" class="form-inline"> <table border="0" class="table table-striped table-bordered table-hover table-condensed" width="100%"> <?php $query = "Select DATE_FORMAT(l.date, '%W') as weekday,e.event_id,e.event_code,l.lesson_id,l.start_time,l.end_time,l.date,stu.first_name, stu.last_name,stu.linking_id,stu.root_id, e.programme_fee_type,e.program_id,e.subject_id,sub.sub_name,prog.program_name, e.primary_individual_price,e.primary_group_price,e.secondary_individual_price,e.secondary_group_price, e.primary_package_price,e.secondary_package_price,g.grade,la.attendance,la.package_discount,la.is_charge from event as e, lesson_attendance as la,student_grade as sg,grade as g,subject as sub,program as prog, student as stu,lesson as l,event_lesson as el where e.event_id=el.event_id and el.lesson_id=l.lesson_id and l.lesson_id=la.lesson_id and sg.student_grade_id=stu.linking_id and sg.grade_id=g.grade_id and stu.root_id=la.stu_linking_id and sg.student_grade_id=stu.linking_id and sg.grade_id=g.grade_id and sub.subject_id=e.subject_id and prog.program_id=e.program_id and e.deleted=0 and e.actived=1 and sg.deleted=0 and sg.actived=1 and g.deleted=0 and g.actived=1 and la.deleted=0 and la.actived=1 and stu.deleted=0 and stu.actived=1 and l.deleted=0 and l.actived=1 and el.deleted=0 and el.actived=1 and stu.linking_id='$stu_id' and l.date>='$from_date' and l.date<='$to_date' and e.event_id='$event_id'"; $result = $dbh->query($query); //get invoice data if ($result) { $result->setFetchMode(PDO::FETCH_OBJ); $total_price = 0.0; $total_discount = 0.0; $total_amount = 0.0; $total_hr=0; $i = 0;
while ($row = $result->fetch()) { $query1 = "Select ss.stu_subsidy_id,s.percent as sum_p from student_subsidy as ss, subsidy as s where ss.subsidy_id = s.subsidy_id and ss.deleted=0 and s.deleted=0 and s.actived=1 and ss.actived=1 and ss.stu_subsidy_id='$stu_id'"; $result1 = $dbh->query($query1); //get percent if ($result1->rowcount() == 0) { $percent = 0; } else { $result1->setFetchMode(PDO::FETCH_OBJ); $row1 = $result1->fetch(); $percent = $row1->sum_p; } if ($i == 0) { ?> <tr> <td colspan="14"><center><h3>INVOICE</h3></center></td> </tr> <tr> <td colspan="4">Bill To:</td> <td colspan="3"> <input type="text" name="bill_to" required="true" value="<?= $row->last_name . ' ' . $row->first_name ?>" readonly="true"> <input type="hidden" name="root_id" id="root_id" value="<?= $row->root_id ?>"> <input type="hidden" name="linking_id" id="linking_id" value="<?= $stu_id ?>"> </td> <td colspan="2">Invoice Date:</td> <td colspan="5"> <div class="input-append date-picker"> <input type="text" name="invoice_date" class="dateISO" required='true'> <span class="add-on"> <i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i> </span> </div> </td> </tr> <tr> <td colspan="4">Program-Subject</td> <td colspan="3"><input type="text" name="prog_sub" value="<?= $row->program_name . '-' . $row->sub_name ?>" readonly="true"></td> <td colspan="2">Event Code:</td> <td colspan="5"><input type="text" name="event_code" value="<?= $row->event_code ?>" readonly="true"></td> </tr> <tr> <td colspan="4">Funding Type</td> <td colspan="13"> <select name="funding_type"> <option value="0">No Funding</option> <?php $query_funding = "Select funding_id,funding_type from funding where deleted=0 and actived=1"; $result_funding = $dbh->query($query_funding); $result_funding->setFetchMode(PDO::FETCH_OBJ); while ($row_funding = $result_funding->fetch()) { ?> <option value="<?= $row_funding->funding_id ?>"><?= $row_funding->funding_type ?></option> <?php } ?> </select> </td> </tr> <tr> <th> </th> <th>Date</th> <th>Time from</th> <th>Time to</th> <th>Hour(s)</th> <th>Fee type</th> <th>Price($)</th> <th>Attendance</th> <th>Subsidy(%)/Package discount($)</th> <th> </th> <th>Discount($)</th> <th>Not Charge?</th> <th>Amount($)</th> </tr> <?php //activity $query_activity = "Select DATE_FORMAT(act.date, '%W') as weekday,e.event_id,act.activity_id,act.start_time,act.end_time,act.payment,act.date from activity as act,activity_stu_list as act_stu,event as e, lesson_attendance as la,student_grade as sg,grade as g,subject as sub,program as prog, student as stu,lesson as l,event_lesson as el where act_stu.activity_id=act.activity_id and act.event_id=e.event_id and e.event_id=el.event_id and el.lesson_id=l.lesson_id and l.lesson_id=la.lesson_id and sg.student_grade_id=stu.linking_id and sg.grade_id=g.grade_id and stu.root_id=la.stu_linking_id and sg.student_grade_id=stu.linking_id and sg.grade_id=g.grade_id and sub.subject_id=e.subject_id and prog.program_id=e.program_id and e.deleted=0 and e.actived=1 and act.deleted=0 and act.actived=1 and sg.deleted=0 and sg.actived=1 and g.deleted=0 and g.actived=1 and la.deleted=0 and la.actived=1 and stu.deleted=0 and stu.actived=1 and l.deleted=0 and l.actived=1 and el.deleted=0 and el.actived=1 and act_stu.invoice_gened=0 and act_stu.stu_linking_id='$row->root_id' and stu.linking_id='$stu_id' and l.date>='$from_date' and l.date<='$to_date' and e.event_id='$event_id' group by act_stu.stu_linking_id"; $result_activity = $dbh->query($query_activity); $result_activity->setFetchMode(PDO::FETCH_OBJ); while ($row_activity = $result_activity->fetch()) { //$query_get_stu = "Select count(*) as no_of_stu from activity_stu_list where activity_id='$row_activity->activity_id'"; //$result_get_stu = $dbh->query($query_get_stu); //$result_get_stu->setFetchMode(PDO::FETCH_OBJ); //$no_of_stu = $result_get_stu->fetch()->no_of_stu; //cal amount and hr $hour = (round((strtotime($row_activity->end_time) - strtotime($row_activity->start_time)) / 3600, 2)); $price = $row_activity->payment * $hour; $amount = ($price * (1 - ((double) $percent / 100))); $discount = $price - ($amount); $total_price +=$price; $total_discount +=$discount; $total_amount +=$amount; $total_hr+=$hour; ?> <tr> <td><input type="checkbox" name="activity_id[]" id="activity_<?= $i ?>" value="<?= $row_activity->activity_id ?>" checked onclick="selected(this);"></td> <td><?= $row_activity->date . '(' . $row_activity->weekday . ')' ?><input type="hidden" name="date[]" value="<?= $row_activity->date ?>"></td> <td><?= $row_activity->start_time ?><input type="hidden" name="start_time[]" value="<?= $row_activity->start_time ?>"></td> <td><?= $row_activity->end_time ?><input type="hidden" name="end_time[]" value="<?= $row_activity->end_time ?>"></td> <td><?= $hour ?><input type="hidden" name="hours[]" value="<?= $hour ?>"></td> <td>Assessment/Test</td> <td><?= $price ?><input type="hidden" name="price[]" id='price_<?= $i ?>' value="<?= $price ?>"></td> <td>/</td><!--attendance--> <td> <select name="type[]" style="width:100%;" id="type_<?= $i ?>" onchange="change_discount(this);" style=""> <option value="1" selected>Subsidy</option> <option value="2">Package discount</option> <!--<option value="3">Funding</option>--> </select> </td> <td><input type="text" style="width:60px;" name="type_rate[]" id="typerate_<?= $i ?>" value="<?= $percent ?>" readonly='true' onblur="funding(this);"></td> <td><input type="text" style="width:90%;" name="discount[]" id="discount_<?= $i ?>" value="<?= $discount ?>" readonly='true'></td> <td><input type="checkbox" name="is_charge[]" id="charge_<?= $i ?>" onclick="not_charge(this);" value="1"></td> <td><input type="text" style="width:90%;" name="amount[]" id='amount_<?= $i ?>' value="<?= $amount ?>" readonly="true"></td> </tr> <?php $i++; } } /* $query2 = "Insert into invoice set createby=0,createdate=Now(),lastupby=0,lastupdate=Now(),actived=1,deleted=0, stu_linking_id='$row->root_id',code='$row->event_code',remarks=''"; $result2 = $dbh->query($query2); */ $query4 = "Select Max(invoice_id) as i from invoice where deleted=0"; $result4 = $dbh->query($query4); $result4->setFetchMode(PDO::FETCH_OBJ); $row4 = $result4->fetch(); $query5 = "Select count(*) as no_of_stu from lesson_attendance where lesson_id ='$row->lesson_id' and deleted=0 and actived=1 group by lesson_id"; $result5 = $dbh->query($query5); $result5->setFetchMode(PDO::FETCH_OBJ); $row5 = $result5->fetch();
//while ($row5 = $result5->fetch()) { $price = 0.0; $discount = 0.0; $amount = 0.0; if ($row->programme_fee_type != 3) {//3=free if ($row->programme_fee_type == 1) {//1=hour , 2=package if ($row5->no_of_stu > 1) {//group hr switch ($row->grade) { case 'K2': case 'K3': case 'P1': case 'P2': case 'P3': case 'P4': case 'P5': case 'P6': case 'Y1': case 'Y2': case 'Y3': case 'Y4': case 'Y5': case 'Y6': $price+=$row->primary_group_price; break; case 'S1': case 'S2': case 'S3': case 'S4': case 'S5': case 'S6': case 'Y7': case 'Y8': case 'Y9': case 'Y10': case 'Y11': case 'Y12': $price+=$row->secondary_group_price; break; } } else { switch ($row->grade) {//induva hr case 'K2': case 'K3': case 'P1': case 'P2': case 'P3': case 'P4': case 'P5': case 'P6': case 'Y1': case 'Y2': case 'Y3': case 'Y4': case 'Y5': case 'Y6': $price+=$row->primary_individual_price; break; case 'S1': case 'S2': case 'S3': case 'S4': case 'S5': case 'S6': case 'Y7': case 'Y8': case 'Y9': case 'Y10': case 'Y11': case 'Y12': $price+=$row->secondary_individual_price; break; } } $price = $price * (round((strtotime($row->end_time) - strtotime($row->start_time)) / 3600, 2)); $amount = ($price * (1 - ((double) $percent / 100))); $discount = $price - ($amount); } else {//package switch ($row->grade) { case 'K2': case 'K3': case 'P1': case 'P2': case 'P3': case 'P4': case 'P5': case 'P6': case 'Y1': case 'Y2': case 'Y3': case 'Y4': case 'Y5': case 'Y6': $price+=$row->primary_package_price; break; case 'S1': case 'S2': case 'S3': case 'S4': case 'S5': case 'S6': case 'Y7': case 'Y8': case 'Y9': case 'Y10': case 'Y11': case 'Y12': $price+=$row->secondary_package_price; break; } $amount = (($price) * (1.0 - ((double) $percent / 100))); $discount = $price - ($amount); } } (double) $total_price +=$price; (double) $total_discount +=$discount; (double) $total_amount +=$amount; $total_hr+=(round((strtotime($row->end_time) - strtotime($row->start_time)) / 3600, 2)); /* echo "<script>alert('".$price."')</script>"; echo "<script>alert('".$discount."')</script>"; echo "<script>alert('".$fee."')</script>"; */ ?> <tr> <td><input type="checkbox" name="lesson_id[]" id="lesson_<?= $i ?>" value="<?= $row->lesson_id ?>" checked onclick="selected(this);"></td> <td><?= $row->date . '(' . $row->weekday . ')' ?><input type="hidden" name="date[]" value="<?= $row->date ?>"></td> <td><?= $row->start_time ?><input type="hidden" name="start_time[]" value="<?= $row->start_time ?>"></td> <td><?= $row->end_time ?><input type="hidden" name="end_time[]" value="<?= $row->end_time ?>"></td> <td><?= (round((strtotime($row->end_time) - strtotime($row->start_time)) / 3600, 2)) ?><input type="hidden" name="hours[]" value="<?= (round((strtotime($row->end_time) - strtotime($row->start_time)) / 3600, 2)) ?>"></td> <td> <?php if ($row->programme_fee_type == 1) { echo 'Hourly' . '<input type="hidden" name="fee_type[]" value="1">'; } else { if ($row->programme_fee_type == 2) { echo 'Package' . '<input type="hidden" name="fee_type[]" value="2">'; } else { echo 'Free' . '<input type="hidden" name="fee_type[]" value="3">'; } } ?> </td> <td><?= $price ?><input type="hidden" name="price[]" id='price_<?= $i ?>' value="<?= $price ?>"></td> <td> <?php if ($row->attendance == 1) { echo 'Present'; echo '<input type="hidden" name="attendance[]" value="1">'; } else { echo 'Absent'; echo '<input type="hidden" name="attendance[]" value="0">'; } ?> </td> <td> <select name="type[]" style="width:100%;" id="type_<?= $i ?>" onchange="change_discount(this);"> <option value="1" selected>Subsidy</option> <option value="2">Package discount</option> <!--<option value="3">Funding</option>--> </select> </td> <td><input type="text" style="width:60px;" name="type_rate[]" id="typerate_<?= $i ?>" value="<?= $percent ?>" readonly='true' onblur="funding(this);"></td> <td><input type="text" style="width:90%;" name="discount[]" id="discount_<?= $i ?>" value="<?= $discount ?>" readonly='true'></td> <td width="10%"><input type="checkbox" name="is_charge[]" id="charge_<?= $i ?>" onclick="not_charge(this);" value="1"></td> <td><input type="text" style="width:90%;" name="amount[]" id='amount_<?= $i ?>' value="<?= $amount ?>" readonly="true"></td> </tr> <?php $i++; } } else { echo '<script>alert("GGGGGGGGGGGg")</script>'; } ?> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td>Total hours:<?=$total_hr?></td> <td> </td> <td>Total price:<?= $total_price ?><input type="hidden" name="total_price" value='<?= $total_price ?>'></td> <td> </td> <td> </td> <td> </td> <td>Total discount:<input type='text' style="width:90%;" name='total_discount' id='total_discount' value='<?= $total_discount ?>' readonly='true'></td> <td> </td> <td> Total amount:<input type='text' style="width:90%;" name='total_amount' id='total_amount' value='<?= $total_amount ?>' readonly='true'> <input type="hidden" name="i" id="i" value="<?= $i ?>"> </td> </tr> </table> <input type="button" value="Cancel" class="btn" onclick="window.history.go(-1);"/> <input type="submit" name="generate" value="Generate" class="btn"> </form> <?php } else { ?> <div> <table border="0" width="100%"> <tr> <td><h2>Generate Invoice</h2></td> </tr> </table> </div> <form action="" method="POST" class="form-inline"> <div class="pathways-search"> <table border="0"> <tr> <?php if (isset($_POST['search']) && $_POST['search'] == "Search In-House") { $from_date = $_POST['from_date']; $to_date = $_POST['to_date']; //$yr = $_POST['sem_yr']; ?> <!--<td width="20%"> Semaster_Year <select name="sem_yr"> <?php $query12 = "Select Sem_yr as yr from student group by Sem_yr"; $result12 = $dbh->query($query12); $result12->setFetchMode(PDO::FETCH_OBJ); while ($row12 = $result12->fetch()) { if ($row12->yr == $yr) print '<option value="' . $row12->yr . '" selected>' . $row12->yr . '</option>'; else print '<option value="' . $row12->yr . '">' . $row12->yr . '</option>'; } ?> </select> </td>--> <td>Date From <div class="input-append date-picker" id="start_date"> <input type="text" name="from_date" id="start_date_input" class="dateISO" required="true" value="<?= $from_date ?>"> <span class="add-on"> <i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i> </span> </div> </td> <td>Date To <div class="input-append date-picker" id="end_date"> <input type="text" name="to_date" class="dateISO" required="true" value="<?= $to_date ?>"> <span class="add-on"> <i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i> </span> </div> </td> <?php } else { if (isset($_POST['search_sch']) && $_POST['search_sch'] == "Search In-School") { $from_date = $_POST['from_date']; $to_date = $_POST['to_date']; //$yr = $_POST['sem_yr']; ?> <!--<td width="20%"> Semaster_Year <select name="sem_yr"> <?php /* $query12 = "Select Sem_yr as yr from student group by Sem_yr"; $result12 = $dbh->query($query12); $result12->setFetchMode(PDO::FETCH_OBJ); while ($row12 = $result12->fetch()) { if ($row12->yr == $yr) print '<option value="' . $row12->yr . '" selected>' . $row12->yr . '</option>'; else print '<option value="' . $row12->yr . '">' . $row12->yr . '</option>'; } */ ?> </select> </td>--> <td>Date From <div class="input-append date-picker" id="start_date"> <input type="text" name="from_date" id="start_date_input" class="dateISO" required="true" value="<?= $from_date ?>"> <span class="add-on"> <i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i> </span> </div> </td> <td>Date To <div class="input-append date-picker" id="end_date"> <input type="text" name="to_date" class="dateISO" required="true" value="<?= $to_date ?>"> <span class="add-on"> <i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i> </span> </div> </td> <?php } else { ?> <!--<td width="20%"> Semaster_Year <select name="sem_yr"> <?php /* $curr_yr = date("Y"); $curr_mon = date("M"); echo "<script>alert('.$curr_yr.' '.$curr_mon.')</script>"; $query12 = "Select Sem_yr as yr from student group by Sem_yr"; $result12 = $dbh->query($query12); $result12->setFetchMode(PDO::FETCH_OBJ); while ($row12 = $result12->fetch()) { $year1 = explode("-", $row12->yr)[0]; $year2 = explode("-", $row12->yr)[1]; if ($curr_yr == $year1 && $curr_mon >= 9) { print '<option value="' . $row12->yr . '"selected>' . $row12->yr . '</option>'; } else { if ($curr_yr == $year2 && $curr_mon < 9) { print '<option value="' . $row12->yr . '"selected>' . $row12->yr . '</option>'; } else print '<option value="' . $row12->yr . '">' . $row12->yr . '</option>'; } } */ ?> </select> </td>--> <td> Date From <div class="input-append date-picker" id="start_date"> <input type="text" name="from_date" id="start_date_input" class="dateISO" required="true"> <span class="add-on"> <i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i> </span> </div> </td> <td> Date To <div class="input-append date-picker" id="end_date"> <input type="text" name="to_date" class="dateISO" required="true"> <span class="add-on"> <i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i> </span> </div> </td> <?php } } ?> <td><input type="submit" name="search" class="btn" value="Search In-House"></td> <td><input type="submit" name="search_sch" class="btn" value="Search In-School"></td> </tr> </table> </div> <table border="0" class="table table-striped table-bordered table-hover table-condensed"> <thead> <tr> <th> </th> <th>Name</th> <th>Event Code</th> </tr> </thead> <?php if (isset($_POST['search']) && $_POST['search'] == "Search In-House") { $from_date = $_POST['from_date']; $to_date = $_POST['to_date']; //$yr = $_POST['sem_yr']; $query = "Select e.event_id,e.event_code,e.school_id,l.lesson_id,l.start_time,l.end_time,l.date,stu.first_name,stu.last_name,stu.linking_id,stu.root_id,stu.New_stu_ID as id,e.programme_fee_type,e.program_id,e.subject_id,e.primary_individual_price,e.primary_group_price,e.secondary_individual_price,e.secondary_group_price, e.primary_package_price,e.secondary_package_price,g.grade,la.attendance from event as e, lesson_attendance as la,student_grade as sg,grade as g, student as stu,lesson as l,event_lesson as el where e.event_id=el.event_id and el.lesson_id=l.lesson_id and l.lesson_id=la.lesson_id and sg.student_grade_id=stu.linking_id and sg.grade_id=g.grade_id and stu.root_id=la.stu_linking_id and sg.student_grade_id=stu.linking_id and sg.grade_id=g.grade_id and e.deleted=0 and e.actived=1 and la.deleted=0 and la.actived=1 and stu.deleted=0 and stu.actived=1 and l.deleted=0 and l.actived=1 and el.deleted=0 and el.actived=1 and la.invoice_gened=0 and e.school_id=0 and l.date>='$from_date' and l.date<='$to_date' group by stu.linking_id,e.event_code"; /* Select e.event_id,e.event_code,ss.subsidy_id,s.subsidy_type,s.percent,l.lesson_id,l.start_time,l.end_time,l.date,stu.first_name,stu.last_name,stu.linking_id,stu.root_id, e.programme_fee_type,e.program_id,e.subject_id,e.primary_individual_price,e.primary_group_price,e.secondary_individual_price,e.secondary_group_price, e.primary_package_price,e.secondary_package_price,e.is_free,g.grade,la.attendance from event as e, lesson_attendance as la,student_grade as sg,grade as g, student as stu,student_subsidy as ss,subsidy as s,lesson as l,event_lesson as el where e.event_id=el.event_id and el.lesson_id=l.lesson_id and l.lesson_id=la.lesson_id and stu.linking_id=ss.stu_subsidy_id and ss.subsidy_id=s.Subsidy_ID and sg.student_grade_id=stu.linking_id and sg.grade_id=g.grade_id and e.deleted=0 and e.actived=1 and la.deleted=0 and la.actived=1 and stu.deleted=0 and stu.actived=1 and ss.deleted=0 and ss.actived=1 and s.deleted=0 and s.actived=1 and l.deleted=0 and l.actived=1 and el.deleted=0 and el.actived=1 and l.date>='$from_date' and l.date<='$to_date' and stu.New_stu_ID='$stu_id' and stu.Sem_yr='$yr' group by e.event_id"; */ /* Select e.event_id,e.event_code,l.lesson_id,l.start_time,l.end_time,l.date, e.programme_fee_type,e.program_id,e.subject_id,e.primary_individual_price,e.primary_group_price,e.secondary_individual_price,e.secondary_group_price, e.primary_package_price,e.secondary_package_price from event as e,lesson as l,event_lesson as el where e.event_id=el.event_id and el.lesson_id=l.lesson_id */ $result = $dbh->query($query); //get invoice data $result->setFetchMode(PDO::FETCH_OBJ); if ($result->rowcount() == 0) { print '<tr>'; print '<td colspan="3"><b>No records</b></td>'; print '</tr>'; } else { while ($row = $result->fetch()) { //if ($row->school_id == 0) { ?> <tr> <td> <input type="radio" name="id" value="<?= $row->event_id . '|' . $row->linking_id ?>" checked> </td> <td><?= $row->last_name . " " . $row->first_name . "(" . $row->id . ")" ?></td> <td><?= $row->event_code ?></td> </tr> <?php //} } } echo '</table><input type="submit" name="select" class="btn" value="Select">'; } else { if (isset($_POST['search_sch']) && $_POST['search_sch'] == "Search In-School") { $from_date = $_POST['from_date']; $to_date = $_POST['to_date']; //$yr = $_POST['sem_yr']; $query = "(Select e.event_id,e.event_code,e.school_id,l.lesson_id,l.start_time,l.end_time,l.date,stu.first_name,stu.last_name,stu.linking_id,stu.root_id,stu.New_stu_ID as id,e.programme_fee_type,e.program_id,e.subject_id,e.primary_individual_price,e.primary_group_price,e.secondary_individual_price,e.secondary_group_price, e.primary_package_price,e.secondary_package_price,g.grade,la.attendance ,sch.school_id,sch.sch_name,sch.sch_ch_name from event as e, lesson_attendance as la,student_grade as sg,grade as g, school as sch, student as stu,lesson as l,event_lesson as el where e.event_id=el.event_id and el.lesson_id=l.lesson_id and l.lesson_id=la.lesson_id and sg.student_grade_id=stu.linking_id and sg.grade_id=g.grade_id and stu.root_id=la.stu_linking_id and sg.student_grade_id=stu.linking_id and sg.grade_id=g.grade_id and sch.school_id=e.school_id and e.deleted=0 and e.actived=1 and la.deleted=0 and la.actived=1 and stu.deleted=0 and stu.actived=1 and l.deleted=0 and l.actived=1 and el.deleted=0 and el.actived=1 and la.invoice_gened=0 and e.school_id<>0 and l.date>='$from_date' and l.date<='$to_date' group by e.event_code)"; $result = $dbh->query($query); $result->setFetchMode(PDO::FETCH_OBJ); if ($result->rowcount() == 0) { print '<tr>'; print '<td colspan="3"><b>No records</b></td>'; print '</tr>'; } else { while ($row = $result->fetch()) { //if ($row->school_id != 0) { ?> <tr> <td> <input type="radio" name="id" value="<?= $row->event_id . '|' . $row->school_id ?>" checked> </td> <td><?= $row->sch_ch_name . "(" . $row->sch_name . ")" ?></td> <td><?= $row->event_code ?></td> </tr> <?php //} } } echo '</table><input type="submit" name="select1" class="btn" value="Select">'; } } ?> </form> <?php } } ?> </div> </body> </html>
|