241 lines
8.5 KiB
PHP
241 lines
8.5 KiB
PHP
<?php
|
|
$headerStyle = 'light';
|
|
$rootPath = dirname(dirname(__DIR__));
|
|
include_once($rootPath . '/header.php');
|
|
checkAdmin();
|
|
|
|
// Fetch all trips
|
|
$tripsSql = "SELECT trip_id, trip_name FROM trips";
|
|
$tripsResult = $conn->query($tripsSql);
|
|
|
|
?>
|
|
<style>
|
|
table {
|
|
width: 100%;
|
|
border-collapse: separate;
|
|
border-spacing: 0;
|
|
margin: 10px 0;
|
|
}
|
|
|
|
thead th {
|
|
cursor: pointer;
|
|
text-align: left;
|
|
padding: 10px;
|
|
font-weight: bold;
|
|
position: relative;
|
|
}
|
|
|
|
thead th::after {
|
|
content: '\25B2';
|
|
/* Up arrow */
|
|
font-size: 0.8em;
|
|
position: absolute;
|
|
right: 10px;
|
|
opacity: 0;
|
|
transition: opacity 0.2s;
|
|
}
|
|
|
|
thead th.asc::after {
|
|
content: '\25B2';
|
|
/* Up arrow */
|
|
opacity: 1;
|
|
}
|
|
|
|
thead th.desc::after {
|
|
content: '\25BC';
|
|
/* Down arrow */
|
|
opacity: 1;
|
|
}
|
|
|
|
tbody tr:nth-child(odd) {
|
|
background-color: transparent;
|
|
}
|
|
|
|
tbody tr:nth-child(even) {
|
|
background-color: rgb(255, 255, 255);
|
|
border-radius: 10px;
|
|
}
|
|
|
|
tbody td {
|
|
padding: 5px;
|
|
}
|
|
|
|
tbody tr:nth-child(even) td:first-child {
|
|
border-top-left-radius: 10px;
|
|
border-bottom-left-radius: 10px;
|
|
}
|
|
|
|
tbody tr:nth-child(even) td:last-child {
|
|
border-top-right-radius: 10px;
|
|
border-bottom-right-radius: 10px;
|
|
}
|
|
|
|
.filter-input {
|
|
width: 100%;
|
|
padding: 5px;
|
|
/* margin-bottom: 20px; */
|
|
font-size: 16px;
|
|
background-color: rgb(255, 255, 255);
|
|
border-radius: 25px;
|
|
}
|
|
|
|
.trip-booking {
|
|
color: #484848;
|
|
background: #f9f9f7;
|
|
border: 1px solid #d8d8d8;
|
|
border-radius: 10px;
|
|
margin-top: 15px;
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
</style>
|
|
<script>
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
const tables = document.querySelectorAll("table");
|
|
tables.forEach((table) => {
|
|
const headers = table.querySelectorAll("thead th");
|
|
const rows = Array.from(table.querySelectorAll("tbody tr"));
|
|
const filterInput = table.previousElementSibling;
|
|
|
|
headers.forEach((header, index) => {
|
|
header.addEventListener("click", () => {
|
|
const sortedRows = rows.sort((a, b) => {
|
|
const aText = a.cells[index].textContent.trim().toLowerCase();
|
|
const bText = b.cells[index].textContent.trim().toLowerCase();
|
|
|
|
if (aText < bText) return -1;
|
|
if (aText > bText) return 1;
|
|
return 0;
|
|
});
|
|
|
|
if (header.classList.contains("asc")) {
|
|
header.classList.remove("asc");
|
|
header.classList.add("desc");
|
|
sortedRows.reverse();
|
|
} else {
|
|
headers.forEach(h => h.classList.remove("asc", "desc"));
|
|
header.classList.add("asc");
|
|
}
|
|
|
|
const tbody = table.querySelector("tbody");
|
|
tbody.innerHTML = "";
|
|
sortedRows.forEach(row => tbody.appendChild(row));
|
|
});
|
|
});
|
|
|
|
if (rows.length === 0) {
|
|
filterInput.style.display = "none";
|
|
} else {
|
|
filterInput.addEventListener("input", function() {
|
|
const filterValue = filterInput.value.trim().toLowerCase();
|
|
rows.forEach(row => {
|
|
const rowText = row.textContent.trim().toLowerCase();
|
|
row.style.display = rowText.includes(filterValue) ? "" : "none";
|
|
});
|
|
});
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
<?php
|
|
$bannerFolder = 'assets/images/banners/';
|
|
$bannerImages = glob($bannerFolder . '*.{jpg,jpeg,png,webp}', GLOB_BRACE);
|
|
|
|
$randomBanner = 'assets/images/base4/camping.jpg'; // default fallback
|
|
if (!empty($bannerImages)) {
|
|
$randomBanner = $bannerImages[array_rand($bannerImages)];
|
|
}
|
|
?>
|
|
<section class="page-banner-area pt-50 pb-35 rel z-1 bgs-cover" style="background-image: url('<?php echo $randomBanner; ?>');">
|
|
<div class="banner-overlay"></div>
|
|
<div class="container">
|
|
<div class="banner-inner text-white mb-50">
|
|
<h2 class="page-title mb-10" data-aos="fade-left" data-aos-duration="1500" data-aos-offset="50">4WDCSA Trip Bookings</h2>
|
|
<nav aria-label="breadcrumb">
|
|
<ol class="breadcrumb justify-content-center mb-20" data-aos="fade-right" data-aos-delay="200" data-aos-duration="1500" data-aos-offset="50">
|
|
<li class="breadcrumb-item"><a href="index.php">Home</a></li>
|
|
<li class="breadcrumb-item active">Trip Bookings</li>
|
|
</ol>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<section class="tour-list-page py-10 rel z-1">
|
|
<div class="container">
|
|
<?php
|
|
if ($tripsResult->num_rows > 0) {
|
|
while ($trip = $tripsResult->fetch_assoc()) {
|
|
$tripId = $trip['trip_id'];
|
|
$tripName = htmlspecialchars($trip['trip_name']);
|
|
|
|
echo "<div class='trip-booking' data-aos='fade-up' data-aos-duration='1500' data-aos-offset='50'>";
|
|
echo "<div style='padding:10px;'>";
|
|
echo "<h4>{$tripName}</h4>";
|
|
|
|
// Fetch bookings for the current trip
|
|
$bookingsSql = "SELECT b.user_id, b.num_vehicles, b.num_adults, b.num_children, b.num_pensioners, b.radio, b.status,
|
|
u.first_name, u.last_name, u.profile_pic,
|
|
(b.total_amount - b.discount_amount) AS paid
|
|
FROM bookings b
|
|
INNER JOIN users u ON b.user_id = u.user_id
|
|
WHERE b.trip_id = ?";
|
|
$stmt = $conn->prepare($bookingsSql);
|
|
$stmt->bind_param('i', $tripId);
|
|
$stmt->execute();
|
|
$bookingsResult = $stmt->get_result();
|
|
|
|
|
|
if ($bookingsResult->num_rows > 0) {
|
|
echo '<input type="text" class="filter-input" placeholder="Filter results...">';
|
|
echo '<table>
|
|
<thead>
|
|
<tr>
|
|
<th></th>
|
|
<th>Name</th>
|
|
<th>Vehicles</th>
|
|
<th>Adults</th>
|
|
<th>Children</th>
|
|
<th>Pensioners</th>
|
|
<th>Radio</th>
|
|
<th>Status</th>
|
|
<th>Amount</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>';
|
|
while ($booking = $bookingsResult->fetch_assoc()) {
|
|
$userName = htmlspecialchars($booking['first_name'] . ' ' . $booking['last_name']);
|
|
$numVehicles = htmlspecialchars($booking['num_vehicles']);
|
|
$numAdults = htmlspecialchars($booking['num_adults']);
|
|
$numPensioners = htmlspecialchars($booking['num_pensioners']);
|
|
$numChildren = htmlspecialchars($booking['num_children']);
|
|
$radio = $booking['radio'] == 1 ? "YES" : "NO";
|
|
$status = htmlspecialchars($booking['status']);
|
|
$paid = "R " . number_format($booking['paid'], 2);
|
|
|
|
echo "<tr>
|
|
<td><img src=".$booking['profile_pic']." alt='Profile Picture' class='profile-pic'></td>
|
|
<td>{$userName}</td>
|
|
<td>{$numVehicles}</td>
|
|
<td>{$numAdults}</td>
|
|
<td>{$numChildren}</td>
|
|
<td>{$numPensioners}</td>
|
|
<td>{$radio}</td>
|
|
<td>{$status}</td>
|
|
<td>{$paid}</td>
|
|
</tr>";
|
|
}
|
|
echo '</tbody></table>';
|
|
} else {
|
|
echo '<p>No bookings found for this trip.</p>';
|
|
}
|
|
echo "</div>";
|
|
echo "</div>";
|
|
}
|
|
} else {
|
|
echo '<p>No trips found.</p>';
|
|
}
|
|
?>
|
|
</div>
|
|
</section>
|
|
<?php include_once($rootPath . '/components/insta_footer.php'); ?>
|