<?php
// guest_registration_print_wrapper.php
// Optional helper for bulk print.
// It opens guest_registration.php in an iframe and calls browser print.
// Put this file under: /rooms/modules/reservations/

require_once __DIR__ . '/../../includes/bootstrap.php';
require_login();

$orderId = (int)($_GET['order_id'] ?? 0);
$roomingId = (int)($_GET['rooming_id'] ?? 0);

if ($orderId <= 0) {
    die('Invalid booking selected.');
}

$pdfUrl = 'guest_registration.php?' . http_build_query([
    'order_id' => $orderId,
    'rooming_id' => $roomingId,
]);

?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>Print Guest Registration</title>
    <style>
        html, body { margin:0; padding:0; height:100%; overflow:hidden; }
        iframe { border:0; width:100%; height:100vh; }
        .printbar {
            position:fixed;
            z-index:10;
            top:10px;
            right:10px;
            background:#111827;
            color:white;
            border-radius:10px;
            padding:8px 10px;
            font-family:Arial, sans-serif;
            font-size:12px;
        }
        .printbar button {
            border:0;
            border-radius:8px;
            padding:6px 9px;
            font-weight:bold;
            cursor:pointer;
        }
        @media print {
            .printbar { display:none; }
        }
    </style>
</head>
<body>
    <div class="printbar">
        Guest registration form
        <button onclick="window.print()">Print</button>
    </div>
    <iframe id="pdfFrame" src="<?php echo htmlspecialchars($pdfUrl, ENT_QUOTES, 'UTF-8'); ?>"></iframe>
    <script>
        window.addEventListener('load', function () {
            setTimeout(function () {
                window.print();
            }, 1000);
        });
    </script>
</body>
</html>
