<div class="container py-4">
    <h4 class="mb-3">Relatório de Diárias por Funcionário</h4>

    <form method="GET" class="row mb-3 g-2">
        <div class="col-md-4">
            <input type="text" name="nome" class="form-control" placeholder="Nome do funcionário" value="<?= htmlspecialchars($_GET['nome'] ?? '') ?>">
        </div>
        <div class="col-md-3">
            <button type="submit" class="btn btn-primary w-100">Filtrar</button>
        </div>
        <div class="col-md-3">
            <a href="index.php?url=Relatorios/pdf_diariasPorFuncionario" target="_blank" class="btn btn-danger w-100">
                <i class="fa fa-file-pdf"></i> Exportar PDF
            </a>
        </div>
    </form>

    <table class="table table-bordered table-striped">
        <thead class="table-dark">
            <tr>
                <th>#</th>
                <th>Nome do Funcionário</th>
                <th>Total de Diárias</th>
                <th>Valor Total (R$)</th>
            </tr>
        </thead>
        <tbody>
            <?php if (!empty($diarias)) : ?>
                <?php foreach ($diarias as $i => $linha) : ?>
                    <tr>
                        <td><?= $i + 1 ?></td>
                        <td><?= htmlspecialchars($linha['nome']) ?></td>
                        <td><?= $linha['total_diarias'] ?></td>
                        <td><?= number_format($linha['valor_total'], 2, ',', '.') ?></td>
                    </tr>
                <?php endforeach; ?>
            <?php else : ?>
                <tr><td colspan="4">Nenhum registro encontrado.</td></tr>
            <?php endif; ?>
        </tbody>
    </table>
</div>
