Welcome, = is_super_admin() ? 'Super Admin' : 'Org Admin' ?>
+Welcome, = is_super_admin() ? 'Super Admin' : htmlspecialchars($user['name'] ?? 'Org Admin') ?>
+Manage your charity activities and donations.
+diff --git a/admin/auth.php b/admin/auth.php index c1ec291..48bf5e2 100644 --- a/admin/auth.php +++ b/admin/auth.php @@ -1,10 +1,27 @@ 0, + 'path' => '/', + 'domain' => '', + 'secure' => $is_https, + 'httponly' => true, + 'samesite' => 'Lax' + ]); + + ini_set('session.use_only_cookies', 1); + ini_set('session.use_strict_mode', 1); // Re-enabling strict mode for security now that login works + session_start(); } @@ -20,8 +37,7 @@ function require_login() { } function get_user() { - if (!is_logged_in()) return null; - return $_SESSION['user']; + return $_SESSION['user'] ?? null; } function is_super_admin() { diff --git a/admin/index.php b/admin/index.php index 1eb20d8..cad74c9 100644 --- a/admin/index.php +++ b/admin/index.php @@ -11,10 +11,34 @@ if (is_super_admin()) { $total_orgs = $pdo->query("SELECT COUNT(*) FROM organizations")->fetchColumn(); $total_cases = $pdo->query("SELECT COUNT(*) FROM cases")->fetchColumn(); $total_donations = $pdo->query("SELECT SUM(amount) FROM donations WHERE status = 'completed'")->fetchColumn() ?: 0; + + // Fetch recent donations + $recent_donations = $pdo->query(" + SELECT d.*, c.title_en as case_title + FROM donations d + JOIN cases c ON d.case_id = c.id + ORDER BY d.created_at DESC + LIMIT 5 + ")->fetchAll(); } else { $org_id = $user['org_id']; $total_cases = $pdo->query("SELECT COUNT(*) FROM cases WHERE org_id = $org_id")->fetchColumn(); - $total_donations = $pdo->query("SELECT SUM(d.amount) FROM donations d JOIN cases c ON d.case_id = c.id WHERE c.org_id = $org_id AND d.status = 'completed'")->fetchColumn() ?: 0; + $total_donations = $pdo->query(" + SELECT SUM(d.amount) + FROM donations d + JOIN cases c ON d.case_id = c.id + WHERE c.org_id = $org_id AND d.status = 'completed' + ")->fetchColumn() ?: 0; + + // Fetch recent donations for this org + $recent_donations = $pdo->query(" + SELECT d.*, c.title_en as case_title + FROM donations d + JOIN cases c ON d.case_id = c.id + WHERE c.org_id = $org_id + ORDER BY d.created_at DESC + LIMIT 5 + ")->fetchAll(); } ?> @@ -36,6 +60,9 @@ if (is_super_admin()) { .card { border: none; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); } .stat-card { padding: 1.5rem; } .stat-icon { font-size: 2rem; color: var(--primary-color); } + .badge-pending { background-color: #fef3c7; color: #92400e; } + .badge-completed { background-color: #d1fae5; color: #065f46; } + .badge-failed { background-color: #fee2e2; color: #991b1b; }
@@ -55,7 +82,10 @@ if (is_super_admin()) {Manage your charity activities and donations.
+New donations and case updates will appear here.
- +| Donor | +Case | +Amount | +Status | +Date | +
|---|---|---|---|---|
| No recent donations found. | +||||
|
+ = htmlspecialchars($donation['donor_name'] ?: 'Anonymous') ?>
+ = htmlspecialchars($donation['donor_email']) ?>
+ |
+ = htmlspecialchars($donation['case_title']) ?> | +$= number_format($donation['amount'], 2) ?> | ++ + = ucfirst($donation['status']) ?> + + | += date('M j, Y H:i', strtotime($donation['created_at'])) ?> | +