index.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. require_once __DIR__ . '/../../../config/database.php';
  3. require_once __DIR__ . '/../../../lib/auth.php';
  4. require_once __DIR__ . '/../../../lib/csrf.php';
  5. if (session_status() === PHP_SESSION_NONE) {
  6. session_start();
  7. }
  8. requireLogin();
  9. $pageTitle = 'Soil Test Analysis Report';
  10. $siteName = 'Crop Management Platform';
  11. $activeItem = 'Soil Analysis';
  12. include __DIR__ . '/../../../layouts/header.php';
  13. include __DIR__ . '/../../../layouts/navbar.php';
  14. ?>
  15. <div id="layoutSidenav">
  16. <div id="layoutSidenav_nav">
  17. <?php include __DIR__ . '/../../../layouts/sidebar.php'; ?>
  18. </div>
  19. <div id="layoutSidenav_content">
  20. <main>
  21. <div class="container-fluid px-4">
  22. <h1 class="mt-4"><?= htmlspecialchars($pageTitle, ENT_QUOTES, 'UTF-8') ?></h1>
  23. <ol class="breadcrumb mb-4"><!-- TODO: render breadcrumbs dynamically --></ol>
  24. <div class="row">
  25. <div class="container">
  26. <h3 id="forms-example">Soil Test Details</h3>
  27. <p class="text-muted">Complete the soil test form and submit.</p>
  28. <!-- Client Details Form Component -->
  29. <?php include __DIR__ . '/../../../components/clientDetailsForm.php'; ?>
  30. <!-- New Client Modal Component -->
  31. <?php include __DIR__ . '/../../../components/newClientModal.php'; ?>
  32. <form method="post" action="/controllers/soilTestSubmit.php" id="SoilcsvForm" class="needs-validation" novalidate>
  33. <input type="hidden" name="csrf_token" value="<?php echo generateCsrfToken(); ?>">
  34. <?php // Soil Analysis Form Component ?>
  35. <?php include __DIR__ . '/../../../components/soilAnalysisForm.php'; ?>
  36. <button form="SoilcsvForm" type="submit" name="SoilcsvForm" class="btn btn-success">Submit</button>
  37. </form>
  38. <hr />
  39. <!-- ── Lab File Import ────────────────────────────── -->
  40. <div class="card mb-4">
  41. <div class="card-header d-flex align-items-center gap-2">
  42. <i class="fas fa-file-excel text-success"></i>
  43. <h5 class="mb-0">Import from Lab File</h5>
  44. </div>
  45. <div class="card-body">
  46. <p class="text-muted mb-3">
  47. Upload a report file from your soil testing laboratory.
  48. Select your lab for accurate direct mapping, or choose <em>Auto-detect</em>.
  49. Multi-sample files can be imported all at once.
  50. </p>
  51. <div class="row g-2 align-items-end">
  52. <div class="col-md-3">
  53. <label for="lab-select" class="form-label fw-semibold">Laboratory</label>
  54. <select id="lab-select" class="form-select form-select-sm">
  55. <option value="auto">Auto-detect</option>
  56. <option value="csbp">CSBP</option>
  57. <option value="generic">Other (AI mapping)</option>
  58. </select>
  59. </div>
  60. <div class="col-md-6">
  61. <label for="lab-file-input" class="form-label fw-semibold">Select file</label>
  62. <input type="file"
  63. class="form-control form-control-sm"
  64. id="lab-file-input"
  65. accept=".xls,.xlsx,.csv,.ods">
  66. </div>
  67. <div class="col-md-3">
  68. <button class="btn btn-success w-100"
  69. type="button"
  70. id="lab-analyse-btn"
  71. disabled>
  72. <i class="fas fa-search me-1"></i>Analyse
  73. </button>
  74. </div>
  75. </div>
  76. <!-- Progress -->
  77. <div id="import-progress" class="mt-3 d-flex align-items-center gap-2 text-muted" hidden>
  78. <div class="spinner-border spinner-border-sm text-success" role="status"></div>
  79. <span class="progress-label">Processing…</span>
  80. </div>
  81. <!-- Status message -->
  82. <div id="import-status" class="alert mt-3" hidden></div>
  83. <!-- ── Bulk confirmation table ──────────────── -->
  84. <div id="bulk-import-panel" hidden class="mt-3">
  85. <div class="d-flex justify-content-between align-items-center mb-2">
  86. <h6 class="fw-semibold mb-0">Review &amp; Import Samples</h6>
  87. <button id="bulk-import-btn" class="btn btn-success btn-sm" type="button">
  88. <i class="fas fa-database me-1"></i>Import Selected
  89. </button>
  90. </div>
  91. <p class="text-muted small mb-2">
  92. Edit the <strong>Paddock / Sample ID</strong> if needed, uncheck any rows to skip,
  93. then click <em>Import Selected</em>. Records are saved directly — no need to fill the form below.
  94. </p>
  95. <div class="table-responsive">
  96. <table class="table table-sm table-hover align-middle mb-0">
  97. <thead class="table-light">
  98. <tr>
  99. <th class="text-center" style="width:40px">
  100. <input type="checkbox" class="form-check-input" id="bulk-select-all" checked title="Select all">
  101. </th>
  102. <th>Lab No.</th>
  103. <th>Paddock / Sample ID</th>
  104. <th>Client</th>
  105. <th>Crop</th>
  106. <th class="text-center" style="width:50px">Form</th>
  107. </tr>
  108. </thead>
  109. <tbody id="bulk-import-tbody"></tbody>
  110. </table>
  111. </div>
  112. </div>
  113. <p class="text-muted small mt-3 mb-0">
  114. <i class="fas fa-info-circle me-1"></i>
  115. Fields highlighted in green were auto-populated. Always review before submitting.
  116. </p>
  117. </div>
  118. </div>
  119. <?php // include __DIR__ . '/../../../controllers/soilTestSubmit.php'; ?>
  120. <!-- old modX placeholders: [[!clientDetailsFORM]], [[!soilformSubmit]], [[!newClientDetails]] -->
  121. </div>
  122. </div>
  123. </div>
  124. </main>
  125. </div>
  126. </div>
  127. <script src="/client-assets/js/soil-import.js"></script>
  128. <?php include __DIR__ . '/../../../layouts/footer.php'; ?>