<?= $this->extend('admin/layout/main') ?>
<?= $this->section('content') ?>
<div class="d-flex justify-content-between align-items-center mb-3">
    <h3><?= lang('App.marketers') ?></h3>
    <a href="/admin/marketers/create" class="btn btn-dark btn-sm"><?= lang('App.add_new') ?></a>
</div>
<div class="card p-3">
<table class="table">
    <thead><tr><th><?= lang('App.name') ?></th><th><?= lang('App.commission_type') ?></th><th><?= lang('App.commission_value') ?></th><th><?= lang('App.total_commissions') ?></th><th><?= lang('App.actions') ?></th></tr></thead>
    <tbody>
    <?php foreach ($marketers as $m): ?>
        <tr>
            <td><?= esc($m['name']) ?></td>
            <td><?= $m['commission_type'] === 'percentage' ? 'نسبة %' : 'مبلغ ثابت' ?></td>
            <td><?= esc($m['commission_value']) ?></td>
            <td><?= number_format($m['total_commissions'], 2) ?></td>
            <td>
                <a href="/admin/marketers/<?= $m['id'] ?>/edit" class="btn btn-sm btn-outline-primary"><?= lang('App.edit') ?></a>
                <form method="post" action="/admin/marketers/<?= $m['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>
</div>
<?= $this->endSection() ?>
