<?php
/** Recent fuel entries feed for the Fuel Officer dashboard. */
$rows = $this->data['feed_fuel'] ?? [];
?>
<div class="card border-0 shadow-sm h-100">
  <div class="card-body p-0">
    <div class="p-3 pb-2 d-flex justify-content-between align-items-center">
      <h6 class="text-uppercase text-muted small mb-0">Recent fuel entries</h6>
      <a href="<?= PROOT; ?>FuelEntries" class="small text-decoration-none">All &rarr;</a>
    </div>
    <?php if (empty($rows)): ?>
      <div class="text-center text-muted small py-4">No entries yet.</div>
    <?php else: ?>
      <table class="table table-sm mb-0">
        <tbody>
          <?php foreach ($rows as $f): ?>
            <tr>
              <td>
                <a href="<?= PROOT; ?>FuelEntries/view/<?= (int)$f['c0d']; ?>" class="text-decoration-none">
                  <div class="font-monospace small"><?= htmlspecialchars($f['entry_no']); ?></div>
                  <div class="small text-muted">
                    <?= htmlspecialchars($f['truck_reg'] ?: '—'); ?> &middot;
                    <?= htmlspecialchars($f['driver_name'] ?: '—'); ?> &middot;
                    <?= humanDate($f['entry_date']); ?>
                  </div>
                </a>
              </td>
              <td class="text-end">
                <div class="fw-bold font-monospace small"><?= number_format((float)$f['liters'], 1); ?> L</div>
                <div class="small text-muted">TZS <?= number_format((float)$f['gross_amount'], 0); ?></div>
              </td>
            </tr>
          <?php endforeach; ?>
        </tbody>
      </table>
    <?php endif; ?>
  </div>
</div>
