|
@@ -1,18 +1,65 @@
|
|
|
-<!doctype html>
|
|
|
|
|
-<html lang="en">
|
|
|
|
|
- <head>
|
|
|
|
|
- <title>[[*longtitle]] | [[++site_name]]</title>
|
|
|
|
|
- <base href="[[!++site_url]]" >
|
|
|
|
|
- <meta charset="[[++modx_charset]]" >
|
|
|
|
|
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" >
|
|
|
|
|
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
|
|
|
|
|
- <meta name="keywords" content="[[*introtext]]" >
|
|
|
|
|
- <meta name="description" content="[[*description]]" >
|
|
|
|
|
-
|
|
|
|
|
- [[!Profile]]
|
|
|
|
|
-
|
|
|
|
|
- <link rel="icon" href="client-assets/images/favicon.ico?v=2" type="image/x-icon" >
|
|
|
|
|
-
|
|
|
|
|
|
|
+<?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';
|
|
|
|
|
+
|
|
|
|
|
+if (session_status() === PHP_SESSION_NONE) {
|
|
|
|
|
+ session_start();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+requireLogin();
|
|
|
|
|
+
|
|
|
|
|
+$client_id = (int)($_GET['cid'] ?? 0);
|
|
|
|
|
+$record_id = (int)($_GET['rid'] ?? 0);
|
|
|
|
|
+$rand_id = (float)($_GET['rand'] ?? 0);
|
|
|
|
|
+
|
|
|
|
|
+if (!$record_id || !$rand_id) {
|
|
|
|
|
+ http_response_code(400);
|
|
|
|
|
+ die('Invalid request parameters');
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+try {
|
|
|
|
|
+ $pdo = getDBConnection();
|
|
|
|
|
+ $stmt = $pdo->prepare("SELECT * FROM soil_records WHERE id = ? AND rand = ?");
|
|
|
|
|
+ $stmt->execute([$record_id, $rand_id]);
|
|
|
|
|
+ $row = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
|
+
|
|
|
|
|
+ if (!$row) {
|
|
|
|
|
+ http_response_code(404);
|
|
|
|
|
+ die('Soil record not found');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $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');
|
|
|
|
|
+
|
|
|
|
|
+} catch (PDOException $e) {
|
|
|
|
|
+ error_log("Database error in soil-report.php: " . $e->getMessage());
|
|
|
|
|
+ die('Database error occurred');
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+$today = date('jS F Y');
|
|
|
|
|
+$pageTitle = 'Soil Report - ' . ($client ?: 'Crop Monitoring');
|
|
|
|
|
+$siteName = 'Crop Management Platform';
|
|
|
|
|
+$activeItem = 'Soil Report';
|
|
|
|
|
+
|
|
|
|
|
+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">
|
|
|
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
|
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
|
|
|
|
|
|
|
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous" rel="stylesheet" type="text/css" />
|
|
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous" rel="stylesheet" type="text/css" />
|
|
@@ -59,10 +106,25 @@
|
|
|
<body>
|
|
<body>
|
|
|
<div class="container">
|
|
<div class="container">
|
|
|
<div class="row">
|
|
<div class="row">
|
|
|
- [[!logoHeader]]
|
|
|
|
|
|
|
+ <div class="col-md-3">
|
|
|
|
|
+ <img class="img-fluid" src="/client-assets/images/crop-monitor.png" alt="Crop Monitor">
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="col-md-9">
|
|
|
|
|
+ <h4 class="mt-2">Soil Analysis for <?php echo $client; ?></h4>
|
|
|
|
|
+ <p><strong>Sample:</strong> <?php echo $sample; ?> | <strong>Date:</strong> <?php echo $sampleDate; ?></p>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
- [[!soilAnalysisClient]]
|
|
|
|
|
|
|
+ <!-- display client metadata -->
|
|
|
|
|
+ <div class="row">
|
|
|
|
|
+ <div class="col-md-12">
|
|
|
|
|
+ <table class="table table-sm table-borderless">
|
|
|
|
|
+ <tr><th>Address</th><td><?php echo $address; ?></td><th>State/Postcode</th><td><?php echo $state; ?></td></tr>
|
|
|
|
|
+ <tr><th>Email</th><td><?php echo $email; ?></td><th>Lab Number</th><td><?php echo $labNo; ?></td></tr>
|
|
|
|
|
+ <tr><th>Crop</th><td><?php echo $crop; ?></td><th>Test Date</th><td><?php echo $sampleDate; ?></td></tr>
|
|
|
|
|
+ </table>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
|
|
|
<!-- Graph Button -->
|
|
<!-- Graph Button -->
|
|
|
<div class="d-print-none">
|
|
<div class="d-print-none">
|
|
@@ -87,24 +149,21 @@
|
|
|
<div class="text-center h5">Total kilograms per hectare of each element needed to balance soil in this test</div>
|
|
<div class="text-center h5">Total kilograms per hectare of each element needed to balance soil in this test</div>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="card-group">
|
|
<div class="card-group">
|
|
|
- [[!soilAnalysisReportCalcs? &symbol=`Ca` &element=`BS_ca_ppm` &min=`ca_ppm_min` &max=`ca_ppm_max` &nutrient=`Calcium` &type=`kg`]]
|
|
|
|
|
- [[!soilAnalysisReportCalcs? &symbol=`Mg` &element=`BS_mg_ppm` &min=`mg_ppm_min` &max=`mg_ppm_max` &nutrient=`Magnesium` &type=`kg`]]
|
|
|
|
|
- [[!soilAnalysisReportCalcs? &symbol=`K` &element=`BS_k_ppm` &min=`k_ppm_min` &max=`k_ppm_max` &nutrient=`Potasium` &type=`kg`]]
|
|
|
|
|
- [[!soilAnalysisReportCalcs? &symbol=`Na` &element=`BS_na_ppm` &min=`na_ppm_min` &max=`na_ppm_max` &nutrient=`Sodium` &type=`kg`]]
|
|
|
|
|
- [[!soilAnalysisReportCalcs? &symbol=`P` &element=`p_colwell` &min=`` &max=`` &nutrient=`Phosphate` &type=`kg`]]
|
|
|
|
|
- [[!soilAnalysisReportCalcs? &symbol=`S` &element=`s_morgan` &min=`` &max=`` &nutrient=`Sulfur` &type=`kg`]]
|
|
|
|
|
- [[!soilAnalysisReportCalcs? &symbol=`Mn` &element=`mn_dtpa` &min=`` &max=`` &nutrient=`Manganese` &type=`kg`]]
|
|
|
|
|
- [[!soilAnalysisReportCalcs? &symbol=`Fe` &element=`fe_dtpa` &min=`` &max=`` &nutrient=`Iron` &type=`kg`]]
|
|
|
|
|
- [[!soilAnalysisReportCalcs? &symbol=`Zn` &element=`zn_dtpa` &min=`` &max=`` &nutrient=`Zinc` &type=`kg`]]
|
|
|
|
|
- [[!soilAnalysisReportCalcs? &symbol=`Cu` &element=`cu_dtpa` &min=`` &max=`` &nutrient=`Copper` &type=`kg`]]
|
|
|
|
|
- [[!soilAnalysisReportCalcs? &symbol=`AmN` &element=`NH3_N` &min=`` &max=`` &nutrient=`AmNitrogen` &type=`kg`]]
|
|
|
|
|
- [[!soilAnalysisReportCalcs? &symbol=`B` &element=`b_cacl2` &min=`` &max=`` &nutrient=`Boron` &type=`kg`]]
|
|
|
|
|
- [[!soilAnalysisReportCalcs? &symbol=`NN` &element=`NO3_N` &min=`` &max=`` &nutrient=`NNitrogen` &type=`kg`]]
|
|
|
|
|
- </div>
|
|
|
|
|
- <hr>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <!-- **************** START OF FORM DATA **************** -->
|
|
|
|
|
|
|
+ <?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);
|
|
|
|
|
+ ?>
|
|
|
<form class="report-form" method="post">
|
|
<form class="report-form" method="post">
|
|
|
<input class="" hidden type="text" name="id" id="id" value="[[+modx.user.id]]" >
|
|
<input class="" hidden type="text" name="id" id="id" value="[[+modx.user.id]]" >
|
|
|
|
|
|
|
@@ -123,9 +182,11 @@
|
|
|
</div>
|
|
</div>
|
|
|
<div class="card">
|
|
<div class="card">
|
|
|
<div class="card-body">
|
|
<div class="card-body">
|
|
|
- [[!soilProgramCalcs? &symbol=`Ca` &element=`BS_ca_ppm` &min=`ca_ppm_min` &max=`ca_ppm_max` &nutrient=`Calcium` &type=`kg`]]
|
|
|
|
|
- [[!soilProgramCalcs? &symbol=`Ca` &element=`BS_ca_ppm` &min=`ca_ppm_min` &max=`ca_ppm_max` &nutrient=`Calcium` &type=`kg`]]
|
|
|
|
|
- [[!soilProgramCalcs? &symbol=`Ca` &element=`BS_ca_ppm` &min=`ca_ppm_min` &max=`ca_ppm_max` &nutrient=`Calcium` &type=`kg`]]
|
|
|
|
|
|
|
+ <?php
|
|
|
|
|
+ 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>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|