<?php \App\Core\View::render('reports/_toolbar', ['show' => ['date' => true, 'priority' => true, 'queue' => true], 'filters' => $filters, 'query' => $query], null); ?>
<div class="card">
  <div class="table-wrap">
    <table class="table">
      <thead><tr><th>Ticket</th><th>Customer</th><th>Subject</th><th>Priority</th><th>Status</th><th>Age</th><th>Band</th></tr></thead>
      <tbody>
      <?php foreach ($rows as $r) : ?>
        <tr>
          <td class="mono"><a class="row-link" href="<?= url('/tickets/' . $r['id']) ?>"><?= e($r['ticket_no']) ?></a></td>
          <td><?= e($r['customer_name']) ?></td>
          <td style="max-width:260px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap"><?= e($r['subject']) ?></td>
          <td><span class="badge badge-outline"><?= e($r['priority']) ?></span></td>
          <td><span class="<?= status_badge_class($r['status']) ?>"><?= status_label($r['status']) ?></span></td>
          <td class="text-sm"><?= fmt_minutes((int)$r['age_hours'] * 60) ?></td>
          <td><span class="badge <?= $r['band']==='7+ days'?'badge-breach':'badge-outline' ?>"><?= $r['band'] ?></span></td>
        </tr>
      <?php endforeach; ?>
      <?php if (empty($rows)) : ?><tr><td colspan="7" class="text-faint">No open tickets.</td></tr><?php endif; ?>
      </tbody>
    </table>
  </div>
</div>
