-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreciept.php
164 lines (156 loc) · 6.72 KB
/
reciept.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
<?php
include_once 'functions/authentication.php';
include_once 'functions/connection.php';
$id = $_GET['id'];
$sql = "SELECT SUM(CASE
WHEN r.type = 'day' THEN co.priceDay
WHEN r.type = 'night' THEN co.priceNight
WHEN r.type = 'package' THEN co.pricePackage
ELSE 0
END) AS total,
c.fullname
FROM transactions t
JOIN rentals r ON t.id = r.transact_id
JOIN customers c ON t.customer_id = c.id
JOIN cottages co ON r.cottage_id = co.id
WHERE t.id = :id;";
$statement = $db->prepare($sql);
$statement->bindParam(':id', $id);
$statement->execute();
$result = $statement->fetch();
$total = $result['total'];
$customer = $result['fullname'];
function getItems(){
global $id;
global $db;
$sql = "SELECT r.*, c.name AS cottage_name,
CASE
WHEN r.type = 'day' THEN c.priceDay
WHEN r.type = 'night' THEN c.priceNight
WHEN r.type = 'package' THEN c.pricePackage
ELSE 0
END AS price
FROM rentals AS r
JOIN cottages AS c ON r.cottage_id = c.id
WHERE r.transact_id = :transact_id";
$statement = $db->prepare($sql);
$statement->bindParam(':transact_id', $id);
$statement->execute();
$items = $statement->fetchAll();
foreach($items as $row){
$startDateObj = new DateTime($row['start_datetime']);
$endDateObj = new DateTime($row['end_datetime']);
$interval = $startDateObj->diff($endDateObj);
$days = $interval->days;
?>
<tr class="font-monospace" style="font-size: 10px;">
<td class="font-monospace" style="font-size: 10px;">Cottage: <strong><?php echo $row['cottage_name'] ?></strong></td>
<td class="font-monospace text-end" style="font-size: 10px;"></td>
<td class="font-monospace text-center" style="font-size: 10px;"><strong>[<?php echo $row['start_datetime'] ?>] - [<?php echo $row['end_datetime'] ?>] | </strong> <?php echo $days ?> DAYS | <?php echo $row['type'] ?></td>
<td class="font-monospace text-end" style="font-size: 10px;"><strong>₱<?php echo number_format($row['price'], 2) ?></strong></td>
</tr>
<?php
}
}
?>
<!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>CUSTMBRS</title>
<meta name="description" content="CUSTMBRS - Cottage Usage Scheduling with Transaction Monitoring for a Beach Resort System">
<link rel="icon" type="image/png" sizes="512x512" href="assets/img/icon.png">
<link rel="icon" type="image/png" sizes="512x512" href="assets/img/icon.png">
<link rel="icon" type="image/png" sizes="512x512" href="assets/img/icon.png">
<link rel="icon" type="image/png" sizes="512x512" href="assets/img/icon.png">
<link rel="icon" type="image/png" sizes="512x512" href="assets/img/icon.png">
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap-select.min.css">
<link rel="stylesheet" href="assets/css/Nunito.css">
</head>
<body onload="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/icon.png" width="40"> Sere's Point Beach Resort<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>
</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: 10px;">Cottage Rental Reciept</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: 10px;"><span style="font-weight: normal !important;">CUSTOMER: <strong><?php echo $customer; ?></strong></span></th>
<th class="font-monospace text-end" style="font-size: 10px;"></th>
<th class="font-monospace text-end" style="font-size: 10px;"></th>
<th class="font-monospace text-end" style="font-size: 10px;">INVOICE #<?php echo $_GET['id'] ?></th>
</tr>
</thead>
<tbody class="font-monospace">
<?php getItems() ?>
</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>
</thead>
<tbody>
<tr></tr>
</tbody>
</table>
</div>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/bootstrap/js/bootstrap-select.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/three.min.js"></script>
<script src="assets/js/theme.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/vanta.birds.min.js"></script>
<script src="assets/js/vanta.waves.min.js"></script>
<script src="assets/js/sweetalert2.all.min.js"></script>
<script src="assets/js/main.js"></script>
<script>
function printPageAndRedirect() {
window.print();
setTimeout(function() {
window.location.href = 'rent.php';
}, 1000); // Redirect after 1 second (adjust as needed)
}
</script>
</body>
</html>