Skip to content

Commit 88eb315

Browse files
Update proceed-transaction.php and setup.php***
***Add amount field to transactions table*** ***Update reciept.php to display amount and changes*** ***Update transaction.php to include amount input field
1 parent ee6b3a6 commit 88eb315

File tree

5 files changed

+63
-22
lines changed

5 files changed

+63
-22
lines changed

functions/proceed-transaction.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,17 @@
5959
}
6060

6161
echo $total_price;
62-
62+
$amount = $_POST['amount'];
6363
// $sql = "UPDATE laundry SET status = 1 WHERE transaction_id = :id AND status = 0";
6464
// $stmt = $db->prepare($sql);
6565
// $stmt->bindParam(':id', $transaction_id);
6666
// $stmt->execute();
6767

68-
$sql = "UPDATE transactions SET total = :total, status = 'completed' WHERE id = :id AND status = 'pending'";
68+
$sql = "UPDATE transactions SET total = :total, amount = :amount, status = 'completed' WHERE id = :id AND status = 'pending'";
6969
$stmt = $db->prepare($sql);
7070
$stmt->bindParam(':total', $total_price);
7171
$stmt->bindParam(':id', $transaction_id);
72+
$stmt->bindParam(':amount', $amount);
7273
$stmt->execute();
7374

7475
generate_logs('New Pending Transaction', $_SESSION['id'].' added a new pending transaction');

functions/setup.php

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
user_id INT,
4545
customer_id INT,
4646
total DECIMAL(10,2),
47+
amount DECIMAL(10,2),
4748
status VARCHAR(255),
4849
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
4950
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,

invoice.php

+34-13
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function getItemsReciept(){
5252
}
5353
}
5454

55-
$sql = "SELECT t.id, t.total, l.kilo, p.price, c.fullname
55+
$sql = "SELECT t.id, t.total, l.kilo, p.price, t.amount, c.fullname
5656
FROM transactions AS t
5757
JOIN laundry AS l ON t.id = l.transaction_id
5858
JOIN prices AS p ON l.type = p.id
@@ -69,6 +69,7 @@ function getItemsReciept(){
6969
foreach($result as $row){
7070
$total += $row['price'] * $row['kilo'];
7171
$customer = $row['fullname'];
72+
$amount = $row['amount'];
7273
}
7374

7475

@@ -90,7 +91,7 @@ function getItemsReciept(){
9091
<script src="assets/js/qrious.min.js"></script>
9192
</head>
9293

93-
<body class="mx-5" onload="">
94+
<body class="mx-5">
9495
<div class="table-responsive">
9596
<table class="table">
9697
<thead>
@@ -197,12 +198,32 @@ function getItemsReciept(){
197198
<tr class="font-monospace">
198199
<th class="font-monospace text-end"><strong>TOTAL</strong>&nbsp;<strong>₱<?php echo number_format($total, 2); ?></strong></th>
199200
</tr>
201+
<tr class="font-monospace">
202+
<th class="font-monospace text-end"><strong>AMOUNT</strong>&nbsp;<strong>₱<?php echo number_format($amount, 2); ?></strong></th>
203+
</tr>
204+
<tr class="font-monospace">
205+
<th class="font-monospace text-end"><strong>CHANGES</strong>&nbsp;<strong>₱<?php echo number_format($amount - $total, 2); ?></strong></th>
206+
</tr>
200207
</thead>
201208
<tbody>
202209
<tr></tr>
203210
</tbody>
204211
</table>
205-
</div>
212+
<table class="table table-borderless">
213+
<thead class="font-monospace">
214+
<tr class="font-monospace">
215+
<th class="font-monospace text-center"><strong class="text-danger">**** PLEASE BRING THE RECIEPT TO CLAIM YOUR LAUNDRY ****</strong></th>
216+
</tr>
217+
</thead>
218+
<tbody>
219+
<tr></tr>
220+
</tbody>
221+
</table>
222+
</div>
223+
<!-- BASKET QRCODE -->
224+
225+
226+
<!-- END BASKET QRCODE -->
206227
<script src="assets/js/jquery.min.js"></script>
207228
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
208229
<script src="assets/js/jquery.dataTables.min.js"></script>
@@ -218,22 +239,22 @@ function getItemsReciept(){
218239
<script>
219240
$(document) .ready(function() {
220241
(function() {
221-
var qr = new QRious({
242+
var qr = new QRious({
222243
element: document.getElementById('qr-code'),
223244
size: 150,
224245
value: '<?php echo $get_tracking_url; ?>'
225246
});
226247
})();
227-
248+
249+
// $('.qr-code').each(function() {
250+
// var qr = new QRious({
251+
// element: this,
252+
// size: 150,
253+
// value: '<?php echo $get_tracking_url; ?>'
254+
// });
255+
// });
228256
} );
229-
function printPageAndRedirect() {
230-
setTimeout(function() {
231-
window.setTimeout(function() {
232-
window.print();
233-
window.location.href = '<?php if(isset($_GET['type'])){ echo 'tracking.php?id='.$_GET['id']; }?>';
234-
}, 500);
235-
}, 500);
236-
}
257+
237258

238259
</script>
239260
</body>

reciept.php

+19-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function getItemsReciept(){
5252
}
5353
}
5454

55-
$sql = "SELECT t.id, t.total, l.kilo, p.price, c.fullname
55+
$sql = "SELECT t.id, t.total, l.kilo, p.price, t.amount, c.fullname
5656
FROM transactions AS t
5757
JOIN laundry AS l ON t.id = l.transaction_id
5858
JOIN prices AS p ON l.type = p.id
@@ -69,6 +69,7 @@ function getItemsReciept(){
6969
foreach($result as $row){
7070
$total += $row['price'] * $row['kilo'];
7171
$customer = $row['fullname'];
72+
$amount = $row['amount'];
7273
}
7374

7475

@@ -197,12 +198,28 @@ function getItemsReciept(){
197198
<tr class="font-monospace">
198199
<th class="font-monospace text-end"><strong>TOTAL</strong>&nbsp;<strong>₱<?php echo number_format($total, 2); ?></strong></th>
199200
</tr>
201+
<tr class="font-monospace">
202+
<th class="font-monospace text-end"><strong>AMOUNT</strong>&nbsp;<strong>₱<?php echo number_format($amount, 2); ?></strong></th>
203+
</tr>
204+
<tr class="font-monospace">
205+
<th class="font-monospace text-end"><strong>CHANGES</strong>&nbsp;<strong>₱<?php echo number_format($amount - $total, 2); ?></strong></th>
206+
</tr>
200207
</thead>
201208
<tbody>
202209
<tr></tr>
203210
</tbody>
204211
</table>
205-
</div>
212+
<table class="table table-borderless">
213+
<thead class="font-monospace">
214+
<tr class="font-monospace">
215+
<th class="font-monospace text-center"><strong class="text-danger">**** PLEASE BRING THE RECIEPT TO CLAIM YOUR LAUNDRY ****</strong></th>
216+
</tr>
217+
</thead>
218+
<tbody>
219+
<tr></tr>
220+
</tbody>
221+
</table>
222+
</div>
206223
<!-- BASKET QRCODE -->
207224

208225
<div class="table-responsive mt-5">

transaction.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,13 @@
353353
<h4 class="modal-title">Proceed Transaction</h4><button class="btn-close" type="button" aria-label="Close" data-bs-dismiss="modal"></button>
354354
</div>
355355
<div class="modal-body">
356-
<p>Are you sure you want to proceed this transaction?</p>
356+
<form action="functions/proceed-transaction.php" method="post">
357+
<p>Are you sure you want to proceed this transaction?</p>
358+
<input type="hidden" name="id" value="<?php echo $id; ?>">
359+
<input type="hidden" name="kilo">
360+
<input type="hidden" name="type">
361+
<div class="mb-3"><label class="form-label" for="amount"><strong>Amount</strong></label><input class="form-control" type="number" placeholder="Amount" name="amount" value="<?=$total_price?>" min="<?=$total_price?>" required></div>
357362
</div>
358-
<form action="functions/proceed-transaction.php" method="post">
359-
<input type="hidden" name="id" value="<?php echo $id; ?>">
360-
<input type="hidden" name="kilo">
361-
<input type="hidden" name="type">
362363
<div class="modal-footer"><button class="btn btn-light" type="button" data-bs-dismiss="modal">No</button><button class="btn btn-primary" type="submit">Yes</button></div>
363364
</form>
364365
</div>

0 commit comments

Comments
 (0)