|
|
@@ -9,6 +9,7 @@ require_once __DIR__ . '/../../../config/database.php';
|
|
|
require_once __DIR__ . '/../../../lib/auth.php';
|
|
|
require_once __DIR__ . '/../../../lib/csrf.php';
|
|
|
require_once __DIR__ . '/../../../lib/soil_calculations.php';
|
|
|
+require_once __DIR__ . '/../../../vendor/autoload.php';
|
|
|
|
|
|
requireLogin();
|
|
|
|
|
|
@@ -113,6 +114,17 @@ function calcDeficit(array $row, array $spec, string $col, string $minCol, strin
|
|
|
return $deficit > 0 ? round($deficit, 2) : 0.0;
|
|
|
}
|
|
|
|
|
|
+// Parse and render markdown text from AI-generated report sections
|
|
|
+function formatReportText(string $text): string
|
|
|
+{
|
|
|
+ if (trim($text) === '') {
|
|
|
+ return '<p class="text-muted fst-italic">No content saved.</p>';
|
|
|
+ }
|
|
|
+ $parsedown = new Parsedown();
|
|
|
+ $parsedown->setSafeMode(true);
|
|
|
+ return $parsedown->text($text);
|
|
|
+}
|
|
|
+
|
|
|
include __DIR__ . '/../../../layouts/header.php';
|
|
|
?>
|
|
|
<link rel="stylesheet" href="/client-assets/home/css/graphPrint.css" media="print">
|
|
|
@@ -120,31 +132,16 @@ include __DIR__ . '/../../../layouts/header.php';
|
|
|
* { 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;
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+ .report-print-preview {
|
|
|
+ display: block !important;
|
|
|
}
|
|
|
}
|
|
|
+ .report-print-preview {
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
.element-required-module .card-group .col {
|
|
|
padding: 0 10px;
|
|
|
}
|
|
|
@@ -286,6 +283,7 @@ include __DIR__ . '/../../../layouts/header.php';
|
|
|
<textarea id="overview" name="overview" class="form-control report-textarea" rows="6"
|
|
|
placeholder="Enter an overview of the soil analysis results..."
|
|
|
><?= htmlspecialchars($savedComments['overview'] ?? '', ENT_QUOTES, 'UTF-8') ?></textarea>
|
|
|
+ <div class="report-print-preview"><?= formatReportText($savedComments['overview'] ?? '') ?></div>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
@@ -306,6 +304,7 @@ include __DIR__ . '/../../../layouts/header.php';
|
|
|
class="form-control report-textarea" rows="10"
|
|
|
placeholder="Click 'Interpret with AI' to generate an agronomic interpretation, or type manually..."
|
|
|
><?= htmlspecialchars($savedComments['ai_interpretation'] ?? '', ENT_QUOTES, 'UTF-8') ?></textarea>
|
|
|
+ <div class="report-print-preview"><?= formatReportText($savedComments['ai_interpretation'] ?? '') ?></div>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
@@ -326,6 +325,7 @@ include __DIR__ . '/../../../layouts/header.php';
|
|
|
class="form-control report-textarea" rows="6"
|
|
|
placeholder="Enter the foliar spray program details..."
|
|
|
><?= htmlspecialchars($savedComments['foliar_details'] ?? '', ENT_QUOTES, 'UTF-8') ?></textarea>
|
|
|
+ <div class="report-print-preview"><?= formatReportText($savedComments['foliar_details'] ?? '') ?></div>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
@@ -343,6 +343,7 @@ include __DIR__ . '/../../../layouts/header.php';
|
|
|
class="form-control report-textarea" rows="6"
|
|
|
placeholder="Enter the microbial / biological program details..."
|
|
|
><?= htmlspecialchars($savedComments['microbe_program'] ?? '', ENT_QUOTES, 'UTF-8') ?></textarea>
|
|
|
+ <div class="report-print-preview"><?= formatReportText($savedComments['microbe_program'] ?? '') ?></div>
|
|
|
</div>
|
|
|
</div>
|
|
|
|