-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinal-invoice.php
More file actions
497 lines (299 loc) · 13.5 KB
/
final-invoice.php
File metadata and controls
497 lines (299 loc) · 13.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
<?php
include 'actions/dbconnection.php';
//Get Invoice Details
$invoice_number = $_GET["InvoiceNumber"];
$get_invoice_sql = "select * from op_invoice_main WHERE INVOICE_NUMBER='".$invoice_number."'";
$get_invoice_query = mysqli_query($dbCon,$get_invoice_sql);
$invoice_data = mysqli_fetch_array($get_invoice_query);
if($invoice_data['CUSTOMER_ID'] == 0){
$customer = "Walk-in Customer";
$customer_mobile = "";
$customer_email = "";
} else {
$get_customer_sql = "select * from op_customers WHERE CUSTOMER_ID='".$invoice_data['CUSTOMER_ID']."'";
$get_customer_query = mysqli_query($dbCon,$get_customer_sql);
$customer_data = mysqli_fetch_array($get_customer_query);
$customer = $customer_data['FIRSTNAME']." ".$customer_data['LASTNAME'];
$customer_mobile = $customer_data['MOBILE_NUMBER'];
$customer_email = $customer_data['EMAIL'];
}
$get_invoice_detail_sql = "select * from op_invoice_detail WHERE INVOICE_NUMBER='".$invoice_number."'";
$get_invoice_detail_query = mysqli_query($dbCon,$get_invoice_detail_sql);
$title = $invoice_data['INVOICE_NUMBER']." | Invoice";
include 'template/header.php';
include 'template/top_navbar.php';
include 'template/main_navbar.php';
?>
<?php include "template/notifications.php"; ?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1>Invoice</h1>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="#">Home</a></li>
<li class="breadcrumb-item active">Invoice</li>
</ol>
</div>
</div>
</div><!-- /.container-fluid -->
</section>
<section class="content">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<!-- Main content -->
<div class="invoice p-3 mb-3">
<!-- title row -->
<div class="row">
<div class="col-12">
<h4>
<i class="fa fa-globe"></i> Fitness Island Store
<small class="float-right">Date: <?php echo $invoice_data['INVOICE_DATE']; ?></small>
</h4>
</div>
<!-- /.col -->
</div>
<!-- info row -->
<div class="row invoice-info">
<div class="col-sm-4 invoice-col">
From
<address>
<strong>Fitness Island Store</strong><br>
29/9 Stratford Avenue,<br>
Colombo 06, Sri Lanka<br>
Phone: +94 77 6676 720<br>
Email: info@fitnessisland.lk
</address>
</div>
<!-- /.col -->
<div class="col-sm-4 invoice-col">
To
<address>
<strong><?php echo $customer; ?></strong><br>
Phone: <?php echo $customer_mobile; ?><br>
Email: <?php echo $customer_email; ?>
</address>
</div>
<!-- /.col -->
<div class="col-sm-4 invoice-col">
<b>Invoice <?php echo $invoice_data['INVOICE_NUMBER']; ?></b><br>
<br>
<?php
if($invoice_data['SHOPBOX_ID'] == "0"){
$shopboxID = "N/A";
} else {
$shopboxID = $invoice_data['SHOPBOX_ID'];
}
if($invoice_data['WAYBILL_ID'] == "0"){
$waybillID = "N/A";
} else {
$waybillID = $invoice_data['WAYBILL_ID'];
}
$find_user_sql = "select * from op_users WHERE USER_ID='".$invoice_data['USER_ID']."'";
$find_user_query = mysqli_query($dbCon,$find_user_sql);
$user_data = mysqli_fetch_array($find_user_query);
?>
<b>Order ID:</b> <?php echo $shopboxID; ?><br>
<b>Waybill ID:</b> <?php echo $waybillID; ?><br>
<b>Invoice User:</b> <?php echo $user_data['FIRSTNAME']; ?><br>
</div>
<!-- /.col -->
</div>
<!-- /.row -->
<!-- Table row -->
<div class="row">
<div class="col-12 table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Product Description</th>
<th>Quantity</th>
<th>Unit Price</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<?php
while($invoice_detail_data = mysqli_fetch_array($get_invoice_detail_query)){
$find_product_sql = "select PRODUCT_DESC from op_products WHERE PRODUCT_DESC='".$invoice_detail_data['PRODUCT_DESC']."'";
$find_product_query = mysqli_query($dbCon,$find_product_sql);
$product_desc = mysqli_fetch_array($find_product_query);
echo "<tr>";
echo "<td>".$product_desc['PRODUCT_DESC']."</td>";
echo "<td>".$invoice_detail_data['QUANTITY']."</td>";
echo "<td>".number_format($invoice_detail_data['UNIT_PRICE'],2)."</td>";
echo "<td>".number_format($invoice_detail_data['LINE_TOTAL'],2)."</td>";
echo "</tr>";
}
?>
</tbody>
</table>
</div>
<!-- /.col -->
</div>
<!-- /.row -->
<div class="row">
<!-- accepted payments column -->
<div class="col-6">
<p class="lead">Payment Methods: <strong><?php echo $invoice_data['PAYMENT_METHOD']; ?></strong></p>
<p class="text-success"><strong>Points Earned : <?php echo $invoice_data['EARNED_POINTS']; ?></strong></p>
</div>
<!-- /.col -->
<div class="col-6">
<p class="lead">Payment Status: <strong><?php echo $invoice_data['PAYMENT_STATUS']; ?></strong></p>
<div class="table-responsive">
<table class="table">
<tr>
<th style="width:50%">Subtotal:</th>
<td><?php echo number_format($invoice_data['INVOICE_SUBTOTAL'],2); ?></td>
</tr>
<tr>
<th>Discount</th>
<td><?php echo $invoice_data['INVOICE_TOTAL_DISCOUNTS']; ?></td>
</tr>
<tr>
<th>Points Redeemed</th>
<td><?php echo $invoice_data['REDEEMED_POINTS']; ?></td>
</tr>
<tr>
<th>Total:</th>
<td><?php echo number_format($invoice_data['INVOICE_TOTAL'],2); ?></td>
</tr>
</table>
</div>
</div>
<!-- /.col -->
</div>
<!-- /.row -->
<!-- this row will not appear when printing -->
<div class="row no-print">
<div class="col-12">
<form method="post" action="actions/mailInvoice.php">
<input type="hidden" name="invoiceNumber" value="<?php echo $invoice_number; ?>">
<button type="submit" name="mailInvoice" class="btn btn-navy"><i class="fa fa-print"></i> Mail Invoice</button>
</form>
<button type="button" class="btn btn-success float-right" data-toggle="modal" data-target="#myModal"><i class="fa fa-credit-card"></i> Update
Payment
</button>
<button type="button" class="btn btn-primary float-right" data-toggle="modal" data-target="#Comments" style="margin-right: 5px;">
<i class="fa fa-download"></i> Comments
</button>
</div>
</div>
</div>
<!-- /.invoice -->
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.container-fluid -->
</section>
<!-- /.content -->
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Process Payment</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<form action="actions/invoice/update_status.php" method="post">
<input type="hidden" name="invoiceNumber" value="<?php echo $invoice_number; ?>" />
<?php
$get_payment_status_sql = "select PAYMENT_STATUS from op_invoice_main where INVOICE_NUMBER='".$invoice_number."'";
$get_payment_status_query = mysqli_query($dbCon,$get_payment_status_sql);
?>
<div class="row">
<label class="col-md-6">Payment Status</label>
<select class="form-control form-control-sm col-md-6" name="paymentStatus">
<?php
$payment_status = mysqli_fetch_array($get_payment_status_query);
?>
<option value="Paid" <?php if($payment_status['PAYMENT_STATUS']=="Paid") echo "selected=\"selected\""; ?>><?php echo "Paid"; ?></option>
<option value="Pending" <?php if($payment_status['PAYMENT_STATUS']=="Pending") echo "selected=\"selected\""; ?>><?php echo "Pending"; ?></option>
</select>
</div>
<br/>
<div class="row">
<div class="form-group col-md-12">
<label>Remarks</label>
<textarea class="form-control" rows="3" name="remarks"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-navy" name="updatePayment">UPDATE PAYMENT</button>
</div>
</div>
</div>
</div>
<!-- end of modal -->
</form>
</div>
</div>
<!-- /.content-wrapper -->
<!-- Modal -->
<div id="Comments" class="modal fade" role="dialog">
<div class="modal-dialog large_modal">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Invoice Comments</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<div class="container">
<div class="row">
<div class="col-md-12">
<form action="actions/invoice/update_status.php" method="post">
<input type="text" name="comment" placeholder="Enter new Invoice Comment" autocomplete="off" class="form-control"><br/>
<table class="table table-bordered">
<tbody>
<tr>
<th>Comment</th>
<th>User</th>
<th>Date</th>
</tr>
<?php
$view_comments_sql ="select * from op_invoice_comments WHERE INVOICE_NUMBER='".$invoice_number."'";
$view_comments_query = mysqli_query($dbCon,$view_comments_sql);
while($invoice_comments = mysqli_fetch_array($view_comments_query)){
$find_user_comments_sql = "select FIRSTNAME from op_users WHERE USER_ID='".$invoice_comments['USER_ID']."'";
$find_user_query = mysqli_query($dbCon,$find_user_comments_sql);
$user_firstname = mysqli_fetch_array($find_user_query);
echo "<tr>";
echo "<td>".$invoice_comments['COMMENT']."</td>";
echo "<td>".$user_firstname['FIRSTNAME']."</td>";
echo "<td>".$invoice_comments['DATE_CREATED']."</td>";
echo "</tr>";
}
?>
</tbody></table>
</div>
</div>
</div>
<div class="modal-footer">
<input type="hidden" name="invoiceNumber" value="<?php echo $invoice_number;?>">
<button type="button" class="btn btn-default pull-left" style="margin-right:5px;" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-navy" name="AddComment">ADD COMMENT</button>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- end of modal -->
<script>
$(document).ready(function() {
if(window.location.href.indexOf('#Comments') != -1) {
$('#Comments').modal('show');
}
});
</script>
<?php include 'template/footer.php'; ?>