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
|
<!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'; ?> <script> function check_all(obj, cName) { var checkboxs = document.getElementsByName(cName); for (var i = 0; i < checkboxs.length; i++) { checkboxs[i].checked = obj.checked; } } ; $(function() { $('.date-picker').datetimepicker({pickTime: false, format: 'yyyy-MM-dd'}); }); </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"> <div> <table border="0" width="100%"> <tr> <td><h2>Generate Invoice</h2></td> <td><a href="" class="btn pull-right"><i class="icon-plus"></i> Add</a></td> </tr> </table> </div> <div class="pathways-search"> <form action="" method="POST" class="form-inline"> <table border="0" width="100%"> <?php if (isset($_POST['search']) && $_POST['search'] == "Search") { $from_date = $_POST['from_date']; $to_date = $_POST['to_date']; $yr = $_POST['sem_yr']; $stu_id = $_POST['stu_id']; ?> <tr> <td> Student No.(new system) <input type="text" name="stu_id" required="true" value="<?= $stu_id ?>"> </td> <td> 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 <div class="input-append date-picker"> <input type="text" name="from_date" 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>To <div class="input-append date-picker"> <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 { ?> <tr> <td> Student No.(new system) <input type="text" name="stu_id" required="true"> </td> <td> 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 <div class="input-append date-picker"> <input type="text" name="from_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> <td>To <div class="input-append date-picker"> <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"></td> </tr> </table> </form> </div> <form action="invoice.php" method="POST" class="form-inline"> <table border="0" class="table table-striped table-bordered table-hover table-condensed"> <thead> <tr> <th> </th> <th>Till Date</th> <th>Event Code</th> <th>Program-Subject</th> <th>Fee</th> <th>Type Rate</th> <th>Hour(s)</th> <th>Amount</th> <th>Attend</th> </tr> </thead> <?php if (isset($_POST['search']) && $_POST['search'] == "Search") { $from_date = $_POST['from_date']; $to_date = $_POST['to_date']; $stu_id = $_POST['stu_id']; $yr = $_POST['sem_yr']; $query = "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,e.package_discount,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 ss.stu_subsidy_id"; $result = $dbh->query($query); //get invoice data $result->setFetchMode(PDO::FETCH_OBJ); while ($row = $result->fetch()) { $query_pro = "Select program_name from program where program_id='$row->program_id'"; $query_sub = "Select sub_name from subject where subject_id='$row->subject_id'"; $result_pro = $dbh->query($query_pro); $result_sub = $dbh->query($query_sub); $result_pro->setFetchMode(PDO::FETCH_OBJ); $result_sub->setFetchMode(PDO::FETCH_OBJ); $sub = $result_sub->fetch(); $pro = $result_pro->fetch(); //*****************************************************************// $query1 = "Select ss.stu_subsidy_id,Sum(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 group by ss.stu_subsidy_id"; $result1 = $dbh->query($query1); //get percent $result1->setFetchMode(PDO::FETCH_OBJ);
while ($row1 = $result1->fetch()) { if ($row->linking_id == $row1->stu_subsidy_id) { echo '<script>' . $row->percent . '</script>'; $percent = $row1->sum_p; } } $query5 = "Select count(*) as no_of_stu from lesson_attendance where lesson_id IN (Select lesson_id from lesson_attendance where stu_linking_id='$row->root_id')"; $result5 = $dbh->query($query5); $result5->setFetchMode(PDO::FETCH_OBJ); $row5 = $result5->fetch(); $price = 0; //price without discount $discount = 0; $total = 0; //total that he need to pay
if ($row->is_free != 1) { 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; } } $total = ($price * $percent / 100); $discount = $price - ($total); } 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; $discount = $row->package_discount; 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; $discount = $row->sec_package_discount; break; } $total = $price - $discount; $total = ($price * $percent / 100); $discount = $price - ($total); } } ?> <tr> <td><input type="checkbox" name="lesson_id[]" value="<?= $row->lesson_id ?>"></td> <td><?= $row->date ?></td> <td><?= $row->event_code ?></td> <td><?php echo $pro->program_name . '-' . $sub->sub_name; ?></td> <td><?= $total ?></td> <td>Type Rate</td> <td><?= $row->end_time - $row->start_time ?></td> <td><?= $price ?></td> <td><?php if ($row->attendance == 1) echo 'Present'; else echo 'Absent'; ?> </td> </tr> <?php } } ?> </table> <input type="submit" name="gene" class="btn" value="Generate"> </form> </div> </body> </html>
|