34414-vm/dashboard.php
Flatlogic Bot ba92df7101 0.2
2025-09-26 09:52:11 +00:00

139 lines
7.2 KiB
PHP

<?php
require_once 'auth.php';
require_login('secretariat');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Secretariat Dashboard</title>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css">
</head>
<body class="bg-gray-100">
<nav class="bg-white shadow-md">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex">
<div class="flex-shrink-0 flex items-center">
<a href="index.php" class="text-2xl font-bold text-blue-600">SecurePort</a>
</div>
<div class="hidden sm:-my-px sm:ml-6 sm:flex sm:space-x-8">
<a href="dashboard.php" class="border-blue-500 text-gray-900 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium" aria-current="page">Dashboard</a>
</div>
</div>
<div class="flex items-center">
<?php if (isset($_SESSION['user_id'])):
require_once 'auth.php';
?>
<span class="mr-4">Welcome, <?php echo htmlspecialchars($_SESSION['username']); ?>!</span>
<a href="logout.php" class="px-3 py-2 rounded-md text-sm font-medium text-gray-700 hover:text-blue-600 hover:bg-gray-50">Logout</a>
<?php else: ?>
<a href="login.php" class="px-3 py-2 rounded-md text-sm font-medium text-gray-700 hover:text-blue-600 hover:bg-gray-50">Login</a>
<?php endif; ?>
</div>
</div>
</div>
</nav>
<main class="container mx-auto px-6 py-8">
<h1 class="text-3xl font-bold text-gray-800 mb-6">Secretariat Dashboard</h1>
<!-- Filter and Search Form -->
<div class="mb-6">
<form action="dashboard.php" method="GET" class="bg-white shadow-md rounded-lg p-4 flex items-center space-x-4">
<div class="flex-grow">
<label for="search" class="sr-only">Search</label>
<input type="text" name="search" id="search" placeholder="Search by name or email..."
class="w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
value="<?php echo isset($_GET['search']) ? htmlspecialchars($_GET['search']) : ''; ?>">
</div>
<div>
<label for="status" class="sr-only">Status</label>
<select name="status" id="status"
class="rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm">
<option value="">All Statuses</option>
<option value="Pending" <?php echo (isset($_GET['status']) && $_GET['status'] === 'Pending') ? 'selected' : ''; ?>>Pending</option>
<option value="Approved" <?php echo (isset($_GET['status']) && $_GET['status'] === 'Approved') ? 'selected' : ''; ?>>Approved</option>
<option value="Rejected" <?php echo (isset($_GET['status']) && $_GET['status'] === 'Rejected') ? 'selected' : ''; ?>>Rejected</option>
</select>
</div>
<div>
<button type="submit" class="px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600">Filter</button>
</div>
</form>
</div>
<div class="bg-white shadow-md rounded-lg overflow-hidden">
<table class="min-w-full bg-white">
<thead class="bg-gray-800 text-white">
<tr>
<th class="w-1/6 text-left py-3 px-4 uppercase font-semibold text-sm">Submission ID</th>
<th class="w-1/6 text-left py-3 px-4 uppercase font-semibold text-sm">Applicant Name</th>
<th class="w-1/4 text-left py-3 px-4 uppercase font-semibold text-sm">Email</th>
<th class="w-1/6 text-left py-3 px-4 uppercase font-semibold text-sm">Submission Date</th>
<th class="w-1/6 text-left py-3 px-4 uppercase font-semibold text-sm">Status</th>
<th class="text-left py-3 px-4 uppercase font-semibold text-sm">Actions</th>
</tr>
</thead>
<tbody class="text-gray-700">
<?php
require_once 'db/config.php';
$pdo = db();
// Base query
$sql = "SELECT id, full_name, email, created_at, status FROM submissions";
$params = [];
$where_clauses = [];
// Search filter
if (!empty($_GET['search'])) {
$search_term = '%' . $_GET['search'] . '%';
$where_clauses[] = "(full_name LIKE ? OR email LIKE ?)";
$params[] = $search_term;
$params[] = $search_term;
}
// Status filter
if (!empty($_GET['status'])) {
$where_clauses[] = "status = ?";
$params[] = $_GET['status'];
}
if (!empty($where_clauses)) {
$sql .= " WHERE " . implode(' AND ', $where_clauses);
}
$sql .= " ORDER BY created_at DESC";
$stmt = $pdo->prepare($sql);
$stmt->execute($params);
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo "<tr>";
echo "<td class='text-left py-3 px-4'>" . htmlspecialchars($row['id']) . "</td>";
echo "<td class='text-left py-3 px-4'>" . htmlspecialchars($row['full_name']) . "</td>";
echo "<td class='text-left py-3 px-4'>" . htmlspecialchars($row['email']) . "</td>";
echo "<td class='text-left py-3 px-4'>" . htmlspecialchars($row['created_at']) . "</td>";
$status_class = 'bg-yellow-200 text-yellow-800';
if ($row['status'] === 'Approved') {
$status_class = 'bg-green-200 text-green-800';
} elseif ($row['status'] === 'Rejected') {
$status_class = 'bg-red-200 text-red-800';
}
echo "<td class='text-left py-3 px-4'><span class='" . $status_class . " py-1 px-3 rounded-full text-xs'>" . htmlspecialchars($row['status']) . "</span></td>";
echo "<td class='text-left py-3 px-4'><a href='view_submission.php?id=" . $row['id'] . "' class='text-blue-500 hover:text-blue-700'>View Details</a></td>";
echo "</tr>";
}
?>
</tbody>
</table>
</div>
</main>
</body>
</html>