35861-vm/dashboard.php
Flatlogic Bot 1b14267623 v4
2025-11-19 22:24:36 +00:00

78 lines
2.7 KiB
PHP

<?php
require_once 'includes/session.php';
require_login();
// Redirect admin users to the admin dashboard
if (is_admin()) {
header('Location: admin/index.php');
exit();
}
require_once 'includes/header.php';
?>
<main class="container my-5">
<h1 class="mb-4">User Dashboard</h1>
<p>Welcome back, <?php echo htmlspecialchars($_SESSION['user']['name']); ?>. Here you can view your applications and manage your profile.</p>
<hr class="my-5">
<h2 class="mb-4">My Applications</h2>
<?php
require_once 'db/config.php';
$pdo = db();
$stmt = $pdo->prepare(
'SELECT a.id, a.status, a.created_at, e.name AS event_name, e.event_date
FROM applications a
JOIN events e ON a.event_id = e.id
WHERE a.user_id = ?
ORDER BY a.created_at DESC'
);
$stmt->execute([$_SESSION['user']['id']]);
$applications = $stmt->fetchAll();
if (count($applications) > 0):
?>
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead class="thead-dark">
<tr>
<th>Event</th>
<th>Event Date</th>
<th>Applied On</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php foreach ($applications as $app): ?>
<tr>
<td><?php echo htmlspecialchars($app['event_name']); ?></td>
<td><?php echo date('M j, Y', strtotime($app['event_date'])); ?></td>
<td><?php echo date('M j, Y, g:i a', strtotime($app['created_at'])); ?></td>
<td>
<span class="badge bg-<?php
switch ($app['status']) {
case 'approved': echo 'success'; break;
case 'rejected': echo 'danger'; break;
default: echo 'secondary';
}
?>">
<?php echo htmlspecialchars(ucfirst($app['status'])); ?>
</span>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php else: ?>
<div class="alert alert-info">
You have not applied to any events yet. <a href="/index.php#events">Find events to apply for.</a>
</div>
<?php endif; ?>
</main>
<?php require_once 'includes/footer.php'; ?>