ソースを参照

Print Improve

Benjamin Harris 2 ヶ月 前
コミット
678aaa1af6

+ 65 - 5
dashboard/crop-analysis/plant-test-data/plant-report.php

@@ -72,6 +72,40 @@ $siteName  = 'Crop Monitor';
 
 include __DIR__ . '/../../../layouts/header.php';
 ?>
+<link rel="stylesheet" href="/client-assets/home/css/graphPrint.css" media="print">
+<style>
+    @media print {
+        @page {
+            size: A4 portrait;
+        }
+        @page :left {
+            margin-left: 0.5cm;
+        }
+        @page :right {
+            margin-right: 0.5cm;
+        }
+        @page :top {
+            margin-top: 0cm;
+        }
+        @page :bottom {
+            margin-bottom: 0cm;
+        }
+        body {
+            min-width: 992px !important;
+        }
+        .container {
+            min-width: 992px !important;
+        }
+        .report-textarea {
+            border:none;
+        }
+    }
+    .report-textarea {
+        overflow: hidden;
+        resize: none;
+        overflow-y: auto;
+    }
+</style>
 
 
             <div class="container-fluid px-4">
@@ -232,12 +266,18 @@ include __DIR__ . '/../../../layouts/header.php';
 
     // ── Auto-save ────────────────────────────────────────────────────────── //
     document.querySelectorAll('.report-form .report-textarea')
-        .forEach(function (el) {
-            el.addEventListener('input', function () {
-                clearTimeout(saveTimer);
-                saveTimer = setTimeout(saveReport, 1200);
-            });
+    .forEach(function (el) {
+
+        // initial resize
+        autoResize(el);
+
+        el.addEventListener('input', function () {
+            autoResize(el);
+
+            clearTimeout(saveTimer);
+            saveTimer = setTimeout(saveReport, 1200);
         });
+    });
 
     function saveReport() {
         var form = document.querySelector('.report-form');
@@ -261,6 +301,26 @@ include __DIR__ . '/../../../layouts/header.php';
         saveReport();
     });
 
+    function autoResize(el) {
+        el.style.height = 'auto';
+        el.style.height = el.scrollHeight + 'px';
+    }
+
+    document.querySelectorAll('.report-textarea').forEach(function (el) {
+
+        // force correct initial height AFTER render
+        setTimeout(function () {
+            autoResize(el);
+        }, 0);
+
+        el.addEventListener('input', function () {
+            autoResize(el);
+
+            clearTimeout(saveTimer);
+            saveTimer = setTimeout(saveReport, 1200);
+        });
+    });
+
     // ── AI generation ────────────────────────────────────────────────────── //
     function generateSection(btn, section, targetSelector) {
         var textarea = document.querySelector(targetSelector);

+ 3 - 0
dashboard/crop-analysis/soil-test-data/soil-print-combined.php

@@ -96,6 +96,9 @@ function h(string $v): string {
             .container {
                 min-width: 992px !important;
             }
+            .report-textarea {
+                border:none;
+            }
         }
     </style>
 </head>

+ 31 - 3
dashboard/crop-analysis/soil-test-data/soil-report.php

@@ -115,11 +115,39 @@ function calcDeficit(array $row, array $spec, string $col, string $minCol, strin
 
 include __DIR__ . '/../../../layouts/header.php';
 ?>
-
+<link rel="stylesheet" href="/client-assets/home/css/graphPrint.css" media="print">
 <style>
+    * { margin: 0; padding: 0; box-sizing: border-box; }
+        body { background: #fff; }
+    @media print {
+        @page {
+            size: A4 portrait;
+        }
+        @page :left {
+            margin-left: 0.5cm;
+        }
+        @page :right {
+            margin-right: 0.5cm;
+        }
+        @page :top {
+            margin-top: 0cm;
+        }
+        @page :bottom {
+            margin-bottom: 0cm;
+        }
+        body {
+            min-width: 992px !important;
+        }
+        .container {
+            min-width: 992px !important;
+        }
+        .report-textarea {
+            border:none;
+        }
+    }
     .element-required-module .card-group .col {
-    padding: 0 10px;
-  }
+        padding: 0 10px;
+    }
 </style>
 
 <div class="container-fluid px-4" id="content">