<?php
include('../../includes/layout_inicio.php');
require_once('../../config/conexao.php');

// LISTAR EVENTOS
$stmt = $pdo->query("SELECT * FROM eventos ORDER BY data_evento DESC");
$eventos = $stmt->fetchAll();
?>

<h1>Eventos</h1>

<a href="criar.php" class="btn btn-primary">+ Novo Evento</a>

<br><br>

<table>

    <tr>
        <th>ID</th>
        <th>Nome</th>
        <th>Data</th>
        <th>Ações</th>
    </tr>

    <?php foreach($eventos as $e){ ?>

    <tr>
        <td><?= $e['id'] ?></td>
        <td><?= $e['nome'] ?></td>
        <td><?= date('d/m/Y', strtotime($e['data_evento'])) ?></td>

        <td>
            <a href="../qrcode/gerar.php?evento_id=<?= $e['id'] ?>" class="btn btn-primary">QR Code</a>
            <a href="../presenca/listar.php?evento_id=<?= $e['id'] ?>" class="btn btn-primary">Presenças</a>
        </td>
    </tr>

    <?php } ?>

</table>

<?php include('../../includes/layout_fim.php'); ?>