-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreceipt.php
166 lines (143 loc) · 4.45 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
<?php
## require connection file
require_once("./conn.php");
## start session
session_start();
## if cashier id, cashier name is not set or total amount is equal to Zero go back to cashier's login page
if (!isset($_SESSION['cashier_id']) || !isset($_SESSION['cashier_name']) || $_SESSION['total'] === 0) {
## Redirect to cashier's login page
header("Location: ./cashier_login/cashier_login.php");
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Customer's Receipt - Dadral Stores</title>
<!-- Link favIcon -->
<link rel="shortcut icon" href="./images/shop_logo.png" type="image/x-icon">
</head>
<body>
<section class="wrapper">
<h2 class="store-name">Dadral Stores</h2>
<div class="address">plot 506 along karu jikwoyi express way Abuja. <br/>
<?php date_default_timezone_set('Africa/Lagos'); ?>
Tel: 08121669013. Date: <?= Date("d/m/Y H:i a") ?>
</div>
<div class="trans-id">TRANS-ID: GR<?= @$_SESSION["trans_id"] ?></div> <br/>
<div class="header">
<div>QTY</div>
<div>DESCRIPTION</div>
<div>AMOUNT</div>
<div>TOTAL</div>
</div>
<?php foreach (@$_SESSION['cart'] as $product_id => $product): ?>
<div class="header items">
<div><?= @$product['quantity']; ?></div>
<div><?= @$product['name']; ?></div>
<div>₦<?= number_format(@$product['price']); ?></div>
<div>₦<?= number_format(@$product['price'] * @$product['quantity']); ?></div>
</div>
<?php endforeach; ?>
<br/>
<div class="sales-infor">
<div><?= @$_SESSION["payment_mode"] ?>: ₦<?= number_format(@$_SESSION['total'], 2)?></div>
<div>Change Element: ₦<?= number_format(@$_SESSION["change_element"], 2) ?></div>
<div>Change Reminant: ₦<?= number_format(@$_SESSION["change_reminant"], 2) ?></div>
<div>Cashier: <?= $_SESSION['cashier_name'] ?></div>
</div>
<p class="vat-inclusive">
THANK YOU FOR YOUR PATRONAGE <br/>
Grand Total Is VAT Inclusive <br/>
No Returns, No Refunds
</p>
<div class="print_btn" onclick="print()"></div>
</section>
<!-- style for receipt starts here-->
<style type="text/css">
body {
font-family: Arial, sans-serif;
}
section.wrapper {
width: 280px; /* Adjusted width for thermal printers */
margin: auto;
text-align: center;
}
h2.store-name {
font-size: 14px;
margin-top: 10px;
margin-bottom: 5px;
text-transform: uppercase;
}
.address {
font-size: 10px;
line-height: 14px;
}
.trans-id {
font-size: 10px;
margin-top: 5px;
margin-bottom: 5px;
}
.header, .items {
display: flex;
justify-content: space-between;
border-bottom: 1px dashed #000;
padding-bottom: 3px;
margin-bottom: 3px;
font-size: 10px;
}
.header div:nth-child(1) {
width: 30px; /* Width for quantity column */
text-align: left;
}
.header div:nth-child(2) {
width: 140px; /* Width for description column */
text-align: left;
}
.header div:nth-child(3),
.items div:nth-child(3),
.items div:nth-child(4) {
width: 50px; /* Width for amount and total columns */
text-align: right;
}
div.sales-infor{
text-align: left;
position: relative;
left: 10px;
font-family: sans-serif;
}
div.sales-infor div{
font-size: 10px !important;
margin: 3px 0;
}
.vat-inclusive {
font-size: 10px;
margin-top: 20px;
text-align: left;
line-height: 14px;
}
</style>
<!-- style for receipt ends here-->
<!--- script for receipt btn click --->
<script type="text/javascript">
let print_btn = document.querySelector(".print_btn");
window.addEventListener('DOMContentLoaded', (e) => {
e.preventDefault();
// Perform printing
print_btn.click();
// Redirect to cart page after printing or canceling
window.addEventListener('afterprint', () => {
// Redirect to cart page
window.location.href = "./cart.php";
});
<?php
## unset cart session
unset($_SESSION['cart']);
?>
});
</script>
</body>
</html>