added richmento pelletteria routine
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<?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.");
|
||||
}
|
||||
Reference in New Issue
Block a user