<?php if (!defined('DASHBOARD_ROOT')) { http_response_code(403); exit; } RBAC::enforce('view.users'); $customers = Database::fetchAll("SELECT id, username, email, credit_balance, status, is_verified, created_at FROM users WHERE account_type = 'customer' ORDER BY id DESC LIMIT 100"); 
// Decrypt fields
foreach ($customers as &$c) {
    $c['username'] = Crypt::render($c['username'] ?? '');
    $c['email'] = Crypt::render($c['email'] ?? '');
}
unset($c);
?> <div class="workspace" id="ws-users"> <div class="workspace-header"> <h1>Users</h1> <div class="workspace-actions"> <input type="search" id="user-search" placeholder="Search customers..." class="search-input" onkeyup="filterUsers()"> </div> </div> <div class="panel"><?php if (empty($customers)): ?> <div class="empty-state">No customers found.</div><?php else: ?> <table class="data-table" id="users-table" style="width:100%; text-align:left; border-collapse:collapse;"> <thead> <tr style="border-bottom: 1px solid rgba(255,255,255,0.1);"> <th style="padding:10px;">ID</th> <th style="padding:10px;">Username</th> <th style="padding:10px;">Email</th> <th style="padding:10px;">Credits</th> <th style="padding:10px;">Status</th> <th style="padding:10px;">Verified</th> <th style="padding:10px;">Joined</th> </tr> </thead> <tbody><?php foreach ($customers as $c): ?> <tr style="border-bottom: 1px solid rgba(255,255,255,0.05);" class="user-row"> <td style="padding:10px;"><?= $c['id'] ?> </td> <td style="padding:10px;"><?= UI::e($c['username']) ?> </td> <td style="padding:10px;" class="user-email"><?= UI::e($c['email']) ?> </td> <td style="padding:10px;">$<?= number_format((float)$c['credit_balance'], 2) ?> </td> <td style="padding:10px;"><?= UI::e($c['status']) ?> </td> <td style="padding:10px;"><?= $c['is_verified'] ? 'Yes' : 'No' ?> </td> <td style="padding:10px;"><?= date('M j, Y', strtotime($c['created_at'])) ?> </td> </tr><?php endforeach; ?> </tbody> </table><?php endif; ?> </div> </div> <script nonce="<?= $cspNonce ?>"> function filterUsers() { var query = document.getElementById('user-search').value.toLowerCase(); var rows = document.querySelectorAll('.user-row'); rows.forEach(function(row) { var email = row.querySelector('.user-email').textContent.toLowerCase(); if (email.includes(query)) row.style.display = ''; else row.style.display = 'none'; }); } </script>