Files
trf_certest/public/userarea/routines/richemont_pelletteria.php
T

72 lines
1.7 KiB
PHP

<?php
/**
* Routine: Richemont Pelletteria
*
* Purpose:
* For each imported XLS row:
* - read the value from column D
* - read the value from column E
* - merge the values
* - save the final value into column D
*
* Target:
* Column D must be mapped to the destination field in the template mapping.
*/
function applyRoutine(&$excelData, $routineData = [])
{
/*
* This routine does not require external routine data.
* Columns are fixed.
*
* Excel column indexes are zero-based:
*
* D = 3
* E = 4
*/
$targetColumnIndex = 3; // D
$columnDIndex = 3; // D
$columnEIndex = 4; // E
foreach ($excelData as $rowIndex => &$row) {
if (!isset($row['data']) || !is_array($row['data'])) {
error_log("Routine Richemont Pelletteria: invalid row structure at index {$rowIndex}.");
continue;
}
$valueD = trim((string)($row['data'][$columnDIndex] ?? ''));
$valueE = trim((string)($row['data'][$columnEIndex] ?? ''));
/*
* Merge values, ignoring empty values.
*/
$mergedValues = [];
if ($valueD !== '') {
$mergedValues[] = $valueD;
}
if ($valueE !== '') {
$mergedValues[] = $valueE;
}
/*
* Save final value into column D.
*/
$row['data'][$targetColumnIndex] = implode(' ', $mergedValues);
error_log(
"Routine Richemont Pelletteria: row " .
($row['excelrow'] ?? $rowIndex) .
" generated value in column D: " .
$row['data'][$targetColumnIndex]
);
}
unset($row);
error_log("Routine Richemont Pelletteria completed.");
}