<?php
require_once __DIR__ . '/../includes/header.php';

$formas = $pdo->query("SELECT * FROM formas_pagamento ORDER BY nome")->fetchAll();
?>

<div class="page-header">
    <div>
        <h2>Formas de Pagamento</h2>
        <div class="subtitle"><?= count($formas) ?> forma(s) cadastrada(s)</div>
    </div>
    <a href="<?= base_url('cadastros/forma_pagamento_form.php') ?>" class="btn btn-novo">+ Nova Forma</a>
</div>

<div class="card-premium">
<div class="table-responsive">
<table class="table-premium">
<thead>
<tr>
    <th>Nome</th>
    <th>Status</th>
    <th class="text-end">Acoes</th>
</tr>
</thead>
<tbody>
<?php foreach ($formas as $f): ?>
<tr>
    <td><strong><?= sanitize($f['nome']) ?></strong></td>
    <td><span class="badge <?= $f['status']==='ativo' ? 'badge-ativo' : 'badge-inativo' ?>"><?= ucfirst($f['status']) ?></span></td>
    <td class="text-end">
        <a href="<?= base_url('cadastros/forma_pagamento_form.php') ?>?id=<?= intval($f['id']) ?>" class="btn btn-sm btn-info">&#9998;</a>
        <a href="<?= base_url('cadastros/forma_pagamento_status.php') ?>?id=<?= intval($f['id']) ?>" class="btn btn-sm btn-warning">&#9899;</a>
    </td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>

<?php require_once __DIR__ . '/../includes/footer.php'; ?>
