routine fendi

This commit is contained in:
2026-05-21 10:11:53 +02:00
parent 1d81d6c996
commit c5f27cb69a
+67
View File
@@ -0,0 +1,67 @@
<?php
/**
* Routine: merge_column_T_and_U_into_T
*
* Purpose:
* For each imported XLS row:
* - read the value from column T
* - read the value from column U
* - merge both values
* - save the final value into column T
*
* Target:
* Column T must be mapped to the destination field in the template mapping.
*/
function applyRoutine(&$excelData, $routineData = [])
{
/*
* Excel column indexes are zero-based:
*
* T = 19
* U = 20
*/
$targetColumnIndex = 19; // T
$firstColumnIndex = 19; // T
$secondColumnIndex = 20; // U
foreach ($excelData as $rowIndex => &$row) {
if (!isset($row['data']) || !is_array($row['data'])) {
error_log("Routine merge T+U: invalid row structure at index {$rowIndex}.");
continue;
}
$valueT = trim((string)($row['data'][$firstColumnIndex] ?? ''));
$valueU = trim((string)($row['data'][$secondColumnIndex] ?? ''));
/*
* Merge values, ignoring empty values.
*/
$mergedValues = [];
if ($valueT !== '') {
$mergedValues[] = $valueT;
}
if ($valueU !== '') {
$mergedValues[] = $valueU;
}
/*
* Save final value into column T.
*/
$row['data'][$targetColumnIndex] = implode(' ', $mergedValues);
error_log(
"Routine merge T+U: row " .
($row['excelrow'] ?? $rowIndex) .
" generated value in column T: " .
$row['data'][$targetColumnIndex]
);
}
unset($row);
error_log("Routine merge T+U completed.");
}