<?php $this->start('body'); ?>

<div class="d-flex align-items-center justify-content-between mb-3">
    <h5 class="mb-0" style="font-weight:600;"><i class="fas fa-stream me-2 text-muted"></i>All In-Flight Approvals</h5>
    <a href="<?= PROOT; ?>FinChains/myQueue" class="btn btn-sm btn-outline-secondary"><i class="fas fa-inbox me-1"></i> My queue</a>
</div>

<div class="card border-0 shadow-sm">
    <div class="table-responsive">
        <table class="table table-sm mb-0 align-middle">
            <thead class="table-light">
                <tr>
                    <th>Chain</th><th>Reference</th><th>Current step</th><th>Role gate</th>
                    <th>Submitted by</th><th>Submitted</th><th></th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($this->data['items'] as $it): ?>
                    <tr>
                        <td class="text-muted small"><?= htmlspecialchars($it['chain_title']); ?></td>
                        <td><strong><?= htmlspecialchars($it['ref_label']); ?></strong></td>
                        <td><span class="badge bg-info text-white"><?= htmlspecialchars($it['step_label'] ?? '—'); ?></span></td>
                        <td class="text-muted"><code><?= htmlspecialchars($it['role_required'] ?? ''); ?></code></td>
                        <td class="text-muted"><?= htmlspecialchars($it['submitted_by_name']); ?></td>
                        <td class="text-muted small"><?= htmlspecialchars($it['submitted_on']); ?></td>
                        <td class="text-end"><a href="<?= PROOT; ?>FinChains/view/<?= (int)$it['c0d']; ?>" class="btn btn-sm btn-outline-secondary"><i class="fas fa-eye"></i></a></td>
                    </tr>
                <?php endforeach; ?>
                <?php if (empty($this->data['items'])): ?>
                    <tr><td colspan="7" class="text-center text-muted py-4">Nothing in flight.</td></tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>

<?php $this->end(); ?>
