35311-vm/location_view.php
Flatlogic Bot 540e3681d5 10 30 2
2025-10-30 19:18:05 +00:00

94 lines
3.8 KiB
PHP

<?php
session_start();
require_once 'db/config.php';
// Check if user is logged in and has the 'staff' role
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'staff') {
header("Location: index.php");
exit;
}
$pdo = db();
// Fetch resident counts by location
$location_counts = $pdo->query("
SELECT state, county, city, COUNT(id) as resident_count
FROM residents
GROUP BY state, county, city
ORDER BY state, county, city
")->fetchAll(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Resident Location View | Continuum Nexus</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">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand" href="staff_dashboard.php">Continuum Nexus</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 me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link" href="staff_dashboard.php">Dashboard</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="location_view.php">Location View</a>
</li>
</ul>
<a href="logout.php" class="btn btn-outline-light">Logout</a>
</div>
</div>
</nav>
<div class="container mt-4">
<h1 class="h2 mb-4">Resident Counts by Location</h1>
<div class="card">
<div class="card-body">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>State</th>
<th>County</th>
<th>City</th>
<th class="text-end">Resident Count</th>
</tr>
</thead>
<tbody>
<?php if (!empty($location_counts)): ?>
<?php foreach ($location_counts as $location): ?>
<tr>
<td><?php echo htmlspecialchars($location['state']); ?></td>
<td><?php echo htmlspecialchars($location['county']); ?></td>
<td><?php echo htmlspecialchars($location['city']); ?></td>
<td class="text-end"><?php echo $location['resident_count']; ?></td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="4" class="text-center text-muted">No location data available.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>