created invoice pdf

This commit is contained in:
Juthatip McDevitt 2024-06-28 17:04:50 -05:00
parent 83b122c4d1
commit d2fe12c1ea
3 changed files with 127 additions and 11 deletions

View file

@ -8,7 +8,7 @@
if(isset($_POST['get_booking'])){ if(isset($_POST['get_booking'])){
$frm_data = filteration($_POST); $frm_data = filteration($_POST);
$query = "SELECT bo.*, bd.* FROM `booking_order` bo INNER JOIN `booking_detail` bd ON bo.booking_id = bd.booking_id WHERE (bo.order_id LIKE ? OR bd.phone LIKE ? OR bd.user_name LIKE ? OR bd.user_lastname LIKE ?) AND (bo.booking_status ='pending' OR bo.booking_status ='cancel') ORDER BY bo.booking_id ASC"; $query = "SELECT bo.*, bd.* FROM `booking_order` bo INNER JOIN `booking_detail` bd ON bo.booking_id = bd.booking_id WHERE (bo.order_id LIKE ? OR bd.phone LIKE ? OR bd.user_name LIKE ? OR bd.user_lastname LIKE ?) AND ((bo.booking_status ='pending' AND bo.arrival = 1) OR bo.booking_status ='cancel') ORDER BY bo.booking_id ASC";
$res = select($query, ["%$frm_data[search]%", "%$frm_data[search]%", "%$frm_data[search]%", "%$frm_data[search]%"], 'ssss'); $res = select($query, ["%$frm_data[search]%", "%$frm_data[search]%", "%$frm_data[search]%", "%$frm_data[search]%"], 'ssss');
$i = 1; $i = 1;
$table_data = ""; $table_data = "";
@ -26,11 +26,11 @@
if($data['booking_status'] == 'pending'){ if($data['booking_status'] == 'pending'){
$status_bg = 'bg-success'; $status_bg = 'bg-success';
$status = 'Booked'; $status = 'Booked';
} else if($data['booking_status'] == 'cancel'){ $invoice = "<button type='button' onclick='download_invoice($data[booking_id])' class='btn-second' style='font-size: 14px; padding: 5px; font-weight: 600;'> Invoice</button>";
} else{
$status_bg = 'bg-danger'; $status_bg = 'bg-danger';
$status = 'Cancelled'; $status = 'Cancelled';
} else{ $invoice = '';
$status_bg = 'bg-warning text-dark';
} }
$table_data .= " $table_data .= "
@ -50,7 +50,7 @@
<span class='$status_bg text-white' style='padding: 5px; border-radius: 5px; font-size: 14px; font-weight: 600;'>$status</span> <span class='$status_bg text-white' style='padding: 5px; border-radius: 5px; font-size: 14px; font-weight: 600;'>$status</span>
</td> </td>
<td> <td>
<button type='button' onclick='download_invoice($data[booking_id])' class='btn-second' style='font-size: 14px; padding: 5px; font-weight: 600;'> Invoice</button> $invoice
</td> </td>
</tr> </tr>
"; ";

View file

@ -0,0 +1,116 @@
<?php
require('components/utils.php');
require('components/db_config.php');
require('components/link.php');
adminLogin();
if(isset($_GET['gen_pdf']) && isset($_GET['id'])){
$frm_data = filteration($_GET);
$query = "SELECT bo.*, bd.* FROM `booking_order` bo INNER JOIN `booking_detail` bd ON bo.booking_id = bd.booking_id WHERE ((bo.booking_status='pending' AND bo.arrival = 1) OR (bo.booking_status='cancel' AND bo.arrival = 0))
AND bo.booking_id = '$frm_data[id]' ";
$res = mysqli_query($con, $query);
$total_rows = mysqli_num_rows($res);
if($total_rows == 0){
header('location: dashboard.php');
exit;
}
$data = mysqli_fetch_assoc($res);
$date = date("M-d-Y", strtotime($data['datentime']));
$checkin = date("M-d-Y", strtotime($data['check_in']));
$checkout = date("M-d-Y", strtotime($data['check_out']));
$total_pay = $data['total_pay'];
$tax = $data['total_pay'] * 0.05;
$total_amount = $tax + $total_pay;
$table_data = "
<div class='container'>
<div class='card' style='max-width: 800px; margin: auto; margin-top: 50px; margin-bottom: 50px;'>
<div class='card-header' style='background-color: #E1F0DA;'>
<div class='card-header-top' style='margin-top: 25px;'>
<div class='card-header-top-left'>
<img src='../images/logo.png'/>
</div>
<div class='card-header-top-right text-end'>
<p style='font-size: 16px; text-transform: uppercase; font-weight: 600;'>Midtown Hotel</p>
<p>36381 Trantow Hill,</p>
<p>New Port, FL 57941</p>
<p>(123) 456-7891</p>
<p>accombooking@midtownhotel.com</p>
</div>
</div>
<div class='card-header-bottom' style='margin-top: 25px;'>
<div class='card-header-bottom-left text-start'>
<p style='font-weight: 600;'>Bill to:</p>
<p style='text-transform: capitalize;'><b>Name:</b> $data[user_name] $data[user_lastname]</p>
<p><b>Adress:</b> $data[address]</p>
<p><b>Phone:</b> $data[phone]</p>
</div>
<div class='card-header-right text-start'>
<p><b>Order ID:</b> $data[order_id]</p>
<p><b>Invoice date:</b> $checkin</p>
</div>
</div>
</div>
<div class='card-body' style='background-color: #F1F8E8; height: 500px;'>
<table class='table table-striped'>
<thead>
<tr class='text-start text-title'>
<th scope='col' style='width: 50%;'>Details</th>
<th scope='col'>Check in</th>
<th scope='col'>Check out</th>
<th scope='col'>Price</th>
</tr>
</thead>
<tbody>
<tr class='text-start text-subtitle'>
<td>$data[room_name]</td>
<td>$checkin</td>
<td>$checkout</td>
<td>$data[price]/night</td>
</tr>
</tbody>
</table>
<div class='card-summary text-end' style='margin: 20px;'>
<p><b>Total:</b> $$total_pay</p>
<p><b>Sale Tax(0.5%):</b> $$tax</p>
<p><b>Total Amount:</b> $$total_amount</p>
</div>
</div>
<div class='card-footer' style='background-color: #E1F0DA;'>
<p class='text-center'>Thank you for staying with us! We hope you have a great time and wonderful memories during your stay. <br>
We will be greatful if you please leave us a review in your client protal.</p>
</div>
</div>
</div>
";
echo $table_data;
} else{
header('location: dashboard.php');
}
?>
<style>
.card-header-top, .card-header-bottom{
display: flex;
justify-content: space-between;
}
.card-header-top-left img{
width: 100px;
}
.card-header-top-right p{
font-size: 14px;
line-height: 10px;
}
.card-footer p{
font-size: 14px;
}
.card-header-bottom-left p, .card-header-right p{
font-size: 16px;
line-height: 12px;
}
.text-title{
font-size: 16px;
}
</style>

View file

@ -45,14 +45,12 @@
} }
.card-header-top-right p{ .card-header-top-right p{
font-size: 14px; font-size: 14px;
line-height: 10px;
} }
.card-footer p{ .card-footer p{
font-size: 14px; font-size: 14px;
} }
.card-header-bottom-left p, .card-header-right p{ .card-header-bottom-left p, .card-header-right p{
font-size: 16px; font-size: 16px;
line-height: 12px;
} }
.text-title{ .text-title{
font-size: 16px; font-size: 16px;
@ -63,7 +61,6 @@
} }
.card-header-top-right p{ .card-header-top-right p{
font-size: 12px; font-size: 12px;
line-height: 5px;
} }
.card-footer p{ .card-footer p{
font-size: 12px; font-size: 12px;
@ -73,7 +70,6 @@
} }
.card-header-bottom-left p, .card-header-right p{ .card-header-bottom-left p, .card-header-right p{
font-size: 14px; font-size: 14px;
line-height: 10px;
} }
.text-title, .text-subtitle, .card-summary p{ .text-title, .text-subtitle, .card-summary p{
font-size: 14px; font-size: 14px;
@ -111,6 +107,8 @@
$room_price = $data['price']; $room_price = $data['price'];
$room_detail = $data['room_name']; $room_detail = $data['room_name'];
$total_pay = $data['total_pay']; $total_pay = $data['total_pay'];
$tax = $data['total_pay'] * 0.05;
$total_amount = $tax + $total_pay;
} }
?> ?>
<div class="card-header-bottom" style="margin-top: 25px;"> <div class="card-header-bottom" style="margin-top: 25px;">
@ -122,7 +120,7 @@
</div> </div>
<div class="card-header-right text-start"> <div class="card-header-right text-start">
<p><b>Order ID:</b> <?php echo $order_id ?></p> <p><b>Order ID:</b> <?php echo $order_id ?></p>
<p><b>Invoice date:</b> <?php echo $date ?></p> <p><b>Reservation date:</b> <?php echo $date ?></p>
<p><b>Due date:</b> <?php echo $checkin ?></p> <p><b>Due date:</b> <?php echo $checkin ?></p>
</div> </div>
</div> </div>
@ -148,7 +146,9 @@
</table> </table>
</div> </div>
<div class="card-summary text-end" style="margin: 20px;"> <div class="card-summary text-end" style="margin: 20px;">
<p>Total: $<?php echo $total_pay?></p> <p><b>Total:</b> $<?php echo $total_pay?></p>
<p><b>Sale Tax(0.5%):</b> $<?php echo $tax?></p>
<p><b>Total Amount:</b> $<?php echo $total_amount?></p>
</div> </div>
<div class="card-footer"> <div class="card-footer">
<p><span style="color: red;">*</span> Please pay the invoice before checking-in to the room. You can pay the invoice by bringing this invoice to make a payment at the hotel reception desk. <span style="color: red;">*</span></p> <p><span style="color: red;">*</span> Please pay the invoice before checking-in to the room. You can pay the invoice by bringing this invoice to make a payment at the hotel reception desk. <span style="color: red;">*</span></p>