MSIN-4469 — Enhance fxBibProductionXmlSetFormula function to support cached values for Excel output, preventing empty totals in Excel/LibreOffice until recalculation occurs. Update fxBibProductionBuildOrderXml to utilize this new functionality for improved total calculations. Increment version code.
This commit is contained in:
@ -342,7 +342,8 @@ function fxBibProductionXmlSetFormula(
|
||||
$strColumn,
|
||||
$intRow,
|
||||
$strFormula,
|
||||
$strStyle = ''
|
||||
$strStyle = '',
|
||||
$mixCachedValue = null
|
||||
) {
|
||||
$strNs = 'http://schemas.openxmlformats.org/spreadsheetml/2006/main';
|
||||
$objCell = fxBibProductionXmlEnsureCell($objDom, $objRow, $strColumn, $intRow, $strStyle);
|
||||
@ -350,6 +351,13 @@ function fxBibProductionXmlSetFormula(
|
||||
$objFormula = $objDom->createElementNS($strNs, 'f');
|
||||
$objFormula->appendChild($objDom->createTextNode($strFormula));
|
||||
$objCell->appendChild($objFormula);
|
||||
// MSIN-4469 — Valeur calculée en cache : sinon Excel/LibreOffice peut
|
||||
// afficher le TOTAL vide tant que le recalcul n'a pas tourné.
|
||||
if ($mixCachedValue !== null && $mixCachedValue !== '') {
|
||||
$objValue = $objDom->createElementNS($strNs, 'v');
|
||||
$objValue->appendChild($objDom->createTextNode((string)$mixCachedValue));
|
||||
$objCell->appendChild($objValue);
|
||||
}
|
||||
}
|
||||
|
||||
function fxBibProductionXmlCloneRow(DOMElement $objTemplateRow, $intTargetRow) {
|
||||
@ -574,23 +582,68 @@ function fxBibProductionBuildOrderXml($strXml, array $tabSnapshot, array $tabLab
|
||||
$objHeaderRow,
|
||||
'K',
|
||||
3,
|
||||
$tabLabels['printer_lines'],
|
||||
isset($tabLabels['printer_lines']) ? $tabLabels['printer_lines'] : 'Lignes Imprimeur',
|
||||
$strHeaderStyleK
|
||||
);
|
||||
}
|
||||
|
||||
$intBibTotal = 0;
|
||||
foreach ($tabOrderRows as $tabRow) {
|
||||
$intBibTotal += (int)$tabRow['quantity'];
|
||||
}
|
||||
|
||||
// Reprendre la ligne TOTAL après les insertions (référence DOM à jour).
|
||||
$objTotal = fxBibProductionXmlFindRow($objXpath, $intTotalRow);
|
||||
if (!$objTotal) {
|
||||
throw new Exception('MSIN-4469 total row missing');
|
||||
}
|
||||
|
||||
fxBibProductionXmlSetInlineString($objDom, $objTotal, 'A', $intTotalRow, $tabLabels['total']);
|
||||
fxBibProductionXmlSetFormula($objDom, $objTotal, 'F', $intTotalRow, 'SUM(F4:F' . ($intTotalRow - 1) . ')');
|
||||
fxBibProductionXmlSetFormula($objDom, $objTotal, 'I', $intTotalRow, 'SUM(I4:I' . ($intTotalRow - 1) . ')');
|
||||
fxBibProductionXmlSetFormula($objDom, $objTotal, 'L', $intTotalRow, 'SUM(L4:L' . ($intTotalRow - 1) . ')');
|
||||
// COUNT ne compte que les numéros (ignore en-tête texte et lignes blanches entre épreuves).
|
||||
fxBibProductionXmlSetFormula($objDom, $objTotal, 'K', $intTotalRow, 'COUNT(Imprimeur!A:A)');
|
||||
fxBibProductionXmlSetFormula(
|
||||
$objDom,
|
||||
$objTotal,
|
||||
'F',
|
||||
$intTotalRow,
|
||||
'SUM(F4:F' . ($intTotalRow - 1) . ')',
|
||||
'',
|
||||
$intBibTotal
|
||||
);
|
||||
fxBibProductionXmlSetFormula(
|
||||
$objDom,
|
||||
$objTotal,
|
||||
'I',
|
||||
$intTotalRow,
|
||||
'SUM(I4:I' . ($intTotalRow - 1) . ')',
|
||||
'',
|
||||
$intBibTotal
|
||||
);
|
||||
fxBibProductionXmlSetFormula(
|
||||
$objDom,
|
||||
$objTotal,
|
||||
'L',
|
||||
$intTotalRow,
|
||||
'SUM(L4:L' . ($intTotalRow - 1) . ')',
|
||||
'',
|
||||
$intBibTotal
|
||||
);
|
||||
// COUNT ignore l'en-tête texte et les lignes blanches entre épreuves.
|
||||
fxBibProductionXmlSetFormula(
|
||||
$objDom,
|
||||
$objTotal,
|
||||
'K',
|
||||
$intTotalRow,
|
||||
'COUNT(Imprimeur!A:A)',
|
||||
'',
|
||||
$intBibTotal
|
||||
);
|
||||
fxBibProductionXmlSetFormula(
|
||||
$objDom,
|
||||
$objTotal,
|
||||
'J',
|
||||
$intTotalRow,
|
||||
'F' . $intTotalRow . '=K' . $intTotalRow
|
||||
'F' . $intTotalRow . '=K' . $intTotalRow,
|
||||
'',
|
||||
'1'
|
||||
);
|
||||
|
||||
$objDimension = $objXpath->query('//m:dimension')->item(0);
|
||||
|
||||
Reference in New Issue
Block a user