<div class="row">
  <div class="col-md-12">
    <div class="card">
      <div class="card-header"><h4><?= e(app_zh('用户管理')) ?></h4></div>
      <div class="card-body">
        <div class="table-responsive">
          <table class="table table-bordered">
            <thead>
              <tr>
                <th>ID</th>
                <th><?= e(app_zh('账号')) ?></th>
                <th><?= e(app_zh('角色')) ?></th>
                <th><?= e(app_zh('状态')) ?></th>
                <th><?= e(app_zh('余额')) ?></th>
                <th><?= e(app_zh('操作')) ?></th>
              </tr>
            </thead>
            <tbody>
              <?php foreach ($users as $u): ?>
              <tr>
                <td data-label="ID"><?= e((string)$u['id']) ?></td>
                <td data-label="<?= e(app_zh('账号')) ?>"><?= e((string)$u['username']) ?></td>
                <td data-label="<?= e(app_zh('角色')) ?>"><?= e((string)$u['role']) ?></td>
                <td data-label="<?= e(app_zh('状态')) ?>">
                  <?php if (($u['status'] ?? '') === 'active'): ?>
                    <span class="badge-status badge-ok"><?= e(app_zh('正常')) ?></span>
                  <?php else: ?>
                    <span class="badge-status badge-danger"><?= e(app_zh('禁用')) ?></span>
                  <?php endif; ?>
                </td>
                <td data-label="<?= e(app_zh('余额')) ?>"><?= e((string)$u['balance']) ?></td>
                <td data-label="<?= e(app_zh('操作')) ?>">
                  <a class="btn btn-xs btn-info" href="<?= e_url(base_url('admin/users/edit/' . $u['id'])) ?>"><?= e(app_zh('编辑')) ?></a>
                  <form method="post" action="<?= e_url(base_url('admin/users/delete')) ?>" style="display:inline" onsubmit="return confirm('<?= e(app_zh('确定要删除该用户吗？')) ?>');">
                    <?= csrf_field() ?>
                    <input type="hidden" name="id" value="<?= e((string)$u['id']) ?>">
                    <button class="btn btn-xs btn-danger" type="submit"><?= e(app_zh('删除')) ?></button>
                  </form>
                </td>
              </tr>
              <?php endforeach; ?>
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
</div>
