<?php \App\Core\View::render('reports/_toolbar', ['show' => ['customer' => true, 'tier' => true], 'filters' => $filters, 'query' => $query], null); ?>
<div class="card">
  <div class="table-wrap">
    <table class="table">
      <thead><tr><th>Customer</th><th>Contract</th><th>Tier</th><th>Used / Total</th><th>% used</th><th>Expiry</th></tr></thead>
      <tbody>
      <?php foreach ($rows as $r) : ?>
        <tr>
          <td><?= e($r['customer_name']) ?></td>
          <td class="mono text-sm"><?= e($r['contract_no']) ?></td>
          <td><span class="badge badge-outline"><?= e($r['tier']) ?></span></td>
          <td class="text-sm"><?= $r['support_hours_used'] ?> / <?= $r['support_hours_total'] ?> hrs</td>
          <td>
            <?= $r['pct_used'] ?>%
            <?php if ($r['pct_used'] >= 80) : ?><span class="badge badge-oe">Near limit</span><?php endif; ?>
          </td>
          <td class="text-sm"><?= fmt_d($r['end_date']) ?><?php if (strtotime($r['end_date']) < strtotime('+30 days')) : ?> <span class="badge badge-breach">Expiring soon</span><?php endif; ?></td>
        </tr>
      <?php endforeach; ?>
      </tbody>
    </table>
  </div>
</div>
