-
Notifications
You must be signed in to change notification settings - Fork 0
/
invoice.php
234 lines (208 loc) · 7.06 KB
/
invoice.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
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
<style>
body {
font-family: 'Arial', sans-serif;
}
#page-wrapper {
max-width: 800px;
margin: 0 auto;
}
.invoice-container {
justify-content: center;
align-items: center;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
border-radius: 5px;
padding: 20px;
margin-top: 50px;
margin-bottom: 50px;
}
.invoice-header {
background-color: #337ab7;
text-align: center;
color: #ffffff;
padding: 20px;
border-radius: 8px 8px 0 0;
}
.invoice-header img {
width: 60px;
height: 60px;
mix-blend-mode: multiply;
}
.invoice-header h1 {
margin: 0;
font-size: 28px;
}
.invoice-header h4,
.invoice-header p {
margin-bottom: 0;
}
.invoice-details {
margin-top: 20px;
font-size: 18px;
}
.table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
.table th,
.table td {
border: 1px solid #ddd;
padding: 12px;
text-align: left;
font-size: 18px;
}
.table th {
background-color: #337ab7;
color: #ffffff;
}
.invoice-footer {
text-align: center;
font-weight: bold;
margin-top: 20px;
padding: 15px;
border-radius: 0 0 8px 8px;
background-color: #f5f5f5;
}
.invoice-footer p {
margin-bottom: 0;
}
.invoice-footer button {
padding: 12px 24px;
background-color: #337ab7;
color: #ffffff;
border: none;
cursor: pointer;
border-radius: 4px;
}
.signature-section {
text-align: center;
display: flex;
justify-content: space-between;
align-items: center;
}
.signature-box {
width: 45%;
border-top: 2px solid #ddd;
padding-top: 20px;
}
.signature-box p {
margin-bottom: 20px;
color: #555;
}
.signature-box .signature-line {
width: 80%;
height: 1px;
background-color: #ddd;
margin: 0 auto;
}
</style>
<?php
session_start();
if (!isset($_SESSION['id']) || !isset($_SESSION['role'])) {
header('Location: login.php');
exit;
}
include 'connection.php';
include_once('includes/header.php');
// Fetch settings from the database
$querySettings = "SELECT * FROM `setting` LIMIT 1";
$resultSettings = mysqli_query($conn, $querySettings);
$settings = mysqli_fetch_assoc($resultSettings);
$id = $_REQUEST['id'];
$query = "SELECT *, transaction.id as transaction_id,
booking.id as booking_id,
booking.date as booking_date,
authentication.name as ref_name,
transaction.status as transaction_status,
customers.name as cus_name,
customers.phone as cus_phone,
start_slot.start_time as start_time,
end_slot.end_time as end_time
FROM transaction
LEFT JOIN customers ON transaction.user_id = customers.id
LEFT JOIN booking ON transaction.id = booking.transaction_id
LEFT JOIN authentication ON booking.reference_id = authentication.id
LEFT JOIN slot_management AS start_slot ON booking.start_slot_id = start_slot.id
LEFT JOIN slot_management AS end_slot ON booking.end_slot_id = end_slot.id
WHERE transaction.id = $id";
$sql = mysqli_query($conn, $query);
if ($row = mysqli_fetch_array($sql)) {
?>
<div id="page-wrapper">
<br>
<button class="btn btn-primary" style="display: block; margin: 0 auto;" onclick="printInvoice()">Print Invoice</button>
<div class="invoice-container">
<div class="invoice">
<div class="invoice-header">
<img src="<?php echo "assets/uploads/" . $settings['logo']; ?>" alt="<?php echo $settings['brand']; ?>'s Logo">
<div>
<h1 class="page-header"><?php echo $settings['brand']; ?></h1>
<h4><?php echo $settings['location']; ?></h4>
<p><?php echo $settings['phone']; ?> || <?php echo $settings['email']; ?></p>
</div>
</div>
<div class="invoice-details">
<h2>Invoice #<?php echo $row['transaction_id']; ?></h2>
<p>Booked By: <?php echo $row['ref_name']; ?></p>
<p>Date: <?php echo $row['booking_date']; ?></p>
<p>Slot: <?php echo $row['start_time'] . ' - ' . $row['end_time']; ?></p>
<p>Customer Name: <?php echo $row['cus_name']; ?></p>
<p>Customer Cantact: <?php echo $row['cus_phone']; ?></p>
</div>
<div class="table-container">
<table class="table table-bordered">
<thead>
<tr>
<th>Description</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td>Advance</td>
<td>৳ <?php echo $row['advance']; ?>/-</td>
</tr>
<tr>
<td>Due</td>
<td>৳ -<?php echo $row['due']; ?>/-</td>
</tr>
<tr>
<td>Cash</td>
<td>৳ <?php echo $row['cash']; ?>/-</td>
</tr>
<tr>
<td>Total</td>
<td>৳ <?php echo $row['total']; ?>/-</td>
</tr>
</tbody>
</table>
</div><br><br><br>
<div class="signature-section">
<div class="signature-box">
<p>Cashier's Signature</p>
<div class="signature-line"></div>
</div>
<div class="signature-box">
<p>Customer's Signature</p>
<div class="signature-line"></div>
</div>
</div>
<div class="invoice-footer">
<p>Thank You!</p>
<p>Come Again</p>
<p>Powered By Terms Brain</p>
</div>
</div>
</div>
</div> <?php }
?>
<button class="btn btn-primary" style="display: block; margin: 0 auto;" onclick="printInvoice()">Print Invoice</button>
<script>
function printInvoice() {
var printContents = document.querySelector('.invoice-container').innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
}
</script>