feat: Version 3.5.2 - Configuration Stripe et gestion des immeubles

- Configuration complète Stripe pour les 3 environnements (DEV/REC/PROD)
  * DEV: Clés TEST Pierre (mode test)
  * REC: Clés TEST Client (mode test)
  * PROD: Clés LIVE Client (mode live)
- Ajout de la gestion des bases de données immeubles/bâtiments
  * Configuration buildings_database pour DEV/REC/PROD
  * Service BuildingService pour enrichissement des adresses
- Optimisations pages et améliorations ergonomie
- Mises à jour des dépendances Composer
- Nettoyage des fichiers obsolètes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
pierre
2025-11-09 18:26:27 +01:00
parent 21657a3820
commit 2f5946a184
812 changed files with 142105 additions and 25992 deletions

View File

@@ -6,6 +6,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
use PhpOffice\PhpSpreadsheet\Cell\AddressRange;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Cell\DataType;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PhpOffice\PhpSpreadsheet\Style\Conditional;
use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter;
use PhpOffice\PhpSpreadsheet\Worksheet\Table;
@@ -194,8 +195,10 @@ class ReferenceHelper
if ($cellReferenceHelper->cellAddressInDeleteRange($cellAddress) === true) {
$worksheet->setHyperlink($cellAddress, null);
} elseif ($cellAddress !== $newReference) {
$worksheet->setHyperlink($newReference, $value);
$worksheet->setHyperlink($cellAddress, null);
if ($newReference) {
$worksheet->setHyperlink($newReference, $value);
}
}
}
}
@@ -248,7 +251,7 @@ class ReferenceHelper
* @param int $numberOfColumns Number of columns to insert/delete (negative values indicate deletion)
* @param int $numberOfRows Number of rows to insert/delete (negative values indicate deletion)
*/
protected function adjustDataValidations(Worksheet $worksheet, int $numberOfColumns, int $numberOfRows): void
protected function adjustDataValidations(Worksheet $worksheet, int $numberOfColumns, int $numberOfRows, string $beforeCellAddress): void
{
$aDataValidationCollection = $worksheet->getDataValidationCollection();
($numberOfColumns > 0 || $numberOfRows > 0)
@@ -256,11 +259,45 @@ class ReferenceHelper
: uksort($aDataValidationCollection, [self::class, 'cellSort']);
foreach ($aDataValidationCollection as $cellAddress => $dataValidation) {
$newReference = $this->updateCellReference($cellAddress);
$formula = $dataValidation->getFormula1();
if ($formula !== '') {
$dataValidation->setFormula1(
$this->updateFormulaReferences(
$formula,
$beforeCellAddress,
$numberOfColumns,
$numberOfRows,
$worksheet->getTitle(),
true
)
);
}
$formula = $dataValidation->getFormula2();
if ($formula !== '') {
$dataValidation->setFormula2(
$this->updateFormulaReferences(
$formula,
$beforeCellAddress,
$numberOfColumns,
$numberOfRows,
$worksheet->getTitle(),
true
)
);
}
$addressParts = explode(' ', $cellAddress);
$newReference = '';
$separator = '';
foreach ($addressParts as $addressPart) {
$newReference .= $separator . $this->updateCellReference($addressPart);
$separator = ' ';
}
if ($cellAddress !== $newReference) {
$dataValidation->setSqref($newReference);
$worksheet->setDataValidation($newReference, $dataValidation);
$worksheet->setDataValidation($cellAddress, null);
if ($newReference) {
$worksheet->setDataValidation($newReference, $dataValidation);
}
}
}
}
@@ -276,7 +313,9 @@ class ReferenceHelper
$aNewMergeCells = []; // the new array of all merge cells
foreach ($aMergeCells as $cellAddress => &$value) {
$newReference = $this->updateCellReference($cellAddress);
$aNewMergeCells[$newReference] = $newReference;
if ($newReference) {
$aNewMergeCells[$newReference] = $newReference;
}
}
$worksheet->setMergeCells($aNewMergeCells); // replace the merge cells array
}
@@ -290,15 +329,17 @@ class ReferenceHelper
*/
protected function adjustProtectedCells(Worksheet $worksheet, int $numberOfColumns, int $numberOfRows): void
{
$aProtectedCells = $worksheet->getProtectedCells();
$aProtectedCells = $worksheet->getProtectedCellRanges();
($numberOfColumns > 0 || $numberOfRows > 0)
? uksort($aProtectedCells, [self::class, 'cellReverseSort'])
: uksort($aProtectedCells, [self::class, 'cellSort']);
foreach ($aProtectedCells as $cellAddress => $value) {
foreach ($aProtectedCells as $cellAddress => $protectedRange) {
$newReference = $this->updateCellReference($cellAddress);
if ($cellAddress !== $newReference) {
$worksheet->protectCells($newReference, $value, true);
$worksheet->unprotectCells($cellAddress);
if ($newReference) {
$worksheet->protectCells($newReference, $protectedRange->getPassword(), true);
}
}
}
}
@@ -410,7 +451,7 @@ class ReferenceHelper
}
$highColumn = Coordinate::columnIndexFromString($highestDataColumn);
for ($row = $startRow; $row <= $highestDataRow; ++$row) {
for ($col = $startCol, $colString = $startColString; $col <= $highColumn; ++$col, ++$colString) {
for ($col = $startCol, $colString = $startColString; $col <= $highColumn; ++$col, StringHelper::stringIncrement($colString)) {
$worksheet->getCell("$colString$row"); // create cell if it doesn't exist
}
}
@@ -426,7 +467,8 @@ class ReferenceHelper
$cell = $worksheet->getCell($coordinate);
$cellIndex = Coordinate::columnIndexFromString($cell->getColumn());
if ($cellIndex - 1 + $numberOfColumns < 0) {
// Don't update cells that are being removed
if ($numberOfColumns < 0 && $cellIndex >= $beforeColumn + $numberOfColumns && $cellIndex < $beforeColumn) {
continue;
}
@@ -464,7 +506,7 @@ class ReferenceHelper
$highestColumn = $worksheet->getHighestColumn();
$highestRow = $worksheet->getHighestRow();
if ($numberOfColumns > 0 && $beforeColumn - 2 > 0) {
if ($numberOfColumns > 0 && $beforeColumn > 1) {
$this->duplicateStylesByColumn($worksheet, $beforeColumn, $beforeRow, $highestRow, $numberOfColumns);
}
@@ -491,7 +533,7 @@ class ReferenceHelper
$this->adjustConditionalFormatting($worksheet, $numberOfColumns, $numberOfRows);
// Update worksheet: data validations
$this->adjustDataValidations($worksheet, $numberOfColumns, $numberOfRows);
$this->adjustDataValidations($worksheet, $numberOfColumns, $numberOfRows, $beforeCellAddress);
// Update worksheet: merge cells
$this->adjustMergeCells($worksheet);
@@ -516,12 +558,7 @@ class ReferenceHelper
$worksheet->freezePane($splitCell, $topLeftCell);
}
// Page setup
if ($worksheet->getPageSetup()->isPrintAreaSet()) {
$worksheet->getPageSetup()->setPrintArea(
$this->updateCellReference($worksheet->getPageSetup()->getPrintArea())
);
}
$this->updatePrintAreas($worksheet, $beforeCellAddress, $numberOfColumns, $numberOfRows);
// Update worksheet: drawings
$aDrawings = $worksheet->getDrawingCollection();
@@ -547,6 +584,93 @@ class ReferenceHelper
$worksheet->garbageCollect();
}
private function updatePrintAreas(Worksheet $worksheet, string $beforeCellAddress, int $numberOfColumns, int $numberOfRows): void
{
$pageSetup = $worksheet->getPageSetup();
if (!$pageSetup->isPrintAreaSet()) {
return;
}
$printAreas = explode(',', $pageSetup->getPrintArea());
$newPrintAreas = [];
foreach ($printAreas as $printArea) {
$result = $this->updatePrintArea($printArea, $beforeCellAddress, $numberOfColumns, $numberOfRows);
if ($result !== '') {
$newPrintAreas[] = $result;
}
}
$result = implode(',', $newPrintAreas);
if ($result === '') {
$pageSetup->clearPrintArea();
} else {
$pageSetup->setPrintArea($result);
}
}
private function updatePrintArea(string $printArea, string $beforeCellAddress, int $numberOfColumns, int $numberOfRows): string
{
$coordinates = Coordinate::indexesFromString($beforeCellAddress);
if (preg_match('/^([A-Z]{1,3})(\d{1,7}):([A-Z]{1,3})(\d{1,7})$/i', $printArea, $matches) === 1) {
$firstRow = (int) $matches[2];
$lastRow = (int) $matches[4];
$firstColumnString = $matches[1];
$lastColumnString = $matches[3];
if ($numberOfRows < 0) {
$affectedRow = $coordinates[1] + $numberOfRows - 1;
$lastAffectedRow = $coordinates[1] - 1;
if ($affectedRow >= $firstRow && $affectedRow <= $lastRow) {
$newLastRow = max($affectedRow, $lastRow + $numberOfRows);
if ($newLastRow >= $firstRow) {
return $matches[1] . $matches[2] . ':' . $matches[3] . $newLastRow;
}
return '';
}
if ($lastAffectedRow >= $firstRow && $affectedRow <= $lastRow) {
$newFirstRow = $affectedRow + 1;
$newLastRow = $lastRow + $numberOfRows;
if ($newFirstRow >= 1 && $newLastRow >= $newFirstRow) {
return $matches[1] . $newFirstRow . ':' . $matches[3] . $newLastRow;
}
return '';
}
}
if ($numberOfColumns < 0) {
$firstColumnInt = Coordinate::columnIndexFromString($firstColumnString);
$lastColumnInt = Coordinate::columnIndexFromString($lastColumnString);
$affectedColumn = $coordinates[0] + $numberOfColumns - 1;
$lastAffectedColumn = $coordinates[0] - 1;
if ($affectedColumn >= $firstColumnInt && $affectedColumn <= $lastColumnInt) {
$newLastColumnInt = max($affectedColumn, $lastColumnInt + $numberOfColumns);
if ($newLastColumnInt >= $firstColumnInt) {
$newLastColumnString = Coordinate::stringFromColumnIndex($newLastColumnInt);
return $matches[1] . $matches[2] . ':' . $newLastColumnString . $matches[4];
}
return '';
}
if ($affectedColumn < $firstColumnInt && $lastAffectedColumn > $lastColumnInt) {
return '';
}
if ($lastAffectedColumn >= $firstColumnInt && $lastAffectedColumn <= $lastColumnInt) {
$newFirstColumn = $affectedColumn + 1;
$newLastColumn = $lastColumnInt + $numberOfColumns;
if ($newFirstColumn >= 1 && $newLastColumn >= $newFirstColumn) {
$firstString = Coordinate::stringFromColumnIndex($newFirstColumn);
$lastString = Coordinate::stringFromColumnIndex($newLastColumn);
return $firstString . $matches[2] . ':' . $lastString . $matches[4];
}
return '';
}
}
}
return $this->updateCellReference($printArea);
}
private static function matchSheetName(?string $match, string $worksheetName): bool
{
return $match === null || $match === '' || $match === "'\u{fffc}'" || $match === "'\u{fffb}'" || strcasecmp(trim($match, "'"), $worksheetName) === 0;
@@ -602,8 +726,8 @@ class ReferenceHelper
if ($matchCount > 0) {
foreach ($matches as $match) {
$fromString = self::sheetnameBeforeCells($match[2], $worksheetName, "{$match[3]}:{$match[4]}");
$modified3 = substr($this->updateCellReference('$A' . $match[3], $includeAbsoluteReferences, $onlyAbsoluteReferences), 2);
$modified4 = substr($this->updateCellReference('$A' . $match[4], $includeAbsoluteReferences, $onlyAbsoluteReferences), 2);
$modified3 = substr($this->updateCellReference('$A' . $match[3], $includeAbsoluteReferences, $onlyAbsoluteReferences, true), 2);
$modified4 = substr($this->updateCellReference('$A' . $match[4], $includeAbsoluteReferences, $onlyAbsoluteReferences, false), 2);
if ($match[3] . ':' . $match[4] !== $modified3 . ':' . $modified4) {
if (self::matchSheetName($match[2], $worksheetName)) {
@@ -626,8 +750,8 @@ class ReferenceHelper
if ($matchCount > 0) {
foreach ($matches as $match) {
$fromString = self::sheetnameBeforeCells($match[2], $worksheetName, "{$match[3]}:{$match[4]}");
$modified3 = substr($this->updateCellReference($match[3] . '$1', $includeAbsoluteReferences, $onlyAbsoluteReferences), 0, -2);
$modified4 = substr($this->updateCellReference($match[4] . '$1', $includeAbsoluteReferences, $onlyAbsoluteReferences), 0, -2);
$modified3 = substr($this->updateCellReference($match[3] . '$1', $includeAbsoluteReferences, $onlyAbsoluteReferences, true), 0, -2);
$modified4 = substr($this->updateCellReference($match[4] . '$1', $includeAbsoluteReferences, $onlyAbsoluteReferences, false), 0, -2);
if ($match[3] . ':' . $match[4] !== $modified3 . ':' . $modified4) {
if (self::matchSheetName($match[2], $worksheetName)) {
@@ -650,8 +774,8 @@ class ReferenceHelper
if ($matchCount > 0) {
foreach ($matches as $match) {
$fromString = self::sheetnameBeforeCells($match[2], $worksheetName, "{$match[3]}:{$match[4]}");
$modified3 = $this->updateCellReference($match[3], $includeAbsoluteReferences, $onlyAbsoluteReferences);
$modified4 = $this->updateCellReference($match[4], $includeAbsoluteReferences, $onlyAbsoluteReferences);
$modified3 = $this->updateCellReference($match[3], $includeAbsoluteReferences, $onlyAbsoluteReferences, true);
$modified4 = $this->updateCellReference($match[4], $includeAbsoluteReferences, $onlyAbsoluteReferences, false);
if ($match[3] . $match[4] !== $modified3 . $modified4) {
if (self::matchSheetName($match[2], $worksheetName)) {
@@ -678,7 +802,7 @@ class ReferenceHelper
foreach ($matches as $match) {
$fromString = self::sheetnameBeforeCells($match[2], $worksheetName, "{$match[3]}");
$modified3 = $this->updateCellReference($match[3], $includeAbsoluteReferences, $onlyAbsoluteReferences);
$modified3 = $this->updateCellReference($match[3], $includeAbsoluteReferences, $onlyAbsoluteReferences, null);
if ($match[3] !== $modified3) {
if (self::matchSheetName($match[2], $worksheetName)) {
$toString = self::sheetnameBeforeCells($match[2], $worksheetName, "$modified3");
@@ -759,7 +883,7 @@ class ReferenceHelper
$column = $columns[$splitCount][0];
$row = $rows[$splitCount][0];
if (!empty($column) && $column[0] !== '$') {
if ($column[0] !== '$') {
$column = ((Coordinate::columnIndexFromString($column) + $numberOfColumns) % AddressRange::MAX_COLUMN_INT) ?: AddressRange::MAX_COLUMN_INT;
$column = Coordinate::stringFromColumnIndex($column);
$rowOffset -= ($columnLength - strlen($column));
@@ -859,7 +983,7 @@ class ReferenceHelper
*
* @return string Updated cell range
*/
private function updateCellReference(string $cellReference = 'A1', bool $includeAbsoluteReferences = false, bool $onlyAbsoluteReferences = false): string
private function updateCellReference(string $cellReference = 'A1', bool $includeAbsoluteReferences = false, bool $onlyAbsoluteReferences = false, ?bool $topLeft = null)
{
// Is it in another worksheet? Will not have to update anything.
if (str_contains($cellReference, '!')) {
@@ -871,7 +995,7 @@ class ReferenceHelper
/** @var CellReferenceHelper */
$cellReferenceHelper = $this->cellReferenceHelper;
return $cellReferenceHelper->updateCellReference($cellReference, $includeAbsoluteReferences, $onlyAbsoluteReferences);
return $cellReferenceHelper->updateCellReference($cellReference, $includeAbsoluteReferences, $onlyAbsoluteReferences, $topLeft);
}
// Range
@@ -977,14 +1101,14 @@ class ReferenceHelper
$cellReferenceHelper = $this->cellReferenceHelper;
if (ctype_alpha($range[$i][$j])) {
$range[$i][$j] = Coordinate::coordinateFromString(
$cellReferenceHelper->updateCellReference($range[$i][$j] . '1', $includeAbsoluteReferences, $onlyAbsoluteReferences)
$cellReferenceHelper->updateCellReference($range[$i][$j] . '1', $includeAbsoluteReferences, $onlyAbsoluteReferences, null)
)[0];
} elseif (ctype_digit($range[$i][$j])) {
$range[$i][$j] = Coordinate::coordinateFromString(
$cellReferenceHelper->updateCellReference('A' . $range[$i][$j], $includeAbsoluteReferences, $onlyAbsoluteReferences)
$cellReferenceHelper->updateCellReference('A' . $range[$i][$j], $includeAbsoluteReferences, $onlyAbsoluteReferences, null)
)[1];
} else {
$range[$i][$j] = $cellReferenceHelper->updateCellReference($range[$i][$j], $includeAbsoluteReferences, $onlyAbsoluteReferences);
$range[$i][$j] = $cellReferenceHelper->updateCellReference($range[$i][$j], $includeAbsoluteReferences, $onlyAbsoluteReferences, null);
}
}
}
@@ -999,7 +1123,7 @@ class ReferenceHelper
$endColumnId = Coordinate::stringFromColumnIndex($beforeColumn);
for ($row = 1; $row <= $highestRow - 1; ++$row) {
for ($column = $startColumnId; $column !== $endColumnId; ++$column) {
for ($column = $startColumnId; $column !== $endColumnId; StringHelper::stringIncrement($column)) {
$coordinate = $column . $row;
$this->clearStripCell($worksheet, $coordinate);
}
@@ -1009,9 +1133,9 @@ class ReferenceHelper
private function clearRowStrips(string $highestColumn, int $beforeColumn, int $beforeRow, int $numberOfRows, Worksheet $worksheet): void
{
$startColumnId = Coordinate::stringFromColumnIndex($beforeColumn);
++$highestColumn;
StringHelper::stringIncrement($highestColumn);
for ($column = $startColumnId; $column !== $highestColumn; ++$column) {
for ($column = $startColumnId; $column !== $highestColumn; StringHelper::stringIncrement($column)) {
for ($row = $beforeRow + $numberOfRows; $row <= $beforeRow - 1; ++$row) {
$coordinate = $column . $row;
$this->clearStripCell($worksheet, $coordinate);
@@ -1067,6 +1191,7 @@ class ReferenceHelper
}
}
/** @param mixed[] $autoFilterColumns */
private function adjustAutoFilterDeleteRules(int $columnIndex, int $numberOfColumns, array $autoFilterColumns, AutoFilter $autoFilter): void
{
// If we're actually deleting any columns that fall within the autofilter range,
@@ -1090,7 +1215,10 @@ class ReferenceHelper
$toColRef = $rangeEnd + $numberOfColumns;
do {
$autoFilter->shiftColumn(Coordinate::stringFromColumnIndex($endColRef), Coordinate::stringFromColumnIndex($toColRef));
$autoFilter->shiftColumn(
Coordinate::stringFromColumnIndex($endColRef),
Coordinate::stringFromColumnIndex($toColRef)
);
--$endColRef;
--$toColRef;
} while ($startColRef <= $endColRef);
@@ -1105,8 +1233,8 @@ class ReferenceHelper
do {
$autoFilter->shiftColumn($startColID, $toColID);
++$startColID;
++$toColID;
StringHelper::stringIncrement($toColID);
StringHelper::stringIncrement($startColID);
} while ($startColID !== $endColID);
}
@@ -1146,6 +1274,7 @@ class ReferenceHelper
}
}
/** @param mixed[] $tableColumns */
private function adjustTableDeleteRules(int $columnIndex, int $numberOfColumns, array $tableColumns, Table $table): void
{
// If we're actually deleting any columns that fall within the table range,
@@ -1169,7 +1298,10 @@ class ReferenceHelper
$toColRef = $rangeEnd + $numberOfColumns;
do {
$table->shiftColumn(Coordinate::stringFromColumnIndex($endColRef), Coordinate::stringFromColumnIndex($toColRef));
$table->shiftColumn(
Coordinate::stringFromColumnIndex($endColRef),
Coordinate::stringFromColumnIndex($toColRef)
);
--$endColRef;
--$toColRef;
} while ($startColRef <= $endColRef);
@@ -1184,15 +1316,15 @@ class ReferenceHelper
do {
$table->shiftColumn($startColID, $toColID);
++$startColID;
++$toColID;
StringHelper::stringIncrement($toColID);
StringHelper::stringIncrement($startColID);
} while ($startColID !== $endColID);
}
private function duplicateStylesByColumn(Worksheet $worksheet, int $beforeColumn, int $beforeRow, int $highestRow, int $numberOfColumns): void
{
$beforeColumnName = Coordinate::stringFromColumnIndex($beforeColumn - 1);
for ($i = $beforeRow; $i <= $highestRow - 1; ++$i) {
for ($i = $beforeRow; $i <= $highestRow; ++$i) {
// Style
$coordinate = $beforeColumnName . $i;
if ($worksheet->cellExists($coordinate)) {