<?php
require_once __DIR__ . '/../includes/functions.php';
requireLogin();

$db   = getDB();
$rows = $db->query("SELECT card_code, name, created_at FROM members ORDER BY created_at DESC LIMIT 10")->fetchAll();

$out = [];
foreach ($rows as $r) {
    $out[] = [
        'card_code'  => $r['card_code'],
        'name'       => $r['name'],
        'created_at' => date('M d, Y', strtotime($r['created_at'])),
    ];
}
jsonResponse(['success'=>true, 'cards'=>$out]);
