<?php
// report_template.php

// 1) Turn on errors (for debugging)
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// 2) Bootstrap your app (loads $con and session, etc.)
require_once __DIR__ . '/config.php';    

// 3) Load your fetch functions
require_once __DIR__ . '/fetch_report_data.php';

// 4) Define or pull in the master_report_id
//    — you can hard-code for testing, or use GET/POST in production
$master_id = $_GET['master_report_id'] 
             ?? 'mr_682596f90f5d40.97081585';

// 5) Fetch all the data
$report = getReportData($master_id);

// 6) Render the HTML
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <style>
    <?=file_get_contents(__DIR__ . '/styles/report.css') ?>
    </style>
</head>

<body>

    <!-- Portrait pages -->
    <div class="portrait">
        <?php include __DIR__ . '/sections/sectionA.php'; ?>
        <?php include __DIR__ . '/sections/sectionB.php'; ?>
        <?php include __DIR__ . '/sections/sectionC.php'; ?>
        <?php include __DIR__ . '/sections/sectionD.php'; ?>
        <?php include __DIR__ . '/sections/sectionE.php'; ?>
        <?php include __DIR__ . '/sections/sectionF.php'; ?>
        <?php include __DIR__ . '/sections/sectionG.php'; ?>
    </div>

    <!-- Landscape pages -->
    <div class="landscape">
        <?php include __DIR__ . '/sections/sectionH.php'; ?>
        <?php include __DIR__ . '/sections/sectionI.php'; ?>
        <?php include __DIR__ . '/sections/sectionJ.php'; ?>
        <?php include __DIR__ . '/sections/sectionK.php'; ?>
    </div>

</body>

</html>