|
@@ -1,138 +1,167 @@
|
|
|
<?php
|
|
<?php
|
|
|
/**
|
|
/**
|
|
|
- * water-analysis-pdf.php
|
|
|
|
|
|
|
+ * dashboard/crop-analysis/water-test-data/water-analysis-pdf.php
|
|
|
*
|
|
*
|
|
|
- * Displays water quality analysis results for a single water_records row.
|
|
|
|
|
- * Standalone PDF-printable page. Accessed via rid + rand URL params.
|
|
|
|
|
|
|
+ * Water quality analysis results display page.
|
|
|
|
|
+ * Supports normal browser access (session login) and headless Chrome (ptoken).
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
require_once __DIR__ . '/../../../config/database.php';
|
|
require_once __DIR__ . '/../../../config/database.php';
|
|
|
require_once __DIR__ . '/../../../lib/auth.php';
|
|
require_once __DIR__ . '/../../../lib/auth.php';
|
|
|
|
|
+require_once __DIR__ . '/../../../lib/print_auth.php';
|
|
|
|
|
|
|
|
if (session_status() === PHP_SESSION_NONE) {
|
|
if (session_status() === PHP_SESSION_NONE) {
|
|
|
session_start();
|
|
session_start();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-requireLogin();
|
|
|
|
|
|
|
+$recordId = (int) ($_GET['rid'] ?? 0);
|
|
|
|
|
+$randId = trim( $_GET['rand'] ?? '');
|
|
|
|
|
+$clientId = (int) ($_GET['cid'] ?? 0);
|
|
|
|
|
+$printMode = isset($_GET['print']) || isset($_GET['ptoken']);
|
|
|
|
|
|
|
|
-$pdo = getDBConnection();
|
|
|
|
|
-$userId = getCurrentUserId();
|
|
|
|
|
|
|
+if (!$recordId || $randId === '') {
|
|
|
|
|
+ http_response_code(400);
|
|
|
|
|
+ die('Invalid request parameters');
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
-$recordId = (int) ($_GET['rid'] ?? 0);
|
|
|
|
|
-$randId = (float) ($_GET['rand'] ?? 0);
|
|
|
|
|
|
|
+$chromeAccess = authenticatePrintPage($recordId, $randId);
|
|
|
|
|
+
|
|
|
|
|
+$pdo = getDBConnection();
|
|
|
|
|
+$userId = $chromeAccess ? null : getCurrentUserId();
|
|
|
|
|
|
|
|
$row = null;
|
|
$row = null;
|
|
|
$specs = [];
|
|
$specs = [];
|
|
|
|
|
|
|
|
-if ($recordId > 0) {
|
|
|
|
|
- $stmt = $pdo->prepare('SELECT * FROM water_records WHERE id = ? AND rand = ? LIMIT 1');
|
|
|
|
|
- $stmt->execute([$recordId, $randId]);
|
|
|
|
|
- $row = $stmt->fetch();
|
|
|
|
|
-}
|
|
|
|
|
|
|
+$stmt = $pdo->prepare('SELECT * FROM water_records WHERE id = ? AND rand = ? LIMIT 1');
|
|
|
|
|
+$stmt->execute([$recordId, $randId]);
|
|
|
|
|
+$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
|
|
|
|
if ($row) {
|
|
if ($row) {
|
|
|
$type = $row['analysis_type'] ?? '';
|
|
$type = $row['analysis_type'] ?? '';
|
|
|
- $stmt = $pdo->prepare('SELECT * FROM water_specifications WHERE type = ? LIMIT 1');
|
|
|
|
|
- $stmt->execute([$type]);
|
|
|
|
|
- $specs = $stmt->fetch() ?: [];
|
|
|
|
|
|
|
+ if ($type !== '') {
|
|
|
|
|
+ $stmtSpec = $pdo->prepare('SELECT * FROM water_specifications WHERE type = ? LIMIT 1');
|
|
|
|
|
+ $stmtSpec->execute([$type]);
|
|
|
|
|
+ $specs = $stmtSpec->fetch(PDO::FETCH_ASSOC) ?: [];
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-$h = fn($v) => htmlspecialchars((string) $v, ENT_QUOTES, 'UTF-8');
|
|
|
|
|
|
|
+$h = fn($v) => htmlspecialchars((string)($v ?? ''), ENT_QUOTES, 'UTF-8');
|
|
|
|
|
|
|
|
function waterBar(float $found, float $min, float $max): string {
|
|
function waterBar(float $found, float $min, float $max): string {
|
|
|
if ($max <= 0) return '<td colspan="3" class="text-muted text-center small">N/A</td>';
|
|
if ($max <= 0) return '<td colspan="3" class="text-muted text-center small">N/A</td>';
|
|
|
- $pct = ($max > $min) ? min(100, max(0, ($found - $min) / ($max - $min) * 100)) : 0;
|
|
|
|
|
if ($found < $min) {
|
|
if ($found < $min) {
|
|
|
return '<td class="text-center"><div class="progress"><div class="progress-bar bg-danger" style="width:100%"></div></div></td>'
|
|
return '<td class="text-center"><div class="progress"><div class="progress-bar bg-danger" style="width:100%"></div></div></td>'
|
|
|
. '<td></td><td></td>';
|
|
. '<td></td><td></td>';
|
|
|
- } elseif ($found > $max) {
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($found > $max) {
|
|
|
return '<td></td><td></td>'
|
|
return '<td></td><td></td>'
|
|
|
. '<td class="text-center"><div class="progress"><div class="progress-bar bg-warning" style="width:100%"></div></div></td>';
|
|
. '<td class="text-center"><div class="progress"><div class="progress-bar bg-warning" style="width:100%"></div></div></td>';
|
|
|
- } else {
|
|
|
|
|
- return '<td></td>'
|
|
|
|
|
- . '<td class="text-center"><div class="progress"><div class="progress-bar bg-success" style="width:' . round($pct) . '%"></div></div></td>'
|
|
|
|
|
- . '<td></td>';
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ $pct = ($max > $min) ? round(min(100, ($found - $min) / ($max - $min) * 100)) : 50;
|
|
|
|
|
+ return '<td></td>'
|
|
|
|
|
+ . '<td class="text-center"><div class="progress"><div class="progress-bar bg-success" style="width:' . $pct . '%"></div></div></td>'
|
|
|
|
|
+ . '<td></td>';
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+$today = date('jS F Y');
|
|
|
|
|
+$pageTitle = 'Water Analysis' . (!empty($row['client_name']) ? ' — ' . $row['client_name'] : '');
|
|
|
|
|
+$siteName = 'Crop Monitor';
|
|
|
|
|
+
|
|
|
|
|
+if (!$printMode) {
|
|
|
|
|
+ include __DIR__ . '/../../../layouts/header.php';
|
|
|
}
|
|
}
|
|
|
?>
|
|
?>
|
|
|
-<!doctype html>
|
|
|
|
|
-<html lang="en">
|
|
|
|
|
-<head>
|
|
|
|
|
- <meta charset="UTF-8">
|
|
|
|
|
- <meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
|
- <title>Water Analysis | Crop Monitor</title>
|
|
|
|
|
- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
|
|
|
|
|
- <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.css" crossorigin="anonymous" rel="stylesheet">
|
|
|
|
|
- <link href="/client-assets/css/dashboard-2021.css" rel="stylesheet">
|
|
|
|
|
- <script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.9.3/html2pdf.bundle.min.js" crossorigin="anonymous"></script>
|
|
|
|
|
- <style>
|
|
|
|
|
- @media print {
|
|
|
|
|
- @page { size: A4 portrait; margin: 0.5cm; }
|
|
|
|
|
- .d-print-none { display: none !important; }
|
|
|
|
|
- }
|
|
|
|
|
- .progress { border-radius: 0 !important; }
|
|
|
|
|
- table.chart { width: 100%; border-collapse: collapse; }
|
|
|
|
|
- table.chart th, table.chart td { padding: 3px 6px; font-size: 0.85rem; }
|
|
|
|
|
- .chart-header th { background: #343a40; color: white; }
|
|
|
|
|
- .chart-header-sub th { background: #6c757d; color: white; }
|
|
|
|
|
- .lightgreen { background: #d4edda !important; color: #155724 !important; }
|
|
|
|
|
- .lightred { background: #f8d7da !important; color: #721c24 !important; }
|
|
|
|
|
- .lightblue { background: #cce5ff !important; color: #004085 !important; }
|
|
|
|
|
- .lightpurple { background: #e2d9f3 !important; color: #432874 !important; }
|
|
|
|
|
- .stripe-1 { background: #f8f9fa; }
|
|
|
|
|
- .border-left { border-left: 1px solid #dee2e6; }
|
|
|
|
|
- .border-right { border-right: 1px solid #dee2e6; }
|
|
|
|
|
- .border-bottom { border-bottom: 1px solid #dee2e6; }
|
|
|
|
|
- .border-top { border-top: 1px solid #dee2e6; }
|
|
|
|
|
- </style>
|
|
|
|
|
-</head>
|
|
|
|
|
-<body>
|
|
|
|
|
|
|
+
|
|
|
|
|
+<link rel="stylesheet" href="/client-assets/home/css/graphPrint.css" media="print">
|
|
|
|
|
+<style>
|
|
|
|
|
+ @media print {
|
|
|
|
|
+ @page { size: A4 portrait; }
|
|
|
|
|
+ body { min-width: 992px !important; }
|
|
|
|
|
+ .container { min-width: 992px !important; }
|
|
|
|
|
+ }
|
|
|
|
|
+ .progress { border-radius: 0 !important; }
|
|
|
|
|
+ .lightgreen { background: #d4edda !important; color: #155724 !important; }
|
|
|
|
|
+ .lightred { background: #f8d7da !important; color: #721c24 !important; }
|
|
|
|
|
+ .lightblue { background: #cce5ff !important; color: #004085 !important; }
|
|
|
|
|
+ .lightpurple { background: #e2d9f3 !important; color: #432874 !important; }
|
|
|
|
|
+ .stripe-1 { background: #f8f9fa; }
|
|
|
|
|
+ .border-left { border-left: 1px solid #dee2e6; }
|
|
|
|
|
+ .border-right { border-right: 1px solid #dee2e6; }
|
|
|
|
|
+ .border-bottom { border-bottom: 1px solid #dee2e6; }
|
|
|
|
|
+ .border-top { border-top: 1px solid #dee2e6; }
|
|
|
|
|
+ table.chart { width: 100%; border-collapse: collapse; }
|
|
|
|
|
+ table.chart th, table.chart td { padding: 3px 6px; font-size: 0.85rem; }
|
|
|
|
|
+ .chart-header th { background: #343a40; color: white; }
|
|
|
|
|
+ .chart-header-sub th { background: #6c757d; color: white; }
|
|
|
|
|
+</style>
|
|
|
|
|
+
|
|
|
<div class="container" id="content">
|
|
<div class="container" id="content">
|
|
|
|
|
|
|
|
<?php if (!$row): ?>
|
|
<?php if (!$row): ?>
|
|
|
<div class="alert alert-danger mt-4">Record not found or access denied.</div>
|
|
<div class="alert alert-danger mt-4">Record not found or access denied.</div>
|
|
|
<?php else: ?>
|
|
<?php else: ?>
|
|
|
|
|
|
|
|
- <div class="row mb-3">
|
|
|
|
|
|
|
+ <!-- ── Header ──────────────────────────────────────────────────────────── -->
|
|
|
|
|
+ <div class="row mb-2 mt-3">
|
|
|
<div class="col-md-3">
|
|
<div class="col-md-3">
|
|
|
<img class="img-fluid" src="/client-assets/images/crop-monitor.png" alt="Crop Monitor">
|
|
<img class="img-fluid" src="/client-assets/images/crop-monitor.png" alt="Crop Monitor">
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
- <div class="d-print-none mb-3">
|
|
|
|
|
- <button class="btn btn-success btn-sm downloadPDF">
|
|
|
|
|
- <i class="fas fa-download me-1"></i>Download PDF
|
|
|
|
|
- </button>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <!-- Client info -->
|
|
|
|
|
- <table class="table table-sm table-bordered mb-3" style="font-size:0.85rem;">
|
|
|
|
|
|
|
+ <table class="title w-100 mb-3 small">
|
|
|
<tbody>
|
|
<tbody>
|
|
|
<tr>
|
|
<tr>
|
|
|
- <th class="w-25">Client</th>
|
|
|
|
|
- <td><?= $h($row['client_name'] ?? '') ?></td>
|
|
|
|
|
- <th class="w-25">Lab No</th>
|
|
|
|
|
- <td><?= $h($row['lab_no'] ?? '') ?></td>
|
|
|
|
|
|
|
+ <td class="text-end fw-bold text-nowrap">DATE:</td>
|
|
|
|
|
+ <td><?= $h($today) ?></td>
|
|
|
|
|
+ <td></td>
|
|
|
|
|
+ <td class="text-end fw-bold text-nowrap">SAMPLE ID:</td>
|
|
|
|
|
+ <td><?= $h($row['sample_id']) ?></td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <td class="text-end fw-bold text-nowrap">CLIENT:</td>
|
|
|
|
|
+ <td><?= $h($row['client_name']) ?></td>
|
|
|
|
|
+ <td></td>
|
|
|
|
|
+ <td class="text-end fw-bold text-nowrap">DATE SAMPLED:</td>
|
|
|
|
|
+ <td><?= $h($row['date_sampled']) ?></td>
|
|
|
</tr>
|
|
</tr>
|
|
|
<tr>
|
|
<tr>
|
|
|
- <th>Sample ID</th>
|
|
|
|
|
- <td><?= $h($row['sample_id'] ?? '') ?></td>
|
|
|
|
|
- <th>Site ID</th>
|
|
|
|
|
- <td><?= $h($row['site_id'] ?? '') ?></td>
|
|
|
|
|
|
|
+ <td class="text-end fw-bold text-nowrap">SITE ID:</td>
|
|
|
|
|
+ <td><?= $h($row['site_id']) ?></td>
|
|
|
|
|
+ <td></td>
|
|
|
|
|
+ <td class="text-end fw-bold text-nowrap">LAB NUMBER:</td>
|
|
|
|
|
+ <td><?= $h($row['lab_no']) ?></td>
|
|
|
</tr>
|
|
</tr>
|
|
|
<tr>
|
|
<tr>
|
|
|
- <th>Analysis Type</th>
|
|
|
|
|
- <td><?= $h($row['analysis_type'] ?? '') ?></td>
|
|
|
|
|
- <th>Date Sampled</th>
|
|
|
|
|
- <td><?= $h($row['date_sampled'] ?? '') ?></td>
|
|
|
|
|
|
|
+ <td class="text-end fw-bold text-nowrap">ANALYSIS TYPE:</td>
|
|
|
|
|
+ <td><?= $h($row['analysis_type']) ?></td>
|
|
|
|
|
+ <td></td>
|
|
|
|
|
+ <td></td>
|
|
|
|
|
+ <td></td>
|
|
|
</tr>
|
|
</tr>
|
|
|
</tbody>
|
|
</tbody>
|
|
|
</table>
|
|
</table>
|
|
|
|
|
|
|
|
|
|
+ <!-- ── Action buttons ──────────────────────────────────────────────────── -->
|
|
|
|
|
+ <?php if (!$printMode): ?>
|
|
|
|
|
+ <div class="d-print-none mb-3 d-flex gap-2 flex-wrap">
|
|
|
|
|
+ <a href="/dashboard/crop-analysis/water-test-data/water-report.php?rid=<?= $recordId ?>&rand=<?= urlencode($randId) ?>&cid=<?= $clientId ?>"
|
|
|
|
|
+ class="btn btn-outline-primary btn-sm">
|
|
|
|
|
+ <i class="fas fa-file-alt me-1"></i>View Report
|
|
|
|
|
+ </a>
|
|
|
|
|
+ <a href="/pdf-files/headlessChrome_pdf.php?type=water-analysis&rid=<?= $recordId ?>&rand=<?= urlencode($randId) ?>&cid=<?= $clientId ?>"
|
|
|
|
|
+ class="btn btn-outline-secondary btn-sm">
|
|
|
|
|
+ <i class="fas fa-file-pdf me-1"></i>PDF — Analysis
|
|
|
|
|
+ </a>
|
|
|
|
|
+ <a href="/pdf-files/headlessChrome_pdf.php?type=water&rid=<?= $recordId ?>&rand=<?= urlencode($randId) ?>&cid=<?= $clientId ?>"
|
|
|
|
|
+ class="btn btn-success btn-sm">
|
|
|
|
|
+ <i class="fas fa-file-pdf me-1"></i>PDF — Analysis & Report
|
|
|
|
|
+ </a>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <?php endif; ?>
|
|
|
|
|
+
|
|
|
<div class="row">
|
|
<div class="row">
|
|
|
- <div class="col-md-12 text-center fw-bold h4">ANALYSIS RESULTS</div>
|
|
|
|
|
|
|
+ <div class="col-md-12 text-center fw-bold h4">Water Quality Analysis Results</div>
|
|
|
</div>
|
|
</div>
|
|
|
- <hr class="p-1 m-1">
|
|
|
|
|
|
|
|
|
|
<table class="chart">
|
|
<table class="chart">
|
|
|
<tbody>
|
|
<tbody>
|
|
@@ -141,104 +170,100 @@ function waterBar(float $found, float $min, float $max): string {
|
|
|
<th colspan="3" class="text-center border-right border-top">STATUS</th>
|
|
<th colspan="3" class="text-center border-right border-top">STATUS</th>
|
|
|
</tr>
|
|
</tr>
|
|
|
<tr class="chart-header-sub">
|
|
<tr class="chart-header-sub">
|
|
|
- <th class="text-center border-bottom border-left">Parameter</th>
|
|
|
|
|
- <th class="text-center border-bottom">Desired</th>
|
|
|
|
|
- <th class="text-center border-bottom">Found</th>
|
|
|
|
|
|
|
+ <th class="text-center border-left">Parameter</th>
|
|
|
|
|
+ <th class="text-center">Desired</th>
|
|
|
|
|
+ <th class="text-center">Found</th>
|
|
|
<th class="text-center stripe-1">Deficit</th>
|
|
<th class="text-center stripe-1">Deficit</th>
|
|
|
<th class="text-center stripe-1">Ideal</th>
|
|
<th class="text-center stripe-1">Ideal</th>
|
|
|
<th class="text-center border-right stripe-1">High</th>
|
|
<th class="text-center border-right stripe-1">High</th>
|
|
|
</tr>
|
|
</tr>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <td class="border-left"></td><td></td><td></td>
|
|
|
|
|
+ <td></td><td></td><td class="border-right"></td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
|
|
|
- <tr><td class="border-left" colspan="6"></td></tr>
|
|
|
|
|
|
|
+ <!-- General Parameters -->
|
|
|
<tr class="chart-header-sub">
|
|
<tr class="chart-header-sub">
|
|
|
- <th colspan="3" class="border-left text-center lightblue">GENERAL PARAMETERS</th>
|
|
|
|
|
- <th class="text-center border-left stripe-1"></th>
|
|
|
|
|
- <th class="text-center border-left stripe-1"></th>
|
|
|
|
|
- <th class="text-center border-left border-right stripe-1"></th>
|
|
|
|
|
|
|
+ <th colspan="6" class="border-left text-center lightblue">GENERAL PARAMETERS</th>
|
|
|
</tr>
|
|
</tr>
|
|
|
-
|
|
|
|
|
<?php
|
|
<?php
|
|
|
$generalParams = [
|
|
$generalParams = [
|
|
|
- ['ph', 'pH', ''],
|
|
|
|
|
- ['cond_dsm', 'Conductivity', 'dS/m'],
|
|
|
|
|
- ['hco3-', 'Bicarbonate (HCO₃)', 'ppm'],
|
|
|
|
|
|
|
+ ['ph', 'pH', '', 3],
|
|
|
|
|
+ ['cond_dsm', 'Conductivity', 'dS/m', 3],
|
|
|
|
|
+ ['hco3-', 'Bicarbonate (HCO₃)', 'ppm', 2],
|
|
|
];
|
|
];
|
|
|
- foreach ($generalParams as [$col, $label, $unit]):
|
|
|
|
|
- $found = (float)($row[$col] ?? 0);
|
|
|
|
|
- $min = (float)($specs[$col . '_min'] ?? 0);
|
|
|
|
|
- $max = (float)($specs[$col . '_max'] ?? 0);
|
|
|
|
|
- $desired = ($min > 0 || $max > 0) ? number_format($min, 2) . '–' . number_format($max, 2) : '—';
|
|
|
|
|
|
|
+ foreach ($generalParams as [$col, $label, $unit, $dp]):
|
|
|
|
|
+ $found = (float)($row[$col] ?? 0);
|
|
|
|
|
+ $min = (float)($specs[$col . '_min'] ?? 0);
|
|
|
|
|
+ $max = (float)($specs[$col . '_max'] ?? 0);
|
|
|
|
|
+ $desired = ($min > 0 || $max > 0) ? number_format($min, $dp) . '–' . number_format($max, $dp) : '—';
|
|
|
$display = $unit ? $label . ' (' . $unit . ')' : $label;
|
|
$display = $unit ? $label . ' (' . $unit . ')' : $label;
|
|
|
?>
|
|
?>
|
|
|
<tr>
|
|
<tr>
|
|
|
<td class="border-left"><?= $h($display) ?></td>
|
|
<td class="border-left"><?= $h($display) ?></td>
|
|
|
- <td><?= $h($desired) ?></td>
|
|
|
|
|
- <td><?= $found > 0 ? number_format($found, 3) : '—' ?></td>
|
|
|
|
|
|
|
+ <td class="text-center"><?= $h($desired) ?></td>
|
|
|
|
|
+ <td class="text-center"><?= $found > 0 ? number_format($found, $dp) : '—' ?></td>
|
|
|
<?= waterBar($found, $min, $max) ?>
|
|
<?= waterBar($found, $min, $max) ?>
|
|
|
</tr>
|
|
</tr>
|
|
|
<?php endforeach; ?>
|
|
<?php endforeach; ?>
|
|
|
|
|
|
|
|
- <tr><td class="border-left" colspan="6"></td></tr>
|
|
|
|
|
|
|
+ <tr><td colspan="6" class="border-left"></td></tr>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- Major Elements -->
|
|
|
<tr class="chart-header-sub">
|
|
<tr class="chart-header-sub">
|
|
|
- <th colspan="3" class="border-left text-center lightgreen">MAJOR ELEMENTS</th>
|
|
|
|
|
- <th class="text-center border-left stripe-1"></th>
|
|
|
|
|
- <th class="text-center border-left stripe-1"></th>
|
|
|
|
|
- <th class="text-center border-left border-right stripe-1"></th>
|
|
|
|
|
|
|
+ <th colspan="6" class="border-left text-center lightgreen">MAJOR ELEMENTS (ppm)</th>
|
|
|
</tr>
|
|
</tr>
|
|
|
-
|
|
|
|
|
<?php
|
|
<?php
|
|
|
$majorElements = [
|
|
$majorElements = [
|
|
|
- ['nh4', 'Ammonium Nitrogen (NH₄)', 'ppm'],
|
|
|
|
|
- ['no3', 'Nitrate Nitrogen (NO₃)', 'ppm'],
|
|
|
|
|
- ['p', 'Phosphorus', 'ppm'],
|
|
|
|
|
- ['k', 'Potassium', 'ppm'],
|
|
|
|
|
- ['s', 'Sulphur', 'ppm'],
|
|
|
|
|
- ['ca', 'Calcium', 'ppm'],
|
|
|
|
|
- ['mg', 'Magnesium', 'ppm'],
|
|
|
|
|
- ['na', 'Sodium', 'ppm'],
|
|
|
|
|
|
|
+ ['nh4', 'Ammonium Nitrogen (NH₄)', 'ppm', 2],
|
|
|
|
|
+ ['no3', 'Nitrate Nitrogen (NO₃)', 'ppm', 2],
|
|
|
|
|
+ ['p', 'Phosphorus', 'ppm', 2],
|
|
|
|
|
+ ['k', 'Potassium', 'ppm', 1],
|
|
|
|
|
+ ['s', 'Sulphur', 'ppm', 2],
|
|
|
|
|
+ ['ca', 'Calcium', 'ppm', 1],
|
|
|
|
|
+ ['mg', 'Magnesium', 'ppm', 1],
|
|
|
|
|
+ ['na', 'Sodium', 'ppm', 1],
|
|
|
];
|
|
];
|
|
|
- foreach ($majorElements as [$col, $label, $unit]):
|
|
|
|
|
- $found = (float)($row[$col] ?? 0);
|
|
|
|
|
- $min = (float)($specs[$col . '_min'] ?? 0);
|
|
|
|
|
- $max = (float)($specs[$col . '_max'] ?? 0);
|
|
|
|
|
- $desired = ($min > 0 || $max > 0) ? number_format($min, 1) . '–' . number_format($max, 1) : '—';
|
|
|
|
|
|
|
+ foreach ($majorElements as [$col, $label, $unit, $dp]):
|
|
|
|
|
+ $found = (float)($row[$col] ?? 0);
|
|
|
|
|
+ $min = (float)($specs[$col . '_min'] ?? 0);
|
|
|
|
|
+ $max = (float)($specs[$col . '_max'] ?? 0);
|
|
|
|
|
+ $desired = ($min > 0 || $max > 0) ? number_format($min, $dp) . '–' . number_format($max, $dp) : '—';
|
|
|
?>
|
|
?>
|
|
|
<tr>
|
|
<tr>
|
|
|
<td class="border-left"><?= $h($label) ?> (<?= $h($unit) ?>)</td>
|
|
<td class="border-left"><?= $h($label) ?> (<?= $h($unit) ?>)</td>
|
|
|
- <td><?= $h($desired) ?></td>
|
|
|
|
|
- <td><?= $found > 0 ? number_format($found, 2) : '—' ?></td>
|
|
|
|
|
|
|
+ <td class="text-center"><?= $h($desired) ?></td>
|
|
|
|
|
+ <td class="text-center"><?= $found > 0 ? number_format($found, $dp) : '—' ?></td>
|
|
|
<?= waterBar($found, $min, $max) ?>
|
|
<?= waterBar($found, $min, $max) ?>
|
|
|
</tr>
|
|
</tr>
|
|
|
<?php endforeach; ?>
|
|
<?php endforeach; ?>
|
|
|
|
|
|
|
|
- <tr><td class="border-left" colspan="6"></td></tr>
|
|
|
|
|
|
|
+ <tr><td colspan="6" class="border-left"></td></tr>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- Trace Elements -->
|
|
|
<tr class="chart-header-sub">
|
|
<tr class="chart-header-sub">
|
|
|
- <th colspan="3" class="border-left text-center lightred">TRACE ELEMENTS</th>
|
|
|
|
|
- <th class="text-center border-left stripe-1"></th>
|
|
|
|
|
- <th class="text-center border-left stripe-1"></th>
|
|
|
|
|
- <th class="text-center border-left border-right stripe-1"></th>
|
|
|
|
|
|
|
+ <th colspan="6" class="border-left text-center lightred">TRACE ELEMENTS (ppm)</th>
|
|
|
</tr>
|
|
</tr>
|
|
|
-
|
|
|
|
|
<?php
|
|
<?php
|
|
|
$traceElements = [
|
|
$traceElements = [
|
|
|
- ['fe', 'Iron', 'ppm'],
|
|
|
|
|
- ['mn', 'Manganese', 'ppm'],
|
|
|
|
|
- ['zn', 'Zinc', 'ppm'],
|
|
|
|
|
- ['cu', 'Copper', 'ppm'],
|
|
|
|
|
- ['b', 'Boron', 'ppm'],
|
|
|
|
|
- ['m', 'Molybdenum','ppm'],
|
|
|
|
|
- ['co', 'Cobalt', 'ppm'],
|
|
|
|
|
|
|
+ ['fe', 'Iron', 'ppm', 3],
|
|
|
|
|
+ ['mn', 'Manganese', 'ppm', 3],
|
|
|
|
|
+ ['zn', 'Zinc', 'ppm', 3],
|
|
|
|
|
+ ['cu', 'Copper', 'ppm', 3],
|
|
|
|
|
+ ['b', 'Boron', 'ppm', 3],
|
|
|
|
|
+ ['m', 'Molybdenum', 'ppm', 3],
|
|
|
|
|
+ ['co', 'Cobalt', 'ppm', 3],
|
|
|
];
|
|
];
|
|
|
- foreach ($traceElements as [$col, $label, $unit]):
|
|
|
|
|
- $found = (float)($row[$col] ?? 0);
|
|
|
|
|
- $min = (float)($specs[$col . '_min'] ?? 0);
|
|
|
|
|
- $max = (float)($specs[$col . '_max'] ?? 0);
|
|
|
|
|
- $desired = ($min > 0 || $max > 0) ? number_format($min, 2) . '–' . number_format($max, 2) : '—';
|
|
|
|
|
|
|
+ foreach ($traceElements as [$col, $label, $unit, $dp]):
|
|
|
|
|
+ $found = (float)($row[$col] ?? 0);
|
|
|
|
|
+ $min = (float)($specs[$col . '_min'] ?? 0);
|
|
|
|
|
+ $max = (float)($specs[$col . '_max'] ?? 0);
|
|
|
|
|
+ $desired = ($min > 0 || $max > 0) ? number_format($min, $dp) . '–' . number_format($max, $dp) : '—';
|
|
|
?>
|
|
?>
|
|
|
<tr>
|
|
<tr>
|
|
|
<td class="border-left"><?= $h($label) ?> (<?= $h($unit) ?>)</td>
|
|
<td class="border-left"><?= $h($label) ?> (<?= $h($unit) ?>)</td>
|
|
|
- <td><?= $h($desired) ?></td>
|
|
|
|
|
- <td><?= $found > 0 ? number_format($found, 3) : '—' ?></td>
|
|
|
|
|
|
|
+ <td class="text-center"><?= $h($desired) ?></td>
|
|
|
|
|
+ <td class="text-center"><?= $found > 0 ? number_format($found, $dp) : '—' ?></td>
|
|
|
<?= waterBar($found, $min, $max) ?>
|
|
<?= waterBar($found, $min, $max) ?>
|
|
|
</tr>
|
|
</tr>
|
|
|
<?php endforeach; ?>
|
|
<?php endforeach; ?>
|
|
@@ -257,24 +282,9 @@ function waterBar(float $found, float $min, float $max): string {
|
|
|
<div class="mt-4 small text-muted">
|
|
<div class="mt-4 small text-muted">
|
|
|
<p><i class="fa fa-tint" style="color:#007bff"></i> Water analysis results should be interpreted in the context of intended use (irrigation, drinking, stock water).</p>
|
|
<p><i class="fa fa-tint" style="color:#007bff"></i> Water analysis results should be interpreted in the context of intended use (irrigation, drinking, stock water).</p>
|
|
|
<p><i class="fa fa-tint" style="color:#007bff"></i> Talk to your qualified consultant to make a plan for correction or maintenance of the found parameter levels.</p>
|
|
<p><i class="fa fa-tint" style="color:#007bff"></i> Talk to your qualified consultant to make a plan for correction or maintenance of the found parameter levels.</p>
|
|
|
- <p style="font-style:italic;font-size:9px;">Any recommendations provided by Cropmonitor are advice only. We are not paid consultants and are not covered to accept responsibility for any of our suggestions.</p>
|
|
|
|
|
|
|
+ <p class="fst-italic" style="font-size:9px;">Any recommendations provided by Crop Monitor are advice only. We are not paid consultants and accept no responsibility for any of our suggestions.</p>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
|
-</div>
|
|
|
|
|
|
|
|
|
|
-<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
|
|
|
|
|
-<script>
|
|
|
|
|
-document.querySelector('.downloadPDF') && document.querySelector('.downloadPDF').addEventListener('click', function () {
|
|
|
|
|
- var opt = {
|
|
|
|
|
- margin: 3,
|
|
|
|
|
- filename: 'water-analysis.pdf',
|
|
|
|
|
- image: { type: 'jpeg', quality: 1.0 },
|
|
|
|
|
- html2canvas: { scale: 2, letterRendering: true, windowWidth: 1024 },
|
|
|
|
|
- jsPDF: { orientation: 'portrait', unit: 'mm', format: 'a4' }
|
|
|
|
|
- };
|
|
|
|
|
- html2pdf().from(document.getElementById('content')).set(opt).save();
|
|
|
|
|
-});
|
|
|
|
|
-</script>
|
|
|
|
|
-</body>
|
|
|
|
|
-</html>
|
|
|
|
|
|
|
+</div><!-- /.container -->
|