<?php
declare(strict_types=1);

// bootstrap starts the session and loads config/db/helpers
require_once __DIR__ . '/../app/bootstrap.php';

// ✅ Auth gate (match your app's session convention)
$uid = (int)($_SESSION['uid'] ?? 0);
if ($uid <= 0) {
    // fallback if some parts of app use a different key
    $uid = (int)($_SESSION['user_id'] ?? 0);
}

if ($uid <= 0) {
    http_response_code(403);
    echo "Unauthorized";
    exit;
}

// Standalone invoice (NO layout shell)
require __DIR__ . '/../app/views/pages/invoice_view.php';