<?php ob_start(); ?>
<div class="card">
  <div class="toolbar"><h2>Users</h2><div><a href="index.php?controller=user&action=add" class="btn btn-secondary">Add User</a></div></div>
  <table class="table"><thead><tr><th>Username</th><th>Fullname</th><th>Role</th><th>Created</th><th>Actions</th></tr></thead><tbody>
  <?php foreach($users as $u): ?>
    <tr>
      <td><?=htmlspecialchars($u['username'])?></td>
      <td><?=htmlspecialchars($u['fullname'])?></td><td><?=htmlspecialchars($u['role'])?></td>
      <td><?=htmlspecialchars($u['created_at'])?></td>
      <td class="actions">
        <a href="index.php?controller=user&action=edit&id=<?=$u['id']?>" class="btn btn-success btn-sm text-white">Edit</a>
        <a href="index.php?controller=user&action=delete&id=<?=$u['id']?>" class="btn btn-danger btn-sm text-white" onclick="return confirm('Delete user?')">Delete</a>
      </td>
    </tr>
  <?php endforeach; ?>
  </tbody></table>
</div>
<?php $content = ob_get_clean(); include __DIR__ . '/../layout.php'; ?>
