web_php/hotel_booking/generate_invoice.php

120 lines
No EOL
5.3 KiB
PHP

<?php
require('admin/components/utils.php');
require('admin/components/db_config.php');
require('admin/components/link.php');
session_start();
if(!(isset($_SESSION['login']) && $_SESSION['login'] == true)){
redirect('index.php');
}
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: index.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(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: index.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>