auth()) { // Rebuild cust / site / key indexes from session — same logic as index.php sidebar $custIndex = isset($_SESSION["custIndex"]) ? $_SESSION["custIndex"] : 0; $custList = $Client->getCustList($_SESSION["office"]); $siteIndex = isset($_SESSION["siteIndex"]) ? $_SESSION["siteIndex"] : 0; $siteList = $Client->getSites($custList[$custIndex]["id"]); $keyIndex = isset($_SESSION["keyIndex"]) ? $_SESSION["keyIndex"] : 0; $keyList = $BasData->getKeys($siteList[$siteIndex]["id"]); if (count($keyList) > 0 && isset($keyList[$keyIndex])) { $basKeyid = $keyList[$keyIndex]["id"]; // ← this is what index.php puts in #sitekeys value $basKeyname = $keyList[$keyIndex]["keyname"]; // ← this is what you see in the dropdown ("asp") $basLiveHint = ""; } } // Optional override: test.php?keyid=3 (same number as asp dropdown value on index) if (isset($_GET["keyid"]) && $_GET["keyid"] !== "") { $basKeyid = (int)$_GET["keyid"]; } // Force sample data: test.php?sample=1 (ignores login — auto-loads rtu-sample.js + veris-sample.js) $basForceSample = isset($_GET["sample"]) && $_GET["sample"] !== "" && $_GET["sample"] !== "0"; if ($basForceSample) { $basKeyid = null; $basLiveHint = "Sample data mode — rtu-sample.js and veris-sample.js (matches forecast.py)."; } // Force forecast overlay: test.php?forecast=1 (auto-loads forecast_output.json) $basForceForecast = isset($_GET["forecast"]) && $_GET["forecast"] !== "" && $_GET["forecast"] !== "0"; // reports.php iframe: test.php?embed=1 hides duplicate page title $basEmbed = isset($_GET["embed"]) && $_GET["embed"] !== "" && $_GET["embed"] !== "0"; // Optional: test.php?interval=48&tstamp=NOW (or YYYY-MM-DD) — same as reports sidebar $basInterval = 35; if (isset($_GET["interval"]) && $_GET["interval"] !== "") { $basInterval = min(max(8, (int)$_GET["interval"]), 72); } $basTstamp = "NOW"; if (isset($_GET["tstamp"]) && $_GET["tstamp"] !== "") { $basTstamp = $_GET["tstamp"]; } ?>