soilTestSubmit.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <?php
  2. /**
  3. * controllers/soilTestSubmit.php
  4. *
  5. * Secure soil test form submission handler.
  6. * Replaces modX [[!soilformSubmit]] snippet.
  7. */
  8. // Start session if not already started
  9. if (session_status() === PHP_SESSION_NONE) {
  10. session_start();
  11. }
  12. // Include configuration and dependencies
  13. require_once __DIR__ . '/../config/database.php';
  14. require_once __DIR__ . '/../lib/auth.php';
  15. require_once __DIR__ . '/../lib/validation.php';
  16. require_once __DIR__ . '/../lib/csrf.php';
  17. // Check authentication
  18. if (!isLoggedIn()) {
  19. http_response_code(403);
  20. die('Access denied: User not authenticated');
  21. }
  22. // Check CSRF token
  23. if (!verifyCsrfToken($_POST['csrf_token'] ?? '')) {
  24. http_response_code(403);
  25. die('CSRF token validation failed');
  26. }
  27. // Only process POST requests
  28. if ($_SERVER['REQUEST_METHOD'] !== 'POST' || !isset($_POST['SoilcsvForm'])) {
  29. http_response_code(405);
  30. die('Method not allowed');
  31. }
  32. try {
  33. // Validate and sanitize input data
  34. $input = validateSoilTestData($_POST);
  35. // Perform soil analysis calculations
  36. $calculations = calculateSoilAnalysis($input);
  37. // Generate unique identifier for this record
  38. $rand = mt_rand(10000, 99999);
  39. // Insert data into database
  40. $recordId = insertSoilRecord($input, $calculations, $rand);
  41. // Log successful submission
  42. error_log("Soil test record created: ID {$recordId}, User: {$_SESSION['user_id']}");
  43. // Redirect to results page
  44. $redirectUrl = "/dashboard/crop-analysis/soil-analysis.php?rand={$rand}&cid={$input['sample_id']}&rid={$recordId}&stid=" . urlencode($input['crop_type']);
  45. header("Location: {$redirectUrl}");
  46. exit;
  47. } catch (ValidationException $e) {
  48. http_response_code(400);
  49. die('Validation error: ' . htmlspecialchars($e->getMessage()));
  50. } catch (PDOException $e) {
  51. error_log("Database error in soil test submission: " . $e->getMessage());
  52. http_response_code(500);
  53. die('Database error occurred. Please try again later.');
  54. } catch (Exception $e) {
  55. error_log("Unexpected error in soil test submission: " . $e->getMessage());
  56. http_response_code(500);
  57. die('An unexpected error occurred. Please try again later.');
  58. }
  59. /**
  60. * Validate and sanitize soil test form data
  61. */
  62. function validateSoilTestData(array $post): array
  63. {
  64. $validated = [];
  65. // Client information
  66. $validated['client_id'] = filter_var($post['client_id'] ?? '', FILTER_VALIDATE_INT);
  67. if ($validated['client_id'] === false) {
  68. throw new ValidationException('Invalid client ID');
  69. }
  70. $validated['name'] = sanitizeString($post['name'] ?? '', 100);
  71. $validated['company'] = sanitizeString($post['company'] ?? '', 100);
  72. $validated['email'] = filter_var($post['email'] ?? '', FILTER_VALIDATE_EMAIL);
  73. if ($validated['email'] === false) {
  74. throw new ValidationException('Invalid email address');
  75. }
  76. $validated['site_address'] = sanitizeString($post['site_address'] ?? '', 255);
  77. $validated['state_postcode'] = sanitizeString($post['state_postcode'] ?? '', 100);
  78. // Analysis details
  79. $validated['lab_no'] = sanitizeString($post['lab_no'] ?? '', 50);
  80. $validated['batch_no'] = sanitizeString($post['batch_no'] ?? '', 50);
  81. $validated['sample_id'] = sanitizeString($post['sample_id'] ?? '', 50);
  82. $validated['site_id'] = sanitizeString($post['site_id'] ?? '', 50);
  83. $validated['crop_type'] = sanitizeString($post['crop_type'] ?? '', 50);
  84. $validated['soil_type'] = sanitizeString($post['soil_type'] ?? '', 50);
  85. $validated['date_sampled'] = $post['date_sampled'] ?? '';
  86. if (!empty($validated['date_sampled'])) {
  87. $date = DateTime::createFromFormat('Y-m-d', $validated['date_sampled']);
  88. if (!$date) {
  89. throw new ValidationException('Invalid date sampled format');
  90. }
  91. $validated['date_sampled'] = $date->format('Y-m-d');
  92. }
  93. // Physical properties
  94. $validated['texture'] = sanitizeString($post['texture'] ?? '', 50);
  95. $validated['gravel'] = validateNumeric($post['gravel'] ?? '', 0, 100);
  96. $validated['colour'] = sanitizeString($post['colour'] ?? '', 50);
  97. $validated['ocarbon'] = validateNumeric($post['ocarbon'] ?? '', 0, 100);
  98. $validated['omatter'] = validateNumeric($post['omatter'] ?? '', 0, 100);
  99. // Chemical properties
  100. $validated['ph_cacl2'] = validateNumeric($post['ph_cacl2'] ?? '', 0, 14);
  101. $validated['ph_h2o'] = validateNumeric($post['ph_h2o'] ?? '', 0, 14);
  102. $validated['paramag'] = validateNumeric($post['paramag'] ?? '');
  103. $validated['ec'] = validateNumeric($post['ec'] ?? '', 0);
  104. // Nutrient analysis
  105. $nutrientFields = [
  106. 'NO3_N', 'NH3_N', 'p_mehlick', 'p_bray2', 'p_morgan', 'k_morgan',
  107. 'ca_morgan', 'mg_morgan', 'na_morgan', 'ch_h2o', 'fe', 's_morgan',
  108. 'b_cacl2', 'mn_dtpa', 'zn_dtpa', 'fe_dtpa', 'cu_dtpa', 'al',
  109. 'sl_cacl2', 'm_dtpa', 'co_dtpa', 'se'
  110. ];
  111. foreach ($nutrientFields as $field) {
  112. $validated[$field] = validateNumeric($post[$field] ?? '', 0);
  113. }
  114. // Base saturation
  115. $validated['tec'] = validateNumeric($post['tec'] ?? '');
  116. $validated['cec'] = validateNumeric($post['cec'] ?? '');
  117. $validated['ca_mehlick3'] = validateNumeric($post['ca_mehlick3'] ?? '');
  118. $validated['mg_mehlick3'] = validateNumeric($post['mg_mehlick3'] ?? '');
  119. $validated['k_mehlick3'] = validateNumeric($post['k_mehlick3'] ?? '');
  120. $validated['na_mehlick3'] = validateNumeric($post['na_mehlick3'] ?? '');
  121. $validated['al_mehlick3'] = validateNumeric($post['al_mehlick3'] ?? '');
  122. // Additional calculations
  123. $validated['c_total'] = validateNumeric($post['c_total'] ?? '');
  124. $validated['n_total'] = validateNumeric($post['n_total'] ?? '');
  125. return $validated;
  126. }
  127. /**
  128. * Perform soil analysis calculations
  129. */
  130. function calculateSoilAnalysis(array $data): array
  131. {
  132. $calculations = [];
  133. // pH lookup table
  134. $phRange = [
  135. 30 => [75.0, 11.4], 31 => [74.0, 11.2], 32 => [73.0, 11.0], 33 => [72.0, 10.8],
  136. 34 => [71.0, 10.6], 35 => [70.0, 10.4], 36 => [69.0, 10.2], 37 => [68.0, 10.0],
  137. 38 => [67.0, 9.8], 39 => [66.0, 9.6], 40 => [65.0, 9.4], 41 => [63.0, 9.2],
  138. 42 => [61.0, 9.0], 43 => [59.0, 8.8], 44 => [57.0, 8.6], 45 => [55.0, 8.4],
  139. 46 => [53.0, 8.2], 47 => [51.0, 8.0], 48 => [49.0, 7.8], 49 => [47.0, 7.6],
  140. 50 => [45.0, 7.4], 51 => [42.0, 7.2], 52 => [39.0, 7.0], 53 => [36.0, 6.8],
  141. 54 => [33.0, 6.6], 55 => [30.0, 6.4], 56 => [27.0, 6.2], 57 => [24.0, 6.0],
  142. 58 => [21.0, 5.8], 59 => [18.0, 5.6], 60 => [15.0, 5.4], 61 => [13.5, 5.3],
  143. 62 => [12.0, 5.2], 63 => [10.5, 5.1], 64 => [9.0, 5.0], 65 => [7.5, 4.9],
  144. 66 => [6.0, 4.8], 67 => [4.5, 4.7], 68 => [3.0, 4.6], 69 => [1.5, 4.5],
  145. 70 => [0.0, 4.4], 71 => [0.0, 4.3], 72 => [0.0, 4.2], 73 => [0.0, 4.1],
  146. 74 => [0.0, 4.0], 75 => [0.0, 3.9], 76 => [0.0, 3.8], 77 => [0.0, 3.7],
  147. 78 => [0.0, 3.6], 79 => [0.0, 3.5], 80 => [0.0, 3.4], 81 => [0.0, 3.3],
  148. 82 => [0.0, 3.2], 83 => [0.0, 3.1], 84 => [0.0, 3.0], 85 => [0.0, 2.9],
  149. 86 => [0.0, 2.8], 87 => [0.0, 2.7], 88 => [0.0, 2.6], 89 => [0.0, 2.5],
  150. 90 => [0.0, 2.4], 91 => [0.0, 2.3], 92 => [0.0, 2.2], 93 => [0.0, 2.1],
  151. 94 => [0.0, 2.0], 95 => [0.0, 1.9], 96 => [0.0, 1.8], 97 => [0.0, 1.7],
  152. 98 => [0.0, 1.6], 99 => [0.0, 1.5], 100 => [0.0, 1.4],
  153. ];
  154. // Base saturation calculations
  155. $ph = $data['ph_h2o'];
  156. $aluminium = $data['al_mehlick3'];
  157. $phLookup = round($ph * 10);
  158. $hydrogen = $phRange[$phLookup][0] ?? 0;
  159. $otherbases = $phRange[$phLookup][1] ?? 0;
  160. $calculations['h_rec'] = round($hydrogen, 2);
  161. $calculations['ob_rec'] = round($otherbases, 2);
  162. if ($aluminium < 0) {
  163. $otherbases = 0;
  164. }
  165. // Calculate hydrogen and other bases results
  166. $obresult = 0;
  167. $hresult = 0;
  168. if ($otherbases > 0) {
  169. while ((($obresult * 100) / ($data['cec'] + $obresult + $hresult)) <= $otherbases) {
  170. $obresult += 0.001;
  171. $hresult = ($obresult * $hydrogen) / $otherbases;
  172. }
  173. $obresult -= 0.001;
  174. if ($hresult != 0) {
  175. $hresult -= 0.001;
  176. }
  177. } else {
  178. while ((($hresult * 100) / $data['tec']) <= $hydrogen) {
  179. $hresult += 0.001;
  180. }
  181. $hresult -= 0.001;
  182. }
  183. $tecTemp = $data['cec'] + $obresult + $hresult;
  184. $calculations['tec'] = round($tecTemp, 2);
  185. $calculations['cec'] = round($data['cec'], 2);
  186. // Base saturation percentages and recommendations
  187. $tec = $calculations['tec'];
  188. if ($tec >= 1 && $tec <= 3) {
  189. $calculations['cabs_max'] = 60.00; $calculations['mgbs_max'] = 20.00; $calculations['kbs'] = 5.00; $calculations['kbs_max'] = 7.00; $calculations['nabs_max'] = 1.50;
  190. } elseif ($tec > 3 && $tec <= 5) {
  191. $calculations['cabs_max'] = 62.00; $calculations['mgbs_max'] = 18.00; $calculations['kbs'] = 5.00; $calculations['kbs_max'] = 7.00; $calculations['nabs_max'] = 1.50;
  192. } elseif ($tec > 5 && $tec <= 7) {
  193. $calculations['cabs_max'] = 64.00; $calculations['mgbs_max'] = 16.00; $calculations['kbs'] = 4.00; $calculations['kbs_max'] = 7.00; $calculations['nabs_max'] = 1.50;
  194. } elseif ($tec > 7 && $tec <= 9) {
  195. $calculations['cabs_max'] = 65.00; $calculations['mgbs_max'] = 15.00; $calculations['kbs'] = 4.00; $calculations['kbs_max'] = 7.00; $calculations['nabs_max'] = 1.50;
  196. } elseif ($tec > 9 && $tec <= 11) {
  197. $calculations['cabs_max'] = 67.00; $calculations['mgbs_max'] = 13.00; $calculations['kbs'] = 4.00; $calculations['kbs_max'] = 7.00; $calculations['nabs_max'] = 1.50;
  198. } elseif ($tec > 11 && $tec <= 30) {
  199. $calculations['cabs_max'] = 68.00; $calculations['mgbs_max'] = 12.00; $calculations['kbs'] = 4.00; $calculations['kbs_max'] = 7.00; $calculations['nabs_max'] = 1.50;
  200. } else {
  201. $calculations['cabs_max'] = 70.00; $calculations['mgbs_max'] = 10.00; $calculations['kbs'] = 3.00; $calculations['kbs_max'] = 6.00; $calculations['nabs_max'] = 1.50;
  202. }
  203. // Calculate percentages and PPM values
  204. $calculations['cabs_tec'] = round(($data['ca_mehlick3'] / $tec) * 100, 2);
  205. $calculations['mgbs_tec'] = round(($data['mg_mehlick3'] / $tec) * 100, 2);
  206. $calculations['kbs_tec'] = round(($data['k_mehlick3'] / $tec) * 100, 2);
  207. $calculations['nabs_tec'] = round(($data['na_mehlick3'] / $tec) * 100, 2);
  208. $calculations['albs_tec'] = round(($data['al_mehlick3'] / $tec) * 100, 2);
  209. $calculations['BS_ca_ppm'] = $data['ca_mehlick3'] * 200;
  210. $calculations['BS_mg_ppm'] = $data['mg_mehlick3'] * 120;
  211. $calculations['BS_k_ppm'] = $data['k_mehlick3'] * 390;
  212. $calculations['BS_na_ppm'] = $data['na_mehlick3'] * 230;
  213. $calculations['BS_al_ppm'] = $data['al_mehlick3'] * 90;
  214. // Calculate ratios
  215. $calculations['ca_mg_ratio'] = $data['mg_mehlick3'] > 0 ? round($data['ca_mehlick3'] / $data['mg_mehlick3'], 2) : 0;
  216. $calculations['c_n_ratio'] = $data['n_total'] > 0 ? round($data['c_total'] / $data['n_total'], 2) : 0;
  217. return $calculations;
  218. }
  219. /**
  220. * Insert soil record into database
  221. */
  222. function insertSoilRecord(array $data, array $calculations, int $rand): int
  223. {
  224. global $pdo;
  225. $sql = "INSERT INTO soil_records (
  226. client_records_id, modx_user_id, date, email, client_name, site_address, state_postcode,
  227. analysis_type, lab_no, batch_no, sample_id, site_id, crop_type, soil_type, date_sampled,
  228. tec, cec, texture, gravel, colour, NO3_N, NH3_N, p_mehlick, p_bray2, p_morgan,
  229. k_morgan, ca_morgan, mg_morgan, na_morgan, ch_h2o, ocarbon, omatter, fe, ec,
  230. ph_cacl2, ph_h2o, paramag, s_morgan, b_cacl2, mn_dtpa, zn_dtpa, fe_dtpa, cu_dtpa,
  231. al, sl_cacl2, m_dtpa, co_dtpa, se, ca_mehlick3, BS_ca_ppm, mg_mehlick3, BS_mg_ppm,
  232. k_mehlick3, BS_k_ppm, na_mehlick3, BS_na_ppm, al_mehlick3, BS_al_ppm,
  233. BS_ca2, BS_mg2, BS_k, BS_na, BS_al3, BS_ob, BS_h,
  234. cabs_min, ca_ppm_min, cabs_max, ca_ppm_max, mgbs_min, mg_ppm_min, mgbs_max, mg_ppm_max,
  235. kbs_min, k_ppm_min, kbs_max, k_ppm_max, nabs_min, na_ppm_min, nabs_max, na_ppm_max,
  236. albs_min, al_ppm_min, albs_max, al_ppm_max, ob_rec, h_rec, ca_mg_ratio, rand
  237. ) VALUES (
  238. :client_id, :modx_user_id, NOW(), :email, :client_name, :site_address, :state_postcode,
  239. 'Soil Test', :lab_no, :batch_no, :sample_id, :site_id, :crop_type, :soil_type, :date_sampled,
  240. :tec, :cec, :texture, :gravel, :colour, :NO3_N, :NH3_N, :p_mehlick, :p_bray2, :p_morgan,
  241. :k_morgan, :ca_morgan, :mg_morgan, :na_morgan, :ch_h2o, :ocarbon, :omatter, :fe, :ec,
  242. :ph_cacl2, :ph_h2o, :paramag, :s_morgan, :b_cacl2, :mn_dtpa, :zn_dtpa, :fe_dtpa, :cu_dtpa,
  243. :al, :sl_cacl2, :m_dtpa, :co_dtpa, :se, :ca_mehlick3, :BS_ca_ppm, :mg_mehlick3, :BS_mg_ppm,
  244. :k_mehlick3, :BS_k_ppm, :na_mehlick3, :BS_na_ppm, :al_mehlick3, :BS_al_ppm,
  245. :cabs_tec, :mgbs_tec, :kbs_tec, :nabs_tec, :al_mehlick3, :ob_rec, :h_rec,
  246. 0, 0, :cabs_max, :ca_ppm_max, 0, 0, :mgbs_max, :mg_ppm_max,
  247. :kbs, :k_ppm_min, :kbs_max, :k_ppm_max, 0.50, :na_ppm_min, :nabs_max, :na_ppm_max,
  248. 0, 0, 0.5, :al_ppm_max, :ob_rec, :h_rec, :ca_mg_ratio, :rand
  249. )";
  250. $stmt = $pdo->prepare($sql);
  251. $stmt->execute([
  252. 'client_id' => $data['client_id'],
  253. 'modx_user_id' => $_SESSION['user_id'],
  254. 'email' => $data['email'],
  255. 'client_name' => $data['name'],
  256. 'site_address' => $data['site_address'],
  257. 'state_postcode' => $data['state_postcode'],
  258. 'lab_no' => $data['lab_no'],
  259. 'batch_no' => $data['batch_no'],
  260. 'sample_id' => $data['sample_id'],
  261. 'site_id' => $data['site_id'],
  262. 'crop_type' => $data['crop_type'],
  263. 'soil_type' => $data['soil_type'],
  264. 'date_sampled' => $data['date_sampled'],
  265. 'tec' => $calculations['tec'],
  266. 'cec' => $calculations['cec'],
  267. 'texture' => $data['texture'] ?: null,
  268. 'gravel' => $data['gravel'],
  269. 'colour' => $data['colour'] ?: null,
  270. 'NO3_N' => $data['NO3_N'],
  271. 'NH3_N' => $data['NH3_N'],
  272. 'p_mehlick' => $data['p_mehlick'],
  273. 'p_bray2' => $data['p_bray2'],
  274. 'p_morgan' => $data['p_morgan'],
  275. 'k_morgan' => $data['k_morgan'],
  276. 'ca_morgan' => $data['ca_morgan'],
  277. 'mg_morgan' => $data['mg_morgan'],
  278. 'na_morgan' => $data['na_morgan'],
  279. 'ch_h2o' => $data['ch_h2o'],
  280. 'ocarbon' => $data['ocarbon'],
  281. 'omatter' => $data['omatter'],
  282. 'fe' => $data['fe'],
  283. 'ec' => $data['ec'],
  284. 'ph_cacl2' => $data['ph_cacl2'],
  285. 'ph_h2o' => $data['ph_h2o'],
  286. 'paramag' => $data['paramag'] ?: null,
  287. 's_morgan' => $data['s_morgan'],
  288. 'b_cacl2' => $data['b_cacl2'],
  289. 'mn_dtpa' => $data['mn_dtpa'],
  290. 'zn_dtpa' => $data['zn_dtpa'],
  291. 'fe_dtpa' => $data['fe_dtpa'],
  292. 'cu_dtpa' => $data['cu_dtpa'],
  293. 'al' => $data['al'],
  294. 'sl_cacl2' => $data['sl_cacl2'],
  295. 'm_dtpa' => $data['m_dtpa'],
  296. 'co_dtpa' => $data['co_dtpa'],
  297. 'se' => $data['se'],
  298. 'ca_mehlick3' => $data['ca_mehlick3'],
  299. 'BS_ca_ppm' => $calculations['BS_ca_ppm'],
  300. 'mg_mehlick3' => $data['mg_mehlick3'],
  301. 'BS_mg_ppm' => $calculations['BS_mg_ppm'],
  302. 'k_mehlick3' => $data['k_mehlick3'],
  303. 'BS_k_ppm' => $calculations['BS_k_ppm'],
  304. 'na_mehlick3' => $data['na_mehlick3'],
  305. 'BS_na_ppm' => $calculations['BS_na_ppm'],
  306. 'al_mehlick3' => $data['al_mehlick3'],
  307. 'BS_al_ppm' => $calculations['BS_al_ppm'],
  308. 'cabs_tec' => $calculations['cabs_tec'],
  309. 'mgbs_tec' => $calculations['mgbs_tec'],
  310. 'kbs_tec' => $calculations['kbs_tec'],
  311. 'nabs_tec' => $calculations['nabs_tec'],
  312. 'cabs_max' => $calculations['cabs_max'],
  313. 'ca_ppm_max' => $calculations['tec'] * $calculations['cabs_max'] * 2,
  314. 'mgbs_max' => $calculations['mgbs_max'],
  315. 'mg_ppm_max' => $calculations['tec'] * $calculations['mgbs_max'] * 1.2,
  316. 'kbs' => $calculations['kbs'],
  317. 'k_ppm_min' => $calculations['tec'] * $calculations['kbs'] * 3.9,
  318. 'kbs_max' => $calculations['kbs_max'],
  319. 'k_ppm_max' => $calculations['tec'] * $calculations['kbs_max'] * 3.9,
  320. 'na_ppm_min' => $calculations['tec'] * 0.5 * 2.3,
  321. 'nabs_max' => $calculations['nabs_max'],
  322. 'na_ppm_max' => $calculations['tec'] * $calculations['nabs_max'] * 2.3,
  323. 'al_ppm_max' => $calculations['tec'] * 0.5 * 0.9,
  324. 'ob_rec' => $calculations['ob_rec'],
  325. 'h_rec' => $calculations['h_rec'],
  326. 'ca_mg_ratio' => $calculations['ca_mg_ratio'],
  327. 'rand' => $rand
  328. ]);
  329. return $pdo->lastInsertId();
  330. }
  331. /**
  332. * Custom exception for validation errors
  333. */
  334. class ValidationException extends Exception {}
  335. /**
  336. * Sanitize string input
  337. */
  338. function sanitizeString(?string $value, int $maxLength = 255): string
  339. {
  340. if ($value === null) return '';
  341. $sanitized = trim($value);
  342. $sanitized = filter_var($sanitized, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
  343. return substr($sanitized, 0, $maxLength);
  344. }
  345. /**
  346. * Validate numeric input
  347. */
  348. function validateNumeric(?string $value, float $min = null, float $max = null): ?float
  349. {
  350. if ($value === '' || $value === null) return null;
  351. $numeric = filter_var($value, FILTER_VALIDATE_FLOAT);
  352. if ($numeric === false) {
  353. throw new ValidationException('Invalid numeric value: ' . $value);
  354. }
  355. if ($min !== null && $numeric < $min) {
  356. throw new ValidationException('Value below minimum: ' . $numeric);
  357. }
  358. if ($max !== null && $numeric > $max) {
  359. throw new ValidationException('Value above maximum: ' . $numeric);
  360. }
  361. return $numeric;
  362. }
  363. ?>