39199-vm/admin_dashboard.php
Flatlogic Bot 270903d716 roni
2026-03-15 02:57:10 +00:00

138 lines
5.8 KiB
PHP

<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
require_once __DIR__ . '/includes/auth.php';
require_once __DIR__ . '/includes/flash.php';
require_once __DIR__ . '/includes/registration_db.php';
require_admin();
ensure_registration_table();
$registrations = fetch_registrations();
$selectedId = isset($_GET['id']) ? (int)$_GET['id'] : 0;
$selected = $selectedId ? fetch_registration($selectedId) : null;
$flash = flash_get();
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
?>
<!doctype html>
<html lang="id">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Admin Dashboard</title>
<?php if ($projectDescription): ?>
<meta name="description" content="<?= htmlspecialchars($projectDescription) ?>" />
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<?php endif; ?>
<?php if ($projectImageUrl): ?>
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<?php endif; ?>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?= time() ?>">
</head>
<body class="app-body">
<nav class="navbar navbar-expand-lg navbar-light bg-white border-bottom">
<div class="container">
<a class="navbar-brand fw-semibold" href="/">Pendaftaran</a>
<div class="d-flex align-items-center gap-2">
<a class="btn btn-outline-secondary btn-sm" href="export_pdf.php">Export PDF</a>
<a class="btn btn-dark btn-sm" href="logout.php">Logout</a>
</div>
</div>
</nav>
<main class="container py-5">
<div class="d-flex flex-wrap justify-content-between align-items-center gap-3 mb-4">
<div>
<h1 class="h4 fw-semibold mb-1">Report Pendaftar</h1>
<p class="text-muted small mb-0">Total pendaftar: <?= count($registrations) ?></p>
</div>
<div class="small text-muted">
Data terbaru otomatis tersimpan di database.
</div>
</div>
<?php if ($flash): ?>
<div class="alert alert-<?= htmlspecialchars($flash['type']) ?> border-0 small">
<?= htmlspecialchars($flash['message']) ?>
</div>
<?php endif; ?>
<div class="row g-4">
<div class="col-lg-7">
<div class="card shadow-sm border-0">
<div class="card-body">
<h2 class="h6 text-uppercase text-muted">Daftar Pendaftar</h2>
<?php if (!$registrations): ?>
<div class="alert alert-light border small mb-0">Belum ada pendaftar.</div>
<?php else: ?>
<div class="table-responsive">
<table class="table table-sm align-middle mb-0">
<thead>
<tr class="text-muted small">
<th>Foto</th>
<th>Nama</th>
<th>Pendidikan</th>
<th>Jurusan</th>
<th>Nomor</th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach ($registrations as $row): ?>
<tr>
<td>
<img src="<?= htmlspecialchars($row['photo_path']) ?>" class="rounded-2 border photo-thumb" alt="Foto">
</td>
<td><?= htmlspecialchars($row['name']) ?></td>
<td><?= htmlspecialchars($row['education']) ?></td>
<td><?= htmlspecialchars($row['major']) ?></td>
<td class="text-muted small"><?= htmlspecialchars($row['reg_code']) ?></td>
<td class="text-end">
<a class="btn btn-outline-secondary btn-sm" href="admin_dashboard.php?id=<?= (int)$row['id'] ?>">Detail</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>
</div>
<div class="col-lg-5">
<div class="card shadow-sm border-0 h-100">
<div class="card-body">
<h2 class="h6 text-uppercase text-muted">Detail Pendaftar</h2>
<?php if (!$selected): ?>
<p class="text-muted small mb-0">Pilih pendaftar dari tabel untuk melihat detail.</p>
<?php else: ?>
<div class="d-flex align-items-center gap-3 mb-3">
<img src="<?= htmlspecialchars($selected['photo_path']) ?>" class="rounded-3 border detail-photo" alt="Foto">
<div>
<div class="fw-semibold"><?= htmlspecialchars($selected['name']) ?></div>
<div class="text-muted small"><?= htmlspecialchars($selected['reg_code']) ?></div>
</div>
</div>
<ul class="list-unstyled small mb-0">
<li class="mb-2"><strong>Pendidikan:</strong> <?= htmlspecialchars($selected['education']) ?></li>
<li class="mb-2"><strong>Jurusan:</strong> <?= htmlspecialchars($selected['major']) ?></li>
<li class="mb-2"><strong>Waktu daftar:</strong> <?= htmlspecialchars($selected['created_at']) ?></li>
</ul>
<?php endif; ?>
</div>
</div>
</div>
</div>
</main>
</body>
</html>