| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <?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 = 'Soil Test Analysis Report';
- $siteName = 'Crop Management Platform';
- $activeItem = 'Soil Analysis';
- include __DIR__ . '/../../../layouts/header.php';
- include __DIR__ . '/../../../layouts/navbar.php';
- ?>
- <div id="layoutSidenav">
- <div id="layoutSidenav_nav">
- <?php include __DIR__ . '/../../../layouts/sidebar.php'; ?>
- </div>
- <div id="layoutSidenav_content">
- <main>
- <div class="container-fluid px-4">
- <h1 class="mt-4"><?= htmlspecialchars($pageTitle, ENT_QUOTES, 'UTF-8') ?></h1>
- <ol class="breadcrumb mb-4"><!-- TODO: render breadcrumbs dynamically --></ol>
- <div class="row">
- <div class="container">
- <h3 id="forms-example">Soil Test Details</h3>
- <p class="text-muted">Complete the soil test form and submit.</p>
- <!-- Client Details Form Component -->
- <?php include __DIR__ . '/../../../components/clientDetailsForm.php'; ?>
- <!-- New Client Modal Component -->
- <?php include __DIR__ . '/../../../components/newClientModal.php'; ?>
- <form method="post" action="/controllers/soilTestSubmit.php" id="SoilcsvForm" class="needs-validation" novalidate>
- <input type="hidden" name="csrf_token" value="<?php echo generateCsrfToken(); ?>">
- <?php // Soil Analysis Form Component ?>
- <?php include __DIR__ . '/../../../components/soilAnalysisForm.php'; ?>
- <button form="SoilcsvForm" type="submit" name="SoilcsvForm" class="btn btn-success">Submit</button>
- </form>
- <hr />
- <!-- ── Lab File Import ────────────────────────────── -->
- <div class="card mb-4">
- <div class="card-header d-flex align-items-center gap-2">
- <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor" class="bi bi-file-earmark-spreadsheet text-success" viewBox="0 0 16 16">
- <path d="M14 14V4.5L9.5 0H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2M9.5 3A1.5 1.5 0 0 0 11 4.5h3V9H2V2a1 1 0 0 1 1-1h5.5zM2 10h1v1H2zm2 0h1v1H4zm3 0h1v1H7zm2 0h1v1H9zm2 0h1v1h-1zm1 1h1v1h-1zm-9 1h1v1H2zm2 0h1v1H4zm3 0h1v1H7zm2 0h1v1H9zm2 0h1v1h-1z"/>
- </svg>
- <h5 class="mb-0">Import from Lab File</h5>
- </div>
- <div class="card-body">
- <p class="text-muted mb-3">
- Upload an XLS, XLSX, CSV, or ODS file from your soil testing laboratory.
- The system will use AI to automatically map the lab's column names to the
- form fields below — works with CSBP and other lab formats.
- </p>
- <div class="row g-2 align-items-end">
- <div class="col-md-8">
- <label for="lab-file-input" class="form-label fw-semibold">Select lab file</label>
- <input type="file"
- class="form-control form-control-sm"
- id="lab-file-input"
- accept=".xls,.xlsx,.csv,.ods">
- </div>
- <div class="col-md-4">
- <button class="btn btn-success w-100"
- type="button"
- id="lab-analyse-btn"
- disabled>
- <span class="spinner-border spinner-border-sm me-1 d-none" id="import-spinner" role="status"></span>
- Analyse & Import
- </button>
- </div>
- </div>
- <!-- Progress indicator -->
- <div id="import-progress" class="mt-3 d-flex align-items-center gap-2 text-muted" hidden>
- <div class="spinner-border spinner-border-sm text-success" role="status"></div>
- <span class="progress-label">Processing…</span>
- </div>
- <!-- Status / result message -->
- <div id="import-status" class="alert mt-3" hidden></div>
- <!-- Sample picker (multi-sample files) -->
- <div id="sample-picker-panel" hidden class="mt-3">
- <h6 class="fw-semibold">Multiple samples found — choose one to import:</h6>
- <div class="table-responsive">
- <table id="sample-picker-table" class="table table-sm table-hover align-middle">
- <thead class="table-light">
- <tr>
- <th>Lab ID</th>
- <th>Client</th>
- <th>Site / Paddock</th>
- <th>Crop / Material</th>
- <th></th>
- </tr>
- </thead>
- <tbody></tbody>
- </table>
- </div>
- </div>
- <p class="text-muted small mt-3 mb-0">
- Fields highlighted in green were auto-populated. Always review values before submitting.
- </p>
- </div>
- </div>
- <?php // include __DIR__ . '/../../../controllers/soilTestSubmit.php'; ?>
- <!-- old modX placeholders: [[!clientDetailsFORM]], [[!soilformSubmit]], [[!newClientDetails]] -->
- </div>
- </div>
- </div>
- </main>
- </div>
- </div>
- <script src="/client-assets/js/soil-import.js"></script>
- <?php include __DIR__ . '/../../../layouts/footer.php'; ?>
|