<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">
        <form method="post" action="<?= e_url(base_url('admin/referrals')) ?>" class="form-inline m-b-15">
          <?= csrf_field() ?>
          <div class="form-group">
            <label class="m-r-10"><?= e(app_zh('充值金额')) ?></label>
            <input class="form-control" name="set_balance" value="0" style="width: 140px;">
          </div>
          <button class="btn btn-primary m-l-10" type="submit"><?= e(app_zh('生成邀请码')) ?></button>
        </form>
        <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 ($referrals as $r): ?>
              <tr>
                <td data-label="ID"><?= e((string)$r['id']) ?></td>
                <td data-label="<?= e(app_zh('邀请码')) ?>"><?= e((string)($r['code'] ?? $r['code_hash'])) ?></td>
                <td data-label="<?= e(app_zh('充值金额')) ?>"><?= e((string)$r['set_balance']) ?></td>
                <td data-label="<?= e(app_zh('创建者')) ?>"><?= e((string)($r['created_by_name'] ?? '')) ?></td>
                <td data-label="<?= e(app_zh('使用者')) ?>"><?= e((string)($r['used_by'] ?? '')) ?></td>
                <td data-label="<?= e(app_zh('使用时间')) ?>"><?= e((string)($r['used_at'] ?? '')) ?></td>
              </tr>
              <?php endforeach; ?>
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
</div>
