<?php
session_start();
include '../includes/config.php';

if (!isset($_SESSION['admin_id'])) { exit; }

header("Content-type: application/vnd-ms-excel");
header("Content-Disposition: attachment; filename=Laporan_Tangkis_".date('Y-m-d').".xls");

$stmt = $pdo->query("SELECT * FROM laporan ORDER BY id DESC");
$data = $stmt->fetchAll();
?>

<table border="1">
    <tr>
        <th>ID Tracking</th>
        <th>Terlapor</th>
        <th>Jenis Dugaan</th>
        <th>Status</th>
        <th>Tanggal</th>
    </tr>
    <?php foreach($data as $row): ?>
    <tr>
        <td>#<?= $row['kode_tracking'] ?></td>
        <td><?= $row['terlapor'] ?></td>
        <td><?= $row['jenis_dugaan'] ?></td>
        <td><?= $row['status'] ?></td>
        <td><?= $row['created_at'] ?></td>
    </tr>
    <?php endforeach; ?>
</table>