<?php

include_once 'auth.php';

session_start();

if(!isset($_SESSION['admin_login'])){

    header("Location: login.php");
    exit;

}

include_once '../config/database.php';

/* =========================================================
   HEADER EXCEL
========================================================= */

header("Content-Type: application/vnd.ms-excel");

header(
    "Content-Disposition: attachment; filename=verified_participants.xls"
);

/* =========================================================
   QUERY
========================================================= */

$result = mysqli_query(
    $conn,
    "SELECT * FROM participants
     WHERE payment_status='verified'
     ORDER BY bib_number ASC"
);

?>

<table border="1">

    <tr>

        <th>BIB</th>
        <th>Full Name</th>
        <th>Gender</th>
        <th>Birth Date</th>
        <th>Blood Type</th>
        <th>Email</th>
        <th>WhatsApp</th>
        <th>Address</th>
        <th>Distance</th>
        <th>Category</th>
        <th>Jersey</th>
        <th>Emergency Name</th>
        <th>Emergency Phone</th>

    </tr>

    <?php while($row = mysqli_fetch_assoc($result)){ ?>

    <tr>

        <td><?php echo $row['bib_number']; ?></td>
        <td><?php echo $row['full_name']; ?></td>
        <td><?php echo $row['gender']; ?></td>
        <td><?php echo $row['birth_date']; ?></td>
        <td><?php echo $row['blood_type']; ?></td>
        <td><?php echo $row['email']; ?></td>
        <td><?php echo $row['whatsapp']; ?></td>
        <td><?php echo $row['address']; ?></td>
        <td><?php echo $row['distance_category']; ?></td>
        <td><?php echo $row['participant_category']; ?></td>
        <td><?php echo $row['jersey_size']; ?></td>
        <td><?php echo $row['emergency_name']; ?></td>
        <td><?php echo $row['emergency_phone']; ?></td>

    </tr>

    <?php } ?>

</table>
