<?php
include 'config.php';

if (isset($_GET['id'])) {
    $documentId = $_GET['id'];

    // Update the document status to "Downloaded"
    $updateStatusSql = "UPDATE document_status SET status = 'Downloaded' WHERE document_id = ?";
    $stmt = $conn->prepare($updateStatusSql);
    $stmt->bind_param("i", $documentId);
    $stmt->execute();

    // Generate the PDF (FPDF logic)
    // Add your existing PDF generation code here
    // Example:
    require('fpdf.php');
    $pdf = new FPDF();
    $pdf->AddPage();
    $pdf->SetFont('Arial', 'B', 16);
    $pdf->Cell(40, 10, 'Your Document Content Here');
    $pdf->Output();

    exit();
}
?>
