- initial
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
$adminTitle = 'Dashboard';
|
||||
include __DIR__.'/admin_header.php';
|
||||
$stats = [
|
||||
'Businesses' => qval("SELECT COUNT(*) FROM businesses WHERE is_active=1"),
|
||||
'Users' => qval("SELECT COUNT(*) FROM users"),
|
||||
'Reviews' => qval("SELECT COUNT(*) FROM reviews"),
|
||||
'Events' => qval("SELECT COUNT(*) FROM events WHERE status='approved'"),
|
||||
'Pending Events' => qval("SELECT COUNT(*) FROM events WHERE status='pending'"),
|
||||
'Open Reports' => qval("SELECT COUNT(*) FROM reports WHERE status='open'"),
|
||||
'Attractions' => qval("SELECT COUNT(*) FROM attractions WHERE is_active=1"),
|
||||
'Active Alerts' => qval("SELECT COUNT(*) FROM alerts WHERE is_active=1"),
|
||||
];
|
||||
$recentBiz = qall("SELECT * FROM businesses ORDER BY created_at DESC LIMIT 5");
|
||||
$recentUsers = qall("SELECT * FROM users ORDER BY created_at DESC LIMIT 5");
|
||||
$pendingEvts = qall("SELECT e.*,u.username FROM events e LEFT JOIN users u ON u.id=e.submitted_by WHERE e.status='pending' ORDER BY e.created_at DESC LIMIT 5");
|
||||
$openReports = qall("SELECT r.*,b.name biz,u.username reporter FROM reports r JOIN businesses b ON b.id=r.business_id JOIN users u ON u.id=r.user_id WHERE r.status='open' ORDER BY r.created_at DESC LIMIT 5");
|
||||
?>
|
||||
<?php adminTitle('Site Overview','Welcome to the Discover Keyser WV administration panel.') ?>
|
||||
|
||||
<div class="stat-cards">
|
||||
<?php foreach($stats as $lbl=>$val): ?>
|
||||
<div class="stat-card"><div class="sc-n"><?=$val?></div><div class="sc-l"><?=e($lbl)?></div></div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<div class="g2" style="gap:1.5rem;margin-bottom:2rem">
|
||||
<?php if($pendingEvts): ?>
|
||||
<div>
|
||||
<div class="admin-sec-title">⏳ PENDING EVENTS (<?=count($pendingEvts)?>)</div>
|
||||
<div class="tbl-wrap">
|
||||
<table class="dtbl">
|
||||
<thead><tr><th>EVENT</th><th>SUBMITTED BY</th><th>DATE</th><th></th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach($pendingEvts as $ev): ?>
|
||||
<tr>
|
||||
<td class="td-name"><?=e($ev['title'])?></td>
|
||||
<td><?=e($ev['username']??'—')?></td>
|
||||
<td><?=fdate($ev['event_date'])?></td>
|
||||
<td><a href="/admin/events.php?edit=<?=$ev['id']?>" class="btn btn-xs btn-primary">Review</a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if($openReports): ?>
|
||||
<div>
|
||||
<div class="admin-sec-title">🚩 OPEN REPORTS (<?=count($openReports)?>)</div>
|
||||
<div class="tbl-wrap">
|
||||
<table class="dtbl">
|
||||
<thead><tr><th>BUSINESS</th><th>TYPE</th><th>FROM</th><th></th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach($openReports as $r): ?>
|
||||
<tr>
|
||||
<td class="td-name"><?=e($r['biz'])?></td>
|
||||
<td><span class="badge badge-gold"><?=e($r['type'])?></span></td>
|
||||
<td><?=e($r['reporter'])?></td>
|
||||
<td><a href="/admin/reports.php" class="btn btn-xs btn-outline">View</a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="g2">
|
||||
<div>
|
||||
<div class="admin-sec-title">🏢 RECENT BUSINESSES</div>
|
||||
<div class="tbl-wrap">
|
||||
<table class="dtbl">
|
||||
<thead><tr><th>NAME</th><th>STATUS</th><th></th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach($recentBiz as $b): ?>
|
||||
<tr>
|
||||
<td class="td-name"><?=e($b['name'])?></td>
|
||||
<td><?=$b['is_active']?'<span class="badge badge-green">Active</span>':'<span class="badge badge-gray">Inactive</span>'?></td>
|
||||
<td><a href="/admin/businesses.php?edit=<?=$b['id']?>" class="btn btn-xs btn-outline">Edit</a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<a href="/admin/businesses.php" class="btn btn-outline btn-sm" style="margin-top:.75rem">Manage All Businesses</a>
|
||||
</div>
|
||||
<div>
|
||||
<div class="admin-sec-title">👥 RECENT USERS</div>
|
||||
<div class="tbl-wrap">
|
||||
<table class="dtbl">
|
||||
<thead><tr><th>USERNAME</th><th>JOINED</th><th></th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach($recentUsers as $u): ?>
|
||||
<tr>
|
||||
<td class="td-name"><?=e($u['username'])?><?=$u['is_admin']?' <span class="badge badge-gold">ADMIN</span>':''?></td>
|
||||
<td><?=fdate($u['created_at'])?></td>
|
||||
<td><a href="/admin/users.php?edit=<?=$u['id']?>" class="btn btn-xs btn-outline">Edit</a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<a href="/admin/users.php" class="btn btn-outline btn-sm" style="margin-top:.75rem">Manage All Users</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php include __DIR__.'/admin_footer.php'; ?>
|
||||
Reference in New Issue
Block a user