Files
fitme3070.pt/views/user/index.php
T
2026-06-12 21:20:23 +01:00

44 lines
1.9 KiB
PHP

<?php
require __DIR__ . '/../../config/db.php';
require __DIR__ . '/../../config/functions.php';
$user = require_admin();
$users = $pdo->query(
"SELECT id, name, email, phone, role, is_active, andmore_id, last_login_at, last_login_ua
FROM users ORDER BY FIELD(role,'sysadmin','admin','staff','client'), name"
)->fetchAll(PDO::FETCH_ASSOC);
include __DIR__ . '/../../includes/header.php';
?>
<div class="container">
<h1 class="h3 mb-4">Utilizadores</h1>
<div class="card shadow-sm"><div class="card-body">
<div class="table-responsive">
<table class="am-datatable table table-hover align-middle">
<thead><tr>
<th>Nome</th><th>Email</th><th>Perfil</th><th>Ativo</th>
<th>Andmore ID</th><th>Último acesso</th>
</tr></thead>
<tbody>
<?php foreach ($users as $u): ?>
<tr>
<td><?= htmlspecialchars($u['name']) ?></td>
<td><?= htmlspecialchars($u['email']) ?></td>
<td><span class="badge text-bg-secondary"><?= htmlspecialchars(role_label($u['role'])) ?></span></td>
<td><?= $u['is_active'] ? '<i class="bi bi-check-circle text-success"></i>' : '<i class="bi bi-x-circle text-muted"></i>' ?></td>
<td><?= $u['andmore_id'] ? (int) $u['andmore_id'] : '<span class="text-muted">—</span>' ?></td>
<td class="small text-muted">
<?php if ($u['last_login_at']): ?>
<?= htmlspecialchars(format_date_pt($u['last_login_at'])) ?>
· <?= htmlspecialchars(parse_user_agent((string) $u['last_login_ua'])) ?>
<?php else: ?>—<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div></div>
</div>
<?php include __DIR__ . '/../../includes/footer.php'; ?>