Dashboard ()
Total Members
₹
Total Donations
Total Events
News
Pending Approvals
Total Members
Total Events
News
Member ID
Membership Status
No activities found.
No new members found.
Name:
Email:
Membership Status:
Member ID:
Mobile:
Designation:
query("SELECT COUNT(*) as total FROM users WHERE status = 'approved'"); $stats['total_members'] = $stmt->fetch()['total']; $stmt = $db->query("SELECT COALESCE(SUM(amount), 0) as total FROM donations WHERE status = 'completed'"); $result = $stmt->fetch(); error_log("Total Donations: " . $result['total']); // Log for debugging $stats['total_donations'] = $result['total']; $stmt = $db->query("SELECT COUNT(*) as total FROM events WHERE status = 'active'"); $stats['total_events'] = $stmt->fetch()['total']; $stmt = $db->query("SELECT COUNT(*) as total FROM news WHERE status = 'active'"); $stats['total_news'] = $stmt->fetch()['total']; $stmt = $db->query("SELECT COUNT(*) as total FROM users WHERE status = 'pending'"); $stats['pending_approvals'] = $stmt->fetch()['total']; // Recent activities for admin $stmt = $db->prepare("SELECT * FROM recent_activities WHERE status = 'active' ORDER BY activity_date DESC LIMIT 5"); $stmt->execute(); $recent_activities = $stmt->fetchAll(PDO::FETCH_ASSOC); } elseif (isCoordinator()) { // Coordinator sees limited data $stmt = $db->query("SELECT COUNT(*) as total FROM users WHERE status = 'approved'"); $stats['total_members'] = $stmt->fetch()['total']; $stmt = $db->query("SELECT COUNT(*) as total FROM events WHERE status = 'active'"); $stats['total_events'] = $stmt->fetch()['total']; $stmt = $db->query("SELECT COUNT(*) as total FROM news WHERE status = 'active'"); $stats['total_news'] = $stmt->fetch()['total']; // Recent activities for coordinator $stmt = $db->prepare("SELECT * FROM recent_activities WHERE status = 'active' ORDER BY activity_date DESC LIMIT 3"); $stmt->execute(); $recent_activities = $stmt->fetchAll(PDO::FETCH_ASSOC); } elseif (isMember()) { // Regular member sees only their own data $stmt = $db->prepare("SELECT * FROM users WHERE id = ? OR email = ?"); $stmt->execute([$userId, $_SESSION['user_email']]); $user_data = $stmt->fetch(PDO::FETCH_ASSOC); $stats['membership_status'] = $user_data['status'] ?? 'pending'; $stats['member_id'] = $user_data['registration_id'] ?? 'N/A'; $recent_activities = []; } // Recent members (admin and coordinator only) if (isAdmin() || isCoordinator()) { $stmt = $db->prepare("SELECT * FROM users WHERE status = 'approved' ORDER BY created_at DESC LIMIT 5"); $stmt->execute(); $recent_members = $stmt->fetchAll(PDO::FETCH_ASSOC); } else { $recent_members = []; } } catch(PDOException $e) { $error = "Error loading data: " . $e->getMessage(); error_log($error); // Log the error $stats = []; $recent_activities = []; $recent_members = []; } include 'includes/header.php'; ?>
Total Members
Total Donations
Total Events
News
Pending Approvals
Total Members
Total Events
News
Member ID
Membership Status
No activities found.
No new members found.
Name:
Email:
Membership Status:
Member ID:
Mobile:
Designation: