2
This commit is contained in:
parent
d04cdf42f1
commit
139ac6de00
132
admin.php
132
admin.php
@ -1,43 +1,133 @@
|
||||
<?php
|
||||
require_once 'auth_check.php'; // Protect this page
|
||||
require_once 'db/config.php'; // Database connection
|
||||
|
||||
// Fetch counts from the database
|
||||
try {
|
||||
$pdo = db();
|
||||
|
||||
// Count clubs
|
||||
$stmt_clubs = $pdo->query('SELECT COUNT(*) FROM clubs');
|
||||
$count_clubs = $stmt_clubs->fetchColumn();
|
||||
|
||||
// Count tournaments
|
||||
$stmt_tournaments = $pdo->query('SELECT COUNT(*) FROM tournaments');
|
||||
$count_tournaments = $stmt_tournaments->fetchColumn();
|
||||
|
||||
} catch (PDOException $e) {
|
||||
// Handle DB connection error
|
||||
$count_clubs = 0;
|
||||
$count_tournaments = 0;
|
||||
$error_message = "Database error: " . $e->getMessage();
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="pt-BR">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Admin Dashboard - PicklePRO</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
<title>Painel Administrativo - 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="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&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-dark bg-primary">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">PicklePRO Admin</a>
|
||||
<div class="collapse navbar-collapse">
|
||||
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
|
||||
|
||||
<!-- 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="logout.php">Logout</a>
|
||||
<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>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<div class="container mt-4">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<!-- Main Content -->
|
||||
<main class="container my-5">
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<h1 class="display-6 fw-bold">Painel Administrativo</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (isset($error_message)): ?>
|
||||
<div class="alert alert-danger"><?php echo $error_message; ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="row g-4">
|
||||
<!-- Card Clubes -->
|
||||
<div class="col-md-4">
|
||||
<div class="card h-100 text-center">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">Welcome, <?php echo htmlspecialchars($_SESSION['username']); ?>!</h4>
|
||||
<p>This is your admin dashboard. From here, you can manage clubs, tournaments, and users.</p>
|
||||
<a href="add_club.php" class="btn btn-primary">Add New Club</a>
|
||||
<h5 class="card-title"><i class="bi bi-building me-2"></i>Clubes</h5>
|
||||
<p class="display-4 fw-bold"><?php echo $count_clubs; ?></p>
|
||||
<a href="clubs.php" class="btn btn-primary">Ver Clubes</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Card Torneios -->
|
||||
<div class="col-md-4">
|
||||
<div class="card h-100 text-center">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title"><i class="bi bi-trophy me-2"></i>Torneios</h5>
|
||||
<p class="display-4 fw-bold"><?php echo $count_tournaments; ?></p>
|
||||
<a href="tournaments.php" class="btn btn-primary">Ver Torneios</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Card Configurações -->
|
||||
<div class="col-md-4">
|
||||
<div class="card h-100 text-center">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title"><i class="bi bi-gear me-2"></i>Configurações</h5>
|
||||
<p class="display-4"><i class="bi bi-gear-wide-connected"></i></p>
|
||||
<a href="#" class="btn btn-secondary disabled">Acessar</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<!-- Footer -->
|
||||
<footer class="footer mt-auto py-4 bg-light fixed-bottom">
|
||||
<div class="container text-center">
|
||||
<p class="mb-1 text-muted small">© <?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>
|
||||
</html>
|
||||
BIN
assets/pasted-20251020-234540-8263a818.png
Normal file
BIN
assets/pasted-20251020-234540-8263a818.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 108 KiB |
120
clubs.php
Normal file
120
clubs.php
Normal file
@ -0,0 +1,120 @@
|
||||
<?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">© <?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>
|
||||
10
index.php
10
index.php
@ -48,14 +48,8 @@
|
||||
<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 dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="adminMenu" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Administrativo
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="adminMenu">
|
||||
<li><a class="dropdown-item" href="add_club.php">Cadastrar Clube</a></li>
|
||||
<li><a class="dropdown-item" href="add_tournament.php">Cadastrar Torneio</a></li>
|
||||
</ul>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="admin.php">Administrativo</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
|
||||
118
tournaments.php
Normal file
118
tournaments.php
Normal file
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
require_once 'auth_check.php'; // Protect this page
|
||||
require_once 'db/config.php'; // Database connection
|
||||
|
||||
// Fetch all tournaments from the database
|
||||
$tournaments = [];
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->query('SELECT id, name, description, created_at FROM tournaments ORDER BY created_at DESC');
|
||||
$tournaments = $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 Torneios - 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 Torneios</h1>
|
||||
<a href="add_tournament.php" class="btn btn-primary"><i class="bi bi-plus-circle me-2"></i>Cadastrar Novo Torneio</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($tournaments) && !isset($error_message)): ?>
|
||||
<div class="text-center p-4">
|
||||
<p>Nenhum torneio cadastrado ainda.</p>
|
||||
</div>
|
||||
<?php else:
|
||||
if (!empty($tournaments)) : ?>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nome</th>
|
||||
<th>Descrição</th>
|
||||
<th>Data de Criação</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($tournaments as $tournament): ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($tournament['name']); ?></td>
|
||||
<td><?php echo htmlspecialchars($tournament['description']); ?></td>
|
||||
<td><?php echo date("d/m/Y H:i", strtotime($tournament['created_at'])); ?></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">© <?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>
|
||||
Loading…
x
Reference in New Issue
Block a user