Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions add_room_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<li><a href="admin_room_status.php">Booking Requests</a></li>
<li><a href="confirmed_bookings.php">Confirmed Bookings</a></li>
<li><a href="booking_history.php">Booking History</a></li>
<li><a href="admin_payments.php">Payments</a></li>
<li><a href="index.php">Logout</a></li>
</ul>
<div style="margin-left:25%;padding:1px 16px;height:1000px;">
Expand Down
40 changes: 40 additions & 0 deletions admin_mark_paid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
// Process admin 'Mark paid' action: move from confirmed_booking -> booked_hist and update balance/rooms
$conn = new mysqli("localhost","root","", "iwp");
if($conn->connect_error) {
die("Connection failed: ".$conn->connect_error);
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['book_id'])) {
$bid = $conn->real_escape_string($_POST['book_id']);
$sql = "SELECT * from confirmed_booking WHERE book_id='$bid'";
$result = mysqli_query($conn, $sql);
if ($row = mysqli_fetch_row($result)) {
// update balance
$sql1 = "SELECT * FROM balance";
$result1 = mysqli_query($conn,$sql1);
$r = mysqli_fetch_row($result1);
$r[0] = $r[0] + $row[13];
$sql2 = "DELETE FROM balance";
mysqli_query($conn, $sql2);
$sql2 = "INSERT INTO balance VALUES ('".$r[0]."')";
mysqli_query($conn, $sql2);

// insert into booked_hist
$sql2 = "INSERT INTO booked_hist VALUES ('".$row[0]."','".$row[1]."','".$row[2]."','".$row[3]."','".$row[4]."','".$row[5]."','".$row[6]."','".$row[7]."','".$row[8]."','".$row[9]."','".$row[10]."','".$row[11]."','".$row[12]."','".$row[13]."','".$row[14]."')";
mysqli_query($conn, $sql2);

// delete from confirmed_booking
$sql2 = "DELETE FROM confirmed_booking WHERE book_id='$bid'";
mysqli_query($conn, $sql2);

// update rooms_count
$sql2 = "UPDATE rooms_count SET available_rooms = available_rooms+1, occupied_rooms = occupied_rooms-1 WHERE room_type='".$row[3]."'";
mysqli_query($conn, $sql2);
}
mysqli_free_result($result);
}
$conn->close();
// redirect back to admin payments with a status message
header('Location: admin_payments.php?status=paid&book_id='.urlencode($bid));
exit;
?>
1 change: 1 addition & 0 deletions admin_modify_room1.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function submitForm(action)
<li><a href="admin_room_status.php">Booking Requests</a></li>
<li><a href="confirmed_bookings.php">Confirmed Bookings</a></li>
<li><a href="booking_history.php">Booking History</a></li>
<li><a href="admin_payments.php">Payments</a></li>
<li><a href="index.php">Logout</a></li>
</ul>
<div style="margin-left:25%;padding:1px 16px;height:1000px;">
Expand Down
187 changes: 187 additions & 0 deletions admin_payments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
<!DOCTYPE html>
<html>
<head>
<title>Admin Payments</title>
</head>
<style>
body { margin: 0; background: #f2f2f2; }
table { font-size: 22px; }
td { text-align: center; }
#td1 { background-color: rgba(09,41,98,0.9); color: white; border: 10px; margin-top: -10px; padding: 10px; }
.basic_box { border: 1px solid #ccc; border-radius: 15px; margin: auto; width: 800px; padding: 30px; box-shadow: 0 10px 20px rgba(0,0,0,0.19); }
ul { list-style-type: none; margin: 0; padding: 0; width: 22%; font-size: 24px; background-color: rgba(09,41,98,0.9); position: fixed; height: 100%; overflow: auto; }
li { color: white; }
li a { display: block; color: white; padding: 8px 16px; text-decoration: none; }
li a.active { background-color: #e6b800; color: white; }
li a:hover:not(.active) { background-color: #e6b800; color: white; text-decoration: underline; }
.flash-message { background: #d4edda; color: #155724; padding: 12px; border-radius: 6px; margin: 12px 0; position: relative; transition: opacity 0.3s ease; }
.flash-message .close-btn { position: absolute; top: 8px; right: 10px; background: transparent; border: none; color: #155724; font-size: 18px; cursor: pointer; }
</style>
<body>
<table style="width: 100%;">
<tr>
<td id="td1" style="padding: 10px; font-size: 48px;">THE <p style="color: #e6b800; display: inline;">DELUXE</p> HOTEL</td>
</tr>
</table>
<ul>
<li><a href="admin_view.php">Rooms Info</a></li>
<li><a href="add_room_admin.php">Add Room</a></li>
<li><a href="remove_room_admin.php">Remove Rooms</a></li>
<li><a href="admin_room_status.php">Booking Requests</a></li>
<li><a href="confirmed_bookings.php">Confirmed Bookings</a></li>
<li><a href="booking_history.php">Booking History</a></li>
<li><a href="admin_payments.php" class="active">Payments</a></li>
<li><a href="index.php">Logout</a></li>
</ul>
<div style="margin-left:25%;padding:1px 16px;">
<?php
$conn = new mysqli("localhost","root","", "iwp");
if($conn->connect_error) { die("Connection failed: ".$conn->connect_error); }
$book_id = isset($_GET['book_id']) ? $conn->real_escape_string($_GET['book_id']) : '';
$name = isset($_GET['name']) ? $conn->real_escape_string($_GET['name']) : '';

// Export CSV when requested
if (isset($_GET['export']) && $_GET['export']=='1') {
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=payments.csv');
$out = fopen('php://output', 'w');
fputcsv($out, ['booking_id','name','room_type','checkin','checkout','price','status']);

// unpaid (confirmed_booking)
$w = [];
if ($book_id !== '') $w[] = "book_id='$book_id'";
if ($name !== '') $w[] = "name LIKE '%$name%'";
$where = count($w) ? ' WHERE '.implode(' AND ', $w) : '';
$sql_unpaid = "SELECT book_id,name,room_type,checkin,checkout,price FROM confirmed_booking".$where;
if ($resu = mysqli_query($conn, $sql_unpaid)) {
while ($r = mysqli_fetch_row($resu)) {
fputcsv($out, [$r[0], $r[1], $r[2], $r[3], $r[4], $r[5], 'Unpaid']);
}
}

// paid (booked_hist)
$w2 = [];
if ($book_id !== '') $w2[] = "book_id='$book_id'";
if ($name !== '') $w2[] = "name LIKE '%$name%'";
$where2 = count($w2) ? ' WHERE '.implode(' AND ', $w2) : '';
$sql_paid = "SELECT book_id,name,room_type,checkin,checkout,price FROM booked_hist".$where2;
if ($resp = mysqli_query($conn, $sql_paid)) {
while ($rp = mysqli_fetch_row($resp)) {
fputcsv($out, [$rp[0], $rp[1], $rp[2], $rp[3], $rp[4], $rp[5], 'Paid']);
}
}
fclose($out);
exit;
}
?>

<?php if (isset($_GET['status']) && $_GET['status']==='paid') {
$paid_bid_msg = isset($_GET['book_id']) ? htmlspecialchars($_GET['book_id']) : '';
echo '<div id="flashMessage" class="flash-message">Booking '.($paid_bid_msg?:'').' marked as paid successfully.<button type="button" class="close-btn" onclick="document.getElementById(\'flashMessage\').style.display=\'none\';">&times;</button></div>';
} ?>

<div class="basic_box" style="max-width:900px;">
<form method="get" action="admin_payments.php" style="margin-bottom:18px; display:flex; gap:8px; align-items:center;">
<div>
<label>Booking ID:</label><br>
<input type="text" name="book_id" value="<?php echo htmlspecialchars($book_id); ?>">
</div>
<div>
<label>Name:</label><br>
<input type="text" name="name" value="<?php echo htmlspecialchars($name); ?>">
</div>
<div style="margin-top:20px;">
<button type="submit">Filter</button>
<a href="admin_payments.php?export=1&book_id=<?php echo urlencode($book_id); ?>&name=<?php echo urlencode($name); ?>" style="margin-left:8px;">Export CSV</a>
</div>
</form>

<p style="font-size: 24px; text-align: left;"><b>Unpaid (Confirmed Bookings)</b></p>
<table style="width:100%; border-collapse: collapse;">
<tr>
<th>Booking ID</th>
<th>Name</th>
<th>Room Type</th>
<th>Check-in</th>
<th>Check-out</th>
<th>Price</th>
<th>Action</th>
</tr>
<?php
$w = [];
if ($book_id !== '') $w[] = "book_id='$book_id'";
if ($name !== '') $w[] = "name LIKE '%$name%'";
$where = count($w) ? ' WHERE '.implode(' AND ', $w) : '';
$sql = "SELECT book_id,name,room_type,checkin,checkout,price FROM confirmed_booking".$where;
if ($res = mysqli_query($conn, $sql)) {
while ($r = mysqli_fetch_row($res)) {
echo '<tr>';
echo '<td>'.htmlspecialchars($r[0]).'</td>';
echo '<td>'.htmlspecialchars($r[1]).'</td>';
echo '<td>'.htmlspecialchars($r[2]).'</td>';
echo '<td>'.htmlspecialchars($r[3]).'</td>';
echo '<td>'.htmlspecialchars($r[4]).'</td>';
echo '<td>'.htmlspecialchars($r[5]).'</td>';
echo '<td>';
echo '<form method="post" action="admin_mark_paid.php" style="margin:0;">';
echo '<input type="hidden" name="book_id" value="'.htmlspecialchars($r[0]).'">';
echo '<button type="submit" onclick="return confirm(\'Mark booking '.htmlspecialchars($r[0]).' as paid?\')">Mark paid</button>';
echo '</form>';
echo '</td>';
echo '</tr>';
}
mysqli_free_result($res);
}
?>
</table>
</div>

<br>
<div class="basic_box" style="max-width:900px;">
<p style="font-size: 24px; text-align: left;"><b>Paid (Booking History)</b></p>
<table style="width:100%; border-collapse: collapse;">
<tr>
<th>Booking ID</th>
<th>Name</th>
<th>Room Type</th>
<th>Check-in</th>
<th>Check-out</th>
<th>Price</th>
</tr>
<?php
$w2 = [];
if ($book_id !== '') $w2[] = "book_id='$book_id'";
if ($name !== '') $w2[] = "name LIKE '%$name%'";
$where2 = count($w2) ? ' WHERE '.implode(' AND ', $w2) : '';
$sql2 = "SELECT book_id,name,room_type,checkin,checkout,price FROM booked_hist".$where2;
if ($res2 = mysqli_query($conn, $sql2)) {
while ($r2 = mysqli_fetch_row($res2)) {
echo '<tr>';
echo '<td>'.htmlspecialchars($r2[0]).'</td>';
echo '<td>'.htmlspecialchars($r2[1]).'</td>';
echo '<td>'.htmlspecialchars($r2[2]).'</td>';
echo '<td>'.htmlspecialchars($r2[3]).'</td>';
echo '<td>'.htmlspecialchars($r2[4]).'</td>';
echo '<td>'.htmlspecialchars($r2[5]).'</td>';
echo '</tr>';
}
mysqli_free_result($res2);
}
$conn->close();
?>
</table>
</div>
</div>
<script>
window.addEventListener('load', function() {
var flash = document.getElementById('flashMessage');
if (flash) {
setTimeout(function() {
flash.style.opacity = '0';
setTimeout(function() { flash.style.display = 'none'; }, 300);
}, 5000);
}
});
</script>
</body>
</html>
1 change: 1 addition & 0 deletions admin_room_added1.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function submitForm(action)
<li><a href="admin_room_status.php">Booking Requests</a></li>
<li><a href="confirmed_bookings.php">Confirmed Bookings</a></li>
<li><a href="booking_history.php">Booking History</a></li>
<li><a href="admin_payments.php">Payments</a></li>
<li><a href="index.php">Logout</a></li>
</ul>
<div style="margin-left:25%;padding:1px 16px;height:1000px;">
Expand Down
1 change: 1 addition & 0 deletions admin_room_history.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function submitForm(action)
<li><a href="admin_room_status.php">Booking Requests</a></li>
<li><a href="confirmed_bookings.php">Confirmed Bookings</a></li>
<li><a href="booking_history.php">Booking History</a></li>
<li><a href="admin_payments.php">Payments</a></li>
<li><a href="index.php">Logout</a></li>
</ul>
<div style="margin-left:25%;padding:1px 16px;height:1000px;">
Expand Down
1 change: 1 addition & 0 deletions admin_room_removed1.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function submitForm(action)
<li><a href="admin_room_status.php">Booking Requests</a></li>
<li><a href="confirmed_bookings.php">Confirmed Bookings</a></li>
<li><a href="booking_history.php">Booking History</a></li>
<li><a href="admin_payments.php">Payments</a></li>
<li><a href="index.php">Logout</a></li>
</ul>
<div style="margin-left:25%;padding:1px 16px;height:1000px;">
Expand Down
1 change: 1 addition & 0 deletions admin_room_status.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function submitForm(action)
<li><a href="admin_room_status.php">Booking Requests</a></li>
<li><a href="confirmed_bookings.php">Confirmed Bookings</a></li>
<li><a href="booking_history.php">Booking History</a></li>
<li><a href="admin_payments.php">Payments</a></li>
<li><a href="index.php">Logout</a></li>
</ul>
<div style="margin-left:25%;padding:1px 16px;height:1000px;">
Expand Down
1 change: 1 addition & 0 deletions admin_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<li><a href="admin_room_status.php">Booking Requests</a></li>
<li><a href="confirmed_bookings.php">Confirmed Bookings</a></li>
<li><a href="booking_history.php">Booking History</a></li>
<li><a href="admin_payments.php">Payments</a></li>
<li><a href="index.php">Logout</a></li>
</ul>
<div style="margin-left:25%;padding:1px 16px;height:1000px;">
Expand Down
22 changes: 19 additions & 3 deletions booking_history.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@
padding: 50px;
box-shadow: 0 10px 20px rgba(0,0,0,0.19);
}
.status-pill {
display: inline-block;
padding: 5px 10px;
border-radius: 12px;
color: white;
font-weight: bold;
}
.status-paid {
background-color: #28a745;
}
.status-unpaid {
background-color: #dc3545;
}
#td1
{
background-color: rgba(09,41,98,0.9);
Expand Down Expand Up @@ -80,13 +93,14 @@
<li><a href="admin_room_status.php">Booking Requests</a></li>
<li><a href="confirmed_bookings.php">Confirmed Bookings</a></li>
<li><a href="booking_history.php">Booking History</a></li>
<li><a href="admin_payments.php">Payments</a></li>
<li><a href="index.php">Logout</a></li>
</ul>
<div style="margin-left:25%;padding:1px 16px;height:1000px;">
<p style="margin-left: 10%; margin-top: 5%; font-size: 28px;"></p>
<table class="basic_box">
<tr>
<td colspan="6"><p style="font-size: 28px; text-align: center; text-decoration: underline;"><b>Booking History</b></p>
<td colspan="7"><p style="font-size: 28px; text-align: center; text-decoration: underline;"><b>Booking History</b></p>
</td>
<tr>
<th>Booking ID</th>
Expand All @@ -95,6 +109,7 @@
<th>Check-in Date</th>
<th>Check-out Date</th>
<th>Price</th>
<th>Payment Status</th>
</tr>
<tr>
<?php
Expand All @@ -106,15 +121,16 @@
$sql1 = "SELECT * from booked_hist";
if ($result=mysqli_query($conn,$sql1))
{
while ($row=mysqli_fetch_row($result))
{
while ($row=mysqli_fetch_row($result)) {
$paid = true;
?>
<td><?php echo $row[14]; ?></td>
<td><?php echo $row[1]; ?></td>
<td><?php echo $row[3]; ?></td>
<td><?php echo $row[4]; ?></td>
<td><?php echo $row[5]; ?></td>
<td><?php echo $row[13]; ?></td>
<td><span class="status-pill <?php echo $paid ? 'status-paid' : 'status-unpaid'; ?>"><?php echo $paid ? 'Paid' : 'Not Paid'; ?></span></td>
</tr><?php
}
mysqli_free_result($result);
Expand Down
1 change: 1 addition & 0 deletions cancel_room1.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<li><a href="admin_room_status.php">Booking Requests</a></li>
<li><a href="confirmed_bookings.php">Confirmed Bookings</a></li>
<li><a href="booking_history.php">Booking History</a></li>
<li><a href="admin_payments.php">Payments</a></li>
<li><a href="index.php">Logout</a></li>
</ul>
<div style="margin-left:25%;padding:1px 16px;height:1000px;">
Expand Down
Loading