34007-vm/venues.php
Flatlogic Bot 1f2c647afc www
2025-09-19 07:15:53 +00:00

115 lines
5.0 KiB
PHP

<?php
require_once 'db/config.php';
try {
$stmt = db()->query('SELECT * FROM venues ORDER BY name ASC
');
$venues = $stmt->fetchAll();
} catch (PDOException $e) {
error_log($e->getMessage());
// You could redirect to an error page or show a friendly message
die('Error connecting to the database.');
}
function render_header($title) {
echo <<<HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{$title} - EventFlow</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-white shadow-sm">
<div class="container-fluid">
<a class="navbar-brand" href="index.php">EventFlow</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link" href="index.php">Home</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="venues.php">Venues</a>
</li>
</ul>
</div>
</div>
</nav>
HTML;
}
function render_footer() {
echo <<<HTML
<footer class="py-4 mt-auto">
<div class="container-fluid px-4">
<div class="d-flex align-items-center justify-content-between small">
<div class="text-muted">Copyright &copy; EventFlow 2025</div>
</div>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script>feather.replace()</script>
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body>
</html>
HTML;
}
render_header('Event Venues');
?>
<main class="container my-5">
<h1 class="mb-4 text-center">Event Venues</h1>
<p class="text-center text-muted mb-5">Browse our curated selection of top-tier venues for your next event.</p>
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4">
<?php if (empty($venues)): ?>
<div class="col">
<p>No venues found.</p>
</div>
<?php else: ?>
<?php foreach ($venues as $venue):
// Corrected the escaping for the status badge
$status_class = $venue['status'] == 'Available' ? 'bg-success-light' : 'bg-danger-light';
?>
<div class="col">
<div class="card h-100 venue-card">
<img src="<?php echo htmlspecialchars($venue['image_url']); ?>" class="card-img-top" alt="<?php echo htmlspecialchars($venue['name']); ?>">
<div class="card-body d-flex flex-column">
<h5 class="card-title"><?php echo htmlspecialchars($venue['name']); ?></h5>
<p class="card-text text-muted flex-grow-1"><?php echo htmlspecialchars($venue['description']); ?></p>
<div class="d-flex justify-content-between align-items-center mb-2">
<span class="badge bg-light text-dark"><i data-feather="users" class="me-1"></i><?php echo htmlspecialchars($venue['capacity']); ?> Guests</span>
<span class="badge <?php echo $status_class; ?>"><?php echo htmlspecialchars($venue['status']); ?></span>
</div>
<div class="mb-3">
<?php foreach (explode(',', $venue['features']) as $feature):
// Ensure feature is not empty before echoing
if (!empty(trim($feature))):
?>
<span class="badge bg-secondary-light me-1 mb-1"><?php echo htmlspecialchars(trim($feature)); ?></span>
<?php endif; endforeach; ?>
</div>
<button class="btn btn-primary mt-auto" <?php echo $venue['status'] == 'Booked' ? 'disabled' : ''; ?>>Book Now</button>
</div>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
</main>
<?php
render_footer();
?>