<?php include app()->basePath('app/Views/partials/header.php'); ?>

<section class="panel">
    <p class="eyebrow">Administracao</p>
    <h1>Comissoes</h1>

    <div class="stats compact">
        <div class="stat"><span>Vendas</span><strong><?= e((string) $totals['count']) ?></strong></div>
        <div class="stat"><span>Bruto</span><strong><?= e(money_mzn($totals['gross'])) ?></strong></div>
        <div class="stat"><span>Plataforma</span><strong><?= e(money_mzn($totals['platform'])) ?></strong></div>
        <div class="stat"><span>Vendedores</span><strong><?= e(money_mzn($totals['seller'])) ?></strong></div>
    </div>

    <div class="table-wrap">
        <table>
            <thead>
                <tr>
                    <th>Curso</th>
                    <th>Vendedor</th>
                    <th>Bruto</th>
                    <th>% Plataforma</th>
                    <th>Plataforma</th>
                    <th>Vendedor</th>
                    <th>Estado</th>
                </tr>
            </thead>
            <tbody>
                <?php if (!$commissions): ?>
                    <tr><td colspan="7">Nenhuma comissao calculada.</td></tr>
                <?php endif; ?>
                <?php foreach ($commissions as $commission): ?>
                    <tr>
                        <td><?= e($commission['course_title']) ?></td>
                        <td><?= e($commission['seller_type']) ?> #<?= e((string) $commission['seller_id']) ?></td>
                        <td><?= e(money_mzn($commission['gross_amount'])) ?></td>
                        <td><?= e((string) $commission['platform_percentage']) ?>%</td>
                        <td><?= e(money_mzn($commission['platform_amount'])) ?></td>
                        <td><?= e(money_mzn($commission['seller_amount'])) ?></td>
                        <td><span class="badge approved"><?= e($commission['status']) ?></span></td>
                    </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</section>

<?php include app()->basePath('app/Views/partials/footer.php'); ?>
