35078-vm/clubs.php
Flatlogic Bot 139ac6de00 2
2025-10-20 23:47:56 +00:00

121 lines
5.3 KiB
PHP

<?php
require_once 'auth_check.php'; // Protect this page
require_once 'db/config.php'; // Database connection
// Fetch all clubs from the database
$clubs = [];
try {
$pdo = db();
$stmt = $pdo->query('SELECT id, name, address, phone, email FROM clubs ORDER BY name');
$clubs = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
$error_message = "Database error: " . $e->getMessage();
}
?>
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gerenciar Clubes - PicklePRO</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body>
<!-- Header -->
<header class="navbar navbar-expand-lg navbar-light bg-white">
<div class="container">
<a class="navbar-brand" href="index.php">
<img src="https://www.svgrepo.com/show/494426/pickleball-paddle.svg" alt="PicklePRO Logo" width="30" height="30" class="d-inline-block align-text-top me-2">
Pickle<span class="text-primary">PRO</span>
</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 mx-auto">
<li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
<li class="nav-item"><a class="nav-link" href="#">Torneios</a></li>
<li class="nav-item"><a class="nav-link" href="#">Reservas</a></li>
<?php if (isset($_SESSION['user_id'])): ?>
<li class="nav-item">
<a class="nav-link" href="admin.php">Administrativo</a>
</li>
<?php endif; ?>
</ul>
<div class="d-flex align-items-center">
<?php if (isset($_SESSION['user_id'])): ?>
<span class="navbar-text me-3">
Olá, <?php echo htmlspecialchars($_SESSION['username']); ?>
</span>
<a href="logout.php" class="btn btn-outline-primary">Sair</a>
<?php else: ?>
<a href="/login.php" class="btn btn-link text-decoration-none me-2">Entrar</a>
<a href="#" class="btn btn-primary">Cadastrar</a>
<?php endif; ?>
</div>
</div>
</div>
</header>
<!-- Main Content -->
<main class="container my-5">
<div class="d-flex justify-content-between align-items-center mb-4">
<h1 class="display-6 fw-bold">Gerenciar Clubes</h1>
<a href="add_club.php" class="btn btn-primary"><i class="bi bi-plus-circle me-2"></i>Cadastrar Novo Clube</a>
</div>
<?php if (isset($error_message)): ?>
<div class="alert alert-danger"><?php echo $error_message; ?></div>
<?php endif; ?>
<div class="card">
<div class="card-body">
<?php if (empty($clubs) && !isset($error_message)): ?>
<div class="text-center p-4">
<p>Nenhum clube cadastrado ainda.</p>
</div>
<?php else:
if (!empty($clubs)) : ?>
<table class="table table-hover">
<thead>
<tr>
<th>Nome</th>
<th>Endereço</th>
<th>Telefone</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<?php foreach ($clubs as $club): ?>
<tr>
<td><?php echo htmlspecialchars($club['name']); ?></td>
<td><?php echo htmlspecialchars($club['address']); ?></td>
<td><?php echo htmlspecialchars($club['phone']); ?></td>
<td><?php echo htmlspecialchars($club['email']); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; endif; ?>
</div>
</div>
<div class="mt-4">
<a href="admin.php" class="btn btn-secondary">Voltar ao Painel</a>
</div>
</main>
<!-- Footer -->
<footer class="footer mt-auto py-4 bg-light">
<div class="container text-center">
<p class="mb-1 text-muted small">&copy; <?php echo date("Y"); ?> PicklePRO. Todos os direitos reservados.</p>
</div>
</footer>
<!-- Scripts -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>