148 lines
7.1 KiB
PHP
148 lines
7.1 KiB
PHP
<?php
|
|
require_once 'includes/admin_header.php';
|
|
require_once 'db/config.php';
|
|
|
|
$pdo = db();
|
|
|
|
// Handle vehicle booking status update
|
|
if (isset($_POST['update_vehicle_booking'])) {
|
|
$booking_id = $_POST['booking_id'];
|
|
$status = $_POST['status'];
|
|
$stmt = $pdo->prepare("UPDATE bookings SET status = ? WHERE id = ?");
|
|
$stmt->execute([$status, $booking_id]);
|
|
}
|
|
|
|
// Handle tour booking status update
|
|
if (isset($_POST['update_tour_booking'])) {
|
|
$booking_id = $_POST['booking_id'];
|
|
$status = $_POST['status'];
|
|
$stmt = $pdo->prepare("UPDATE tour_bookings SET status = ? WHERE id = ?");
|
|
$stmt->execute([$status, $booking_id]);
|
|
}
|
|
|
|
// Fetch vehicle bookings
|
|
$stmt_bookings = $pdo->query('SELECT b.*, v.name as vehicle_name FROM bookings b JOIN vehicles v ON b.vehicle_id = v.id ORDER BY b.start_date DESC');
|
|
$vehicle_bookings = $stmt_bookings->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
// Fetch tour bookings
|
|
$stmt_tour_bookings = $pdo->query('SELECT tb.*, tp.name as package_name FROM tour_bookings tb JOIN tour_packages tp ON tb.tour_package_id = tp.id ORDER BY tb.tour_date DESC');
|
|
$tour_bookings = $stmt_tour_bookings->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
$statuses = ['pending', 'confirmed', 'completed', 'cancelled'];
|
|
|
|
require_once 'includes/admin_sidebar.php';
|
|
?>
|
|
|
|
<div class="container-fluid">
|
|
<h1 class="h2">Manage Bookings</h1>
|
|
<p>View and manage customer bookings for vehicles and tours.</p>
|
|
|
|
<div class="card mb-4">
|
|
<div class="card-header">
|
|
<h5 class="mb-0">Vehicle Rentals</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th>Customer</th>
|
|
<th>Vehicle</th>
|
|
<th>Dates</th>
|
|
<th>Status</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($vehicle_bookings)): ?>
|
|
<tr>
|
|
<td colspan="5" class="text-center">No vehicle bookings found.</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($vehicle_bookings as $booking): ?>
|
|
<tr>
|
|
<td>
|
|
<?php echo htmlspecialchars($booking['customer_name']); ?><br>
|
|
<small class="text-muted"><?php echo htmlspecialchars($booking['customer_email']); ?></small>
|
|
</td>
|
|
<td><?php echo htmlspecialchars($booking['vehicle_name']); ?></td>
|
|
<td><?php echo htmlspecialchars($booking['start_date']); ?> to <?php echo htmlspecialchars($booking['end_date']); ?></td>
|
|
<td>
|
|
<form method="POST" action="">
|
|
<input type="hidden" name="booking_id" value="<?php echo $booking['id']; ?>">
|
|
<select name="status" class="form-select form-select-sm">
|
|
<?php foreach ($statuses as $status): ?>
|
|
<option value="<?php echo $status; ?>" <?php echo ($booking['status'] == $status) ? 'selected' : ''; ?>><?php echo ucfirst($status); ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</td>
|
|
<td>
|
|
<button type="submit" name="update_vehicle_booking" class="btn btn-primary btn-sm">Update</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="mb-0">Tour Package Bookings</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th>Customer</th>
|
|
<th>Tour Package</th>
|
|
<th>Tour Date</th>
|
|
<th># of People</th>
|
|
<th>Status</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($tour_bookings)): ?>
|
|
<tr>
|
|
<td colspan="6" class="text-center">No tour bookings found.</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($tour_bookings as $booking): ?>
|
|
<tr>
|
|
<td>
|
|
<?php echo htmlspecialchars($booking['customer_name']); ?><br>
|
|
<small class="text-muted"><?php echo htmlspecialchars($booking['customer_email']); ?></small>
|
|
</td>
|
|
<td><?php echo htmlspecialchars($booking['package_name']); ?></td>
|
|
<td><?php echo htmlspecialchars($booking['tour_date']); ?></td>
|
|
<td><?php echo htmlspecialchars($booking['num_people']); ?></td>
|
|
<td>
|
|
<form method="POST" action="">
|
|
<input type="hidden" name="booking_id" value="<?php echo $booking['id']; ?>">
|
|
<select name="status" class="form-select form-select-sm">
|
|
<?php foreach ($statuses as $status): ?>
|
|
<option value="<?php echo $status; ?>" <?php echo ($booking['status'] == $status) ? 'selected' : ''; ?>><?php echo ucfirst($status); ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</td>
|
|
<td>
|
|
<button type="submit" name="update_tour_booking" class="btn btn-primary btn-sm">Update</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php require_once 'includes/admin_footer.php'; ?>
|