|
|
@@ -1,811 +1,503 @@
|
|
|
-<!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]]">
|
|
|
- <link rel="icon" href="client-assets/images/favicon.ico?v=2" type="image/x-icon"> [[!Profile]]
|
|
|
-
|
|
|
- <script type="text/javascript">
|
|
|
- window.dataLayer = window.dataLayer || [];
|
|
|
-
|
|
|
- function gtag() {
|
|
|
- dataLayer.push(arguments);
|
|
|
- }
|
|
|
- gtag('js', new Date());
|
|
|
- gtag('set', {
|
|
|
- 'user_id': '[[+modx.user.id]]'
|
|
|
- }); // Set the user ID using signed-in user_id.
|
|
|
- gtag('config', 'UA-133963301-1');
|
|
|
- </script>
|
|
|
-
|
|
|
- <link href="https://cdn.jsdelivr.net/npm/simple-datatables@latest/dist/style.css" rel="stylesheet" />
|
|
|
- <link href="client-assets/css/dashboard-2021.css" rel="stylesheet" />
|
|
|
- <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/js/all.min.js" crossorigin="anonymous"></script>
|
|
|
- <link href="https://cdn.datatables.net/1.10.20/css/dataTables.bootstrap4.min.css" rel="stylesheet" crossorigin="anonymous" />
|
|
|
- <script src="client-assets/js/skycons.js"></script>
|
|
|
- <style>
|
|
|
- .btn-append {
|
|
|
- color: #495057;
|
|
|
- background-color: #e9ecef;
|
|
|
- border: 1px solid #ced4da;
|
|
|
- }
|
|
|
- .footer {
|
|
|
- position: absolute;
|
|
|
- bottom: 0;
|
|
|
- width: 100%;
|
|
|
- height: 60px;
|
|
|
- line-height: 60px;
|
|
|
- }
|
|
|
- </style>
|
|
|
-</head>
|
|
|
-
|
|
|
-<body class="sb-nav-fixed" id="page-top">
|
|
|
- [[!Personalize?
|
|
|
- &yesChunk=`navHeaderLogged`
|
|
|
- &noChunk=`navHeader`
|
|
|
- &allowedGroups=`basicClients,bacicAdmin,companyClients,companyManagers`
|
|
|
- ]]
|
|
|
-
|
|
|
- <div id="layoutSidenav">
|
|
|
- <div id="layoutSidenav_nav">
|
|
|
- <!-- Sidebar -->
|
|
|
- [[Wayfinder?
|
|
|
- &startId=`2`
|
|
|
- &displayStart=`0`
|
|
|
- &startitemTpl=`startitemTpl`
|
|
|
- &selfClass=`show`
|
|
|
- &level=`2`
|
|
|
- &outerTpl=`outer`
|
|
|
- &outerClass=`sb-sidenav accordion sb-sidenav-dark`
|
|
|
- &rowTpl=`row`
|
|
|
- &rowClass=`nav-link`
|
|
|
- &parentRowTpl=`parentRow`
|
|
|
- &parentClass=`nav-link collapsed`
|
|
|
- &innerTpl=`inner`
|
|
|
- &innerClass=`collapse`
|
|
|
- &innerRowTpl=`secondInner`
|
|
|
- &innerRowClass=`nav-link`
|
|
|
- ]]
|
|
|
- </div>
|
|
|
-
|
|
|
- <div id="layoutSidenav_content">
|
|
|
- <main>
|
|
|
-
|
|
|
- <div class="container-fluid px-4">
|
|
|
- <h1 class="mt-4">[[*pagetitle]]</h1>
|
|
|
-
|
|
|
- <ol class="breadcrumb mb-4"> [[$dash-breadcrumbs]] </ol>
|
|
|
-
|
|
|
- <div class="row">
|
|
|
- <div class="container-fluid">
|
|
|
- <div class="row">
|
|
|
- <div class="col">
|
|
|
- <h2>[[*pagetitle]]</h2>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <!--grid-->
|
|
|
- <div class="row">
|
|
|
- <div class="col-12 col-md-3">
|
|
|
-
|
|
|
- <div class="row">
|
|
|
- <div class="col">
|
|
|
- <form action="#" method="GET">
|
|
|
- <div class="input-group mb-3">
|
|
|
- <input type="text" class="form-control" aria-label="Recipient's username" aria-describedby="basic-addon2" placeholder="Search...">
|
|
|
- <div class="input-group-append">
|
|
|
- <span class="input-group-text" id="basic-addon2"><i class="fa fa-search"></i></span>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <!-- Input Group -->
|
|
|
- </form>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="row ">
|
|
|
- <div class="col">
|
|
|
- <div class="alert alert-danger" role="alert">
|
|
|
- <h3>[[*longtitle]]</h3>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="row ">
|
|
|
- <div class="col">
|
|
|
- <div class="list-group">
|
|
|
- <a href="#" class="list-group-item list-group-item-action"> Folders
|
|
|
- </a>
|
|
|
- <a href="#" class="list-group-item list-group-item-action list-group-item-light text-warning">
|
|
|
- <i class="fa fa-archive text-warning" aria-hidden="true"></i> Archived
|
|
|
- <span class="badge badge-warning badge-pill float-right">[[!analysisCount? &analysis=`block_info` &cid=`[[+id]]` &status=`2` ]]</span>
|
|
|
- </a>
|
|
|
- <a href="#" class="list-group-item list-group-item-action list-group-item-light text-danger">
|
|
|
- <i class="fa fa-trash text-danger" aria-hidden="true"></i> Deleted
|
|
|
- <span class="badge badge-danger badge-pill float-right">[[!analysisCount? &analysis=`block_info` &cid=`[[+id]]` &status=`3` ]]</span>
|
|
|
- </a>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- </div>
|
|
|
-
|
|
|
- <hr>
|
|
|
-
|
|
|
- <!-- tab content -->
|
|
|
- <div class="col-12 col-md-9 ">
|
|
|
- <!-- tab content -->
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- <br>
|
|
|
-
|
|
|
- <div class="row">
|
|
|
- <div class="col">
|
|
|
- <h3>[[*longtitle]]</h3>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="row">
|
|
|
- <div class="col">
|
|
|
- <button type="button" class="btn btn-success" data-toggle="modal" data-target="#createPaddock">Create New Paddock</button>
|
|
|
- <!-- Modal -->
|
|
|
-<div class="modal fade" id="createPaddock" tabindex="-1" role="dialog" aria-labelledby="createPaddock" aria-hidden="true">
|
|
|
- <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
|
|
|
- <div class="modal-content">
|
|
|
- <div class="modal-header">
|
|
|
- <h5 class="modal-title" id="exampleModalLabel">Create Paddock Record</h5>
|
|
|
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
|
- <span aria-hidden="true">×</span>
|
|
|
- </button>
|
|
|
- </div>
|
|
|
- <div class="modal-body">
|
|
|
-
|
|
|
- <?php
|
|
|
-error_reporting(E_ALL);
|
|
|
-ini_set('display_errors', 1);
|
|
|
-
|
|
|
-if(isset($_POST['submit'])) {
|
|
|
-
|
|
|
- $sql = null;
|
|
|
- //$con = mysqli_connect("localhost", "root", "R3M0T31", "cropmonitor");
|
|
|
- $con = mysqli_connect("localhost", "cropmonitor", "brvnCcaEYxlPCS3", "cropmonitor");
|
|
|
-
|
|
|
- //set todays date
|
|
|
- $date_added = date("Y-m-d H:i:s");
|
|
|
-
|
|
|
- //Get figures
|
|
|
- $modx_user_id = (isset($_POST["m_user"])) ? $_POST["m_user"] : "";
|
|
|
-
|
|
|
- $client_name = (isset($_POST["name"])) ? $_POST["name"] : "";
|
|
|
- $site_address = (isset($_POST["site_address"])) ? $_POST["site_address"] : "";
|
|
|
-
|
|
|
- $site_id = (isset($_POST["site_id"])) ? $_POST["site_id"] : "";
|
|
|
-
|
|
|
- $soil_type = (isset($_POST["analysis_type"])) ? $_POST["analysis_type"] : ""; //need to fix form to say soil_type not analysis_type
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /* ********* END ********* */
|
|
|
-
|
|
|
- // Check connection
|
|
|
- if (mysqli_connect_errno()) {
|
|
|
- echo "Failed to connect to MySQL: " . mysqli_connect_error();
|
|
|
- }
|
|
|
-
|
|
|
- $sql = mysqli_query($con, "INSERT into `block_info`
|
|
|
- (
|
|
|
- modx_user_id,
|
|
|
- date_added,
|
|
|
- area,
|
|
|
- block_id
|
|
|
- ) VALUES (
|
|
|
- '" . $modx_user_id . "',
|
|
|
- '" . $date_added . "',
|
|
|
- '" . $area . "',
|
|
|
- '" . $block_id . "'
|
|
|
- )" );
|
|
|
-
|
|
|
- $insert_id = mysqli_insert_id($con);
|
|
|
-
|
|
|
-
|
|
|
- if ($sql === TRUE)
|
|
|
- {
|
|
|
- //echo "success"; //CHECKING
|
|
|
- // forward to results page if successfully inserts to database [[~32]]
|
|
|
- echo "";
|
|
|
- } else {
|
|
|
- die(mysqli_error($con)); // TODO: better error handling
|
|
|
- //echo "User Profile incorrect";
|
|
|
- }
|
|
|
-}
|
|
|
-?>
|
|
|
-
|
|
|
- <form method="post" action="[~[*id*]~]" id="createPaddock" novalidate>
|
|
|
-
|
|
|
- <input type="text" class="form-control" id="modx_user" value="[[+user]]" hidden>
|
|
|
- <input type="text" class="form-control" id="mid" value="[[+id]]" hidden>
|
|
|
-
|
|
|
- <h6>Block Identification</h6>
|
|
|
- <div class="form-row">
|
|
|
- <div class="col">
|
|
|
- <label for="exampleInputEmail1">Block ID</label>
|
|
|
- <input type="text" class="form-control form-control-sm" id="id" aria-describedby="idHelp" placeholder="Block Id" required>
|
|
|
- <small id="emailHelp" class="form-text text-muted"></small>
|
|
|
- <div class="valid-feedback">Looks good!</div>
|
|
|
- </div>
|
|
|
- <div class="col">
|
|
|
- <label for="exampleInputEmail1">Block Name</label>
|
|
|
- <input type="text" class="form-control form-control-sm" id="name" aria-describedby="idHelp" placeholder="Block Name" required>
|
|
|
- <small id="emailHelp" class="form-text text-muted"></small>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <hr>
|
|
|
- <h6>Location / Sizing</h6>
|
|
|
- <div class="form-group">
|
|
|
- <label for="exampleInputPassword1">Location</label>
|
|
|
- <input type="text" class="form-control form-control-sm" id="location" placeholder="Block Address">
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="form-row">
|
|
|
- <div class="col">
|
|
|
- <label for="exampleInputEmail1">Area</label>
|
|
|
- <input type="number" class="form-control form-control-sm" id="area_ha" aria-describedby="areaHelp" placeholder="Block Size" oninput="areaConverter(this.id,this.value)" onchange="areaConverter(this.value)">
|
|
|
- <small id="areaHelp" class="form-text text-muted">in hectare's</small>
|
|
|
- </div>
|
|
|
- <div class="col">
|
|
|
- <label for="exampleInputEmail1">Area</label>
|
|
|
- <input type="number" class="form-control form-control-sm" id="area_ac" aria-describedby="areaHelp" placeholder="Block Size" oninput="areaConverter(this.id,this.value)" onchange="areaConverter(this.value)">
|
|
|
- <small id="areaHelp" class="form-text text-muted">in acre's</small>
|
|
|
- </div>
|
|
|
- <div class="col">
|
|
|
- <label for="exampleInputEmail1">Block Name</label>
|
|
|
- <input type="text" class="form-control form-control-sm" id="name" aria-describedby="idHelp" placeholder="Block Name">
|
|
|
- <small id="emailHelp" class="form-text text-muted"></small>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <script>
|
|
|
- function areaConverter(source,valNum) {
|
|
|
- valNum = parseFloat(valNum);
|
|
|
- var area_ha = document.getElementById("area_ha");
|
|
|
- var area_ac = document.getElementById("area_ac");
|
|
|
-
|
|
|
- if (source=="area_ha") {
|
|
|
- area_ac.value=(valNum/0.404686).toFixed(2);
|
|
|
- }
|
|
|
- if (source=="area_ac") {
|
|
|
- area_ha.value=(valNum/2.4710559990832).toFixed(2);
|
|
|
- }
|
|
|
- }
|
|
|
- </script>
|
|
|
-
|
|
|
- <hr>
|
|
|
- <h6>Soil Clasification</h6>
|
|
|
- <div class="form-row">
|
|
|
- <div class="col">
|
|
|
- <label for="exampleInputEmail1">Area</label>
|
|
|
- <select class="form-control form-control-sm" name="analysis_type" id="analysis_type" required>
|
|
|
- <option>Select the type of soil...</option>
|
|
|
- <option id="sandy">sandy</option>
|
|
|
- <option id="light">light</option>
|
|
|
- <option id="medium">medium</option>
|
|
|
- <option id="heavy">heavy</option>
|
|
|
- </select>
|
|
|
- </div>
|
|
|
- <div class="col">
|
|
|
- <label for="exampleInputEmail1">Block Name</label>
|
|
|
- <input type="text" class="form-control form-control-sm" id="name" aria-describedby="idHelp" placeholder="Block Name">
|
|
|
- <small id="emailHelp" class="form-text text-muted"></small>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
-
|
|
|
- </div>
|
|
|
- <div class="modal-footer">
|
|
|
- <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
|
|
- <button form="createPaddock" type="submit" class="btn btn-success">Save changes</button>
|
|
|
- </form>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-</div>
|
|
|
-
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <br>
|
|
|
-
|
|
|
-
|
|
|
- <div class="row">
|
|
|
- <div class="col">
|
|
|
- <div class="d-none d-md-block "> <!-- d-lg-none -->
|
|
|
- <div class='form-row'>
|
|
|
- <div class='col-md-1'><input type='text' readonly class='text-center form-control-plaintext font-weight-bold' placeholder='ID' ></div>
|
|
|
- <div class='col-md-1'><input type='text' readonly class='text-center form-control-plaintext font-weight-bold' placeholder='Edit' ></div>
|
|
|
- <div class='col'><input type='text' readonly class='text-center form-control-plaintext font-weight-bold' placeholder='Name' ></div>
|
|
|
- <div class='col-md-1'><input type='text' readonly class='text-center form-control-plaintext font-weight-bold' placeholder='Size' ></div>
|
|
|
- <div class='col-md-2'><input type='text' readonly class='text-center form-control-plaintext font-weight-bold' placeholder='Location' ></div>
|
|
|
- <div class='col-md-2'><input type='text' readonly class='text-center form-control-plaintext font-weight-bold' placeholder='Current Crop' ></div>
|
|
|
- <div class='col-md-1'><input type='text' readonly class='text-center form-control-plaintext font-weight-bold' placeholder='Status' ></div>
|
|
|
- <div class='col-md-1'><input type='text' readonly class='text-center form-control-plaintext font-weight-bold' placeholder='Actions' ></div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- /*[[!blockIdentification? &cid=`[[+id]]` ]]*/
|
|
|
- <?php
|
|
|
-if ($cid) {
|
|
|
- $client_id = $cid; // client number
|
|
|
-} else {
|
|
|
- $client_id = '2'; // client number
|
|
|
+<?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();
|
|
|
}
|
|
|
|
|
|
-$client_id = '2'; // client number
|
|
|
+requireLogin();
|
|
|
|
|
|
-$analysisType = $analysis;
|
|
|
-$icon = $icon;
|
|
|
+$pageTitle = 'Crop Cards';
|
|
|
+$siteName = 'Crop Monitor';
|
|
|
|
|
|
-/*
|
|
|
-Status Table
|
|
|
-0 = Blank
|
|
|
-1 = Read
|
|
|
-2 = Archived
|
|
|
-3 = Deleted
|
|
|
-*/
|
|
|
+$pdo = getDBConnection();
|
|
|
+$userId = getCurrentUserId();
|
|
|
|
|
|
-//Database connection
|
|
|
-//$con = mysqli_connect("localhost", "root", "R3M0T31", "cropmonitor");
|
|
|
-$con = mysqli_connect("localhost", "cropmonitor", "brvnCcaEYxlPCS3", "cropmonitor");
|
|
|
+// ── Block counts for sidebar badges ──────────────────────────────────────────
|
|
|
+$stmtArchived = $pdo->prepare(
|
|
|
+ 'SELECT COUNT(*) FROM block_info WHERE modx_user_id = ? AND status = 2'
|
|
|
+);
|
|
|
+$stmtArchived->execute([$userId]);
|
|
|
+$archivedCount = (int) $stmtArchived->fetchColumn();
|
|
|
|
|
|
-// Check connection
|
|
|
-if (mysqli_connect_errno()) {
|
|
|
- echo "Failed to connect to MySQL: " . mysqli_connect_error();
|
|
|
-}
|
|
|
+$stmtDeleted = $pdo->prepare(
|
|
|
+ 'SELECT COUNT(*) FROM block_info WHERE modx_user_id = ? AND status = 3'
|
|
|
+);
|
|
|
+$stmtDeleted->execute([$userId]);
|
|
|
+$deletedCount = (int) $stmtDeleted->fetchColumn();
|
|
|
|
|
|
-// Get results from database
|
|
|
-$result = mysqli_query($con, "SELECT * FROM `block_info` WHERE `modx_user_id` = ". $client_id ." AND `status` <= 1 "); //
|
|
|
- //
|
|
|
-//plant_records.crop_type, plant_specifications.plant_type, plant_specifications.N_Min, plant_specifications.N_Max, plant_records.N, plant_records.id
|
|
|
-// mysqli_query returns false if something went wrong with the query
|
|
|
-
|
|
|
-if ($result === FALSE) {
|
|
|
- die(mysqli_error($con)); // TODO: better error handling
|
|
|
- echo "User Profile incorrect";
|
|
|
-
|
|
|
-} else {
|
|
|
- $i = 1;
|
|
|
- while ($row = mysqli_fetch_array($result)) {
|
|
|
-
|
|
|
- $rowid = $row['id'];
|
|
|
- $name = $row['name'];
|
|
|
- $block = $row['block_id'];
|
|
|
- $location = $row['location'];
|
|
|
- $area = $row['area'];
|
|
|
- $area_ha = number_format($area,1);
|
|
|
- $area_ac = number_format(($area * 2.47105),1);
|
|
|
- $area_value = $area_ha . "ha - " . $area_ac . "acres";
|
|
|
- $gps = $row['gps'];
|
|
|
- $status = $row['status'];
|
|
|
-
|
|
|
- $currentCrop = '';
|
|
|
-
|
|
|
- /* Status Table */
|
|
|
- if ($row['status'] == 0 ) { // 0 = Blank
|
|
|
- $colour = 'table-secondary';
|
|
|
- } else if ($row['status'] == 1 ) { //1 = Read
|
|
|
- $colour = '';
|
|
|
- } else if ($row['status'] == 2 ) { //2 = Archived
|
|
|
- $colour = '';
|
|
|
- } else if ($row['status'] == 3 ) { //3 = Deleted
|
|
|
- $colour = '';
|
|
|
- } else {
|
|
|
- $colour = '';
|
|
|
- }
|
|
|
-
|
|
|
- //$today = date('dS l M y');
|
|
|
- //$filename = $row['rand'] . " - Soil-Analysis - " . $today;
|
|
|
-
|
|
|
- echo "<div class='row mb-2'>";
|
|
|
- echo "<div class='col border border-success rounded p-1'>";
|
|
|
- echo "<div class='form-row m-1'>";
|
|
|
- echo "<div class='text-left font-weight-bold' ><p>$i</p></div>"; //<label for=''>ID</label> d-none d-md-block d-lg-none
|
|
|
- echo "<div class='col-6 col-sm-11 col-md-2'>";
|
|
|
- echo "<div class='row'>";
|
|
|
- echo "<div class='col-6 col-md-6'><a class='text-left font-weight-bold btn btn-primary btn-sm btn-block' href='[[~93]]?rid=$rowid&id=$block&block=$name'><i class='fas fa-globe-asia fa-1x text-white' aria-hidden='true'></i></a></div>";
|
|
|
- echo "<div class='col-6 col-md-6'><button type='submit' class='text-left font-weight-bold btn btn-success btn-sm btn-block ' data-toggle='modal' data-target='#editPaddock$rowid'><i class='far fa-edit'></i> " . $block . "</button></div>";
|
|
|
- echo "</div>"; //<label for=''>Block</label>
|
|
|
- echo "</div>";
|
|
|
- echo "<div class='col'><label class='form-label form-label-sm m-0 d-block d-sm-none' for=''>Name</label><input type='text' class='form-control form-control-sm' value='$name'></div>"; //<label for=''>Name</label>
|
|
|
- echo "<div class='col-md-1'><label class='form-label form-label-sm m-0 d-block d-sm-none' for=''>Size</label><input type='text' class='form-control form-control-sm text-center' value='$area_value'></div>"; //<label for=''>Size</label>
|
|
|
- echo "<div class='col-md-2'><label class='form-label form-label-sm m-0 d-block d-sm-none' for=''>Location</label><input type='text' class='form-control form-control-sm' value='$location'></div>"; //<label for=''>Location</label>
|
|
|
- echo "<div class='col-md-2'><label class='form-label form-label-sm m-0 d-block d-sm-none' for=''>Current Crop</label><input type='text' class='form-control form-control-sm' value='$currentCrop'></div>"; //<label for=''>Location</label>
|
|
|
- echo "<div class='col-md-1'><label class='form-label form-label-sm m-0 d-block d-sm-none' for=''>Location</label><input type='text' readonly class='form-control form-control-plaintext form-control-sm' value='$status'></div>"; //<label for=''>Location</label>
|
|
|
- echo "<div class='col-md-1'><label class='form-label form-label-sm m-0 d-block d-sm-none' for=''>Actions</label>";
|
|
|
- echo "<a href='#' target='_blank' data-toggle='tooltip' data-placement='top' title='Delete Block'><i class='fa fa-trash text-danger' aria-hidden='true'></i> ";
|
|
|
- echo "<a href='#' target='_blank' data-toggle='tooltip' data-placement='top' title='Archive Block'><i class='fa fa-archive text-warning' aria-hidden='true'></i> ";
|
|
|
- echo "<a href='#' target='_blank' data-toggle='tooltip' data-placement='top' title='Reply to Client'><i class='text-success fa fa-reply' aria-hidden='true'></i> ";
|
|
|
- echo "<a href='#' target='_blank' data-toggle='tooltip' data-placement='top' title='Share Report'><i class='text-success fa fa-share' aria-hidden='true'></i></a> ";
|
|
|
- echo "<a href='#' target='_blank' data-toggle='tooltip' data-placement='top' title='Download Report'><i class='text-dark fas fa-cloud-download-alt'></i></a>";
|
|
|
- echo "</div>";
|
|
|
- echo "</div>";
|
|
|
- echo "</div>";
|
|
|
- echo "</div>";
|
|
|
-
|
|
|
- ?>
|
|
|
-
|
|
|
- <!-- ********************************************************* Modal ********************************************************* -->
|
|
|
- <div class="modal fade" id="editPaddock<?php echo $rowid; ?>" tabindex="-1" role="dialog" aria-labelledby="editPaddock<?php echo $rowid; ?>" aria-hidden="true">
|
|
|
- <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
|
|
|
- <div class="modal-content">
|
|
|
- <div class="modal-header">
|
|
|
- <h5 class="modal-title" id="exampleModalLabel">Edit Paddock Record</h5>
|
|
|
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
|
- <span aria-hidden="true">×</span>
|
|
|
- </button>
|
|
|
- </div>
|
|
|
- <div class="modal-body">
|
|
|
-
|
|
|
- [[!createBlockSubmit]]
|
|
|
-
|
|
|
- <form method="post" action="[~[*id*]~]" id="editPaddock<?php echo $rowid; ?>" novalidate>
|
|
|
-
|
|
|
- <input type="text" class="form-control" id="modx_user" value="<?php echo $rowid; ?>" hidden>
|
|
|
- <input type="text" class="form-control" id="mid" value="[[+id]]" hidden>
|
|
|
-
|
|
|
- <div class="form-row">
|
|
|
- <div class="col">
|
|
|
- <label for="exampleInputEmail1">Block ID</label>
|
|
|
- <input type="text" class="form-control form-control-sm" id="block_id" aria-describedby="block_idHelp" value="<?php echo $block; ?>" required>
|
|
|
- <small id="block_idHelp" class="form-text text-muted"></small>
|
|
|
- <div class="valid-feedback">Looks good!</div>
|
|
|
- </div>
|
|
|
- <div class="col">
|
|
|
- <label for="exampleInputEmail1">Block Name</label>
|
|
|
- <input type="text" class="form-control form-control-sm" id="name" aria-describedby="nameHelp" value="<?php echo $name; ?>" required>
|
|
|
- <small id="nameHelp" class="form-text text-muted"></small>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <hr>
|
|
|
- <h6>Location / Sizing</h6>
|
|
|
- <div class="form-group">
|
|
|
- <label for="exampleInputPassword1">Location</label>
|
|
|
- <input type="text" class="form-control form-control-sm" id="location" value="<?php echo $location; ?>" >
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="form-row">
|
|
|
- <div class="col">
|
|
|
- <label for="exampleInputEmail1">Area</label>
|
|
|
- <input type="text" class="form-control form-control-sm" id="area_ha" aria-describedby="areahaHelp" value="<?php echo $area_ha; ?>" oninput="areaConverter(this.id,this.value)" onchange="areaConverter(this.value)">
|
|
|
- <small id="areahaHelp" class="form-text text-muted">in hectare's</small>
|
|
|
- </div>
|
|
|
- <div class="col">
|
|
|
- <label for="exampleInputEmail1">Area</label>
|
|
|
- <input type="text" class="form-control form-control-sm" id="area_ac" aria-describedby="areaacHelp" value="<?php echo $area_ac; ?>" oninput="areaConverter(this.id,this.value)" onchange="areaConverter(this.value)">
|
|
|
- <small id="areaaHelp" class="form-text text-muted">in acre's</small>
|
|
|
- </div>
|
|
|
- <div class="col">
|
|
|
- <label for="exampleInputEmail1">GPS</label>
|
|
|
- <input type="text" class="form-control form-control-sm" id="gps" aria-describedby="gpsHelp" value="<?php echo $gps; ?>" >
|
|
|
- <small id="gpsHelp" class="form-text text-muted"></small>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <script>
|
|
|
- function areaConverter(source,valNum) {
|
|
|
- valNum = parseFloat(valNum);
|
|
|
- var area_ha = document.getElementById("area_ha");
|
|
|
- var area_ac = document.getElementById("area_ac");
|
|
|
-
|
|
|
- if (source=="area_ha") {
|
|
|
- area_ac.value=(valNum/0.404686).toFixed(2);
|
|
|
- }
|
|
|
- if (source=="area_ac") {
|
|
|
- area_ha.value=(valNum/2.4710559990832).toFixed(2);
|
|
|
- }
|
|
|
- }
|
|
|
- </script>
|
|
|
-
|
|
|
- <hr>
|
|
|
- <h6>Soil Clasification</h6>
|
|
|
- <div class="form-row">
|
|
|
- <div class="col">
|
|
|
- <label for="exampleInputEmail1">Area</label>
|
|
|
- <select class="form-control form-control-sm" name="analysis_type" id="analysis_type" required>
|
|
|
- <option>Select the type of soil...</option>
|
|
|
- <option id="sandy">sandy</option>
|
|
|
- <option id="light">light</option>
|
|
|
- <option id="medium">medium</option>
|
|
|
- <option id="heavy">heavy</option>
|
|
|
- </select>
|
|
|
- </div>
|
|
|
- <div class="col">
|
|
|
- <label for="exampleInputEmail1">Block Name</label>
|
|
|
- <input type="text" class="form-control form-control-sm" id="name" aria-describedby="idHelp" placeholder="Block Name">
|
|
|
- <small id="emailHelp" class="form-text text-muted"></small>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <hr>
|
|
|
- <h6>Current Crop Details</h6>
|
|
|
- <div class="form-row">
|
|
|
- <div class="col">
|
|
|
- <label for="exampleInputEmail1">Block Name</label>
|
|
|
- <input type="text" class="form-control form-control-sm" id="name" aria-describedby="idHelp" placeholder="Block Name">
|
|
|
- <small id="emailHelp" class="form-text text-muted"></small>
|
|
|
- </div>
|
|
|
- <div class="col">
|
|
|
- <label for="exampleInputEmail1">Block Name</label>
|
|
|
- <input type="text" class="form-control form-control-sm" id="name" aria-describedby="idHelp" placeholder="Block Name">
|
|
|
- <small id="emailHelp" class="form-text text-muted"></small>
|
|
|
- </div>
|
|
|
- <div class="col">
|
|
|
- <label for="exampleInputEmail1">Block Name</label>
|
|
|
- <input type="text" class="form-control form-control-sm" id="name" aria-describedby="idHelp" placeholder="Block Name">
|
|
|
- <small id="emailHelp" class="form-text text-muted"></small>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
-
|
|
|
- </div>
|
|
|
- <div class="modal-footer">
|
|
|
- <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
|
|
- <button form="editPaddock<?php echo $rowid; ?>" type="submit" class="btn btn-success">Save changes</button>
|
|
|
- </form>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+// ── Block list (status 0 = new, 1 = active) ───────────────────────────────
|
|
|
+$stmtBlocks = $pdo->prepare(
|
|
|
+ 'SELECT * FROM block_info WHERE modx_user_id = ? AND status <= 1 ORDER BY id ASC'
|
|
|
+);
|
|
|
+$stmtBlocks->execute([$userId]);
|
|
|
+$blocks = $stmtBlocks->fetchAll();
|
|
|
|
|
|
+// ── Flash messages ────────────────────────────────────────────────────────
|
|
|
+$flashSuccess = $_SESSION['flash_success'] ?? null;
|
|
|
+$flashError = $_SESSION['flash_error'] ?? null;
|
|
|
+unset($_SESSION['flash_success'], $_SESSION['flash_error']);
|
|
|
|
|
|
-<?php
|
|
|
- $i++;
|
|
|
- }
|
|
|
-}
|
|
|
+$h = fn($v) => htmlspecialchars((string) $v, ENT_QUOTES, 'UTF-8');
|
|
|
|
|
|
-mysqli_close($con);
|
|
|
+include __DIR__ . '/../../layouts/header.php';
|
|
|
+include __DIR__ . '/../../layouts/navbar.php';
|
|
|
?>
|
|
|
-
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- </div>
|
|
|
-</div>
|
|
|
|
|
|
+<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"><?= $h($pageTitle) ?></h1>
|
|
|
+ <ol class="breadcrumb mb-4">
|
|
|
+ <li class="breadcrumb-item"><a href="/dashboard/dashboard.php">Dashboard</a></li>
|
|
|
+ <li class="breadcrumb-item active">Crop Cards</li>
|
|
|
+ </ol>
|
|
|
|
|
|
-<div class="container-fluid">
|
|
|
- <div class="row clearfix ">
|
|
|
- <div class="col border border-success rounded shadow">
|
|
|
- <form>
|
|
|
- <div class="form-row">
|
|
|
- <div class="form-group col-3">
|
|
|
- <label for="farm_name">Farm Name</label>
|
|
|
- <input type="text" class="form-control" for="farm_name" placeholder="" readonly></input>
|
|
|
- <small id="farm_name" class="form-text text-muted"></small>
|
|
|
- </div>
|
|
|
- <div class="form-group col-3">
|
|
|
- <label for="paddock_name">Paddock Name</label>
|
|
|
- <input type="text" class="form-control" for="paddock_name" placeholder="" readonly></input>
|
|
|
- <small id="paddock_name" class="form-text text-muted"></small>
|
|
|
+ <?php if ($flashSuccess): ?>
|
|
|
+ <div class="alert alert-success alert-dismissible fade show" role="alert">
|
|
|
+ <?= $h($flashSuccess) ?>
|
|
|
+ <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
|
</div>
|
|
|
- <div class="form-group col-3">
|
|
|
- <label for="crop_name">Crop Name</label>
|
|
|
- <input type="text" class="form-control" for="crop_name" placeholder="" readonly></input>
|
|
|
- <small id="crop_name" class="form-text text-muted"></small>
|
|
|
+ <?php endif; ?>
|
|
|
+ <?php if ($flashError): ?>
|
|
|
+ <div class="alert alert-danger alert-dismissible fade show" role="alert">
|
|
|
+ <?= $h($flashError) ?>
|
|
|
+ <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
|
</div>
|
|
|
-
|
|
|
- <div class="form-group col-3">
|
|
|
- <label for="paddock_area">Area</label>
|
|
|
- <input type="text" class="form-control" for="paddock_area" placeholder="" readonly></input>
|
|
|
- <small id="paddock_area" class="form-text text-muted"></small>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </form>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="row clearfix">
|
|
|
- <div class="col">
|
|
|
- <br>
|
|
|
- <h3>Crop Information</h3>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="row clearfix">
|
|
|
- <div class="col-4 ">
|
|
|
- <div class="card">
|
|
|
- <div class="card-header">
|
|
|
- <h4>Current Alerts</h4>
|
|
|
- </div>
|
|
|
- <div class="card-body">
|
|
|
- <div class="table-responsive table-editable">
|
|
|
- <span class="table-add float-right mb-3 mr-2"><a href="#!" class="text-success"><i class="fas fa-plus fa-2x" aria-hidden="true"></i></a></span>
|
|
|
- <table class="table table-striped table-hover">
|
|
|
- <thead class="table-danger">
|
|
|
- <tr>
|
|
|
- <th scope="col">#</th>
|
|
|
- <th scope="col">First</th>
|
|
|
- <th scope="col">Last</th>
|
|
|
- <th scope="col">Handle</th>
|
|
|
- </tr>
|
|
|
- </thead>
|
|
|
- <tbody>
|
|
|
- <tr>
|
|
|
- <th scope="row">1</th>
|
|
|
- <td>Mark</td>
|
|
|
- <td>Otto</td>
|
|
|
- <td>@mdo</td>
|
|
|
- </tr>
|
|
|
- <tr>
|
|
|
- <th scope="row">2</th>
|
|
|
- <td>Jacob</td>
|
|
|
- <td>Thornton</td>
|
|
|
- <td>@fat</td>
|
|
|
- </tr>
|
|
|
- <tr>
|
|
|
- <th scope="row">3</th>
|
|
|
- <td>Larry</td>
|
|
|
- <td>the Bird</td>
|
|
|
- <td>@twitter</td>
|
|
|
- </tr>
|
|
|
- </tbody>
|
|
|
- </table>
|
|
|
+ <?php endif; ?>
|
|
|
+
|
|
|
+ <div class="row">
|
|
|
+
|
|
|
+ <!-- ── Left sidebar panel ──────────────────────────────── -->
|
|
|
+ <div class="col-12 col-md-3">
|
|
|
+
|
|
|
+ <div class="row mb-3">
|
|
|
+ <div class="col">
|
|
|
+ <form action="" method="GET">
|
|
|
+ <div class="input-group">
|
|
|
+ <input type="text" class="form-control" name="q"
|
|
|
+ placeholder="Search..."
|
|
|
+ value="<?= $h($_GET['q'] ?? '') ?>">
|
|
|
+ <span class="input-group-text"><i class="fa fa-search"></i></span>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="row mb-3">
|
|
|
+ <div class="col">
|
|
|
+ <div class="alert alert-danger">
|
|
|
+ <h5 class="mb-0"><?= $h($pageTitle) ?></h5>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="row">
|
|
|
+ <div class="col">
|
|
|
+ <div class="list-group">
|
|
|
+ <a href="#" class="list-group-item list-group-item-action fw-bold">
|
|
|
+ Folders
|
|
|
+ </a>
|
|
|
+ <a href="#" class="list-group-item list-group-item-action list-group-item-light text-warning">
|
|
|
+ <i class="fa fa-archive text-warning"></i> Archived
|
|
|
+ <span class="badge bg-warning text-dark float-end"><?= $archivedCount ?></span>
|
|
|
+ </a>
|
|
|
+ <a href="#" class="list-group-item list-group-item-action list-group-item-light text-danger">
|
|
|
+ <i class="fa fa-trash text-danger"></i> Deleted
|
|
|
+ <span class="badge bg-danger float-end"><?= $deletedCount ?></span>
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </div><!-- /col: left panel -->
|
|
|
+
|
|
|
+ <!-- ── Block list ───────────────────────────────────────── -->
|
|
|
+ <div class="col-12 col-md-9">
|
|
|
+
|
|
|
+ <div class="row mb-3">
|
|
|
+ <div class="col">
|
|
|
+ <button type="button" class="btn btn-success"
|
|
|
+ data-bs-toggle="modal" data-bs-target="#createPaddock">
|
|
|
+ <i class="fas fa-plus me-1"></i>Create New Paddock
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- Column headers (desktop only) -->
|
|
|
+ <div class="d-none d-md-block mb-1">
|
|
|
+ <div class="row fw-bold text-center text-muted small">
|
|
|
+ <div class="col-md-1">ID</div>
|
|
|
+ <div class="col-md-2">Block</div>
|
|
|
+ <div class="col">Name</div>
|
|
|
+ <div class="col-md-1">Size</div>
|
|
|
+ <div class="col-md-2">Location</div>
|
|
|
+ <div class="col-md-2">Current Crop</div>
|
|
|
+ <div class="col-md-1">Status</div>
|
|
|
+ <div class="col-md-1">Actions</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <?php if (empty($blocks)): ?>
|
|
|
+ <div class="alert alert-info">No paddock records found. Create your first paddock above.</div>
|
|
|
+ <?php endif; ?>
|
|
|
+
|
|
|
+ <?php foreach ($blocks as $i => $row):
|
|
|
+ $rowid = (int) $row['id'];
|
|
|
+ $areaHa = number_format((float) $row['area'], 1);
|
|
|
+ $areaAc = number_format((float) $row['area'] * 2.47105, 1);
|
|
|
+ $areaDisp = $areaHa . ' ha – ' . $areaAc . ' ac';
|
|
|
+ ?>
|
|
|
+ <div class="row mb-2">
|
|
|
+ <div class="col border border-success rounded p-2">
|
|
|
+ <div class="row align-items-center">
|
|
|
+ <div class="col-md-1 text-center fw-bold"><?= $i + 1 ?></div>
|
|
|
+ <div class="col-6 col-sm-11 col-md-2">
|
|
|
+ <div class="row g-1">
|
|
|
+ <div class="col-6">
|
|
|
+ <a class="btn btn-primary btn-sm w-100"
|
|
|
+ href="/dashboard/crop-cards/block-detail.php?rid=<?= $rowid ?>&id=<?= $h($row['block_id']) ?>&block=<?= urlencode($row['name'] ?? '') ?>"
|
|
|
+ title="View block">
|
|
|
+ <i class="fas fa-globe-asia text-white"></i>
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ <div class="col-6">
|
|
|
+ <button type="button"
|
|
|
+ class="btn btn-success btn-sm w-100"
|
|
|
+ data-bs-toggle="modal"
|
|
|
+ data-bs-target="#editPaddock<?= $rowid ?>">
|
|
|
+ <i class="far fa-edit"></i> <?= $h($row['block_id']) ?>
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="col">
|
|
|
+ <label class="form-label form-label-sm mb-0 d-block d-sm-none">Name</label>
|
|
|
+ <input type="text" class="form-control form-control-sm"
|
|
|
+ value="<?= $h($row['name']) ?>" readonly>
|
|
|
+ </div>
|
|
|
+ <div class="col-md-1">
|
|
|
+ <label class="form-label form-label-sm mb-0 d-block d-sm-none">Size</label>
|
|
|
+ <input type="text" class="form-control form-control-sm text-center"
|
|
|
+ value="<?= $h($areaDisp) ?>" readonly>
|
|
|
+ </div>
|
|
|
+ <div class="col-md-2">
|
|
|
+ <label class="form-label form-label-sm mb-0 d-block d-sm-none">Location</label>
|
|
|
+ <input type="text" class="form-control form-control-sm"
|
|
|
+ value="<?= $h($row['location']) ?>" readonly>
|
|
|
+ </div>
|
|
|
+ <div class="col-md-2">
|
|
|
+ <label class="form-label form-label-sm mb-0 d-block d-sm-none">Current Crop</label>
|
|
|
+ <input type="text" class="form-control form-control-sm" value="" readonly>
|
|
|
+ </div>
|
|
|
+ <div class="col-md-1">
|
|
|
+ <label class="form-label form-label-sm mb-0 d-block d-sm-none">Status</label>
|
|
|
+ <input type="text" class="form-control form-control-plaintext form-control-sm text-center"
|
|
|
+ value="<?= $h($row['status']) ?>" readonly>
|
|
|
+ </div>
|
|
|
+ <div class="col-md-1">
|
|
|
+ <label class="form-label form-label-sm mb-0 d-block d-sm-none">Actions</label>
|
|
|
+ <a href="#" title="Delete Block"><i class="fa fa-trash text-danger"></i></a>
|
|
|
+ <a href="#" title="Archive Block"><i class="fa fa-archive text-warning"></i></a>
|
|
|
+ <a href="#" title="Reply to Client"><i class="fa fa-reply text-success"></i></a>
|
|
|
+ <a href="#" title="Share Report"><i class="fa fa-share text-success"></i></a>
|
|
|
+ <a href="#" title="Download Report"><i class="fas fa-cloud-download-alt text-dark"></i></a>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- Edit Paddock modal -->
|
|
|
+ <div class="modal fade" id="editPaddock<?= $rowid ?>" tabindex="-1"
|
|
|
+ aria-labelledby="editPaddock<?= $rowid ?>Label" aria-hidden="true">
|
|
|
+ <div class="modal-dialog modal-lg modal-dialog-centered">
|
|
|
+ <div class="modal-content">
|
|
|
+ <div class="modal-header">
|
|
|
+ <h5 class="modal-title" id="editPaddock<?= $rowid ?>Label">
|
|
|
+ Edit Paddock — <?= $h($row['name']) ?>
|
|
|
+ </h5>
|
|
|
+ <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
|
+ </div>
|
|
|
+ <form method="post" action="/controllers/blockSubmit.php"
|
|
|
+ id="editPaddockForm<?= $rowid ?>">
|
|
|
+ <div class="modal-body">
|
|
|
+ <input type="hidden" name="csrf_token"
|
|
|
+ value="<?= $h(generateCsrfToken()) ?>">
|
|
|
+ <input type="hidden" name="action" value="edit">
|
|
|
+ <input type="hidden" name="record_id" value="<?= $rowid ?>">
|
|
|
+
|
|
|
+ <div class="row mb-3">
|
|
|
+ <div class="col">
|
|
|
+ <label class="form-label">Block ID</label>
|
|
|
+ <input type="text" class="form-control form-control-sm"
|
|
|
+ name="block_id" value="<?= $h($row['block_id']) ?>" required>
|
|
|
+ </div>
|
|
|
+ <div class="col">
|
|
|
+ <label class="form-label">Block Name</label>
|
|
|
+ <input type="text" class="form-control form-control-sm"
|
|
|
+ name="name" value="<?= $h($row['name']) ?>" required>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <hr>
|
|
|
+ <h6>Location / Sizing</h6>
|
|
|
+
|
|
|
+ <div class="mb-3">
|
|
|
+ <label class="form-label">Location</label>
|
|
|
+ <input type="text" class="form-control form-control-sm"
|
|
|
+ name="location" value="<?= $h($row['location']) ?>">
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="row mb-3">
|
|
|
+ <div class="col">
|
|
|
+ <label class="form-label">Area (hectares)</label>
|
|
|
+ <input type="number" step="0.01" class="form-control form-control-sm"
|
|
|
+ id="edit_area_ha_<?= $rowid ?>" name="area_ha"
|
|
|
+ value="<?= $h(number_format((float) $row['area'], 2)) ?>"
|
|
|
+ oninput="areaConverter('area_ha',this.value,'<?= $rowid ?>')">
|
|
|
+ <div class="form-text">in hectares</div>
|
|
|
+ </div>
|
|
|
+ <div class="col">
|
|
|
+ <label class="form-label">Area (acres)</label>
|
|
|
+ <input type="number" step="0.01" class="form-control form-control-sm"
|
|
|
+ id="edit_area_ac_<?= $rowid ?>"
|
|
|
+ value="<?= $h(number_format((float) $row['area'] * 2.47105, 2)) ?>"
|
|
|
+ oninput="areaConverter('area_ac',this.value,'<?= $rowid ?>')">
|
|
|
+ <div class="form-text">in acres</div>
|
|
|
+ </div>
|
|
|
+ <div class="col">
|
|
|
+ <label class="form-label">GPS</label>
|
|
|
+ <input type="text" class="form-control form-control-sm"
|
|
|
+ name="gps" value="<?= $h($row['gps']) ?>">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <hr>
|
|
|
+ <h6>Soil Classification</h6>
|
|
|
+ <div class="row">
|
|
|
+ <div class="col">
|
|
|
+ <label class="form-label">Soil Type</label>
|
|
|
+ <select class="form-select form-select-sm" name="analysis_type">
|
|
|
+ <option value="">Select soil type...</option>
|
|
|
+ <option value="sandy">Sandy</option>
|
|
|
+ <option value="light">Light</option>
|
|
|
+ <option value="medium">Medium</option>
|
|
|
+ <option value="heavy">Heavy</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </div><!-- /modal-body -->
|
|
|
+ <div class="modal-footer">
|
|
|
+ <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
|
|
+ <button type="submit" class="btn btn-success">Save Changes</button>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div><!-- /editPaddock modal -->
|
|
|
+
|
|
|
+ <?php endforeach; ?>
|
|
|
+
|
|
|
+ </div><!-- /col: block list -->
|
|
|
+
|
|
|
+ </div><!-- /row: main content -->
|
|
|
+
|
|
|
+ <!-- ── Crop Information summary (placeholder) ─────────────── -->
|
|
|
+ <div class="container-fluid mt-4">
|
|
|
+ <div class="row mb-3">
|
|
|
+ <div class="col">
|
|
|
+ <div class="card border-success">
|
|
|
+ <div class="card-body py-2">
|
|
|
+ <div class="row">
|
|
|
+ <div class="col-3">
|
|
|
+ <label class="form-label small mb-0">Farm Name</label>
|
|
|
+ <input type="text" class="form-control form-control-sm" readonly>
|
|
|
+ </div>
|
|
|
+ <div class="col-3">
|
|
|
+ <label class="form-label small mb-0">Paddock Name</label>
|
|
|
+ <input type="text" class="form-control form-control-sm" readonly>
|
|
|
+ </div>
|
|
|
+ <div class="col-3">
|
|
|
+ <label class="form-label small mb-0">Crop Name</label>
|
|
|
+ <input type="text" class="form-control form-control-sm" readonly>
|
|
|
+ </div>
|
|
|
+ <div class="col-3">
|
|
|
+ <label class="form-label small mb-0">Area</label>
|
|
|
+ <input type="text" class="form-control form-control-sm" readonly>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="col-4 ">
|
|
|
- <div class="card">
|
|
|
- <div class="card-header">
|
|
|
- <h4>Fertiliser and Disease Control</h4>
|
|
|
- </div>
|
|
|
- <div class="card-body">
|
|
|
- <div class="table-responsive table-editable">
|
|
|
- <span class="table-add float-right mb-3 mr-2"><a href="#!" class="text-success"><i class="fas fa-plus fa-2x" aria-hidden="true"></i></a></span>
|
|
|
- <table class="table table-striped table-hover">
|
|
|
- <thead class="table-success">
|
|
|
- <tr>
|
|
|
- <th scope="col">#</th>
|
|
|
- <th scope="col">First</th>
|
|
|
- <th scope="col">Last</th>
|
|
|
- <th scope="col">Handle</th>
|
|
|
- </tr>
|
|
|
- </thead>
|
|
|
- <tbody>
|
|
|
- <tr>
|
|
|
- <th scope="row">1</th>
|
|
|
- <td>Mark</td>
|
|
|
- <td>Otto</td>
|
|
|
- <td>@mdo</td>
|
|
|
- </tr>
|
|
|
- <tr>
|
|
|
- <th scope="row">2</th>
|
|
|
- <td>Jacob</td>
|
|
|
- <td>Thornton</td>
|
|
|
- <td>@fat</td>
|
|
|
- </tr>
|
|
|
- <tr>
|
|
|
- <th scope="row">3</th>
|
|
|
- <td>Larry</td>
|
|
|
- <td>the Bird</td>
|
|
|
- <td>@twitter</td>
|
|
|
- </tr>
|
|
|
- </tbody>
|
|
|
- </table>
|
|
|
+
|
|
|
+ <h4>Crop Information</h4>
|
|
|
+
|
|
|
+ <div class="row">
|
|
|
+ <div class="col-4">
|
|
|
+ <div class="card">
|
|
|
+ <div class="card-header"><h5 class="mb-0">Current Alerts</h5></div>
|
|
|
+ <div class="card-body p-0">
|
|
|
+ <table class="table table-striped table-hover mb-0">
|
|
|
+ <thead class="table-danger">
|
|
|
+ <tr><th>#</th><th>Alert</th><th>Level</th></tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>
|
|
|
+ <tr><td colspan="3" class="text-muted text-center">No alerts</td></tr>
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="col-4">
|
|
|
+ <div class="card">
|
|
|
+ <div class="card-header"><h5 class="mb-0">Fertiliser & Disease Control</h5></div>
|
|
|
+ <div class="card-body p-0">
|
|
|
+ <table class="table table-striped table-hover mb-0">
|
|
|
+ <thead class="table-success">
|
|
|
+ <tr><th>#</th><th>Product</th><th>Date</th></tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>
|
|
|
+ <tr><td colspan="3" class="text-muted text-center">No records</td></tr>
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="col-4">
|
|
|
+ <div class="card">
|
|
|
+ <div class="card-header"><h5 class="mb-0">Irrigation & Weather</h5></div>
|
|
|
+ <div class="card-body p-0">
|
|
|
+ <table class="table table-striped table-hover mb-0">
|
|
|
+ <thead class="table-warning">
|
|
|
+ <tr><th>#</th><th>Event</th><th>Date</th></tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>
|
|
|
+ <tr><td colspan="3" class="text-muted text-center">No records</td></tr>
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="col-4 ">
|
|
|
- <div class="card">
|
|
|
- <div class="card-header">
|
|
|
- <h4>Irrigation and Weather</h4>
|
|
|
- </div>
|
|
|
- <div class="card-body">
|
|
|
- <div class="table-responsive table-editable">
|
|
|
- <span class="table-add float-right mb-3 mr-2"><a href="#!" class="text-success"><i class="fas fa-plus fa-2x" aria-hidden="true"></i></a></span>
|
|
|
- <table class="table table-striped table-hover">
|
|
|
- <thead class="table-warning">
|
|
|
- <tr>
|
|
|
- <th scope="col">#</th>
|
|
|
- <th scope="col">First</th>
|
|
|
- <th scope="col">Last</th>
|
|
|
- <th scope="col">Handle</th>
|
|
|
- </tr>
|
|
|
- </thead>
|
|
|
- <tbody>
|
|
|
- <tr>
|
|
|
- <th scope="row">1</th>
|
|
|
- <td>Mark</td>
|
|
|
- <td>Otto</td>
|
|
|
- <td>@mdo</td>
|
|
|
- </tr>
|
|
|
- <tr>
|
|
|
- <th scope="row">2</th>
|
|
|
- <td>Jacob</td>
|
|
|
- <td>Thornton</td>
|
|
|
- <td>@fat</td>
|
|
|
- </tr>
|
|
|
- <tr>
|
|
|
- <th scope="row">3</th>
|
|
|
- <td>Larry</td>
|
|
|
- <td>the Bird</td>
|
|
|
- <td>@twitter</td>
|
|
|
- </tr>
|
|
|
- </tbody>
|
|
|
- </table>
|
|
|
+ </div><!-- /crop information -->
|
|
|
+
|
|
|
+ </div><!-- /container-fluid -->
|
|
|
+
|
|
|
+ </main>
|
|
|
+
|
|
|
+ <!-- ── Create New Paddock modal ──────────────────────────────────────── -->
|
|
|
+ <div class="modal fade" id="createPaddock" tabindex="-1"
|
|
|
+ aria-labelledby="createPaddockLabel" aria-hidden="true">
|
|
|
+ <div class="modal-dialog modal-lg modal-dialog-centered">
|
|
|
+ <div class="modal-content">
|
|
|
+ <div class="modal-header">
|
|
|
+ <h5 class="modal-title" id="createPaddockLabel">Create Paddock Record</h5>
|
|
|
+ <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
-
|
|
|
- </div>
|
|
|
-
|
|
|
-</div>
|
|
|
- </div>
|
|
|
-
|
|
|
- </div>
|
|
|
-
|
|
|
- </main>
|
|
|
-
|
|
|
- <footer class="py-4 bg-light mt-auto">
|
|
|
- <div class="container-fluid px-4">
|
|
|
- <div class="d-flex align-items-center justify-content-between small">
|
|
|
- <div class="text-muted">[[SimpleCopyright? &startYear=`2003`]]. All Rights Reserved <a href="[[~1]]"></a></div>
|
|
|
- <div>
|
|
|
- <a href="[[~39~]]">Privacy Policy</a>
|
|
|
- ·
|
|
|
- <a href="[[~39~]]">Terms & Conditions</a>
|
|
|
+ <form method="post" action="/controllers/blockSubmit.php" id="createPaddockForm">
|
|
|
+ <div class="modal-body">
|
|
|
+ <input type="hidden" name="csrf_token"
|
|
|
+ value="<?= $h(generateCsrfToken()) ?>">
|
|
|
+ <input type="hidden" name="action" value="create">
|
|
|
+
|
|
|
+ <h6>Block Identification</h6>
|
|
|
+ <div class="row mb-3">
|
|
|
+ <div class="col">
|
|
|
+ <label class="form-label">Block ID</label>
|
|
|
+ <input type="text" class="form-control form-control-sm"
|
|
|
+ name="block_id" placeholder="e.g. BLK-001" required>
|
|
|
+ </div>
|
|
|
+ <div class="col">
|
|
|
+ <label class="form-label">Block Name</label>
|
|
|
+ <input type="text" class="form-control form-control-sm"
|
|
|
+ name="name" placeholder="e.g. North Paddock" required>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <hr>
|
|
|
+ <h6>Location / Sizing</h6>
|
|
|
+
|
|
|
+ <div class="mb-3">
|
|
|
+ <label class="form-label">Location / Address</label>
|
|
|
+ <input type="text" class="form-control form-control-sm"
|
|
|
+ name="location" placeholder="Block address">
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="row mb-3">
|
|
|
+ <div class="col">
|
|
|
+ <label class="form-label">Area (hectares)</label>
|
|
|
+ <input type="number" step="0.01" class="form-control form-control-sm"
|
|
|
+ id="create_area_ha" name="area_ha" placeholder="0.00"
|
|
|
+ oninput="areaConverter('area_ha',this.value,'create')">
|
|
|
+ <div class="form-text">in hectares</div>
|
|
|
+ </div>
|
|
|
+ <div class="col">
|
|
|
+ <label class="form-label">Area (acres)</label>
|
|
|
+ <input type="number" step="0.01" class="form-control form-control-sm"
|
|
|
+ id="create_area_ac" placeholder="0.00"
|
|
|
+ oninput="areaConverter('area_ac',this.value,'create')">
|
|
|
+ <div class="form-text">in acres</div>
|
|
|
+ </div>
|
|
|
+ <div class="col">
|
|
|
+ <label class="form-label">GPS Coordinates</label>
|
|
|
+ <input type="text" class="form-control form-control-sm"
|
|
|
+ name="gps" placeholder="e.g. -33.8688, 151.2093">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <hr>
|
|
|
+ <h6>Soil Classification</h6>
|
|
|
+ <div class="row">
|
|
|
+ <div class="col">
|
|
|
+ <label class="form-label">Soil Type</label>
|
|
|
+ <select class="form-select form-select-sm" name="analysis_type">
|
|
|
+ <option value="">Select soil type...</option>
|
|
|
+ <option value="sandy">Sandy</option>
|
|
|
+ <option value="light">Light</option>
|
|
|
+ <option value="medium">Medium</option>
|
|
|
+ <option value="heavy">Heavy</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </div><!-- /modal-body -->
|
|
|
+ <div class="modal-footer">
|
|
|
+ <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
|
|
+ <button type="submit" class="btn btn-success">Create Paddock</button>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </form>
|
|
|
</div>
|
|
|
- </footer>
|
|
|
-
|
|
|
- </div>
|
|
|
-
|
|
|
- </div>
|
|
|
-
|
|
|
- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
|
|
|
- <script>
|
|
|
- /*!
|
|
|
- * Start Bootstrap - SB Admin v7.0.3 (https://startbootstrap.com/template/sb-admin)
|
|
|
- * Copyright 2013-2021 Start Bootstrap
|
|
|
- * Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-sb-admin/blob/master/LICENSE)
|
|
|
- */
|
|
|
- //
|
|
|
- // Scripts
|
|
|
- //
|
|
|
-
|
|
|
- window.addEventListener('DOMContentLoaded', event => {
|
|
|
-
|
|
|
- // Toggle the side navigation
|
|
|
- const sidebarToggle = document.body.querySelector('#sidebarToggle');
|
|
|
- if (sidebarToggle) {
|
|
|
- // Uncomment Below to persist sidebar toggle between refreshes
|
|
|
- // if (localStorage.getItem('sb|sidebar-toggle') === 'true') {
|
|
|
- // document.body.classList.toggle('sb-sidenav-toggled');
|
|
|
- // }
|
|
|
- sidebarToggle.addEventListener('click', event => {
|
|
|
- event.preventDefault();
|
|
|
- document.body.classList.toggle('sb-sidenav-toggled');
|
|
|
- localStorage.setItem('sb|sidebar-toggle', document.body.classList.contains('sb-sidenav-toggled'));
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
- </script>
|
|
|
- <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js" crossorigin="anonymous"></script>
|
|
|
- <script src="https://cdn.jsdelivr.net/npm/simple-datatables@latest" crossorigin="anonymous"></script>
|
|
|
-</body>
|
|
|
-</html>
|
|
|
+ </div>
|
|
|
+ </div><!-- /createPaddock modal -->
|
|
|
+
|
|
|
+<?php include __DIR__ . '/../../layouts/footer.php'; ?>
|
|
|
+
|
|
|
+<script>
|
|
|
+/**
|
|
|
+ * Convert between hectares and acres in Create and Edit paddock modals.
|
|
|
+ * suffix: 'create' for the create modal, or the rowid for edit modals.
|
|
|
+ */
|
|
|
+function areaConverter(source, valNum, suffix) {
|
|
|
+ valNum = parseFloat(valNum) || 0;
|
|
|
+ var haId = (suffix === 'create') ? 'create_area_ha' : 'edit_area_ha_' + suffix;
|
|
|
+ var acId = (suffix === 'create') ? 'create_area_ac' : 'edit_area_ac_' + suffix;
|
|
|
+ var haEl = document.getElementById(haId);
|
|
|
+ var acEl = document.getElementById(acId);
|
|
|
+ if (!haEl || !acEl) return;
|
|
|
+
|
|
|
+ if (source === 'area_ha') {
|
|
|
+ acEl.value = (valNum / 0.404686).toFixed(2);
|
|
|
+ } else {
|
|
|
+ haEl.value = (valNum / 2.47105).toFixed(2);
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|