| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- /**
- * plant-print-combined.php
- *
- * Combined print/PDF page: Plant Analysis + Plant Report in one document.
- * Accessed by headlessChrome_pdf.php (type=plant) — never directly by users.
- * Auth is via the shared ptoken written by the generator.
- */
- require_once __DIR__ . '/../../../config/database.php';
- require_once __DIR__ . '/../../../lib/auth.php';
- require_once __DIR__ . '/../../../lib/print_auth.php';
- if (session_status() === PHP_SESSION_NONE) {
- session_start();
- }
- $recordId = (int) ($_GET['rid'] ?? 0);
- $randId = trim( $_GET['rand'] ?? '');
- $clientId = (int) ($_GET['cid'] ?? 0);
- $ptoken = trim( $_GET['ptoken'] ?? '');
- authenticatePrintPage($recordId, $randId);
- $coverpageUrl = '/dashboard/crop-analysis/coverpage.php?'
- . http_build_query([
- 'type' => 'plant',
- 'rid' => $recordId,
- 'rand' => $randId,
- 'cid' => $clientId,
- 'ptoken' => $ptoken,
- 'print' => '1',
- ]);
- $analysisUrl = '/dashboard/crop-analysis/plant-test-data/plant-analysis.php?'
- . http_build_query([
- 'rid' => $recordId,
- 'rand' => $randId,
- 'cid' => $clientId,
- 'ptoken' => $ptoken,
- 'print' => '1',
- ]);
- $reportUrl = '/dashboard/crop-analysis/plant-test-data/plant-report-pdf.php?'
- . http_build_query([
- 'rid' => $recordId,
- 'rand' => $randId,
- 'ptoken' => $ptoken,
- ]);
- function h(string $v): string {
- return htmlspecialchars($v, ENT_QUOTES, 'UTF-8');
- }
- ?>
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Plant Analysis & Report</title>
- <style>
- * { margin: 0; padding: 0; box-sizing: border-box; }
- body { background: #fff; }
- iframe {
- width: 100%;
- border: none;
- display: block;
- min-height: 200px;
- }
- .page-section { page-break-after: always; }
- .page-section:last-child { page-break-after: avoid; }
- @media print {
- @page { size: A4 portrait; margin: 0; }
- html, body { margin: 0; padding: 0; background: #fff; }
- body { min-width: 1030px !important; font-size: 0.75em; }
- .container { min-width: 1030px !important; }
- .report-textarea { border: none; }
- }
- </style>
- </head>
- <body>
- <div class="page-section page">
- <iframe id="frame-coverpage" src="<?= h($coverpageUrl) ?>" scrolling="no"></iframe>
- </div>
- <div class="page-section page">
- <iframe id="frame-analysis" src="<?= h($analysisUrl) ?>" scrolling="no"></iframe>
- </div>
- <div class="page-section page">
- <iframe id="frame-report" src="<?= h($reportUrl) ?>" scrolling="no"></iframe>
- </div>
- <script>
- (function () {
- function resizeFrame(iframe) {
- try {
- var h = iframe.contentDocument.documentElement.scrollHeight;
- if (h > 0) iframe.style.height = h + 'px';
- } catch (e) {
- iframe.style.height = '2970px';
- }
- }
- var cover = document.getElementById('frame-coverpage');
- if (cover) cover.style.height = '1457px';
- ['frame-analysis', 'frame-report'].forEach(function (id) {
- var el = document.getElementById(id);
- el.addEventListener('load', function () { resizeFrame(el); });
- });
- })();
- </script>
- </body>
- </html>
|