<?php
$db = Database::getInstance();
$newCount = (int) $db->fetchColumn("SELECT COUNT(*) FROM members WHERE status = 'active' AND is_deleted = 0 AND MONTH(activation_date) = MONTH(CURDATE()) AND YEAR(activation_date) = YEAR(CURDATE())");
$recent = $db->fetchAll("SELECT membership_number, full_name_en, activation_date FROM members WHERE status = 'active' AND is_deleted = 0 AND MONTH(activation_date) = MONTH(CURDATE()) AND YEAR(activation_date) = YEAR(CURDATE()) ORDER BY activation_date DESC LIMIT 5");
?>
<div class="card border-primary h-100">
    <div class="card-body">
        <div class="d-flex justify-content-between mb-2">
            <h6 class="text-muted mb-0"><?= lang('members.new_this_month') ?></h6>
            <h3 class="mb-0 text-primary"><?= $newCount ?></h3>
        </div>
        <?php foreach ($recent as $r): ?>
        <div class="small border-bottom py-1">
            <a href="/members" class="text-decoration-none"><?= e($r['membership_number']) ?></a> — <?= e(str_limit($r['full_name_en'], 25)) ?>
        </div>
        <?php endforeach; ?>
    </div>
</div>