|
@@ -1,36 +1,33 @@
|
|
|
<?php
|
|
<?php
|
|
|
/**
|
|
/**
|
|
|
- * dashboard/crop-analysis/soil-analysis.php
|
|
|
|
|
|
|
+ * dashboard/crop-analysis/soil-test-data/soil-analysis.php
|
|
|
*
|
|
*
|
|
|
* Soil Analysis Results Display Page
|
|
* Soil Analysis Results Display Page
|
|
|
- * Shows detailed soil test results with calculations and recommendations
|
|
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-require_once __DIR__.'/../../config/database.php';
|
|
|
|
|
-require_once __DIR__.'/../../lib/auth.php';
|
|
|
|
|
-require_once __DIR__.'/../../lib/validation.php';
|
|
|
|
|
|
|
+require_once __DIR__.'/../../../config/database.php';
|
|
|
|
|
+require_once __DIR__.'/../../../lib/auth.php';
|
|
|
|
|
+require_once __DIR__.'/../../../lib/validation.php';
|
|
|
|
|
+require_once __DIR__.'/../../../lib/soil_calculations.php';
|
|
|
|
|
|
|
|
-// Start session if not already started
|
|
|
|
|
if (session_status() === PHP_SESSION_NONE) {
|
|
if (session_status() === PHP_SESSION_NONE) {
|
|
|
session_start();
|
|
session_start();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// Require authentication
|
|
|
|
|
requireLogin();
|
|
requireLogin();
|
|
|
|
|
|
|
|
-// Get and validate parameters
|
|
|
|
|
-$client_id = (int)($_GET['cid'] ?? 0);
|
|
|
|
|
-$record_id = (float)($_GET['rid'] ?? 0);
|
|
|
|
|
-$rand_id = (float)($_GET['rand'] ?? 0);
|
|
|
|
|
|
|
+$record_id = (float)($_GET['rid'] ?? 0);
|
|
|
|
|
+$rand_id = (float)($_GET['rand'] ?? 0);
|
|
|
|
|
+$client_id = (int) ($_GET['cid'] ?? 0);
|
|
|
|
|
|
|
|
-// Validate required parameters
|
|
|
|
|
if (!$record_id || !$rand_id) {
|
|
if (!$record_id || !$rand_id) {
|
|
|
die('Invalid request parameters');
|
|
die('Invalid request parameters');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// Get soil record data securely
|
|
|
|
|
try {
|
|
try {
|
|
|
$pdo = getDBConnection();
|
|
$pdo = getDBConnection();
|
|
|
|
|
+
|
|
|
|
|
+ // Load soil record
|
|
|
$stmt = $pdo->prepare("SELECT * FROM soil_records WHERE id = ? AND rand = ?");
|
|
$stmt = $pdo->prepare("SELECT * FROM soil_records WHERE id = ? AND rand = ?");
|
|
|
$stmt->execute([$record_id, $rand_id]);
|
|
$stmt->execute([$record_id, $rand_id]);
|
|
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
@@ -39,276 +36,482 @@ try {
|
|
|
die('Soil record not found');
|
|
die('Soil record not found');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Extract data
|
|
|
|
|
- $client = htmlspecialchars($row['client_name'] ?? '', ENT_QUOTES, 'UTF-8');
|
|
|
|
|
- $address = htmlspecialchars($row['site_address'] ?? '', ENT_QUOTES, 'UTF-8');
|
|
|
|
|
- $state = htmlspecialchars($row['state_postcode'] ?? '', ENT_QUOTES, 'UTF-8');
|
|
|
|
|
- $email = htmlspecialchars($row['email'] ?? '', ENT_QUOTES, 'UTF-8');
|
|
|
|
|
- $labNo = htmlspecialchars($row['lab_no'] ?? '', ENT_QUOTES, 'UTF-8');
|
|
|
|
|
- $sampleDate = htmlspecialchars($row['date_sampled'] ?? '', ENT_QUOTES, 'UTF-8');
|
|
|
|
|
- $sample = htmlspecialchars($row['site_id'] ?? '', ENT_QUOTES, 'UTF-8');
|
|
|
|
|
- $crop = htmlspecialchars($row['sample_id'] ?? '', ENT_QUOTES, 'UTF-8');
|
|
|
|
|
|
|
+ // Load matching specifications row for this soil type
|
|
|
|
|
+ $spec = [];
|
|
|
|
|
+ if (!empty($row['soil_type'])) {
|
|
|
|
|
+ $stmtSpec = $pdo->prepare("SELECT * FROM soil_specifications WHERE soil_type = ? LIMIT 1");
|
|
|
|
|
+ $stmtSpec->execute([$row['soil_type']]);
|
|
|
|
|
+ $spec = $stmtSpec->fetch(PDO::FETCH_ASSOC) ?: [];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
} catch (PDOException $e) {
|
|
} catch (PDOException $e) {
|
|
|
error_log("Database error in soil-analysis.php: " . $e->getMessage());
|
|
error_log("Database error in soil-analysis.php: " . $e->getMessage());
|
|
|
die('Database error occurred');
|
|
die('Database error occurred');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-$today = date('jS F Y');
|
|
|
|
|
-$pageTitle = 'Soil Analysis Results - ' . $client;
|
|
|
|
|
-$siteName = 'Crop Management Platform';
|
|
|
|
|
-$activeItem = 'Soil Analysis';
|
|
|
|
|
-
|
|
|
|
|
-include __DIR__.'/../../layouts/header.php';
|
|
|
|
|
-include __DIR__.'/../../layouts/navbar.php';
|
|
|
|
|
-?>
|
|
|
|
|
-
|
|
|
|
|
-<div id="layoutSidenav">
|
|
|
|
|
- <div id="layoutSidenav_nav">
|
|
|
|
|
- <?php include __DIR__.'/../../layouts/sidebar.php'; ?>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div id="layoutSidenav_content">
|
|
|
|
|
- <main>
|
|
|
|
|
- <div class="container-fluid px-4"> <div class="row">
|
|
|
|
|
- <?php
|
|
|
|
|
- // Replace Logo with Customer Logo if supplied.
|
|
|
|
|
- $client = '';
|
|
|
|
|
-
|
|
|
|
|
- echo "<div class='col-md-3'>";
|
|
|
|
|
- if ($client === "") {
|
|
|
|
|
- echo "<img class='img-fluid' src='client-assets/images/crop-monitor.png' alt='Crop Monitor' >";
|
|
|
|
|
- } else {
|
|
|
|
|
- echo "<img class='img-fluid' src='client-assets/images/crop-monitor.png' alt='Crop Monitor' >";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //echo "<span class='col'></span>";
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- //Client Test Description
|
|
|
|
|
- if ($client === "") {
|
|
|
|
|
- echo "";
|
|
|
|
|
- } else {
|
|
|
|
|
- echo "<img class='img-fluid' src='client-assets/images/crop-monitor.png' alt='Crop Monitor' >";
|
|
|
|
|
- }
|
|
|
|
|
- echo "</div>";
|
|
|
|
|
-
|
|
|
|
|
- echo "<div class='col-md-9'></div>";
|
|
|
|
|
- ?>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <table class='title'>
|
|
|
|
|
- <tbody>
|
|
|
|
|
- <tr>
|
|
|
|
|
- <th class='col-20'></th>
|
|
|
|
|
- <th class='col-20'></th>
|
|
|
|
|
- <th class='col-20'></th>
|
|
|
|
|
- <th class='col-20'></th>
|
|
|
|
|
- <th class='col-20'></th>
|
|
|
|
|
- </tr>
|
|
|
|
|
- <tr>
|
|
|
|
|
- <td class='right'><b>DATE:</b></td>
|
|
|
|
|
- <td class='left'><?php echo $today; ?></td>
|
|
|
|
|
- <td></td>
|
|
|
|
|
- <td class='right'><b>SAMPLE ID:</b></td>
|
|
|
|
|
- <td class='left'><?php echo $sample; ?></td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- <tr>
|
|
|
|
|
- <td class='right'><b>CLIENT:</b></td>
|
|
|
|
|
- <td class='left'><?php echo $client; ?></td>
|
|
|
|
|
- <td></td>
|
|
|
|
|
- <td class='right'><b>DATE SAMPLED:</b></td>
|
|
|
|
|
- <td class='left'><?php echo $sampleDate; ?></td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- <tr>
|
|
|
|
|
- <td class='right'><b>ADDRESS:</b></td>
|
|
|
|
|
- <td class='left'><?php echo $address; ?></td>
|
|
|
|
|
- <td></td>
|
|
|
|
|
- <td class='right'><b>LAB NUMBER:</b></td>
|
|
|
|
|
- <td class='left'><?php echo $labNo; ?></td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- <tr>
|
|
|
|
|
- <td class='right'><b> </b></td>
|
|
|
|
|
- <td class='left'><?php echo $state; ?></td>
|
|
|
|
|
- <td></td>
|
|
|
|
|
- <td class='right'><b>CROP:</b></td>
|
|
|
|
|
- <td class='left'><?php echo $crop; ?></td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- <tr>
|
|
|
|
|
- <td class='right'><b> </b></td>
|
|
|
|
|
- <td class='left'><?php echo $email; ?></td>
|
|
|
|
|
- <td></td>
|
|
|
|
|
- <td class='right'></td>
|
|
|
|
|
- <td class='left'></td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- </tbody>
|
|
|
|
|
- </table>
|
|
|
|
|
-
|
|
|
|
|
- <!-- Graph Button -->
|
|
|
|
|
- <div class="d-print-none">
|
|
|
|
|
- <div class="row p-2">
|
|
|
|
|
- <div class="col">
|
|
|
|
|
- <button type="button" class="btn btn-primary" onclick="generateGraph()">
|
|
|
|
|
- <i class="fas fa-chart-bar"></i> Generate Graph
|
|
|
|
|
- </button>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div class="col">
|
|
|
|
|
- <div class="form-status-holder"></div>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- <!-- GRAPH BANNER -->
|
|
|
|
|
|
|
+// ── Helper: render one analysis row ───────────────────────────────────────
|
|
|
|
|
+/**
|
|
|
|
|
+ * Renders a <tr> for a single nutrient with three progress-bar columns.
|
|
|
|
|
+ *
|
|
|
|
|
+ * Parameters ($p keys):
|
|
|
|
|
+ * element string Column name in soil_records
|
|
|
|
|
+ * sbl string Chemical symbol (may contain HTML, e.g. "NO<sub>3</sub>-N")
|
|
|
|
|
+ * nutrient string Display name (may contain HTML)
|
|
|
|
|
+ * min string Column in soil_records, numeric literal, or '' for no bar
|
|
|
|
|
+ * max string Column in soil_records, 'soil_type' (special), numeric literal, or ''
|
|
|
|
|
+ * type string Unit label (ppm, %, mS/cm …)
|
|
|
|
|
+ * text string Value cell alignment: c|r|l
|
|
|
|
|
+ * rec_text string Recommended cell alignment: c|r|l
|
|
|
|
|
+ * recV string Recommended display: 'n'=none, 'ph'='6.4', 'max'=max only, else=min–max
|
|
|
|
|
+ * decimal int Decimal places for value
|
|
|
|
|
+ * graph string CSS class for progress-bar colour
|
|
|
|
|
+ */
|
|
|
|
|
+function soilRow(array $row, array $spec, array $p): void
|
|
|
|
|
+{
|
|
|
|
|
+ $element = $p['element'] ?? '';
|
|
|
|
|
+ $sbl = $p['sbl'] ?? '';
|
|
|
|
|
+ $nutrient = $p['nutrient'] ?? '';
|
|
|
|
|
+ $minParam = $p['min'] ?? '';
|
|
|
|
|
+ $maxParam = $p['max'] ?? '';
|
|
|
|
|
+ $type = $p['type'] ?? '';
|
|
|
|
|
+ $text = $p['text'] ?? 'c';
|
|
|
|
|
+ $recText = $p['rec_text'] ?? 'c';
|
|
|
|
|
+ $recV = $p['recV'] ?? '';
|
|
|
|
|
+ $decimal = (int)($p['decimal'] ?? 2);
|
|
|
|
|
+ $graph = $p['graph'] ?? '';
|
|
|
|
|
+
|
|
|
|
|
+ $label = ($sbl !== '') ? $sbl . ' - ' . $nutrient : $nutrient;
|
|
|
|
|
+ $rawVal = $row[$element] ?? null;
|
|
|
|
|
+ $value = ($rawVal !== null && $rawVal !== '') ? (float)$rawVal : 0.0;
|
|
|
|
|
+ $valueFmt = number_format($value, $decimal, '.', '') . ($type !== '' ? ' ' . $type : '');
|
|
|
|
|
+
|
|
|
|
|
+ // Resolve min
|
|
|
|
|
+ $min = 0.0;
|
|
|
|
|
+ if ($minParam !== '') {
|
|
|
|
|
+ if (is_numeric($minParam)) {
|
|
|
|
|
+ $min = (float)$minParam;
|
|
|
|
|
+ } elseif (isset($row[$minParam]) && $row[$minParam] !== '') {
|
|
|
|
|
+ $min = (float)$row[$minParam];
|
|
|
|
|
+ } elseif (isset($spec[$minParam]) && $spec[$minParam] !== '') {
|
|
|
|
|
+ $min = (float)$spec[$minParam];
|
|
|
|
|
+ }
|
|
|
|
|
+ } elseif (isset($spec[$element]) && $spec[$element] !== '') {
|
|
|
|
|
+ $min = (float)$spec[$element] / 2; // fallback: half the spec average
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- <div class="row">
|
|
|
|
|
- <div class="col-md-12 text-center fw-bold h4">Soil Analysis Summary</div>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ // Resolve max + recommended display label
|
|
|
|
|
+ $max = 0.0;
|
|
|
|
|
+ $maxLabel = '';
|
|
|
|
|
+ if ($maxParam === 'soil_type') {
|
|
|
|
|
+ $st = strtolower($row['soil_type'] ?? '');
|
|
|
|
|
+ $maxLabel = match($st) {
|
|
|
|
|
+ 'light' => 'Light Soil',
|
|
|
|
|
+ 'medium' => 'Medium Soil',
|
|
|
|
|
+ 'heavy' => 'Heavy Soil',
|
|
|
|
|
+ default => htmlspecialchars($row['soil_type'] ?? '', ENT_QUOTES, 'UTF-8'),
|
|
|
|
|
+ };
|
|
|
|
|
+ } elseif ($maxParam !== '') {
|
|
|
|
|
+ if (is_numeric($maxParam)) {
|
|
|
|
|
+ $max = (float)$maxParam;
|
|
|
|
|
+ } elseif (isset($row[$maxParam]) && $row[$maxParam] !== '') {
|
|
|
|
|
+ $max = (float)$row[$maxParam];
|
|
|
|
|
+ } elseif (isset($spec[$maxParam]) && $spec[$maxParam] !== '') {
|
|
|
|
|
+ $max = (float)$spec[$maxParam];
|
|
|
|
|
+ }
|
|
|
|
|
+ } elseif (isset($spec[$element]) && $spec[$element] !== '') {
|
|
|
|
|
+ $max = (float)$spec[$element] * 2; // fallback: double the spec average
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ // Recommended cell text
|
|
|
|
|
+ $measurement = ($type !== '') ? ' ' . $type : '';
|
|
|
|
|
+ if ($maxParam === 'soil_type') {
|
|
|
|
|
+ $recommended = $maxLabel;
|
|
|
|
|
+ } elseif ($recV === 'n') {
|
|
|
|
|
+ $recommended = '';
|
|
|
|
|
+ } elseif ($recV === 'ph') {
|
|
|
|
|
+ $recommended = '6.4';
|
|
|
|
|
+ } elseif ($recV === 'max') {
|
|
|
|
|
+ $recommended = number_format($max, $decimal, '.', '') . $measurement;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $recommended = number_format($min, $decimal, '.', '') . ' - ' . number_format($max, $decimal, '.', '') . $measurement;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- <!-- CHART HEADER -->
|
|
|
|
|
|
|
+ $alignVal = match($text) { 'r' => 'text-right', 'l' => 'text-left', default => 'text-center' };
|
|
|
|
|
+ $alignRec = match($recText) { 'r' => 'text-right', 'l' => 'text-left', default => 'text-center' };
|
|
|
|
|
|
|
|
- <div class="row bg-dark text-white p-2 mt-3">
|
|
|
|
|
- <div class="text-center col-md-12 h5">Total kilograms per hectare of each element needed to balance soil in this test</div>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ // Bar calculations (replicates original int-cast logic)
|
|
|
|
|
+ $c_min = $min - ($max - $min);
|
|
|
|
|
+ $c_max = $max + ($max - $min);
|
|
|
|
|
+ $hasValue = ($rawVal !== null && $rawVal !== '' && $rawVal !== '0');
|
|
|
|
|
|
|
|
- <div class="row">
|
|
|
|
|
- <div class="">
|
|
|
|
|
- <?php
|
|
|
|
|
- require_once __DIR__.'/../../lib/soil_calculations.php';
|
|
|
|
|
- echo soilAnalysisReportCalcs('Ca', 'BS_ca_ppm', 'ca_ppm_min', 'ca_ppm_max', 'Calcium', 'kg', 'col', $record_id, $rand_id);
|
|
|
|
|
- echo soilAnalysisReportCalcs('Mg', 'BS_mg_ppm', 'mg_ppm_min', 'mg_ppm_max', 'Magnesium', 'kg', 'col', $record_id, $rand_id);
|
|
|
|
|
- echo soilAnalysisReportCalcs('K', 'BS_k_ppm', 'k_ppm_min', 'k_ppm_max', 'Potasium', 'kg', 'col', $record_id, $rand_id);
|
|
|
|
|
- echo soilAnalysisReportCalcs('Na', 'BS_na_ppm', 'na_ppm_min', 'na_ppm_max', 'Sodium', 'kg', 'col', $record_id, $rand_id);
|
|
|
|
|
- echo soilAnalysisReportCalcs('P', 'p_colwell', '', '', 'Phosphate', 'kg', 'col', $record_id, $rand_id);
|
|
|
|
|
- echo soilAnalysisReportCalcs('S', 's_morgan', '', '', 'Sulfur', 'kg', 'col', $record_id, $rand_id);
|
|
|
|
|
- echo soilAnalysisReportCalcs('Mn', 'mn_dtpa', '', '', 'Manganese', 'kg', 'col', $record_id, $rand_id);
|
|
|
|
|
- echo soilAnalysisReportCalcs('Fe', 'fe_dtpa', '', '', 'Iron', 'kg', 'col', $record_id, $rand_id);
|
|
|
|
|
- echo soilAnalysisReportCalcs('Zn', 'zn_dtpa', '', '', 'Zinc', 'kg', 'col', $record_id, $rand_id);
|
|
|
|
|
- echo soilAnalysisReportCalcs('Cu', 'cu_dtpa', '', '', 'Copper', 'kg', 'col', $record_id, $rand_id);
|
|
|
|
|
- echo soilAnalysisReportCalcs('AmN', 'NH3_N', '', '', 'AmNitrogen', 'kg', 'col', $record_id, $rand_id);
|
|
|
|
|
- echo soilAnalysisReportCalcs('B', 'b_cacl2', '', '', 'Boron', 'kg', 'col', $record_id, $rand_id);
|
|
|
|
|
- echo soilAnalysisReportCalcs('NN', 'NO3_N', '', '', 'NNitrogen', 'kg', 'col', $record_id, $rand_id);
|
|
|
|
|
- ?>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ // First bar (deficit zone: c_min → min)
|
|
|
|
|
+ if (!$hasValue || (int)($c_min - $min) == 0) {
|
|
|
|
|
+ $fb = 0;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $fb = (int)($c_min - $value) / (int)($c_min - $min) * 100;
|
|
|
|
|
+ }
|
|
|
|
|
+ $fb = !$hasValue ? 0 : ($fb > 100 ? 100 : ($fb < 0 ? 2 : $fb));
|
|
|
|
|
|
|
|
- <hr>
|
|
|
|
|
|
|
+ // Second bar (ideal zone: min → max)
|
|
|
|
|
+ if (!$hasValue || (int)($min - $max) == 0) {
|
|
|
|
|
+ $sb = 0;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $sb = (int)($min - $value) / (int)($min - $max) * 100;
|
|
|
|
|
+ }
|
|
|
|
|
+ $sbp = ($fb < 100) ? 0 : ($sb < 0 ? 0 : ($sb > 101 ? 100 : $sb));
|
|
|
|
|
|
|
|
- <!-- **************** START OF FORM DATA **************** -->
|
|
|
|
|
- <form class="report-form" method="post">
|
|
|
|
|
|
|
+ // Third bar (excess zone: max → c_max)
|
|
|
|
|
+ if (!$hasValue || (int)($max - $c_max) == 0) {
|
|
|
|
|
+ $tb = 0;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $tb = (int)($max - $value) / (int)($max - $c_max) * 100;
|
|
|
|
|
+ }
|
|
|
|
|
+ $tbp = ($sb < 100) ? 0 : ($tb < 0 ? 0 : ($tb > 101 ? 100 : $tb));
|
|
|
|
|
+
|
|
|
|
|
+ echo "<tr class='sub-chart'>\n";
|
|
|
|
|
+ echo " <td class='text-left border-left text-capitalize pl-2'>{$label}</td>\n";
|
|
|
|
|
+ echo " <td class='{$alignRec} border-left px-3'>{$recommended}</td>\n";
|
|
|
|
|
+ echo " <td class='{$alignVal} border-left nutrient-balance px-3'>{$valueFmt}</td>\n";
|
|
|
|
|
+ echo " <td class='text-center border-left graph-border'><div class='progress'><div class='progress-bar {$graph}' style='width:{$fb}%'></div></div></td>\n";
|
|
|
|
|
+ echo " <td class='text-center border-left graph-border'><div class='progress'><div class='progress-bar {$graph}' style='width:{$sbp}%'></div></div></td>\n";
|
|
|
|
|
+ echo " <td class='text-center border-left border-right graph-border'><div class='progress'><div class='progress-bar {$graph}' style='width:{$tbp}%'></div></div></td>\n";
|
|
|
|
|
+ echo "</tr>\n";
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
- <input type="hidden" name="record_id" value="<?php echo htmlspecialchars($record_id, ENT_QUOTES, 'UTF-8'); ?>">
|
|
|
|
|
- <input type="hidden" name="rand_id" value="<?php echo htmlspecialchars($rand_id, ENT_QUOTES, 'UTF-8'); ?>">
|
|
|
|
|
|
|
+// ── Helper: render a ratio row ─────────────────────────────────────────────
|
|
|
|
|
+/**
|
|
|
|
|
+ * Renders a <tr> for a calculated ratio (element ÷ elementTwo).
|
|
|
|
|
+ *
|
|
|
|
|
+ * Parameters ($p keys):
|
|
|
|
|
+ * element string Numerator column in soil_records
|
|
|
|
|
+ * elementTwo string Denominator column in soil_records
|
|
|
|
|
+ * sbl string Chemical symbol
|
|
|
|
|
+ * nutrient string Display name
|
|
|
|
|
+ * rec string Column in soil_specifications for the recommended ratio
|
|
|
|
|
+ * type string Unit suffix (e.g. ':1')
|
|
|
|
|
+ * rec_text string Recommended alignment: c|r|l
|
|
|
|
|
+ * decimal int Decimal places
|
|
|
|
|
+ * graph string CSS class for progress-bar colour
|
|
|
|
|
+ */
|
|
|
|
|
+function soilRatio(array $row, array $spec, array $p): void
|
|
|
|
|
+{
|
|
|
|
|
+ $element = $p['element'] ?? '';
|
|
|
|
|
+ $element2 = $p['elementTwo'] ?? '';
|
|
|
|
|
+ $sbl = $p['sbl'] ?? '';
|
|
|
|
|
+ $nutrient = $p['nutrient'] ?? '';
|
|
|
|
|
+ $rec = $p['rec'] ?? '';
|
|
|
|
|
+ $type = $p['type'] ?? '';
|
|
|
|
|
+ $recText = $p['rec_text'] ?? 'c';
|
|
|
|
|
+ $decimal = (int)($p['decimal'] ?? 1);
|
|
|
|
|
+ $graph = $p['graph'] ?? '';
|
|
|
|
|
+
|
|
|
|
|
+ $label = ($sbl !== '') ? $sbl . ' - ' . $nutrient : $nutrient;
|
|
|
|
|
+ $val1 = isset($row[$element]) && $row[$element] !== '' ? (float)$row[$element] : 0.0;
|
|
|
|
|
+ $val2 = isset($row[$element2]) && $row[$element2] !== '' ? (float)$row[$element2] : 0.0;
|
|
|
|
|
+ $ratio = ($val2 != 0) ? $val1 / $val2 : 0.0;
|
|
|
|
|
+
|
|
|
|
|
+ $valueFmt = number_format($ratio, $decimal, '.', '') . ($type !== '' ? ' ' . $type : '');
|
|
|
|
|
+ $recommended = (isset($spec[$rec]) && $spec[$rec] !== '') ? htmlspecialchars($spec[$rec], ENT_QUOTES, 'UTF-8') : '';
|
|
|
|
|
+ $alignRec = match($recText) { 'r' => 'text-right', 'l' => 'text-left', default => 'text-center' };
|
|
|
|
|
+
|
|
|
|
|
+ echo "<tr class='sub-chart'>\n";
|
|
|
|
|
+ echo " <td class='text-left border-left text-capitalize pl-2'>{$label}</td>\n";
|
|
|
|
|
+ echo " <td class='{$alignRec} border-left px-3'>{$recommended}</td>\n";
|
|
|
|
|
+ echo " <td class='text-center border-left nutrient-balance px-3'>{$valueFmt}</td>\n";
|
|
|
|
|
+ echo " <td class='text-center border-left graph-border'><div class='progress'><div class='progress-bar {$graph}' style='width:0%'></div></div></td>\n";
|
|
|
|
|
+ echo " <td class='text-center border-left graph-border'><div class='progress'><div class='progress-bar {$graph}' style='width:0%'></div></div></td>\n";
|
|
|
|
|
+ echo " <td class='text-center border-left border-right graph-border'><div class='progress'><div class='progress-bar {$graph}' style='width:0%'></div></div></td>\n";
|
|
|
|
|
+ echo "</tr>\n";
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
- <!-- **************** OVERVIEW SECTION **************** -->
|
|
|
|
|
- <div class="row bg-dark text-white p-2 mt-3">
|
|
|
|
|
- <div class="text-center col-md-12 h5 ">Overview</div>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div class="row">
|
|
|
|
|
- <div class="col-md-12 p-0" >
|
|
|
|
|
- <textarea class="form-control rounded-0" rows="5" id="overview" name="overview" ></textarea>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+// ── Page setup ─────────────────────────────────────────────────────────────
|
|
|
|
|
+$client = htmlspecialchars($row['client_name'] ?? '', ENT_QUOTES, 'UTF-8');
|
|
|
|
|
+$address = htmlspecialchars($row['site_address'] ?? '', ENT_QUOTES, 'UTF-8');
|
|
|
|
|
+$state = htmlspecialchars($row['state_postcode'] ?? '', ENT_QUOTES, 'UTF-8');
|
|
|
|
|
+$email = htmlspecialchars($row['email'] ?? '', ENT_QUOTES, 'UTF-8');
|
|
|
|
|
+$labNo = htmlspecialchars($row['lab_no'] ?? '', ENT_QUOTES, 'UTF-8');
|
|
|
|
|
+$sampleDate = htmlspecialchars($row['date_sampled'] ?? '', ENT_QUOTES, 'UTF-8');
|
|
|
|
|
+$sample = htmlspecialchars($row['site_id'] ?? '', ENT_QUOTES, 'UTF-8');
|
|
|
|
|
+$crop = htmlspecialchars($row['sample_id'] ?? '', ENT_QUOTES, 'UTF-8');
|
|
|
|
|
|
|
|
- <hr>
|
|
|
|
|
|
|
+$today = date('jS F Y');
|
|
|
|
|
+$pageTitle = 'Soil Analysis Results' . ($client !== '' ? ' - ' . $client : '');
|
|
|
|
|
|
|
|
- <div class="row bg-dark text-white p-2 mt-3">
|
|
|
|
|
- <div class="text-center col-md-12 h5 ">Ideal Soil Balancing Program for One Season of a FIVE YEAR Plan</div>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+include __DIR__.'/../../../layouts/header.php';
|
|
|
|
|
+?>
|
|
|
|
|
|
|
|
- <div class="">
|
|
|
|
|
- <?php
|
|
|
|
|
- // Generate 5-year soil balancing program
|
|
|
|
|
- for ($year = 1; $year <= 5; $year++) {
|
|
|
|
|
- echo soilProgramCalcs('Ca', 'BS_ca_ppm', 'ca_ppm_min', 'ca_ppm_max', 'Calcium', 'kg', $record_id, $rand_id);
|
|
|
|
|
- }
|
|
|
|
|
- ?>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+<link rel="stylesheet" href="client-assets/home/css/graphPrint.css" media="print">
|
|
|
|
|
+<style>
|
|
|
|
|
+ .progress { border-radius: 0 !important; }
|
|
|
|
|
+</style>
|
|
|
|
|
|
|
|
- <hr>
|
|
|
|
|
|
|
+<div class="container" id="content">
|
|
|
|
|
|
|
|
- <!-- **************** FOLIAR PROGRAM SECTION **************** -->
|
|
|
|
|
- <div class="row bg-dark text-white p-2 mt-3">
|
|
|
|
|
- <div class="text-center col-md-12 h5" ><input type="text" class="text-center form-control-plaintext text-white border-dark bg-dark" name="header1" id="header1" value="Foliar Program"></div>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div class="row">
|
|
|
|
|
- <div class="col-md-12 p-0" >
|
|
|
|
|
- <textarea class="form-control rounded-0" rows="5" id="foliar_Details" name="foliar_Details"></textarea>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ <div class="row mb-2">
|
|
|
|
|
+ <div class="col-md-3">
|
|
|
|
|
+ <img class="img-fluid" src="client-assets/images/crop-monitor.png" alt="Crop Monitor">
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
|
|
|
- <!-- **************** MICROBE PROGRAM SECTION **************** -->
|
|
|
|
|
- <div class="row bg-dark text-white p-2 mt-3">
|
|
|
|
|
- <div class="text-center col-md-12 h5">Microbe Program</div>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div class="row">
|
|
|
|
|
- <div class="col-md-12 p-0" >
|
|
|
|
|
- <textarea class="form-control rounded-0" rows="5" id="microbe_Program" name="microbe_Program" ></textarea>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ <table class="title">
|
|
|
|
|
+ <tbody>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <th class="col-20"></th><th class="col-20"></th><th class="col-20"></th>
|
|
|
|
|
+ <th class="col-20"></th><th class="col-20"></th>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <td class="right"><b>DATE:</b></td>
|
|
|
|
|
+ <td class="left"><?= $today ?></td>
|
|
|
|
|
+ <td></td>
|
|
|
|
|
+ <td class="right"><b>SAMPLE ID:</b></td>
|
|
|
|
|
+ <td class="left"><?= $sample ?></td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <td class="right"><b>CLIENT:</b></td>
|
|
|
|
|
+ <td class="left"><?= $client ?></td>
|
|
|
|
|
+ <td></td>
|
|
|
|
|
+ <td class="right"><b>DATE SAMPLED:</b></td>
|
|
|
|
|
+ <td class="left"><?= $sampleDate ?></td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <td class="right"><b>ADDRESS:</b></td>
|
|
|
|
|
+ <td class="left"><?= $address ?></td>
|
|
|
|
|
+ <td></td>
|
|
|
|
|
+ <td class="right"><b>LAB NUMBER:</b></td>
|
|
|
|
|
+ <td class="left"><?= $labNo ?></td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <td class="right"></td>
|
|
|
|
|
+ <td class="left"><?= $state ?></td>
|
|
|
|
|
+ <td></td>
|
|
|
|
|
+ <td class="right"><b>CROP:</b></td>
|
|
|
|
|
+ <td class="left"><?= $crop ?></td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <td class="right"></td>
|
|
|
|
|
+ <td class="left"><?= $email ?></td>
|
|
|
|
|
+ <td></td><td></td><td></td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ </tbody>
|
|
|
|
|
+ </table>
|
|
|
|
|
+
|
|
|
|
|
+ <div class="d-print-none">
|
|
|
|
|
+ <div class="row p-2">
|
|
|
|
|
+ <div class="col">
|
|
|
|
|
+ <button type="button" class="btn btn-primary" onclick="generateGraph()">
|
|
|
|
|
+ <i class="fas fa-chart-bar"></i> Generate Graph
|
|
|
|
|
+ </button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="col">
|
|
|
|
|
+ <div class="form-status-holder"></div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
|
|
|
- <div class="row">
|
|
|
|
|
- <p style="font-style: italic; font-size: 9px;">Any recommendations provided by Cropmonitor are advice only, We are not paid consultants and we are not covered to accept responsibiliy for any of our suggestions. As no control can be exercised over storage, handling, mixing application or use, or weather, plant or soil conditions before, during or after application (all of which may affect the preformance of our program), no responsibility for, or liability for any failure in performance, losses, damage or injuries consequential or otherwise, arisiing form such storage mixng application or use will be accepted under any circumstances whatsoever. The buyer assumes all responsibility for the use of any of our products.</p>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ <div class="row">
|
|
|
|
|
+ <div class="col-md-12 text-center fw-bold h4">Soil Analysis Summary</div>
|
|
|
|
|
+ </div>
|
|
|
|
|
|
|
|
- </form>
|
|
|
|
|
- </div>
|
|
|
|
|
- </main>
|
|
|
|
|
|
|
+ <table class="chart">
|
|
|
|
|
+ <tbody>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- ── CHART HEADER ──────────────────────────────────────────── -->
|
|
|
|
|
+ <tr class="chart-header">
|
|
|
|
|
+ <th colspan="3" class="text-center col-md-6 border-left border-right border-top">ELEMENT</th>
|
|
|
|
|
+ <th colspan="3" class="text-center col-md-6 border-right border-top">STATUS</th>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <tr class="chart-header-sub">
|
|
|
|
|
+ <th class="text-center col-18 border-left"></th>
|
|
|
|
|
+ <th class="text-center col-15">DESIRED</th>
|
|
|
|
|
+ <th class="text-center col-15">FOUND</th>
|
|
|
|
|
+ <th class="text-center col-16 stripe-1">LIGHT</th>
|
|
|
|
|
+ <th class="text-center col-16 stripe-1">MEDIUM</th>
|
|
|
|
|
+ <th class="text-center col-16 border-right stripe-1">HEAVY</th>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <td class="border-left"></td>
|
|
|
|
|
+ <td class="border-left"></td>
|
|
|
|
|
+ <td class="border-left nutrient-balance"></td>
|
|
|
|
|
+ <td class="border-left"></td>
|
|
|
|
|
+ <td class="border-left"></td>
|
|
|
|
|
+ <td class="border-left border-right"></td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+
|
|
|
|
|
+ <?php
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'cec', 'nutrient'=>'CEC', 'recV'=>'n', 'decimal'=>2, 'graph'=>'lightorangeGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'tec', 'nutrient'=>'TEC', 'max'=>'soil_type', 'recV'=>'max', 'rec_text'=>'c', 'decimal'=>2, 'graph'=>'lightorangeGraph']);
|
|
|
|
|
+ ?>
|
|
|
|
|
+
|
|
|
|
|
+ <tr class="chart-header-sub">
|
|
|
|
|
+ <th class="text-center col-18 border-left text-dark bg-white"></th>
|
|
|
|
|
+ <th class="text-center col-15 border-left text-dark bg-white"></th>
|
|
|
|
|
+ <th class="text-center col-15 border-left nutrient-balance"></th>
|
|
|
|
|
+ <th class="text-center col-16 border-left stripe-1">DEFICIT</th>
|
|
|
|
|
+ <th class="text-center col-16 stripe-1">IDEAL</th>
|
|
|
|
|
+ <th class="text-center col-16 border-right stripe-1">HIGH</th>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+
|
|
|
|
|
+ <?php
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'ph_h2o', 'nutrient'=>'pH-level (H20)', 'type'=>'pH', 'recV'=>'ph', 'decimal'=>1, 'graph'=>'lightorangeGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'ph_cacl2', 'nutrient'=>'pH-level (CaCl2)', 'type'=>'pH', 'recV'=>'n', 'decimal'=>1, 'graph'=>'lightorangeGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'ec', 'nutrient'=>'Conductivity (EC)','type'=>'mS/cm', 'decimal'=>2, 'graph'=>'lightorangeGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'ocarbon', 'nutrient'=>'Organic Carbon', 'type'=>'%', 'decimal'=>1, 'graph'=>'lightorangeGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'omatter', 'nutrient'=>'Organic Matter', 'type'=>'%', 'decimal'=>1, 'graph'=>'lightorangeGraph']);
|
|
|
|
|
+ ?>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- ── MAJOR ELEMENTS ─────────────────────────────────────────── -->
|
|
|
|
|
+ <tr class="chart-header-sub">
|
|
|
|
|
+ <th colspan="3" class="col-16 border-left text-center lightgreen">MAJOR ELEMENTS</th>
|
|
|
|
|
+ <th class="text-center col-16 stripe-1"></th>
|
|
|
|
|
+ <th class="text-center col-16 stripe-1"></th>
|
|
|
|
|
+ <th class="text-center col-16 border-right stripe-1"></th>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+
|
|
|
|
|
+ <?php
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'NO3_N', 'sbl'=>'NO<sub>3</sub>-N', 'nutrient'=>'Nitrate <small class="d-print-none">Nitrogen</small>', 'min'=>'10', 'max'=>'20', 'type'=>'ppm', 'text'=>'c', 'rec_text'=>'r', 'decimal'=>0, 'graph'=>'lightgreenGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'NH3_N', 'sbl'=>'NH<sub>3</sub>-N', 'nutrient'=>'Ammonium <small class="d-print-none">Nitrogen</small>', 'type'=>'ppm', 'text'=>'c', 'rec_text'=>'r', 'decimal'=>0, 'graph'=>'lightgreenGraph']);
|
|
|
|
|
+ // p_mehlick, p_bray2, p_morgan excluded (commented in original)
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'p_colwell', 'sbl'=>'P', 'nutrient'=>'Phosphate <small>(colwell)</small>', 'type'=>'ppm', 'text'=>'c', 'rec_text'=>'r', 'decimal'=>0, 'graph'=>'lightgreenGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'BS_ca_ppm', 'sbl'=>'Ca', 'nutrient'=>'Calcium', 'min'=>'ca_ppm_min', 'max'=>'ca_ppm_max', 'type'=>'ppm', 'text'=>'c', 'rec_text'=>'r', 'recV'=>'max', 'decimal'=>0, 'graph'=>'lightgreenGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'BS_mg_ppm', 'sbl'=>'Mg', 'nutrient'=>'Magnesium', 'min'=>'mg_ppm_min', 'max'=>'mg_ppm_max', 'type'=>'ppm', 'text'=>'c', 'rec_text'=>'r', 'recV'=>'max', 'decimal'=>0, 'graph'=>'lightgreenGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'BS_k_ppm', 'sbl'=>'K', 'nutrient'=>'Potassium', 'min'=>'k_ppm_min', 'max'=>'k_ppm_max', 'type'=>'ppm', 'text'=>'c', 'rec_text'=>'r', 'recV'=>'max', 'decimal'=>0, 'graph'=>'lightgreenGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'BS_na_ppm', 'sbl'=>'Na', 'nutrient'=>'Sodium', 'min'=>'na_ppm_min', 'max'=>'na_ppm_max', 'type'=>'ppm', 'text'=>'c', 'rec_text'=>'r', 'recV'=>'max', 'decimal'=>0, 'graph'=>'lightgreenGraph']);
|
|
|
|
|
+ ?>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- ── TRACE ELEMENTS ─────────────────────────────────────────── -->
|
|
|
|
|
+ <tr class="chart-header-sub">
|
|
|
|
|
+ <th colspan="3" class="col-16 border-left text-center lightred">TRACE ELEMENTS</th>
|
|
|
|
|
+ <th class="text-center col-16 stripe-1"></th>
|
|
|
|
|
+ <th class="text-center col-16 stripe-1"></th>
|
|
|
|
|
+ <th class="text-center col-16 border-right stripe-1"></th>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+
|
|
|
|
|
+ <?php
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'s_morgan', 'sbl'=>'S', 'nutrient'=>'Sulfur', 'type'=>'ppm', 'text'=>'c', 'rec_text'=>'r', 'decimal'=>2, 'graph'=>'lightredGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'b_cacl2', 'sbl'=>'B', 'nutrient'=>'Boron', 'type'=>'ppm', 'text'=>'c', 'rec_text'=>'r', 'decimal'=>2, 'graph'=>'lightredGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'mn_dtpa', 'sbl'=>'Mn', 'nutrient'=>'Manganese', 'type'=>'ppm', 'text'=>'c', 'rec_text'=>'r', 'decimal'=>2, 'graph'=>'lightredGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'cu_dtpa', 'sbl'=>'Cu', 'nutrient'=>'Copper', 'type'=>'ppm', 'text'=>'c', 'rec_text'=>'r', 'decimal'=>2, 'graph'=>'lightredGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'zn_dtpa', 'sbl'=>'Zn', 'nutrient'=>'Zinc', 'type'=>'ppm', 'text'=>'c', 'rec_text'=>'r', 'decimal'=>2, 'graph'=>'lightredGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'fe_dtpa', 'sbl'=>'Fe', 'nutrient'=>'Iron', 'type'=>'ppm', 'text'=>'c', 'rec_text'=>'r', 'decimal'=>2, 'graph'=>'lightredGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'al', 'sbl'=>'Al', 'nutrient'=>'Aluminium', 'type'=>'ppm', 'text'=>'c', 'rec_text'=>'r', 'decimal'=>2, 'graph'=>'lightredGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'sl_cacl2', 'sbl'=>'Si', 'nutrient'=>'Silicon', 'type'=>'ppm', 'text'=>'c', 'rec_text'=>'r', 'decimal'=>2, 'graph'=>'lightredGraph']);
|
|
|
|
|
+ ?>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- ── BASE SATURATION ────────────────────────────────────────── -->
|
|
|
|
|
+ <tr class="chart-header-sub">
|
|
|
|
|
+ <th colspan="3" class="col-16 border-left text-center lightpurple">BASE SATURATION</th>
|
|
|
|
|
+ <th class="text-center col-16 stripe-1"></th>
|
|
|
|
|
+ <th class="text-center col-16 stripe-1"></th>
|
|
|
|
|
+ <th class="text-center col-16 border-right stripe-1"></th>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+
|
|
|
|
|
+ <?php
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'BS_ca2', 'sbl'=>'Ca', 'nutrient'=>'Calcium', 'min'=>'cabs_min', 'max'=>'cabs_max', 'type'=>'%', 'text'=>'c', 'rec_text'=>'r', 'recV'=>'max', 'decimal'=>2, 'graph'=>'lightpurpleGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'BS_mg2', 'sbl'=>'Mg', 'nutrient'=>'Magnesium', 'min'=>'mgbs_min', 'max'=>'mgbs_max', 'type'=>'%', 'text'=>'c', 'rec_text'=>'r', 'recV'=>'max', 'decimal'=>2, 'graph'=>'lightpurpleGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'BS_k', 'sbl'=>'K', 'nutrient'=>'Potassium', 'min'=>'kbs_min', 'max'=>'kbs_max', 'type'=>'%', 'text'=>'c', 'rec_text'=>'r', 'recV'=>'max', 'decimal'=>2, 'graph'=>'lightpurpleGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'BS_na', 'sbl'=>'Na', 'nutrient'=>'Sodium', 'min'=>'nabs_min', 'max'=>'nabs_max', 'type'=>'%', 'text'=>'c', 'rec_text'=>'r', 'recV'=>'max', 'decimal'=>2, 'graph'=>'lightpurpleGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'BS_ob', 'nutrient'=>'Other Bases', 'max'=>'ob_rec', 'type'=>'%', 'text'=>'c', 'rec_text'=>'r', 'recV'=>'max', 'decimal'=>2, 'graph'=>'lightpurpleGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'BS_h', 'nutrient'=>'Hydrogen', 'max'=>'h_rec', 'type'=>'%', 'text'=>'c', 'rec_text'=>'r', 'recV'=>'max', 'decimal'=>2, 'graph'=>'lightpurpleGraph']);
|
|
|
|
|
+ ?>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- ── SOLUBLE MORGAN 2 EXTRACT ───────────────────────────────── -->
|
|
|
|
|
+ <tr class="chart-header-sub">
|
|
|
|
|
+ <th colspan="3" class="col-16 border-left text-center lightgrey">SOLUBLE MORGAN 2 EXTRACT</th>
|
|
|
|
|
+ <th class="text-center col-16 stripe-1"></th>
|
|
|
|
|
+ <th class="text-center col-16 stripe-1"></th>
|
|
|
|
|
+ <th class="text-center col-16 border-right stripe-1"></th>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+
|
|
|
|
|
+ <?php
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'s_morgan', 'sbl'=>'Ca', 'nutrient'=>'Calcium', 'type'=>'%', 'text'=>'c', 'rec_text'=>'r', 'decimal'=>0, 'graph'=>'lightgreyGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'b_cacl2', 'sbl'=>'Mg', 'nutrient'=>'Magnesium', 'type'=>'%', 'text'=>'c', 'rec_text'=>'r', 'decimal'=>0, 'graph'=>'lightgreyGraph']);
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'mn_dtpa', 'sbl'=>'K', 'nutrient'=>'Potassium', 'type'=>'%', 'text'=>'c', 'rec_text'=>'r', 'decimal'=>0, 'graph'=>'lightgreyGraph']);
|
|
|
|
|
+ ?>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- ── ADDITIONAL DATA ────────────────────────────────────────── -->
|
|
|
|
|
+ <tr class="chart-header-sub">
|
|
|
|
|
+ <th colspan="3" class="col-16 border-left text-center lightgrey">ADDITIONAL DATA</th>
|
|
|
|
|
+ <th class="text-center col-16 stripe-1">LOW</th>
|
|
|
|
|
+ <th class="text-center col-16 stripe-1">IDEAL</th>
|
|
|
|
|
+ <th class="text-center col-16 border-right stripe-1">EXCELLENT</th>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+
|
|
|
|
|
+ <?php
|
|
|
|
|
+ soilRow($row, $spec, ['element'=>'s_morgan', 'sbl'=>'Ca', 'nutrient'=>'Calcium', 'type'=>'%', 'text'=>'c', 'rec_text'=>'r', 'decimal'=>0, 'graph'=>'lightgreyGraph']);
|
|
|
|
|
+ ?>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- ── RATIOS ─────────────────────────────────────────────────── -->
|
|
|
|
|
+ <tr class="chart-header-sub">
|
|
|
|
|
+ <th colspan="3" class="col-16 border-left text-center lightblue">RATIOS</th>
|
|
|
|
|
+ <th class="text-center col-16 stripe-1"></th>
|
|
|
|
|
+ <th class="text-center col-16 stripe-1"></th>
|
|
|
|
|
+ <th class="text-center col-16 border-right stripe-1"></th>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+
|
|
|
|
|
+ <?php
|
|
|
|
|
+ soilRatio($row, $spec, ['element'=>'ca_mehlick3', 'elementTwo'=>'mg_mehlick3', 'rec'=>'ca_mg_ratio', 'nutrient'=>'Ca:Mg Ratio', 'rec_text'=>'r', 'decimal'=>1, 'graph'=>'lightblueGraph']);
|
|
|
|
|
+ soilRow ($row, $spec, ['element'=>'NH3_N', 'nutrient'=>'Total Nitrogen', 'type'=>'%', 'text'=>'c', 'rec_text'=>'r', 'decimal'=>1, 'graph'=>'lightblueGraph']);
|
|
|
|
|
+ soilRow ($row, $spec, ['element'=>'ocarbon', 'nutrient'=>'Total Carbon', 'type'=>'%', 'text'=>'c', 'rec_text'=>'r', 'decimal'=>1, 'graph'=>'lightblueGraph']);
|
|
|
|
|
+ soilRatio($row, $spec, ['element'=>'ocarbon', 'elementTwo'=>'NO3_N', 'rec'=>'c_n_ratio', 'nutrient'=>'C:N Ratio', 'type'=>':1', 'rec_text'=>'r', 'decimal'=>1, 'graph'=>'lightblueGraph']);
|
|
|
|
|
+ ?>
|
|
|
|
|
+
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <td class="border-bottom border-left"></td>
|
|
|
|
|
+ <td class="border-bottom border-left"></td>
|
|
|
|
|
+ <td class="border-bottom border-left nutrient-balance"></td>
|
|
|
|
|
+ <td class="border-bottom border-left"></td>
|
|
|
|
|
+ <td class="border-bottom border-left"></td>
|
|
|
|
|
+ <td class="border-bottom border-left border-right"></td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+
|
|
|
|
|
+ </tbody>
|
|
|
|
|
+ </table>
|
|
|
|
|
|
|
|
<footer class="py-4 bg-light mt-auto">
|
|
<footer class="py-4 bg-light mt-auto">
|
|
|
<div class="container-fluid px-4">
|
|
<div class="container-fluid px-4">
|
|
|
<div class="d-flex align-items-center justify-content-between small">
|
|
<div class="d-flex align-items-center justify-content-between small">
|
|
|
<div class="text-muted">© <?= date('Y') ?> Crop Management Platform. All Rights Reserved.</div>
|
|
<div class="text-muted">© <?= date('Y') ?> Crop Management Platform. All Rights Reserved.</div>
|
|
|
- <div><a href="/privacy-policy.php">Privacy Policy</a> · <a href="/terms.php">Terms & Conditions</a></div>
|
|
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <a href="/privacy-policy">Privacy Policy</a> ·
|
|
|
|
|
+ <a href="/terms">Terms & Conditions</a>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</footer>
|
|
</footer>
|
|
|
-</div>
|
|
|
|
|
-</div>
|
|
|
|
|
|
|
|
|
|
-<?php include __DIR__.'/../../layouts/footer.php'; ?>
|
|
|
|
|
|
|
+</div><!-- /.container -->
|
|
|
|
|
+
|
|
|
|
|
+<?php include __DIR__.'/../../../layouts/footer.php'; ?>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
function generateGraph() {
|
|
function generateGraph() {
|
|
|
alert('Graph generation functionality will be implemented here.');
|
|
alert('Graph generation functionality will be implemented here.');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-$(document).ready(function(){
|
|
|
|
|
|
|
+$(document).ready(function () {
|
|
|
var timeoutId;
|
|
var timeoutId;
|
|
|
- $('form textarea, form input').on('input propertychange change', function() {
|
|
|
|
|
- console.log('Textarea Change');
|
|
|
|
|
-
|
|
|
|
|
- clearTimeout(timeoutId);
|
|
|
|
|
- timeoutId = setTimeout(function() {
|
|
|
|
|
- // Runs 1 second (1000 ms) after the last change
|
|
|
|
|
- saveToDB();
|
|
|
|
|
- }, 1000);
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- function saveToDB() {
|
|
|
|
|
- console.log('Saving to the db');
|
|
|
|
|
- form = $('.report-form');
|
|
|
|
|
- $.ajax({
|
|
|
|
|
- url: "/controllers/save_soil_analysis.php",
|
|
|
|
|
- type: "POST",
|
|
|
|
|
- data: form.serialize(), // serializes the form's elements.
|
|
|
|
|
- beforeSend: function(xhr) {
|
|
|
|
|
- // Let them know we are saving
|
|
|
|
|
- $('.form-status-holder').html('Saving...');
|
|
|
|
|
- },
|
|
|
|
|
- success: function(data) {
|
|
|
|
|
- var jqObj = jQuery(data); // You can get data returned from your ajax call here. ex. jqObj.find('.returned-data').html()
|
|
|
|
|
- // Now show them we saved and when we did
|
|
|
|
|
- var d = new Date();
|
|
|
|
|
- $('.form-status-holder').html('Saved! Last: ' + d.toLocaleTimeString());
|
|
|
|
|
- },
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // This is just so we don't go anywhere
|
|
|
|
|
- // and still save if you submit the form
|
|
|
|
|
- $('.report-form').submit(function(e) {
|
|
|
|
|
- saveToDB();
|
|
|
|
|
- e.preventDefault();
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ $('form textarea, form input').on('input propertychange change', function () {
|
|
|
|
|
+ clearTimeout(timeoutId);
|
|
|
|
|
+ timeoutId = setTimeout(saveToDB, 1000);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ function saveToDB() {
|
|
|
|
|
+ var form = $('.report-form');
|
|
|
|
|
+ $.ajax({
|
|
|
|
|
+ url: '/controllers/save_soil_analysis.php',
|
|
|
|
|
+ type: 'POST',
|
|
|
|
|
+ data: form.serialize(),
|
|
|
|
|
+ beforeSend: function () { $('.form-status-holder').html('Saving...'); },
|
|
|
|
|
+ success: function () {
|
|
|
|
|
+ var d = new Date();
|
|
|
|
|
+ $('.form-status-holder').html('Saved! Last: ' + d.toLocaleTimeString());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $('.report-form').submit(function (e) {
|
|
|
|
|
+ saveToDB();
|
|
|
|
|
+ e.preventDefault();
|
|
|
|
|
+ });
|
|
|
|
|
+});
|
|
|
</script>
|
|
</script>
|
|
|
-
|
|
|