<?= $this->extend('admin/layout/main') ?>
<?= $this->section('content') ?>
<div class="d-flex justify-content-between align-items-center mb-3">
    <h3><?= lang('App.expenses') ?></h3>
    <a href="/admin/expenses/create" class="btn btn-dark btn-sm"><?= lang('App.add_new') ?></a>
</div>
<div class="card p-3">
<table class="table">
    <thead><tr><th>التصنيف</th><th>الوصف</th><th><?= lang('App.amount') ?></th><th>التاريخ</th><th><?= lang('App.actions') ?></th></tr></thead>
    <tbody>
    <?php foreach ($expenses as $e): ?>
        <tr>
            <td><?= esc($e['category']) ?></td>
            <td><?= esc($e['description']) ?></td>
            <td><?= number_format($e['amount'], 2) ?> <?= esc($e['currency']) ?></td>
            <td><?= esc($e['date']) ?></td>
            <td>
                <a href="/admin/expenses/<?= $e['id'] ?>/edit" class="btn btn-sm btn-outline-primary"><?= lang('App.edit') ?></a>
                <form method="post" action="/admin/expenses/<?= $e['id'] ?>/delete" class="d-inline" onsubmit="return confirm('?')">
                    <?= csrf_field() ?><button class="btn btn-sm btn-outline-danger"><?= lang('App.delete') ?></button>
                </form>
            </td>
        </tr>
    <?php endforeach; ?>
    </tbody>
</table>
<?= $pager->links() ?>
</div>
<?= $this->endSection() ?>
