<?php
require('fpdf/fpdf.php'); 

require 'db_config.php';

$result = $conn->query("SELECT * FROM attendance");

$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', 12);
$pdf->Cell(0, 10, 'ATTENDANCE LIST', 0, 1, 'C');  // 'C' centers the text, 0 border, 1 for line break
$pdf->Ln(10);

// Column headers

$pdf->Cell(10, 10, 'ID', 1);
$pdf->Cell(40, 10, 'Check-in Time', 1);
$pdf->Cell(40, 10, 'Participant Type', 1);
$pdf->Cell(50, 10, 'Full Name', 1);

$pdf->Ln();

$pdf->SetFont('Arial', '', 10);
while ($row = $result->fetch_assoc()) {
    $pdf->Cell(10, 10, $row['id'], 1);
    $pdf->Cell(40, 10, $row['checkin_time'], 1);
    $pdf->Cell(40, 10, $row['participant_type'], 1);
    $pdf->Cell(50, 10, $row['fullname'], 1);
    
    $pdf->Ln();
}

$pdf->Output('D', 'attendance.pdf');

$conn->close();
?>
