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
|
<!DOCTYPE html> <html> <head> <?php require_once '../include/head.php'; ?> <?php require_once '../include/checkuser.php'; ?> <?php require_once '../include/Nav_bar.php'; ?> <?php include_once '../include/DBConnect.php'; ?> <script> var total = 0; $(function() { $('.date-picker').datetimepicker({pickTime: false}); $('.searchstun').select2(); $('.stun').select2(); $('#payway').change(function() { var type = $('#payway').val(); $.get('receipt_search_ajax.php?paytype=' + type, ff); }); function ff(res) { $('#paytype_tr').html(res); } ; }); $(document).ready(function() { $(function() { $('#form').on('submit', function(e) { var array = new Array(); for (var i = 0; i < (document.getElementsByName("selected_invoice[]")).length; i++) { if (document.getElementsByName("selected_invoice[]")[i].checked == true) { array.push((document.getElementsByName("selected_invoice[]")[i].value)); total += parseInt((document.getElementsByName("invoice_pay[]")[i].value)); alert(total); } } if (total != $('#total_fee').val()) { alert('Not match the total amount'); total = 0; e.preventDefault(); } }); }); }); </script> </head> <?php $invoice_id; $startdate = date('Y-m-d'); $enddate = date('Y-m-d'); $today = date('Y-m-d'); $countinvoice = 0; if (isset($_POST['save'])) { $totalmoney = 0; $countinvoice = 0; $name = $_POST['from_name']; $money = $_POST['total_fee']; $payof = $_POST['payof'][$countinvoice]; $payway = $_POST['payway']; if ($payway == 1) { $bank_name = $_POST['bankname']; $cheque_no = $_POST['cheque_no']; } else { $bank_name = '0'; $cheque_no = '0'; } $campus = $_POST['campus']; $type = $_POST['type']; $paydate = $_POST['paydate']; $dontinsert = false; $loadname; $receiptNo = 'KL130001'; if ($campus != 1 && $campus != 2) { $dontinsert = true; echo "<script>alert('plz select a campus!!!')</script>"; } if ($dontinsert == false) { $sth = $dbh->prepare("INSERT INTO `receipt`(`receipt_code`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `receipt_date`, `receipt_from`, `payment_of`, `total_amount`, `is_cash`, `bank_name`, `cheque_code`, `is_normal`, `campus_id`) VALUES (?,1,now(),1,now(),1,0,?,?,?,?,?,?,?,?,?)"); $sth->bindParam(1, $receiptNo); $sth->bindParam(2, $paydate); $sth->bindParam(3, $name); $sth->bindParam(4, $payof); $sth->bindParam(5, $money); $sth->bindParam(6, $payway); $sth->bindParam(7, $bank_name); $sth->bindParam(8, $cheque_no); $sth->bindParam(9, $type); $sth->bindParam(10, $campus); $sth->execute();
echo "<script>alert('Insert data successful.')</script>"; echo("<script>location.href ='receipt_index.php';</script>"); } } ?> <body> <!-- line between nav bar and content --> <div class="text-right"> <ul class="breadcrumb"> <li class="active">Receipt</li> </ul> </div>
<div class="container-fluid pathways-container"> <div> <table border="0" width="100%"> <tr> <td><h2>Add Receipt</h2></td> </tr> </table> </div> <div class="pathways-search"> <form id="search_form" class="form-inline" action="" method="POST"> <div class="pathways-inline-block"> <label>Student</label> <select name="searchstun" id="stun" class="stun" style="width:230px"> <option value="ALL"></option> <?php $sth = $dbh->query("SELECT `root_id` root_id,linking_id,`New_stu_ID` id,CONCAT(last_name, ' ', first_name) studentname,`ch_name`FROM `student` WHERE `actived`=1 and`deleted`=0 group by `New_stu_ID`,`Sem_yr`"); ?> <?php while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) { ?> <option <?php if (isset($_POST['go'])) { if ($_POST['searchstun'] == $ResultSet['root_id']) { ?> selected="" <?php } } ?>value="<?= $ResultSet['root_id']; ?>"><?= $ResultSet['studentname'] ?> | <?= $ResultSet['id'] ?></option> <?php } ?> </select> </div> <div class="pathways-inline-block"> <button class="btn" name="go" value="go" style="margin-left:30px" type="submit">Search</button> </div> </form> </div> <?php if (isset($_POST['go'])) { $studentid = $_POST['searchstun']; $Tdata = false; if ($studentid == 'ALL') { echo "<script>alert('Please select a student!')</script>"; } else { $query = "select root_id from invoice where deleted = 0 and stu_linking_id = '$studentid' "; $result = $dbh->query($query); $result->setFetchMode(PDO::FETCH_OBJ); while ($row = $result->fetch()) { $Tdata = true; } ?> <form id="form" class="form-inline" action="" method="POST"> <?php if ($Tdata == true) { ?> <table style=" background:#eeefde;" border="0" class="table table-bordered table-hover table-condensed"> <tr> <td><label>Receipt From</label></td> <td><input type="text" name="from_name" required=""></td> <td><label>Total Money</label> </td><td><input type="text" name="total_fee" id="total_fee" required=""></td> </tr> <tr> <td width="20%"><label>Type</label></td> <td><select name="type"> <option value="0">Normal</option> <option value="1">Community Chest</option> </select></td> <td width="20%"><label>Date</label></td> <td><div class="input-append date-picker"> <input id="start_date" class="dateISO" type="text" maxlength="200" data-format="yyyy-MM-dd" name="paydate" value="<?= $today ?>" style="width:90px" required> <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 width="20%">Pay Type</td> <td><select name ="payway" id="payway"> <option value="0">By cash</option> <option value="1">By cheque</option> </select></td> <!--td width="10%"><label>Bank Name</label></td> <td><input type="text" name="bankname"></td> <td width="10%">Cheque No</td> <td><input type="text" name="cheque_no"></td--> </tr> <tbody id="paytype_tr"> <tr> </tr> </tbody> <tr> <!--td width="20%"><label>Payment of:</label></td> <td><input type="text" name="payof"></td--> <td width="20%">Campus:</td> <td><select name="campus" required="true"> <option></option> <?php $query = "Select campus_id,campus_name from campus"; $result = $dbh->query($query); $result->setFetchMode(PDO::FETCH_OBJ); while ($row = $result->fetch()) { print '<option value=' . $row->campus_id . '>' . $row->campus_name . '</option>'; } ?> </select> </td>
</tr> </table> <?php } ?> <table class="table table-striped table-bordered table-hover table-condensed" id="tablehead"> <thead> <tr> <th style="min-width:50px; width:5%"></th> <th style="min-width:50px;">Invoice_Code</th> <th style="min-width:50px;">Event_Code</th> <th style="min-width:50px; width:10%">Total Amount</th> <th style="min-width:50px; width:10%">Payed</th> <th style="min-width:50px; width:10%">Pay</th> </tr> </thead> <tbody> <?php //$query = "select receive_id, receive_code, is_normal from receive where deleted = 0 and invoice_id = 0 and receive_date between '$startdate' and '$enddate' "; $query = "select root_id, total_amount, invoice_code, event_code from invoice where deleted = 0 and stu_linking_id = '$studentid' "; $result = $dbh->query($query); $result->setFetchMode(PDO::FETCH_OBJ); while ($row = $result->fetch()) { ?> <tr> <td> <input type="checkbox" name="selected_invoice[]" id="selected_invoice<?= $countinvoice ?>" value="1"> </td> <td> <input type="hidden" name="payof[]" value="<?=$row->invoice_code ?>" ><h5><?= $row->invoice_code ?></h5> </td> <td> <h5><?= $row->event_code ?></h5> </td> <td> <h5>$<?= $row->total_amount ?></h5> </td> <td> <h5>0</h5> </td> <td> <input type="text" name="invoice_pay[]" id="invoive_pay<?= $countinvoice ?>" value="" style="width: 100px"> </td> </tr> <?php $countinvoice++; } if ($Tdata == FALSE) { ?> <tr><td colspan = "5"><h5>No invoice searched</h5></td></tr> <?php } ?> </tbody> </table> <div class="pathways-inline-block"> <button class="btn" name="save" value="save" type="submit" style="margin-left:30px" >Save</button> </div> </form> <?php } } ?> </div> <!-- /container --> </body> </html>
|