<?= $this->extend('admin/layout/default') ?>
<?= $this->section('content') ?>

<section class="content-header">
  <div class="container-fluid">
    <div class="row mb-2">
      <div class="col-sm-6">
        <h1>Wallets</h1>
      </div>
      <div class="col-sm-6 text-right">
        <a href="<?php echo url('rewarderWallets/add') ?>" class="btn btn-primary btn-sm"><i class="fa fa-plus pr-1"></i> Add</a>
      </div>
    </div>
  </div>
</section>

<section class="content">
  <div class="card">
    <div class="card-body">
      <table id="example1" class="table table-bordered table-striped">
        <thead>
          <tr>
            <th>User</th>
            <th width="130">Points</th>
            <th width="170">Updated</th>
            <th width="140">Action</th>
          </tr>
        </thead>
        <tbody>
          <?php foreach ($rows as $row): ?>
            <tr>
              <td><?php echo esc($row->user_name) ?> <span class="text-muted">(<?php echo esc($row->user_username ?? $row->user_email) ?>)</span></td>
              <td><?php echo esc($row->points_balance) ?></td>
              <td><?php echo esc($row->updated_at) ?></td>
              <td>
                <a href="<?php echo url('rewarderWallets/edit/'.$row->user_id) ?>" class="btn btn-sm btn-default"><i class="fas fa-edit"></i></a>
                <a href="<?php echo url('rewarderWallets/delete/'.$row->user_id) ?>" class="btn btn-sm btn-danger" onclick="return confirm('Delete this wallet?')"><i class="fas fa-trash"></i></a>
              </td>
            </tr>
          <?php endforeach ?>
        </tbody>
      </table>
    </div>
  </div>
</section>

<?= $this->endSection() ?>

