ソースを参照

update sidebar

Benjamin Harris 2 ヶ月 前
コミット
5661ffe581

+ 0 - 0
dashboard/crop-analysis/animal-dietary-balance/amdb.php → dashboard/crop-analysis/animal-dietary-balance/index.php


+ 0 - 0
dashboard/crop-analysis/compost-test-data/index.php


+ 228 - 2
dashboard/crop-analysis/plant-test-data/index.php

@@ -1,3 +1,229 @@
 <?php
-header('Location: /dashboard/crop-analysis/plant-test-data/plant-test-data.php');
-exit;
+require_once __DIR__ . '/../../../config/database.php';
+require_once __DIR__ . '/../../../lib/auth.php';
+require_once __DIR__ . '/../../../lib/csrf.php';
+
+if (session_status() === PHP_SESSION_NONE) {
+    session_start();
+}
+
+requireLogin();
+
+$pageTitle = 'Plant Tissue Analysis';
+$siteName  = 'Crop Monitor';
+
+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">
+                <h1 class="mt-4"><?= htmlspecialchars($pageTitle, ENT_QUOTES, 'UTF-8') ?></h1>
+                <ol class="breadcrumb mb-4">
+                    <li class="breadcrumb-item"><a href="/dashboard/dashboard.php">Dashboard</a></li>
+                    <li class="breadcrumb-item active">Plant Test Data</li>
+                </ol>
+
+                <div class="row">
+                    <div class="container">
+                        <h3>Plant Tissue Test Details</h3>
+                        <span class="text-danger small">* required fields.</span>
+
+                        <?php include __DIR__ . '/../../../components/clientDetailsForm.php'; ?>
+
+                        <form method="post" action="/controllers/plantTestSubmit.php" id="PlantcsvForm" class="needs-validation" novalidate>
+                            <input type="hidden" name="csrf_token" value="<?= htmlspecialchars(generateCsrfToken(), ENT_QUOTES, 'UTF-8') ?>">
+
+                            <hr>
+                            <div class="row">
+                                <div class="col">
+                                    <small class="form-text text-muted">Lab No</small>
+                                    <input type="text" class="form-control form-control-sm" name="lab_no" id="lab_no" placeholder="Lab No">
+                                </div>
+                                <div class="col">
+                                    <small class="form-text text-muted">Batch No</small>
+                                    <input type="text" class="form-control form-control-sm" name="batch_no" id="batch_no" placeholder="Batch No">
+                                </div>
+                                <div class="col">
+                                    <small class="form-text text-muted">Date Sampled</small>
+                                    <input type="date" class="form-control form-control-sm" name="date_sampled" id="date_sampled">
+                                </div>
+                                <div class="col">
+                                    <small class="form-text text-muted">Sample ID <span class="text-danger">*</span></small>
+                                    <input type="text" class="form-control form-control-sm" name="sample_id" id="sample_id" placeholder="Sample ID" required>
+                                </div>
+                                <div class="col">
+                                    <small class="form-text text-muted">Site ID</small>
+                                    <input type="text" class="form-control form-control-sm" name="site_id" id="site_id" placeholder="Paddock ID">
+                                </div>
+                                <div class="col">
+                                    <small class="form-text text-muted">Crop Type</small>
+                                    <input type="text" class="form-control form-control-sm" name="crop_type" id="crop_type" placeholder="Crop Type">
+                                </div>
+                            </div>
+
+                            <hr>
+                            <label><b>Major Elements (% dry weight)</b></label>
+                            <div class="row mt-2">
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted">Nitrogen (N) %</small>
+                                    <input type="text" class="form-control form-control-sm" name="n" id="n" placeholder="0.00">
+                                </div>
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted">Phosphorus (P) %</small>
+                                    <input type="text" class="form-control form-control-sm" name="p" id="p" placeholder="0.00">
+                                </div>
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted">Potassium (K) %</small>
+                                    <input type="text" class="form-control form-control-sm" name="k" id="k" placeholder="0.00">
+                                </div>
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted">Sulphur (S) %</small>
+                                    <input type="text" class="form-control form-control-sm" name="s" id="s" placeholder="0.00">
+                                </div>
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted">Magnesium (Mg) %</small>
+                                    <input type="text" class="form-control form-control-sm" name="mg" id="mg" placeholder="0.00">
+                                </div>
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted">Calcium (Ca) %</small>
+                                    <input type="text" class="form-control form-control-sm" name="ca" id="ca" placeholder="0.00">
+                                </div>
+                            </div>
+                            <div class="row mt-2">
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted">Sodium (Na) %</small>
+                                    <input type="text" class="form-control form-control-sm" name="na" id="na" placeholder="0.00">
+                                </div>
+                            </div>
+
+                            <hr>
+                            <label><b>Trace Elements (ppm)</b></label>
+                            <div class="row mt-2">
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted">Iron (Fe) ppm</small>
+                                    <input type="text" class="form-control form-control-sm" name="fe" id="fe" placeholder="0.0">
+                                </div>
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted">Manganese (Mn) ppm</small>
+                                    <input type="text" class="form-control form-control-sm" name="mn" id="mn" placeholder="0.0">
+                                </div>
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted">Zinc (Zn) ppm</small>
+                                    <input type="text" class="form-control form-control-sm" name="zn" id="zn" placeholder="0.0">
+                                </div>
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted">Copper (Cu) ppm</small>
+                                    <input type="text" class="form-control form-control-sm" name="cu" id="cu" placeholder="0.0">
+                                </div>
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted">Boron (B) ppm</small>
+                                    <input type="text" class="form-control form-control-sm" name="b" id="b" placeholder="0.0">
+                                </div>
+                            </div>
+
+                            <hr>
+                            <label><b>Other Elements (ppm)</b></label>
+                            <div class="row mt-2">
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted">Molybdenum (Mo) ppm</small>
+                                    <input type="text" class="form-control form-control-sm" name="m" id="m" placeholder="0.00">
+                                </div>
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted">Cobalt (Co) ppm</small>
+                                    <input type="text" class="form-control form-control-sm" name="co" id="co" placeholder="0.00">
+                                </div>
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted">Selenium (Se) ppm</small>
+                                    <input type="text" class="form-control form-control-sm" name="se" id="se" placeholder="0.00">
+                                </div>
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted">Chloride (Cl) ppm</small>
+                                    <input type="text" class="form-control form-control-sm" name="cl" id="cl" placeholder="0.00">
+                                </div>
+                            </div>
+
+                            <hr>
+                            <button form="PlantcsvForm" type="submit" name="PlantcsvForm" class="btn btn-success">
+                                Submit
+                            </button>
+                        </form>
+
+                        <?php include __DIR__ . '/../../../components/newClientModal.php'; ?>
+
+                        <hr>
+                        <div class="card mt-3">
+                            <div class="card-body">
+                                <h5 class="card-title">CSV Upload / Download</h5>
+                                <p class="card-text text-muted">Download a CSV template or upload a filled CSV to pre-populate the form.</p>
+                                <div class="input-group mt-2">
+                                    <input type="file" class="form-control form-control-sm" id="csvUpload" accept=".csv">
+                                    <button class="btn btn-success btn-sm" type="button" id="csvDownload">Download Template</button>
+                                </div>
+                            </div>
+                        </div>
+
+                    </div>
+                </div>
+            </div>
+        </main>
+
+        <?php include __DIR__ . '/../../../layouts/footer.php'; ?>
+    </div>
+</div>
+
+<script>
+(function () {
+    'use strict';
+    window.addEventListener('load', function () {
+        var forms = document.getElementsByClassName('needs-validation');
+        Array.prototype.forEach.call(forms, function (form) {
+            form.addEventListener('submit', function (event) {
+                if (!form.checkValidity()) {
+                    event.preventDefault();
+                    event.stopPropagation();
+                }
+                form.classList.add('was-validated');
+            }, false);
+        });
+    }, false);
+})();
+
+document.getElementById('csvUpload').addEventListener('change', function (e) {
+    var file = e.target.files[0];
+    if (!file) return;
+    var reader = new FileReader();
+    reader.onload = function (ev) {
+        var rows = ev.target.result.split('\n');
+        rows.forEach(function (row, i) {
+            if (i === 0) return;
+            var cols = row.split(',');
+            if (cols.length >= 2) {
+                var el = document.getElementById(cols[0].trim());
+                if (el) el.value = cols[1].trim();
+            }
+        });
+    };
+    reader.readAsText(file);
+});
+
+document.getElementById('csvDownload').addEventListener('click', function () {
+    var fields = ['lab_no','batch_no','date_sampled','sample_id','site_id','crop_type',
+                  'n','p','k','s','mg','ca','na','fe','mn','zn','cu','b','m','co','se','cl'];
+    var rows = [['id','value']];
+    fields.forEach(function (id) {
+        var el = document.getElementById(id);
+        rows.push([id, el ? el.value : '']);
+    });
+    var csv = rows.map(function (r) { return r.join(','); }).join('\n');
+    var a = document.createElement('a');
+    a.href = 'data:text/csv;charset=utf-8,' + encodeURIComponent(csv);
+    a.download = 'plant-tissue-analysis.csv';
+    a.click();
+});
+</script>

+ 0 - 229
dashboard/crop-analysis/plant-test-data/plant-test-data.php

@@ -1,229 +0,0 @@
-<?php
-require_once __DIR__ . '/../../../config/database.php';
-require_once __DIR__ . '/../../../lib/auth.php';
-require_once __DIR__ . '/../../../lib/csrf.php';
-
-if (session_status() === PHP_SESSION_NONE) {
-    session_start();
-}
-
-requireLogin();
-
-$pageTitle = 'Plant Tissue Analysis';
-$siteName  = 'Crop Monitor';
-
-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">
-                <h1 class="mt-4"><?= htmlspecialchars($pageTitle, ENT_QUOTES, 'UTF-8') ?></h1>
-                <ol class="breadcrumb mb-4">
-                    <li class="breadcrumb-item"><a href="/dashboard/dashboard.php">Dashboard</a></li>
-                    <li class="breadcrumb-item active">Plant Test Data</li>
-                </ol>
-
-                <div class="row">
-                    <div class="container">
-                        <h3>Plant Tissue Test Details</h3>
-                        <span class="text-danger small">* required fields.</span>
-
-                        <?php include __DIR__ . '/../../../components/clientDetailsForm.php'; ?>
-
-                        <form method="post" action="/controllers/plantTestSubmit.php" id="PlantcsvForm" class="needs-validation" novalidate>
-                            <input type="hidden" name="csrf_token" value="<?= htmlspecialchars(generateCsrfToken(), ENT_QUOTES, 'UTF-8') ?>">
-
-                            <hr>
-                            <div class="row">
-                                <div class="col">
-                                    <small class="form-text text-muted">Lab No</small>
-                                    <input type="text" class="form-control form-control-sm" name="lab_no" id="lab_no" placeholder="Lab No">
-                                </div>
-                                <div class="col">
-                                    <small class="form-text text-muted">Batch No</small>
-                                    <input type="text" class="form-control form-control-sm" name="batch_no" id="batch_no" placeholder="Batch No">
-                                </div>
-                                <div class="col">
-                                    <small class="form-text text-muted">Date Sampled</small>
-                                    <input type="date" class="form-control form-control-sm" name="date_sampled" id="date_sampled">
-                                </div>
-                                <div class="col">
-                                    <small class="form-text text-muted">Sample ID <span class="text-danger">*</span></small>
-                                    <input type="text" class="form-control form-control-sm" name="sample_id" id="sample_id" placeholder="Sample ID" required>
-                                </div>
-                                <div class="col">
-                                    <small class="form-text text-muted">Site ID</small>
-                                    <input type="text" class="form-control form-control-sm" name="site_id" id="site_id" placeholder="Paddock ID">
-                                </div>
-                                <div class="col">
-                                    <small class="form-text text-muted">Crop Type</small>
-                                    <input type="text" class="form-control form-control-sm" name="crop_type" id="crop_type" placeholder="Crop Type">
-                                </div>
-                            </div>
-
-                            <hr>
-                            <label><b>Major Elements (% dry weight)</b></label>
-                            <div class="row mt-2">
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted">Nitrogen (N) %</small>
-                                    <input type="text" class="form-control form-control-sm" name="n" id="n" placeholder="0.00">
-                                </div>
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted">Phosphorus (P) %</small>
-                                    <input type="text" class="form-control form-control-sm" name="p" id="p" placeholder="0.00">
-                                </div>
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted">Potassium (K) %</small>
-                                    <input type="text" class="form-control form-control-sm" name="k" id="k" placeholder="0.00">
-                                </div>
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted">Sulphur (S) %</small>
-                                    <input type="text" class="form-control form-control-sm" name="s" id="s" placeholder="0.00">
-                                </div>
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted">Magnesium (Mg) %</small>
-                                    <input type="text" class="form-control form-control-sm" name="mg" id="mg" placeholder="0.00">
-                                </div>
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted">Calcium (Ca) %</small>
-                                    <input type="text" class="form-control form-control-sm" name="ca" id="ca" placeholder="0.00">
-                                </div>
-                            </div>
-                            <div class="row mt-2">
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted">Sodium (Na) %</small>
-                                    <input type="text" class="form-control form-control-sm" name="na" id="na" placeholder="0.00">
-                                </div>
-                            </div>
-
-                            <hr>
-                            <label><b>Trace Elements (ppm)</b></label>
-                            <div class="row mt-2">
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted">Iron (Fe) ppm</small>
-                                    <input type="text" class="form-control form-control-sm" name="fe" id="fe" placeholder="0.0">
-                                </div>
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted">Manganese (Mn) ppm</small>
-                                    <input type="text" class="form-control form-control-sm" name="mn" id="mn" placeholder="0.0">
-                                </div>
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted">Zinc (Zn) ppm</small>
-                                    <input type="text" class="form-control form-control-sm" name="zn" id="zn" placeholder="0.0">
-                                </div>
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted">Copper (Cu) ppm</small>
-                                    <input type="text" class="form-control form-control-sm" name="cu" id="cu" placeholder="0.0">
-                                </div>
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted">Boron (B) ppm</small>
-                                    <input type="text" class="form-control form-control-sm" name="b" id="b" placeholder="0.0">
-                                </div>
-                            </div>
-
-                            <hr>
-                            <label><b>Other Elements (ppm)</b></label>
-                            <div class="row mt-2">
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted">Molybdenum (Mo) ppm</small>
-                                    <input type="text" class="form-control form-control-sm" name="m" id="m" placeholder="0.00">
-                                </div>
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted">Cobalt (Co) ppm</small>
-                                    <input type="text" class="form-control form-control-sm" name="co" id="co" placeholder="0.00">
-                                </div>
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted">Selenium (Se) ppm</small>
-                                    <input type="text" class="form-control form-control-sm" name="se" id="se" placeholder="0.00">
-                                </div>
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted">Chloride (Cl) ppm</small>
-                                    <input type="text" class="form-control form-control-sm" name="cl" id="cl" placeholder="0.00">
-                                </div>
-                            </div>
-
-                            <hr>
-                            <button form="PlantcsvForm" type="submit" name="PlantcsvForm" class="btn btn-success">
-                                Submit
-                            </button>
-                        </form>
-
-                        <?php include __DIR__ . '/../../../components/newClientModal.php'; ?>
-
-                        <hr>
-                        <div class="card mt-3">
-                            <div class="card-body">
-                                <h5 class="card-title">CSV Upload / Download</h5>
-                                <p class="card-text text-muted">Download a CSV template or upload a filled CSV to pre-populate the form.</p>
-                                <div class="input-group mt-2">
-                                    <input type="file" class="form-control form-control-sm" id="csvUpload" accept=".csv">
-                                    <button class="btn btn-success btn-sm" type="button" id="csvDownload">Download Template</button>
-                                </div>
-                            </div>
-                        </div>
-
-                    </div>
-                </div>
-            </div>
-        </main>
-
-        <?php include __DIR__ . '/../../../layouts/footer.php'; ?>
-    </div>
-</div>
-
-<script>
-(function () {
-    'use strict';
-    window.addEventListener('load', function () {
-        var forms = document.getElementsByClassName('needs-validation');
-        Array.prototype.forEach.call(forms, function (form) {
-            form.addEventListener('submit', function (event) {
-                if (!form.checkValidity()) {
-                    event.preventDefault();
-                    event.stopPropagation();
-                }
-                form.classList.add('was-validated');
-            }, false);
-        });
-    }, false);
-})();
-
-document.getElementById('csvUpload').addEventListener('change', function (e) {
-    var file = e.target.files[0];
-    if (!file) return;
-    var reader = new FileReader();
-    reader.onload = function (ev) {
-        var rows = ev.target.result.split('\n');
-        rows.forEach(function (row, i) {
-            if (i === 0) return;
-            var cols = row.split(',');
-            if (cols.length >= 2) {
-                var el = document.getElementById(cols[0].trim());
-                if (el) el.value = cols[1].trim();
-            }
-        });
-    };
-    reader.readAsText(file);
-});
-
-document.getElementById('csvDownload').addEventListener('click', function () {
-    var fields = ['lab_no','batch_no','date_sampled','sample_id','site_id','crop_type',
-                  'n','p','k','s','mg','ca','na','fe','mn','zn','cu','b','m','co','se','cl'];
-    var rows = [['id','value']];
-    fields.forEach(function (id) {
-        var el = document.getElementById(id);
-        rows.push([id, el ? el.value : '']);
-    });
-    var csv = rows.map(function (r) { return r.join(','); }).join('\n');
-    var a = document.createElement('a');
-    a.href = 'data:text/csv;charset=utf-8,' + encodeURIComponent(csv);
-    a.download = 'plant-tissue-analysis.csv';
-    a.click();
-});
-</script>

+ 0 - 0
dashboard/crop-analysis/soil-test-data/soil-test-data.php → dashboard/crop-analysis/soil-test-data/index.php


+ 261 - 2
dashboard/crop-analysis/water-test-data/index.php

@@ -1,3 +1,262 @@
 <?php
-header('Location: /dashboard/crop-analysis/water-test-data/water-test-data.php');
-exit;
+require_once __DIR__ . '/../../../config/database.php';
+require_once __DIR__ . '/../../../lib/auth.php';
+require_once __DIR__ . '/../../../lib/csrf.php';
+
+if (session_status() === PHP_SESSION_NONE) {
+    session_start();
+}
+
+requireLogin();
+
+$pageTitle = 'Water Test Analysis';
+$siteName  = 'Crop Monitor';
+
+include __DIR__ . '/../../../layouts/header.php';
+include __DIR__ . '/../../../layouts/navbar.php';
+?>
+
+<style>
+    .btn-append {
+        color: #495057;
+        background-color: #e9ecef;
+        border: 1px solid #ced4da;
+    }
+</style>
+
+<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">
+                <h1 class="mt-4"><?= htmlspecialchars($pageTitle, ENT_QUOTES, 'UTF-8') ?></h1>
+                <ol class="breadcrumb mb-4">
+                    <li class="breadcrumb-item"><a href="/dashboard/dashboard.php">Dashboard</a></li>
+                    <li class="breadcrumb-item active">Water Test Analysis</li>
+                </ol>
+
+                <div class="row">
+                    <div class="container">
+                        <h3>Water Test Details</h3>
+                        <span class="text-danger small">* required fields.</span>
+
+                        <?php include __DIR__ . '/../../../components/clientDetailsForm.php'; ?>
+
+                        <form method="post" action="/controllers/waterTestSubmit.php" id="WatercsvForm" class="needs-validation" novalidate>
+                            <input type="hidden" name="csrf_token" value="<?= htmlspecialchars(generateCsrfToken(), ENT_QUOTES, 'UTF-8') ?>">
+
+                            <hr>
+                            <div class="row">
+                                <div class="col">
+                                    <small class="form-text text-muted">Lab No</small>
+                                    <input type="text" class="form-control form-control-sm" name="lab_no" id="lab_no" placeholder="Lab No">
+                                </div>
+
+                                <div class="col">
+                                    <small class="form-text text-muted">Batch No</small>
+                                    <input type="text" class="form-control form-control-sm" name="batch_no" id="batch_no" placeholder="Batch No">
+                                </div>
+
+                                <div class="col">
+                                    <small class="form-text text-muted">Date Sampled</small>
+                                    <input type="date" class="form-control form-control-sm" name="date_sampled" id="date_sampled" placeholder="Date Sampled">
+                                </div>
+
+                                <div class="col">
+                                    <small class="form-text text-muted">Sample ID <span class="text-danger">*</span></small>
+                                    <input type="text" class="form-control form-control-sm" name="sample_id" id="sample_id" placeholder="Sample Id" required>
+                                </div>
+
+                                <div class="col">
+                                    <small class="form-text text-muted">Site ID</small>
+                                    <input type="text" class="form-control form-control-sm" name="site_id" id="site_id" placeholder="Paddock Id">
+                                </div>
+                            </div>
+
+                            <hr>
+                            <label class="col"><b>Analysis Inputs</b></label>
+
+                            <div class="row mt-2">
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted">pH <span class="text-danger">*</span></small>
+                                    <div class="input-group input-group-sm mb-3">
+                                        <input type="text" class="form-control form-control-sm" name="ph" id="ph" placeholder="pH" required>
+                                        <span class="input-group-text">pH</span>
+                                    </div>
+                                </div>
+
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted">Conductivity</small>
+                                    <div class="input-group input-group-sm mb-3">
+                                        <input type="text" class="form-control form-control-sm" name="cond_dsm" id="cond_dsm" placeholder="Conductivity">
+                                        <span class="input-group-text">dS/m</span>
+                                    </div>
+                                </div>
+
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted">Bicarbonate (HCO3-)</small>
+                                    <div class="input-group input-group-sm mb-3">
+                                        <input type="text" class="form-control form-control-sm" name="hco3" id="hco3" placeholder="HCO3-">
+                                        <span class="input-group-text">mg/L</span>
+                                    </div>
+                                </div>
+                            </div>
+
+                            <div class="row">
+                                <?php
+                                $elements = [
+                                    ['n',  'Nitrogen',   10000],
+                                    ['p',  'Phosphorus', 10000],
+                                    ['k',  'Potassium',  10000],
+                                    ['s',  'Sulphur',    10000],
+                                    ['mg', 'Magnesium',  10000],
+                                    ['ca', 'Calcium',    10000],
+                                ];
+                                foreach ($elements as [$id, $label, $factor]): ?>
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted"><?= htmlspecialchars($label, ENT_QUOTES, 'UTF-8') ?></small>
+                                    <div class="input-group input-group-sm mb-3">
+                                        <input type="text" class="form-control form-control-sm"
+                                               name="<?= $id ?>" id="<?= $id ?>"
+                                               placeholder="<?= htmlspecialchars($id . ' - ' . $label, ENT_QUOTES, 'UTF-8') ?>">
+                                        <input class="btn btn-append" type="button"
+                                               id="btn_<?= $id ?>" value="ppm"
+                                               onclick="conversion(this, document.getElementById('<?= $id ?>'), <?= $factor ?>)">
+                                    </div>
+                                </div>
+                                <?php endforeach; ?>
+                            </div>
+
+                            <div class="row">
+                                <?php
+                                $elements2 = [
+                                    ['na', 'Sodium',    10000],
+                                    ['fe', 'Iron',      10000],
+                                    ['mn', 'Manganese', 10000],
+                                    ['zn', 'Zinc',      10000],
+                                    ['cu', 'Copper',    10000],
+                                    ['b',  'Boron',     10000],
+                                ];
+                                foreach ($elements2 as [$id, $label, $factor]): ?>
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted"><?= htmlspecialchars($label, ENT_QUOTES, 'UTF-8') ?></small>
+                                    <div class="input-group input-group-sm mb-3">
+                                        <input type="text" class="form-control form-control-sm"
+                                               name="<?= $id ?>" id="<?= $id ?>"
+                                               placeholder="<?= htmlspecialchars($id . ' - ' . $label, ENT_QUOTES, 'UTF-8') ?>">
+                                        <input class="btn btn-append" type="button"
+                                               id="btn_<?= $id ?>" value="ppm"
+                                               onclick="conversion(this, document.getElementById('<?= $id ?>'), <?= $factor ?>)">
+                                    </div>
+                                </div>
+                                <?php endforeach; ?>
+                            </div>
+
+                            <div class="row">
+                                <?php
+                                $elements3 = [
+                                    ['m',  'Molybdenum', 10000],
+                                    ['co', 'Cobalt',     10000],
+                                    ['se', 'Selenium',   10000],
+                                    ['ch', 'Chloride',   10000],
+                                ];
+                                foreach ($elements3 as [$id, $label, $factor]): ?>
+                                <div class="col-md-2">
+                                    <small class="form-text text-muted"><?= htmlspecialchars($label, ENT_QUOTES, 'UTF-8') ?></small>
+                                    <div class="input-group input-group-sm mb-3">
+                                        <input type="text" class="form-control form-control-sm"
+                                               name="<?= $id ?>" id="<?= $id ?>"
+                                               placeholder="<?= htmlspecialchars($id . ' - ' . $label, ENT_QUOTES, 'UTF-8') ?>">
+                                        <input class="btn btn-append" type="button"
+                                               id="btn_<?= $id ?>" value="ppm"
+                                               onclick="conversion(this, document.getElementById('<?= $id ?>'), <?= $factor ?>)">
+                                    </div>
+                                </div>
+                                <?php endforeach; ?>
+                            </div>
+
+                            <button type="submit" class="btn btn-success">Submit</button>
+                        </form>
+
+                        <?php include __DIR__ . '/../../../components/newClientModal.php'; ?>
+
+                        <hr>
+
+                        <div class="card mt-3">
+                            <div class="card-body">
+                                <h5 class="card-title">Excel/CSV Upload</h5>
+                                <p class="card-text">Download a CSV of this form for easy filling or upload a filled form to pre-populate.</p>
+                                <div class="input-group mt-3">
+                                    <input type="file" class="form-control" id="upload" accept=".csv">
+                                    <button class="btn btn-success" type="button" id="download">Download</button>
+                                </div>
+                            </div>
+                        </div>
+
+                    </div>
+                </div>
+            </div>
+        </main>
+
+        <?php include __DIR__ . '/../../../layouts/footer.php'; ?>
+    </div>
+</div>
+
+<script>
+function conversion(btnEl, element, factor) {
+    var val = parseFloat(element.value) || 0;
+    if (btnEl.value === 'ppm') {
+        btnEl.value = '%';
+        element.value = (val / factor).toFixed(4);
+    } else {
+        btnEl.value = 'ppm';
+        element.value = (val * factor).toFixed(2);
+    }
+}
+
+// CSV download
+document.getElementById('download').addEventListener('click', function () {
+    var data = [['id', 'value']];
+    document.querySelectorAll('#WatercsvForm input:not([type=hidden]):not([type=button]):not([type=submit]), #WatercsvForm select').forEach(function (el) {
+        if (el.id) data.push([el.id, el.value]);
+    });
+    var csv = data.map(function (r) { return r.join(','); }).join('\n');
+    var today = new Date();
+    var fname = today.getDate() + '' + (today.getMonth() + 1) + '' + today.getFullYear() + '-water.csv';
+    var link = document.createElement('a');
+    link.setAttribute('href', 'data:text/csv;charset=utf-8,' + encodeURIComponent(csv));
+    link.setAttribute('download', fname);
+    link.click();
+});
+
+// CSV upload
+document.getElementById('upload').addEventListener('change', function (e) {
+    var file = e.target.files[0];
+    if (!file) return;
+    var reader = new FileReader();
+    reader.onload = function (ev) {
+        ev.target.result.split('\n').slice(1).forEach(function (line) {
+            var parts = line.split(',');
+            var el = document.getElementById(parts[0]);
+            if (el) el.value = parts[1] || '';
+        });
+    };
+    reader.readAsText(file);
+});
+
+// Bootstrap validation
+(function () {
+    'use strict';
+    document.querySelectorAll('.needs-validation').forEach(function (form) {
+        form.addEventListener('submit', function (event) {
+            if (!form.checkValidity()) {
+                event.preventDefault();
+                event.stopPropagation();
+            }
+            form.classList.add('was-validated');
+        }, false);
+    });
+})();
+</script>

+ 0 - 262
dashboard/crop-analysis/water-test-data/water-test-data.php

@@ -1,262 +0,0 @@
-<?php
-require_once __DIR__ . '/../../../config/database.php';
-require_once __DIR__ . '/../../../lib/auth.php';
-require_once __DIR__ . '/../../../lib/csrf.php';
-
-if (session_status() === PHP_SESSION_NONE) {
-    session_start();
-}
-
-requireLogin();
-
-$pageTitle = 'Water Test Analysis';
-$siteName  = 'Crop Monitor';
-
-include __DIR__ . '/../../../layouts/header.php';
-include __DIR__ . '/../../../layouts/navbar.php';
-?>
-
-<style>
-    .btn-append {
-        color: #495057;
-        background-color: #e9ecef;
-        border: 1px solid #ced4da;
-    }
-</style>
-
-<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">
-                <h1 class="mt-4"><?= htmlspecialchars($pageTitle, ENT_QUOTES, 'UTF-8') ?></h1>
-                <ol class="breadcrumb mb-4">
-                    <li class="breadcrumb-item"><a href="/dashboard/dashboard.php">Dashboard</a></li>
-                    <li class="breadcrumb-item active">Water Test Analysis</li>
-                </ol>
-
-                <div class="row">
-                    <div class="container">
-                        <h3>Water Test Details</h3>
-                        <span class="text-danger small">* required fields.</span>
-
-                        <?php include __DIR__ . '/../../../components/clientDetailsForm.php'; ?>
-
-                        <form method="post" action="/controllers/waterTestSubmit.php" id="WatercsvForm" class="needs-validation" novalidate>
-                            <input type="hidden" name="csrf_token" value="<?= htmlspecialchars(generateCsrfToken(), ENT_QUOTES, 'UTF-8') ?>">
-
-                            <hr>
-                            <div class="row">
-                                <div class="col">
-                                    <small class="form-text text-muted">Lab No</small>
-                                    <input type="text" class="form-control form-control-sm" name="lab_no" id="lab_no" placeholder="Lab No">
-                                </div>
-
-                                <div class="col">
-                                    <small class="form-text text-muted">Batch No</small>
-                                    <input type="text" class="form-control form-control-sm" name="batch_no" id="batch_no" placeholder="Batch No">
-                                </div>
-
-                                <div class="col">
-                                    <small class="form-text text-muted">Date Sampled</small>
-                                    <input type="date" class="form-control form-control-sm" name="date_sampled" id="date_sampled" placeholder="Date Sampled">
-                                </div>
-
-                                <div class="col">
-                                    <small class="form-text text-muted">Sample ID <span class="text-danger">*</span></small>
-                                    <input type="text" class="form-control form-control-sm" name="sample_id" id="sample_id" placeholder="Sample Id" required>
-                                </div>
-
-                                <div class="col">
-                                    <small class="form-text text-muted">Site ID</small>
-                                    <input type="text" class="form-control form-control-sm" name="site_id" id="site_id" placeholder="Paddock Id">
-                                </div>
-                            </div>
-
-                            <hr>
-                            <label class="col"><b>Analysis Inputs</b></label>
-
-                            <div class="row mt-2">
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted">pH <span class="text-danger">*</span></small>
-                                    <div class="input-group input-group-sm mb-3">
-                                        <input type="text" class="form-control form-control-sm" name="ph" id="ph" placeholder="pH" required>
-                                        <span class="input-group-text">pH</span>
-                                    </div>
-                                </div>
-
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted">Conductivity</small>
-                                    <div class="input-group input-group-sm mb-3">
-                                        <input type="text" class="form-control form-control-sm" name="cond_dsm" id="cond_dsm" placeholder="Conductivity">
-                                        <span class="input-group-text">dS/m</span>
-                                    </div>
-                                </div>
-
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted">Bicarbonate (HCO3-)</small>
-                                    <div class="input-group input-group-sm mb-3">
-                                        <input type="text" class="form-control form-control-sm" name="hco3" id="hco3" placeholder="HCO3-">
-                                        <span class="input-group-text">mg/L</span>
-                                    </div>
-                                </div>
-                            </div>
-
-                            <div class="row">
-                                <?php
-                                $elements = [
-                                    ['n',  'Nitrogen',   10000],
-                                    ['p',  'Phosphorus', 10000],
-                                    ['k',  'Potassium',  10000],
-                                    ['s',  'Sulphur',    10000],
-                                    ['mg', 'Magnesium',  10000],
-                                    ['ca', 'Calcium',    10000],
-                                ];
-                                foreach ($elements as [$id, $label, $factor]): ?>
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted"><?= htmlspecialchars($label, ENT_QUOTES, 'UTF-8') ?></small>
-                                    <div class="input-group input-group-sm mb-3">
-                                        <input type="text" class="form-control form-control-sm"
-                                               name="<?= $id ?>" id="<?= $id ?>"
-                                               placeholder="<?= htmlspecialchars($id . ' - ' . $label, ENT_QUOTES, 'UTF-8') ?>">
-                                        <input class="btn btn-append" type="button"
-                                               id="btn_<?= $id ?>" value="ppm"
-                                               onclick="conversion(this, document.getElementById('<?= $id ?>'), <?= $factor ?>)">
-                                    </div>
-                                </div>
-                                <?php endforeach; ?>
-                            </div>
-
-                            <div class="row">
-                                <?php
-                                $elements2 = [
-                                    ['na', 'Sodium',    10000],
-                                    ['fe', 'Iron',      10000],
-                                    ['mn', 'Manganese', 10000],
-                                    ['zn', 'Zinc',      10000],
-                                    ['cu', 'Copper',    10000],
-                                    ['b',  'Boron',     10000],
-                                ];
-                                foreach ($elements2 as [$id, $label, $factor]): ?>
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted"><?= htmlspecialchars($label, ENT_QUOTES, 'UTF-8') ?></small>
-                                    <div class="input-group input-group-sm mb-3">
-                                        <input type="text" class="form-control form-control-sm"
-                                               name="<?= $id ?>" id="<?= $id ?>"
-                                               placeholder="<?= htmlspecialchars($id . ' - ' . $label, ENT_QUOTES, 'UTF-8') ?>">
-                                        <input class="btn btn-append" type="button"
-                                               id="btn_<?= $id ?>" value="ppm"
-                                               onclick="conversion(this, document.getElementById('<?= $id ?>'), <?= $factor ?>)">
-                                    </div>
-                                </div>
-                                <?php endforeach; ?>
-                            </div>
-
-                            <div class="row">
-                                <?php
-                                $elements3 = [
-                                    ['m',  'Molybdenum', 10000],
-                                    ['co', 'Cobalt',     10000],
-                                    ['se', 'Selenium',   10000],
-                                    ['ch', 'Chloride',   10000],
-                                ];
-                                foreach ($elements3 as [$id, $label, $factor]): ?>
-                                <div class="col-md-2">
-                                    <small class="form-text text-muted"><?= htmlspecialchars($label, ENT_QUOTES, 'UTF-8') ?></small>
-                                    <div class="input-group input-group-sm mb-3">
-                                        <input type="text" class="form-control form-control-sm"
-                                               name="<?= $id ?>" id="<?= $id ?>"
-                                               placeholder="<?= htmlspecialchars($id . ' - ' . $label, ENT_QUOTES, 'UTF-8') ?>">
-                                        <input class="btn btn-append" type="button"
-                                               id="btn_<?= $id ?>" value="ppm"
-                                               onclick="conversion(this, document.getElementById('<?= $id ?>'), <?= $factor ?>)">
-                                    </div>
-                                </div>
-                                <?php endforeach; ?>
-                            </div>
-
-                            <button type="submit" class="btn btn-success">Submit</button>
-                        </form>
-
-                        <?php include __DIR__ . '/../../../components/newClientModal.php'; ?>
-
-                        <hr>
-
-                        <div class="card mt-3">
-                            <div class="card-body">
-                                <h5 class="card-title">Excel/CSV Upload</h5>
-                                <p class="card-text">Download a CSV of this form for easy filling or upload a filled form to pre-populate.</p>
-                                <div class="input-group mt-3">
-                                    <input type="file" class="form-control" id="upload" accept=".csv">
-                                    <button class="btn btn-success" type="button" id="download">Download</button>
-                                </div>
-                            </div>
-                        </div>
-
-                    </div>
-                </div>
-            </div>
-        </main>
-
-        <?php include __DIR__ . '/../../../layouts/footer.php'; ?>
-    </div>
-</div>
-
-<script>
-function conversion(btnEl, element, factor) {
-    var val = parseFloat(element.value) || 0;
-    if (btnEl.value === 'ppm') {
-        btnEl.value = '%';
-        element.value = (val / factor).toFixed(4);
-    } else {
-        btnEl.value = 'ppm';
-        element.value = (val * factor).toFixed(2);
-    }
-}
-
-// CSV download
-document.getElementById('download').addEventListener('click', function () {
-    var data = [['id', 'value']];
-    document.querySelectorAll('#WatercsvForm input:not([type=hidden]):not([type=button]):not([type=submit]), #WatercsvForm select').forEach(function (el) {
-        if (el.id) data.push([el.id, el.value]);
-    });
-    var csv = data.map(function (r) { return r.join(','); }).join('\n');
-    var today = new Date();
-    var fname = today.getDate() + '' + (today.getMonth() + 1) + '' + today.getFullYear() + '-water.csv';
-    var link = document.createElement('a');
-    link.setAttribute('href', 'data:text/csv;charset=utf-8,' + encodeURIComponent(csv));
-    link.setAttribute('download', fname);
-    link.click();
-});
-
-// CSV upload
-document.getElementById('upload').addEventListener('change', function (e) {
-    var file = e.target.files[0];
-    if (!file) return;
-    var reader = new FileReader();
-    reader.onload = function (ev) {
-        ev.target.result.split('\n').slice(1).forEach(function (line) {
-            var parts = line.split(',');
-            var el = document.getElementById(parts[0]);
-            if (el) el.value = parts[1] || '';
-        });
-    };
-    reader.readAsText(file);
-});
-
-// Bootstrap validation
-(function () {
-    'use strict';
-    document.querySelectorAll('.needs-validation').forEach(function (form) {
-        form.addEventListener('submit', function (event) {
-            if (!form.checkValidity()) {
-                event.preventDefault();
-                event.stopPropagation();
-            }
-            form.classList.add('was-validated');
-        }, false);
-    });
-})();
-</script>

+ 16 - 16
layouts/sidebar.php

@@ -20,13 +20,13 @@ $isActive = fn(string $href): string =>
     str_starts_with($currentPath, $href) ? ' active' : '';
 
 /**
- * Return 'show' if any child href is active (keeps accordion open on load).
+ * Return true if any child href matches the current path.
  */
-$groupActive = function (array $children) use ($currentPath): string {
+$groupActive = function (array $children) use ($currentPath): bool {
     foreach ($children as $child) {
-        if (str_starts_with($currentPath, $child)) return ' show';
+        if (str_starts_with($currentPath, $child)) return true;
     }
-    return '';
+    return false;
 };
 
 // Child paths per collapsible group — used to keep the right group open
@@ -68,7 +68,7 @@ $settingsChildren  = [
             </a>
 
             <!-- Weather (collapsible) -->
-            <a class="nav-link collapsed<?= $groupActive($weatherChildren) ?>"
+            <a class="nav-link<?= $groupActive($weatherChildren) ? '' : ' collapsed' ?>"
                href="#"
                data-bs-toggle="collapse"
                data-bs-target="#collapseWeather"
@@ -82,7 +82,7 @@ $settingsChildren  = [
                     <i class="fas fa-angle-down"></i>
                 </div>
             </a>
-            <div class="collapse<?= $groupActive($weatherChildren) ?>"
+            <div class="collapse<?= $groupActive($weatherChildren) ? ' show' : '' ?>"
                  id="collapseWeather"
                  data-bs-parent="#sidenavAccordion">
                 <nav class="sb-sidenav-menu-nested nav">
@@ -111,7 +111,7 @@ $settingsChildren  = [
             </a>
 
             <!-- Crop Analysis (collapsible) -->
-            <a class="nav-link collapsed<?= $groupActive($cropChildren) ?>"
+            <a class="nav-link<?= $groupActive($cropChildren) ? '' : ' collapsed' ?>"
                href="#"
                data-bs-toggle="collapse"
                data-bs-target="#collapseCropAnalysis"
@@ -125,31 +125,31 @@ $settingsChildren  = [
                     <i class="fas fa-angle-down"></i>
                 </div>
             </a>
-            <div class="collapse<?= $groupActive($cropChildren) ?>"
+            <div class="collapse<?= $groupActive($cropChildren) ? ' show' : '' ?>"
                  id="collapseCropAnalysis"
                  data-bs-parent="#sidenavAccordion">
                 <nav class="sb-sidenav-menu-nested nav">
                     <a class="nav-link<?= $isActive('/dashboard/crop-analysis/soil-test-data/') ?>"
-                       href="/dashboard/crop-analysis/soil-test-data/soil-test-data.php">
+                       href="/dashboard/crop-analysis/soil-test-data/index.php">
                         <i class="fas fa-globe-asia nav_icon"></i>&nbsp;Soil Test Data
                     </a>
                     <a class="nav-link<?= $isActive('/dashboard/crop-analysis/plant-test-data/') ?>"
-                       href="/dashboard/crop-analysis/plant-test-data/">
+                       href="/dashboard/crop-analysis/plant-test-data/index.php">
                         <i class="fab fa-pagelines nav_icon"></i>&nbsp;Plant Test Data
                     </a>
                     <a class="nav-link<?= $isActive('/dashboard/crop-analysis/water-test-data/') ?>"
-                       href="/dashboard/crop-analysis/water-test-data/">
+                       href="/dashboard/crop-analysis/water-test-data/index.php">
                         <i class="fa fa-tint nav_icon"></i>&nbsp;Water Test Data
                     </a>
                     <a class="nav-link<?= $isActive('/dashboard/crop-analysis/animal-dietary-balance/') ?>"
-                       href="/dashboard/crop-analysis/animal-dietary-balance/">
+                       href="/dashboard/crop-analysis/animal-dietary-balance/index.php">
                         <i class="fas fa-dog nav_icon"></i>&nbsp;Animal Dietary Balance
                     </a>
                     <a class="nav-link<?= $isActive('/dashboard/crop-analysis/compost-test-data/') ?>"
-                       href="/dashboard/crop-analysis/compost-test-data/">
+                       href="/dashboard/crop-analysis/compost-test-data/index.php">
                         <i class="fas fa-cloud nav_icon"></i>&nbsp;Compost Test Data
                     </a>
-                </nav>
+                </nav>s
             </div>
 
             <!-- Irrigation Controller -->
@@ -162,7 +162,7 @@ $settingsChildren  = [
             </a>
 
             <!-- Client Settings (collapsible) -->
-            <a class="nav-link collapsed<?= $groupActive($settingsChildren) ?>"
+            <a class="nav-link<?= $groupActive($settingsChildren) ? '' : ' collapsed' ?>"
                href="#"
                data-bs-toggle="collapse"
                data-bs-target="#collapseSettings"
@@ -176,7 +176,7 @@ $settingsChildren  = [
                     <i class="fas fa-angle-down"></i>
                 </div>
             </a>
-            <div class="collapse<?= $groupActive($settingsChildren) ?>"
+            <div class="collapse<?= $groupActive($settingsChildren) ? ' show' : '' ?>"
                  id="collapseSettings"
                  data-bs-parent="#sidenavAccordion">
                 <nav class="sb-sidenav-menu-nested nav">