Skip to content

Commit 0952f42

Browse files
Fix bug in login functionality
1 parent 1f53843 commit 0952f42

File tree

2 files changed

+346
-100
lines changed

2 files changed

+346
-100
lines changed

reciept.php

Lines changed: 191 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,75 @@
11
<?php
2+
include_once 'functions/authentication.php';
23
include_once 'functions/connection.php';
3-
session_start();
4-
if (!isset($_SESSION['username'])) {
5-
header('location:login.php');
6-
}
74
$id = $_GET['id'];
8-
$kilo = $_GET['kilo'];
9-
$type = $_GET['type'];
10-
$type_price = $_GET['type_price'];
11-
$products = $_GET['products'];
12-
$total = $_GET['total'];
135
$get_tracking_url = getHostByName(getHostName()) . dirname($_SERVER['PHP_SELF']) . '/tracking.php?id=' . $id;
146

15-
$sql = 'SELECT Transactions.id, customers.fullname AS fullname
16-
FROM Transactions
17-
JOIN users ON Transactions.user_id = users.id
18-
JOIN customers ON Transactions.customer_id = customers.id
19-
WHERE Transactions.id = :id';
7+
function getLaundryReciept(){
8+
global $db;
9+
global $id;
10+
$sql = "SELECT t.id, t.customer_id, t.user_id, t.total, l.kilo, p.price, p.name, c.fullname
11+
FROM transactions AS t
12+
JOIN laundry AS l ON t.id = l.transaction_id
13+
JOIN prices AS p ON l.type = p.id
14+
JOIN users AS u ON t.user_id = u.id
15+
JOIN customers AS c ON t.customer_id = c.id
16+
WHERE t.id = :id";
17+
$stmt = $db->prepare($sql);
18+
$stmt->bindParam(':id', $id);
19+
$stmt->execute();
20+
$result = $stmt->fetchAll();
21+
foreach($result as $row){
22+
?>
23+
<tr class="font-monospace">
24+
<td class="font-monospace text-start mt-0 mb-0" style="font-size: 10px;"><?= $row['name']?></td>
25+
<th class="font-monospace text-center mt-0 mb-0" style="font-size: 10px;"><?= $row['kilo']?>kg</th>
26+
<th class="font-monospace text-center mt-0 mb-0" style="font-size: 10px;">₱<?= number_format($row['price'], 2)?></th>
27+
<td class="font-monospace text-end mt-0 mb-0" style="font-size: 10px;">₱<?= number_format($row['price'] * $row['kilo'], 2)?></td>
28+
</tr>
29+
<?php
30+
}
31+
}
32+
33+
function getItemsReciept(){
34+
global $db;
35+
global $id;
36+
$sql = "SELECT e.qty, e.item_id, i.name, i.unit
37+
FROM items AS i
38+
JOIN expenditures AS e ON i.id = e.item_id
39+
WHERE e.transaction_id = :id";
40+
$stmt = $db->prepare($sql);
41+
$stmt->bindParam(':id', $id);
42+
$stmt->execute();
43+
$result = $stmt->fetchAll();
44+
foreach($result as $row){
45+
?>
46+
<tr class="font-monospace">
47+
<td class="font-monospace text-start mt-0 mb-0" style="font-size: 10px;"><?= $row['name']?></td>
48+
<th class="font-monospace text-center mt-0 mb-0" style="font-size: 10px;"><?= $row['unit']?></th>
49+
<td class="font-monospace text-end mt-0 mb-0" style="font-size: 10px;"><?= $row['qty']?></td>
50+
</tr>
51+
<?php
52+
}
53+
}
54+
55+
$sql = "SELECT t.id, t.total, l.kilo, p.price, c.fullname
56+
FROM transactions AS t
57+
JOIN laundry AS l ON t.id = l.transaction_id
58+
JOIN prices AS p ON l.type = p.id
59+
JOIN customers AS c ON t.customer_id = c.id
60+
WHERE t.id = :id";
2061
$stmt = $db->prepare($sql);
21-
$stmt->execute(['id' => $id]);
22-
$result = $stmt->fetch();
62+
$stmt->bindParam(':id', $id);
63+
$stmt->execute();
64+
$result = $stmt->fetchAll();
65+
66+
$total = 0;
67+
$customer = '';
68+
69+
foreach($result as $row){
70+
$total += $row['price'] * $row['kilo'];
71+
$customer = $row['fullname'];
72+
}
2373

2474

2575
?>
@@ -29,7 +79,8 @@
2979
<head>
3080
<meta charset="utf-8">
3181
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
32-
<title>Laundry</title>
82+
<title>LMS</title>
83+
<meta name="description" content="LMS - Laundry Management System">
3384
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
3485
<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&amp;display=swap">
3586
<link rel="stylesheet" href="assets/css/bs-theme-overrides.css">
@@ -38,49 +89,118 @@
3889
<script src="assets/js/qrious.min.js"></script>
3990
</head>
4091

41-
<body>
42-
<div class="container py-4 py-xl-5">
43-
<div class="row row-cols-1 row-cols-md-2 row-cols-xl-3 d-xl-flex justify-content-center gutter-y">
44-
<div class="col">
45-
<div class="card border-primary border-2">
46-
<div class="card-body text-center p-4">
47-
<span class="badge rounded-pill bg-primary position-absolute top-0 start-50 translate-middle text-uppercase">Reciept</span>
48-
<h6 class="text-uppercase text-muted card-subtitle">Total</h6>
49-
<h4 class="display-4 fw-bold card-title">₱<?php echo number_format($total, 2); ?></h4>
50-
<canvas id="qr-code"></canvas>
51-
</div>
52-
<div class="card-footer p-4">
53-
<div id="receipt">
54-
55-
<ul class="list-unstyled">
56-
<li class="d-flex mb-2"><span class="bs-icon-xs bs-icon-rounded bs-icon-primary-light bs-icon me-2"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-check2-circle">
57-
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"></path>
58-
<path d="M10.97 4.97a.235.235 0 0 0-.02.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-1.071-1.05z"></path>
59-
</svg></span><span><strong>Customer : <?php echo $result['fullname']; ?></strong></span></li>
60-
<li class="d-flex mb-2"><span class="bs-icon-xs bs-icon-rounded bs-icon-primary-light bs-icon me-2"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-check2-circle">
61-
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"></path>
62-
<path d="M10.97 4.97a.235.235 0 0 0-.02.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-1.071-1.05z"></path>
63-
</svg></span><span><strong>Kg/Kilo : <?php echo $kilo; ?></strong></span></li>
64-
<li class="d-flex mb-2"><span class="bs-icon-xs bs-icon-rounded bs-icon-primary-light bs-icon me-2"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-check2-circle">
65-
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"></path>
66-
<path d="M10.97 4.97a.235.235 0 0 0-.02.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-1.071-1.05z"></path>
67-
</svg></span><span><strong>Type : <?php echo $type; ?> -&nbsp;₱<?php echo number_format($type_price, 2); ?></strong></span></li>
68-
<li class="d-flex mb-2"><span class="bs-icon-xs bs-icon-rounded bs-icon-primary-light bs-icon me-2"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-check2-circle">
69-
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"></path>
70-
<path d="M10.97 4.97a.235.235 0 0 0-.02.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-1.071-1.05z"></path>
71-
</svg></span><span><strong>Products</strong>&nbsp;: <strong>₱<?php echo number_format($products, 2); ?></strong></span></li>
72-
<li class="d-flex mb-2"><span class="bs-icon-xs bs-icon-rounded bs-icon-primary-light bs-icon me-2"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-check-circle">
73-
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"></path>
74-
<path d="M10.97 4.97a.235.235 0 0 0-.02.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-1.071-1.05z"></path>
75-
</svg></span><span><strong>Total :&nbsp;₱<?php echo number_format($total, 2); ?></strong></span></li>
76-
</ul>
77-
</div>
78-
<a class="btn btn-primary d-block w-100" role="button" onclick="printReceipt()">Print</a>
79-
<a class="btn btn-primary d-block w-100" role="button" href="transaction.php" style="margin-top: 10px;">Go back</a>
80-
</div>
81-
</div>
82-
</div>
83-
</div>
92+
<body onload="printPageAndRedirect()">
93+
<div class="table-responsive">
94+
<table class="table">
95+
<thead>
96+
<tr>
97+
<th class="font-monospace text-center" style="color: var(--bs-gray-900);font-size: 13px;">
98+
<img src="assets/img/washing-clothes.gif" width="40">&nbsp;Laundry Management System<br>
99+
<span style="font-weight: normal !important;">Street Unknown, Pagadian City</span><br>
100+
<span style="font-weight: normal !important;">Phone (+63) 000-000-000</span><br>
101+
<span style="font-weight: normal !important;">Date: <?php echo date('Y-m-d')?></span><br>
102+
<canvas class="mt-1 mb-2 text-center" id="qr-code"></canvas>
103+
</th>
104+
</tr>
105+
</thead>
106+
<tbody>
107+
<tr></tr>
108+
<tr></tr>
109+
</tbody>
110+
</table>
111+
</div>
112+
<div class="table-responsive">
113+
<table class="table table-borderless">
114+
<thead>
115+
<tr>
116+
<th class="font-monospace text-center" style="font-size: 15px;">Laundry Reciept</th>
117+
</tr>
118+
</thead>
119+
<tbody class="font-monospace">
120+
<tr class="font-monospace"></tr>
121+
<tr class="font-monospace"></tr>
122+
</tbody>
123+
</table>
124+
</div>
125+
<div class="table-responsive font-monospace">
126+
<table class="table table-borderless">
127+
<thead class="font-monospace">
128+
<tr class="font-monospace">
129+
<th class="font-monospace" style="font-size: 15px;"><span style="font-weight: normal !important;">CUSTOMER: <strong><?php echo $customer; ?></strong></span></th>
130+
<th class="font-monospace text-end" style="font-size: 15px;"></th>
131+
<th class="font-monospace text-end" style="font-size: 15px;"></th>
132+
<th class="font-monospace text-end" style="font-size: 15px;">INVOICE #<?php echo $_GET['id'] ?></th>
133+
</tr>
134+
</thead>
135+
<tbody class="font-monospace">
136+
137+
</tbody>
138+
</table>
139+
</div>
140+
<div class="table-responsive font-monospace">
141+
<table class="table table-borderless">
142+
<thead class="font-monospace">
143+
<tr class="font-monospace">
144+
<th class="font-monospace text-center" style="font-size: 15px;"><span style="font-weight: normal !important;">LAUNDRY</span></th>
145+
</tr>
146+
</thead>
147+
<tbody class="font-monospace">
148+
149+
</tbody>
150+
</table>
151+
</div>
152+
<div class="table-responsive font-monospace">
153+
<table class="table table-borderless">
154+
<thead class="font-monospace">
155+
<tr class="font-monospace">
156+
<th class="font-monospace text-start" style="font-size: 12px;"><span><strong>TYPE</strong></span></th>
157+
<th class="font-monospace text-center" style="font-size: 12px;"><span><strong>LOAD</strong></span></th>
158+
<th class="font-monospace text-center" style="font-size: 12px;"><span><strong>PRICE</strong></span></th>
159+
<th class="font-monospace text-end" style="font-size: 12px;"><span><strong>TOTAL</strong></span></th>
160+
</tr>
161+
</thead>
162+
<tbody class="font-monospace">
163+
<?php getLaundryReciept()?>
164+
</tbody>
165+
</table>
166+
</div>
167+
<div class="table-responsive font-monospace">
168+
<table class="table table-borderless">
169+
<thead class="font-monospace">
170+
<tr class="font-monospace">
171+
<th class="font-monospace text-center" style="font-size: 15px;"><span style="font-weight: normal !important;">ITEMS</span></th>
172+
</tr>
173+
</thead>
174+
<tbody class="font-monospace">
175+
176+
</tbody>
177+
</table>
178+
</div>
179+
<div class="table-responsive font-monospace">
180+
<table class="table table-borderless">
181+
<thead class="font-monospace">
182+
<tr class="font-monospace">
183+
<th class="font-monospace text-start" style="font-size: 12px;"><span><strong>ITEM</strong></span></th>
184+
<th class="font-monospace text-center" style="font-size: 12px;"><span><strong>UNIT</strong></span></th>
185+
<th class="font-monospace text-end" style="font-size: 12px;"><span><strong>QTY</strong></span></th>
186+
</tr>
187+
</thead>
188+
<tbody class="font-monospace">
189+
<?php getItemsReciept() ?>
190+
</tbody>
191+
</table>
192+
</div>
193+
<div class="table-responsive">
194+
<table class="table">
195+
<thead class="font-monospace">
196+
<tr class="font-monospace">
197+
<th class="font-monospace text-end"><strong>TOTAL</strong>&nbsp;<strong>₱<?php echo number_format($total, 2); ?></strong></th>
198+
</tr>
199+
</thead>
200+
<tbody>
201+
<tr></tr>
202+
</tbody>
203+
</table>
84204
</div>
85205
<script src="assets/js/jquery.min.js"></script>
86206
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
@@ -94,55 +214,26 @@
94214
<script src="assets/js/buttons.print.min.js"></script>
95215
<script src="assets/js/listTable.js"></script>
96216
<script src="assets/js/theme.js"></script>
97-
98217
<script>
99218
$(document) .ready(function() {
100219
(function() {
101220
var qr = new QRious({
102221
element: document.getElementById('qr-code'),
103-
size: 200,
222+
size: 150,
104223
value: '<?php echo $get_tracking_url; ?>'
105224
});
106225
})();
107-
} );
108-
109-
110226

111-
function printReceipt() {
112-
var printWindow = window.open('', '_blank');
113-
printWindow.document.open();
114-
printWindow.document.write('<html><head>');
115-
printWindow.document.write('<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">');
116-
printWindow.document.write('</head><body>');
117-
printWindow.document.write('<div class="card border-primary border-2 mt-1">');
118-
printWindow.document.write('<div class="card-body text-center p-4">');
119-
printWindow.document.write('<span class="badge rounded-pill bg-primary position-absolute top-0 start-50 translate-middle text-uppercase">Reciept</span>');
120-
printWindow.document.write(' <h6 class="text-uppercase text-muted card-subtitle">Total</h6>');
121-
printWindow.document.write(' <h4 class="display-4 fw-bold card-title">₱<?php echo $total; ?></h4>');
122-
printWindow.document.write('<img id="qr-code-img" src="" />');
123-
printWindow.document.write('</div>');
124-
printWindow.document.write('<div class="card-footer p-4">');
125-
printWindow.document.write('');
126-
printWindow.document.write(document.getElementById('receipt').innerHTML);
127-
printWindow.document.write('</div>');
128-
printWindow.document.write('</body></html>');
129-
130-
var qrValue = '<?php echo $get_tracking_url; ?>';
131-
var qrCodeImg = printWindow.document.getElementById('qr-code-img');
132-
133-
var qr = new QRious({
134-
value: qrValue,
135-
size: 200
136-
});
137-
138-
qrCodeImg.src = qr.toDataURL();
139-
140-
setInterval(function() {
141-
printWindow.close();
142-
}, 10);
143-
printWindow.document.close();
144-
printWindow.print();
145-
}
227+
} );
228+
function printPageAndRedirect() {
229+
setTimeout(function() {
230+
window.setTimeout(function() {
231+
window.print();
232+
window.location.href = 'transaction.php';
233+
}, 500);
234+
}, 500);
235+
}
236+
146237
</script>
147238
</body>
148239

0 commit comments

Comments
 (0)