From 0eb4f7a2ad3a6623da9455df3f23797d5e81e952 Mon Sep 17 00:00:00 2001 From: solocla Date: Tue, 19 May 2026 11:12:18 +0200 Subject: [PATCH] valentino routine --- .../routines/valentino_compliance.php | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 public/userarea/routines/valentino_compliance.php diff --git a/public/userarea/routines/valentino_compliance.php b/public/userarea/routines/valentino_compliance.php new file mode 100644 index 0000000..e3b09ff --- /dev/null +++ b/public/userarea/routines/valentino_compliance.php @@ -0,0 +1,99 @@ + &$row) { + if (!isset($row['data']) || !is_array($row['data'])) { + error_log("Routine field_id 347: invalid row structure at index {$rowIndex}."); + continue; + } + + $selectedValues = []; + + /* + * Check columns from P to AT. + * If the cell contains x, take the related column header. + */ + for ($columnIndex = $startColumnIndex; $columnIndex <= $endColumnIndex; $columnIndex++) { + $cellValue = strtolower(trim((string)($row['data'][$columnIndex] ?? ''))); + + if ($cellValue === 'x') { + $headerTitle = trim((string)($headers[$columnIndex] ?? '')); + + if ($headerTitle !== '') { + $selectedValues[] = $headerTitle; + } + } + } + + /* + * Add free text from column AU. + */ + $extraText = trim((string)($row['data'][$extraColumnIndex] ?? '')); + + if ($extraText !== '') { + $selectedValues[] = $extraText; + } + + /* + * Remove empty and duplicate values. + */ + $selectedValues = array_values(array_unique(array_filter($selectedValues, function ($value) { + return trim((string)$value) !== ''; + }))); + + /* + * Save final value into column P. + * Column P must be mapped to field_id 347 in the template mapping. + */ + $row['data'][$targetColumnIndex] = implode(', ', $selectedValues); + + error_log( + "Routine field_id 347: row " . + ($row['excelrow'] ?? $rowIndex) . + " generated value: " . + $row['data'][$targetColumnIndex] + ); + } + + unset($row); + + error_log("Routine field_id 347 completed."); +}