routine burberry
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Routine: burberry
|
||||
*
|
||||
* Purpose:
|
||||
* For each imported XLS row:
|
||||
* - read the value from column S
|
||||
* - read the value from column T
|
||||
* - merge the values
|
||||
* - save the final value into column S
|
||||
*
|
||||
* Target:
|
||||
* Column S 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:
|
||||
*
|
||||
* S = 18
|
||||
* T = 19
|
||||
*/
|
||||
$targetColumnIndex = 18; // S
|
||||
|
||||
$columnSIndex = 18; // S
|
||||
$columnTIndex = 19; // T
|
||||
|
||||
foreach ($excelData as $rowIndex => &$row) {
|
||||
if (!isset($row['data']) || !is_array($row['data'])) {
|
||||
error_log("Routine burberry: invalid row structure at index {$rowIndex}.");
|
||||
continue;
|
||||
}
|
||||
|
||||
$valueS = trim((string)($row['data'][$columnSIndex] ?? ''));
|
||||
$valueT = trim((string)($row['data'][$columnTIndex] ?? ''));
|
||||
|
||||
/*
|
||||
* Merge values, ignoring empty values.
|
||||
*/
|
||||
$mergedValues = [];
|
||||
|
||||
if ($valueS !== '') {
|
||||
$mergedValues[] = $valueS;
|
||||
}
|
||||
|
||||
if ($valueT !== '') {
|
||||
$mergedValues[] = $valueT;
|
||||
}
|
||||
|
||||
/*
|
||||
* Save final value into column S.
|
||||
*/
|
||||
$row['data'][$targetColumnIndex] = implode(' ', $mergedValues);
|
||||
|
||||
error_log(
|
||||
"Routine burberry: row " .
|
||||
($row['excelrow'] ?? $rowIndex) .
|
||||
" generated value in column S: " .
|
||||
$row['data'][$targetColumnIndex]
|
||||
);
|
||||
}
|
||||
|
||||
unset($row);
|
||||
|
||||
error_log("Routine burberry completed.");
|
||||
}
|
||||
Reference in New Issue
Block a user