PNG IHDR x sBIT|d pHYs + tEXtSoftware www.inkscape.org< ,tEXtComment
<?php
session_start();
require_once "../config.php";
if (!isset($_SESSION['admin_auth'])) {
header("Location: login.php");
exit;
}
// Auto filter by GET parameter (default = pending)
$status = $_GET['status'] ?? 'pending';
// Valid statuses
$validStatuses = ['pending','approved','rejected','all'];
if (!in_array($status, $validStatuses)) {
$status = 'pending';
}
try {
if ($status === 'all') {
$stmt = $pdo->query("
SELECT b.id, b.name, b.category, b.location, b.status, b.created_at, u.fullname
FROM businesses b
JOIN users u ON b.user_id = u.id
ORDER BY b.created_at DESC
");
} else {
$stmt = $pdo->prepare("
SELECT b.id, b.name, b.category, b.location, b.status, b.created_at, u.fullname
FROM businesses b
JOIN users u ON b.user_id = u.id
WHERE b.status = ?
ORDER BY b.created_at DESC
");
$stmt->execute([$status]);
}
$businesses = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (Exception $e) {
die("Error fetching businesses: " . $e->getMessage());
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Manage Businesses - Admin</title>
<style>
body {
font-family: 'Segoe UI', sans-serif;
background: #f5f7fb;
margin: 0;
}
.header {
background: #003366;
color: white;
padding: 20px 40px;
font-size: 22px;
}
nav {
background: #00284d;
display: flex;
gap: 20px;
padding: 10px 30px;
}
nav a {
color: white;
text-decoration: none;
padding: 10px;
}
nav a:hover {
background: #004080;
border-radius: 6px;
}
.container {
padding: 30px;
}
.status-tabs {
display: flex;
gap: 15px;
margin-bottom: 20px;
}
.status-tabs a {
padding: 8px 14px;
border-radius: 6px;
text-decoration: none;
font-weight: 500;
background: #ddd;
color: #333;
}
.status-tabs a.active {
background: #003366;
color: white;
}
.table {
width: 100%;
border-collapse: collapse;
background: white;
border-radius: 10px;
overflow: hidden;
}
.table th, .table td {
padding: 14px;
text-align: left;
border-bottom: 1px solid #eee;
}
.table th {
background: #f0f4fa;
font-weight: 600;
}
.view-btn {
background: #004080;
color: white;
padding: 6px 14px;
border-radius: 6px;
text-decoration: none;
font-size: 14px;
}
.view-btn:hover {
background: #003060;
}
.badge {
padding: 5px 12px;
border-radius: 6px;
font-size: 13px;
}
.badge.pending { background: #ffcc00; color: #333; }
.badge.approved { background: #28a745; color: white; }
.badge.rejected { background: #d9534f; color: white; }
</style>
</head>
<body>
<div class="header">Admin - Manage Businesses</div>
<?php include("header.php") ?>
<div class="container">
<div class="status-tabs">
<a href="?status=pending" class="<?= $status=='pending'?'active':'' ?>">Pending</a>
<a href="?status=approved" class="<?= $status=='approved'?'active':'' ?>">Approved</a>
<a href="?status=rejected" class="<?= $status=='rejected'?'active':'' ?>">Rejected</a>
<a href="?status=all" class="<?= $status=='all'?'active':'' ?>">All</a>
</div>
<table class="table">
<tr>
<th>Business Name</th>
<th>Owner</th>
<th>Category</th>
<th>Location</th>
<th>Status</th>
<th>Action</th>
</tr>
<?php if (count($businesses) == 0): ?>
<tr><td colspan="6" style="text-align:center;padding:20px;">No records found</td></tr>
<?php else: foreach ($businesses as $b): ?>
<tr>
<td><?= htmlspecialchars($b['name']) ?></td>
<td><?= htmlspecialchars($b['fullname']) ?></td>
<td><?= htmlspecialchars($b['category']) ?></td>
<td><?= htmlspecialchars($b['location']) ?></td>
<td><span class="badge <?= $b['status'] ?>"><?= ucfirst($b['status']) ?></span></td>
<td><a class="view-btn" href="business_view.php?id=<?= bin2hex($b['id']) ?>">View</a></td>
</tr>
<?php endforeach; endif; ?>
</table>
</div>
</body>
</html>
b IDATxytVսϓ22 A@IR:hCiZ[v*E:WũZA ^dQeQ @ !jZ'>gsV仿$|?g)&x-E