<?php
declare(strict_types=1);
require __DIR__ . '/app/bootstrap.php';
require_auth();
require_current_schema();
header('Content-Type: application/json; charset=utf-8');
header('Cache-Control: private, no-store, max-age=0');
$id=(int)($_GET['id']??0);
$stmt=db()->prepare('SELECT customer_reference,order_source,fulfilment_method,delivery_address,share_view_count,share_first_viewed_at,share_last_viewed_at FROM documents WHERE id=?');
$stmt->execute([$id]);
$row=$stmt->fetch();
if(!$row){http_response_code(404);echo json_encode(['error'=>'Document not found']);exit;}
echo json_encode($row,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
