-
Notifications
You must be signed in to change notification settings - Fork 3
/
receipt.php
294 lines (277 loc) · 12.5 KB
/
receipt.php
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
<?php
include_once 'functions/authentication.php';
include_once 'functions/connection.php';
$id = $_GET['id'];
$get_tracking_url = getHostByName(getHostName()) . dirname($_SERVER['PHP_SELF']) . '/tracking.php?id=' . $id;
function getLaundryReceipt(){
global $db;
global $id;
$sql = "SELECT t.id, t.customer_id, t.user_id, t.total, l.kilo, p.price, p.name, c.fullname, p.unit
FROM transactions AS t
JOIN laundry AS l ON t.id = l.transaction_id
JOIN prices AS p ON l.type = p.id
JOIN users AS u ON t.user_id = u.id
JOIN customers AS c ON t.customer_id = c.id
WHERE t.id = :id";
$stmt = $db->prepare($sql);
$stmt->bindParam(':id', $id);
$stmt->execute();
$result = $stmt->fetchAll();
foreach($result as $row){
?>
<tr class="font-monospace">
<td class="font-monospace text-start mt-0 mb-0" style="font-size: 10px;"><?= $row['name']?></td>
<th class="font-monospace text-center mt-0 mb-0" style="font-size: 10px;"><?= $row['kilo'].' '.$row['unit']?></th>
<th class="font-monospace text-center mt-0 mb-0" style="font-size: 10px;">₱<?= number_format($row['price'], 2)?></th>
<td class="font-monospace text-end mt-0 mb-0" style="font-size: 10px;">₱<?= number_format($row['price'] * $row['kilo'], 2)?></td>
</tr>
<?php
}
}
function getItemsReceipt(){
global $db;
global $id;
$sql = "SELECT e.qty, e.item_id, i.name, i.unit
FROM items AS i
JOIN expenditures AS e ON i.id = e.item_id
WHERE e.transaction_id = :id";
$stmt = $db->prepare($sql);
$stmt->bindParam(':id', $id);
$stmt->execute();
$result = $stmt->fetchAll();
foreach($result as $row){
?>
<tr class="font-monospace">
<td class="font-monospace text-start mt-0 mb-0" style="font-size: 10px;"><?= $row['name']?></td>
<th class="font-monospace text-center mt-0 mb-0" style="font-size: 10px;"><?= $row['unit']?></th>
<td class="font-monospace text-end mt-0 mb-0" style="font-size: 10px;"><?= $row['qty']?></td>
</tr>
<?php
}
}
$sql = "SELECT t.id, t.total, l.kilo, p.price, t.amount, c.fullname
FROM transactions AS t
JOIN laundry AS l ON t.id = l.transaction_id
JOIN prices AS p ON l.type = p.id
JOIN customers AS c ON t.customer_id = c.id
WHERE t.id = :id";
$stmt = $db->prepare($sql);
$stmt->bindParam(':id', $id);
$stmt->execute();
$result = $stmt->fetchAll();
$total = 0;
$customer = '';
foreach($result as $row){
$total += $row['price'] * $row['kilo'];
$customer = $row['fullname'];
$amount = $row['amount'];
}
?>
<!DOCTYPE html>
<html data-bs-theme="light" lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<title>LMS</title>
<link rel="shortcut icon" href="assets/img/washing-clothes.gif" type="image/gif">
<meta name="description" content="LMS - Laundry Management System">
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i&display=swap">
<link rel="stylesheet" href="assets/css/bs-theme-overrides.css">
<link rel="stylesheet" href="assets/css/dataTables.bootstrap5.min.css">
<link rel="stylesheet" href="assets/css/Pricing-Centered-badges.css">
<script src="assets/js/qrious.min.js"></script>
</head>
<body class="mx-5" onload="<?php if (!isset($_GET['type'])){echo 'printPageAndRedirect()';}?>">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th class="font-monospace text-center" style="color: var(--bs-gray-900);font-size: 13px;">
<img src="assets/img/washing-clothes.gif" width="40"> Laundry Management System<br>
<span style="font-weight: normal !important;">Street Unknown, Pagadian City</span><br>
<span style="font-weight: normal !important;">Phone (+63) 000-000-000</span><br>
<span style="font-weight: normal !important;">Date: <?php echo date('Y-m-d')?></span><br>
<canvas class="mt-1 mb-2 text-center" id="qr-code"></canvas>
</th>
</tr>
</thead>
<tbody>
<tr></tr>
<tr></tr>
</tbody>
</table>
</div>
<div class="table-responsive">
<table class="table table-borderless">
<thead>
<tr>
<th class="font-monospace text-center" style="font-size: 15px;">Laundry Receipt</th>
</tr>
</thead>
<tbody class="font-monospace">
<tr class="font-monospace"></tr>
<tr class="font-monospace"></tr>
</tbody>
</table>
</div>
<div class="table-responsive font-monospace">
<table class="table table-borderless">
<thead class="font-monospace">
<tr class="font-monospace">
<th class="font-monospace" style="font-size: 15px;"><span style="font-weight: normal !important;">CUSTOMER: <strong><?php echo $customer; ?></strong></span></th>
<th class="font-monospace text-end" style="font-size: 15px;"></th>
<th class="font-monospace text-end" style="font-size: 15px;"></th>
<th class="font-monospace text-end" style="font-size: 15px;">INVOICE #<?php echo $_GET['id'] ?></th>
</tr>
</thead>
<tbody class="font-monospace">
</tbody>
</table>
</div>
<div class="table-responsive font-monospace">
<table class="table table-borderless">
<thead class="font-monospace">
<tr class="font-monospace">
<th class="font-monospace text-center" style="font-size: 15px;"><span style="font-weight: normal !important;">LAUNDRY</span></th>
</tr>
</thead>
<tbody class="font-monospace">
</tbody>
</table>
</div>
<div class="table-responsive font-monospace">
<table class="table table-borderless">
<thead class="font-monospace">
<tr class="font-monospace">
<th class="font-monospace text-start" style="font-size: 12px;"><span><strong>LAUNDRY</strong></span></th>
<th class="font-monospace text-center" style="font-size: 12px;"><span><strong></strong></span></th>
<th class="font-monospace text-center" style="font-size: 12px;"><span><strong>PRICE</strong></span></th>
<th class="font-monospace text-end" style="font-size: 12px;"><span><strong>TOTAL</strong></span></th>
</tr>
</thead>
<tbody class="font-monospace">
<?php getLaundryReceipt()?>
</tbody>
</table>
</div>
<div class="table-responsive font-monospace">
<table class="table table-borderless">
<thead class="font-monospace">
<tr class="font-monospace">
<th class="font-monospace text-center" style="font-size: 15px;"><span style="font-weight: normal !important;">ITEMS</span></th>
</tr>
</thead>
<tbody class="font-monospace">
</tbody>
</table>
</div>
<div class="table-responsive font-monospace">
<table class="table table-borderless">
<thead class="font-monospace">
<tr class="font-monospace">
<th class="font-monospace text-start" style="font-size: 12px;"><span><strong>ITEM</strong></span></th>
<th class="font-monospace text-center" style="font-size: 12px;"><span><strong>UNIT</strong></span></th>
<th class="font-monospace text-end" style="font-size: 12px;"><span><strong>QTY</strong></span></th>
</tr>
</thead>
<tbody class="font-monospace">
<?php getItemsReceipt() ?>
</tbody>
</table>
</div>
<div class="table-responsive">
<table class="table">
<thead class="font-monospace">
<tr class="font-monospace">
<th class="font-monospace text-end"><strong>TOTAL</strong> <strong>₱<?php echo number_format($total, 2); ?></strong></th>
</tr>
<tr class="font-monospace">
<th class="font-monospace text-end"><strong>AMOUNT</strong> <strong>₱<?php echo number_format($amount, 2); ?></strong></th>
</tr>
<tr class="font-monospace">
<th class="font-monospace text-end"><strong>CHANGES</strong> <strong>₱<?php echo number_format($amount - $total, 2); ?></strong></th>
</tr>
</thead>
<tbody>
<tr></tr>
</tbody>
</table>
<table class="table table-borderless">
<thead class="font-monospace">
<tr class="font-monospace">
<th class="font-monospace text-center"><strong class="text-danger">**** PLEASE BRING THE Receipt TO CLAIM YOUR LAUNDRY ****</strong></th>
</tr>
</thead>
<tbody>
<tr></tr>
</tbody>
</table>
</div>
<!-- BASKET QRCODE -->
<div class="table-responsive mt-5">
<table class="table">
<thead>
<tr>
<th class="font-monospace text-center" style="color: var(--bs-gray-900);font-size: 13px;">
<img src="assets/img/washing-clothes.gif" width="40"> Laundry Management System<br>
<span style="font-weight: normal !important;">Street Unknown, Pagadian City</span><br>
<span style="font-weight: normal !important;">Phone (+63) 000-000-000</span><br>
<span style="font-weight: normal !important;">Date: <?php echo date('Y-m-d')?></span><br>
<canvas class="mt-1 mb-2 text-center w-100" id="qr-code-basket"></canvas>
<h1 class="display-1">BASKET QRCODE</h1>
</th>
</tr>
</thead>
<tbody>
<tr></tr>
<tr></tr>
</tbody>
</table>
</div>
<!-- END BASKET QRCODE -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/js/jquery.dataTables.min.js"></script>
<script src="assets/js/dataTables.bootstrap5.min.js"></script>
<script src="assets/js/dataTables.buttons.min.js"></script>
<script src="assets/js/jszip.min.js"></script>
<script src="assets/js/pdfmake.min.js"></script>
<script src="assets/js/vfs_fonts.js"></script>
<script src="assets/js/buttons.html5.min.js"></script>
<script src="assets/js/buttons.print.min.js"></script>
<script src="assets/js/listTable.js"></script>
<script src="assets/js/theme.js"></script>
<script>
$(document) .ready(function() {
(function() {
var qr = new QRious({
element: document.getElementById('qr-code'),
size: 150,
value: '<?php echo $get_tracking_url; ?>'
});
var qr = new QRious({
element: document.getElementById('qr-code-basket'),
size: 350,
value: 'id=17'
});
})();
// $('.qr-code').each(function() {
// var qr = new QRious({
// element: this,
// size: 150,
// value: '<?php echo $get_tracking_url; ?>'
// });
// });
} );
function printPageAndRedirect() {
setTimeout(function() {
window.setTimeout(function() {
window.print();
window.location.href = 'transaction.php';
}, 500);
}, 500);
}
</script>
</body>
</html>