-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinvoice.php
More file actions
329 lines (291 loc) · 12.1 KB
/
Copy pathinvoice.php
File metadata and controls
329 lines (291 loc) · 12.1 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
<!DOCTYPE html>
<html lang="en" data-bs-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Invoice | Nimsara Computers</title>
<link rel="stylesheet" href="style.css">
<link href="css\bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css" />
<link rel="icon" href="resource/logo.svg">
<style>
body {
background-color: #111;
color: #fff;
font-family: Arial, sans-serif;
}
.full-width-header, .full-width-footer {
width: 100%;
background-color: #222;
padding: 10px 0;
}
.full-width-header img, .full-width-footer p {
margin-left: 20px;
}
.container-fluid {
max-width: 900px;
margin: 20px auto;
background-color: #222;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
}
.invoice-header,
.invoice-details,
.invoice-table,
.thank-you,
.notice,
.invoice-footer {
color: #fff;
}
.invoice-header h2,
.invoice-footer p {
font-size: 1.2rem;
}
.invoice-table th,
.invoice-table td {
font-size: 0.9rem;
border: 1px solid #444;
}
.invoice-table th {
background-color: #333;
text-align: center;
}
.invoice-table td {
text-align: center;
}
.thank-you {
text-align: center;
margin-top: 20px;
font-size: 1.1rem;
font-weight: bold;
}
.notice {
margin-top: 20px;
font-size: 0.9rem;
background-color: #333;
padding: 10px;
border-radius: 5px;
}
.invoice-footer {
margin-top: 20px;
font-size: 0.8rem;
color: #bbb;
}
.btn-dark {
background-color: #333;
border: none;
}
@media print {
body {
background-color: black;
color: black;
}
.container-fluid {
background-color: black;
color: black;
}
.invoice-header, .invoice-details, .invoice-table, .thank-you, .notice, .invoice-footer {
color: black;
}
.invoice-table th, .invoice-table td {
border: 1px solid black;
}
body * {
visibility: hidden;
}
#printarea, #printarea * {
visibility: visible;
}
#printarea {
position: absolute;
left: 0;
top: 0;
width: 100%;
padding: 20px;
}
.btn, .navbars, .main-footer {
display: none !important;
}
}
</style>
</head>
<body class="main-body">
<!-- Full-Width Header -->
<div class="full-width-header">
<div class="d-flex justify-content-between align-items-center">
<img src="images/Capture-removebg-preview (1).png" alt="Nimsara Computers" class="img-fluid" style="max-height: 80px;">
<div class="text-end text-white me-3">
<h2>Nimsara Computers</h2>
<p>Maradana, Colombo 10, Sri Lanka.<br>+94112 555448<br>nimsara@gmail.com</p>
</div>
</div>
</div>
<!-- Main Container -->
<div class="container-fluid mt-3">
<div class="row">
<?php
session_start();
include "db/connections.php";
if (isset($_SESSION["u"])) {
$umail = $_SESSION["u"]["email"];
$oid = $_GET["id"] ?? null;
if ($oid) {
?>
<div class="col-12 mb-3 invoice-header">
<div class="d-flex justify-content-between">
<button class="btn btn-dark" onclick="printReport();"><i class="bi bi-printer-fill"></i> Print</button>
</div>
</div>
<div id="printarea">
<div class="col-12 invoice-header">
<div class="row">
<div class="col-6">
<img src="images/Capture-removebg-preview (1).png" alt="Nimsara Computers" class="img-fluid text-black" style="max-height: 80px;">
</div>
<div class="col-6 text-end text-black">
<h2>Nimsara Computers</h2>
<p>Maradana, Colombo 10, Sri Lanka.<br>+94112 555448<br>nimsara@gmail.com</p>
</div>
</div>
</div>
<div class="col-12 mb-4">
<div class="row">
<div class="col-md-6">
<table class="table invoice-details">
<tr>
<th>From:</th>
<td>
<strong>Nimsara Computers</strong><br>Maradana, Colombo 10, Sri Lanka.<br>+94112 555448<br>nimsara@gmail.com
</td>
</tr>
<tr>
<th>Bill To:</th>
<td>
<?php echo htmlspecialchars($_SESSION["u"]["first_name"] . " " . $_SESSION["u"]["last_name"]); ?><br>
<?php echo htmlspecialchars($_SESSION["u"]["address_line1"] . " " . $_SESSION["u"]["address_line2"]); ?><br>
<?php echo htmlspecialchars($umail); ?>
</td>
</tr>
</table>
</div>
<div class="col-md-6 text-end">
<?php
$invoice_rs = Database::search("SELECT * FROM `invoice` WHERE `order_id`='" . $oid . "'");
if ($invoice_rs->num_rows > 0) {
$invoice_data = $invoice_rs->fetch_assoc();
?>
<table class="table invoice-details">
<tr>
<th>Date:</th>
<td><?php echo htmlspecialchars($invoice_data["date"]); ?></td>
</tr>
<tr>
<th>Invoice #:</th>
<td><?php echo htmlspecialchars($invoice_data["invoice_id"]); ?></td>
</tr>
</table>
<?php
} else {
echo "<p>No invoice data available</p>";
}
?>
</div>
</div>
</div>
<div class="col-12">
<table class="table table-bordered invoice-table">
<thead>
<tr>
<th>#</th>
<th>Description</th>
<th>Quantity</th>
<th>Unit Price</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<?php
if (isset($invoice_data)) {
$products_rs = Database::search("SELECT * FROM `invoice` WHERE `order_id`='" . $invoice_data["order_id"] . "'");
$counter = 1;
$subtotal = 0;
while ($product_item = $products_rs->fetch_assoc()) {
$product_rs = Database::search("SELECT * FROM `products` WHERE `id`='" . $product_item["products_id"] . "'");
if ($product_rs->num_rows > 0) {
$product_data = $product_rs->fetch_assoc();
$total = $product_data["price"] * $product_item["qty"];
$subtotal += $total;
?>
<tr>
<td><?php echo $counter++; ?></td>
<td><?php echo htmlspecialchars($product_data["title"]); ?></td>
<td><?php echo htmlspecialchars($product_item["qty"]); ?></td>
<td>Rs. <?php echo number_format($product_data["price"], 2); ?></td>
<td>Rs. <?php echo number_format($total, 2); ?></td>
</tr>
<?php
}
}
}
?>
</tbody>
<tfoot class="invoice-summary">
<?php
$delivery = 200;
$grand_total = isset($subtotal) ? $subtotal + $delivery : $delivery;
?>
<tr>
<td colspan="3"></td>
<td>SUBTOTAL</td>
<td>Rs. <?php echo isset($subtotal) ? number_format($subtotal, 2) : '0.00'; ?></td>
</tr>
<tr>
<td colspan="3"></td>
<td>Delivery Fee</td>
<td>Rs. <?php echo number_format($delivery, 2); ?></td>
</tr>
<tr>
<td colspan="3"></td>
<td class="text-primary">GRAND TOTAL</td>
<td class="text-primary">Rs. <?php echo number_format($grand_total, 2); ?></td>
</tr>
</tfoot>
</table>
</div>
<div class="col-12 thank-you">
<span>Thank You!</span>
</div>
<div class="col-12 notice">
<h5>NOTICE:</h5>
<p>Purchased items can be returned before 7 days of delivery.</p>
</div>
<div class="col-12 invoice-footer text-center">
<p>Invoice was created on a computer and is valid without the Signature and Seal.</p>
</div>
</div>
<?php
} else {
echo "<p>No order ID provided.</p>";
}
} else {
echo "<p>User session not set. Please log in.</p>";
}
?>
</div>
</div>
<!-- Full-Width Footer -->
<div class="full-width-footer text-center">
<p>© 2024 Nimsara Computers. All rights reserved.</p>
</div>
<script src="js/bootstrap.bundle.js"></script>
<script src="script.js"></script>
<script src="swalw2.js"></script>
<script src="swalw.js"></script>
<script>
function printReport() {
window.print();
}
</script>
</body>
</html>