Commit 52accc28 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

- DataManager : Ajout de l'option "hard-delete" pour faire des delete à la...

- DataManager : Ajout de l'option "hard-delete" pour faire des delete à la place des historisations si nécessaire
- [Fix] Lorsque les colonnes d'historiques sont spécifiées à null, elle le restent. Pour qu'elles soient initialisées automatiquement, il ne faut pas fournir ces colonnes
parent 2bda5006
Loading
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
1.5.0 (26/06/2025)
------------------

- DataManager : Ajout de l'option "hard-delete" pour faire des delete à la place des historisations si nécessaire
- [Fix] Lorsque les colonnes d'historiques sont spécifiées à null, elle le restent. Pour qu'elles soient initialisées automatiquement, il ne faut pas fournir ces colonnes


1.4.3 (24/06/2025)
------------------

+26 −17
Original line number Diff line number Diff line
@@ -347,10 +347,10 @@ class Table
            $histoModificationCol   = $this->getBdd()->getOption(Bdd::OPTION_HISTO_MODIFICATION_COLUMN);
            $histoModificateurIdCol = $this->getBdd()->getOption(Bdd::OPTION_HISTO_MODIFICATEUR_ID_COLUMN);

            if (!isset($data[$histoCreationCol])) $data[$histoCreationCol] = new \DateTime();
            if (!isset($data[$histoCreateurIdCol])) $data[$histoCreateurIdCol] = $histoUserId;
            if (!isset($data[$histoModificationCol])) $data[$histoModificationCol] = new \DateTime();
            if (!isset($data[$histoModificateurIdCol])) $data[$histoModificateurIdCol] = $histoUserId;
            if (!array_key_exists($histoCreationCol, $data)) $data[$histoCreationCol] = new \DateTime();
            if (!array_key_exists($histoCreateurIdCol, $data)) $data[$histoCreateurIdCol] = $histoUserId;
            if (!array_key_exists($histoModificationCol, $data)) $data[$histoModificationCol] = new \DateTime();
            if (!array_key_exists($histoModificateurIdCol, $data)) $data[$histoModificateurIdCol] = $histoUserId;
        }

        $sourceId = (int)$bdd->getSourceId();
@@ -396,8 +396,8 @@ class Table
            $histoModificationCol   = $this->getBdd()->getOption(Bdd::OPTION_HISTO_MODIFICATION_COLUMN);
            $histoModificateurIdCol = $this->getBdd()->getOption(Bdd::OPTION_HISTO_MODIFICATEUR_ID_COLUMN);

            if (!isset($data[$histoModificationCol])) $data[$histoModificationCol] = new \DateTime();
            if (!isset($data[$histoModificateurIdCol])) $data[$histoModificateurIdCol] = $histoUserId;
            if (!array_key_exists($histoModificationCol, $data)) $data[$histoModificationCol] = new \DateTime();
            if (!array_key_exists($histoModificateurIdCol, $data)) $data[$histoModificateurIdCol] = $histoUserId;
        }

        $dataSql = '';
@@ -498,16 +498,17 @@ class Table
            'custom-select'      => null,
            'where'              => null,
            'key'                => $key,
            'delete'             => true,
            'soft-delete'        => true,
            'undelete'           => true,
            'insert'             => true,
            'update'             => true,
            'hard-delete'        => false, // force l'usage du delete plutôt que de l'historisation
            'delete'             => true,  // effectue ou non les actions de delete détectées
            'soft-delete'        => true,  // effectue ou non les actions d'historisation détectées
            'undelete'           => true,  // effectue ou non les actions de restauration détectées
            'insert'             => true,  // effectue ou non les actions d'insertions détectées
            'update'             => true,  // effectue ou non les actions de mises à jour détectées
            'return-insert-data' => false,
            'update-cols'        => [],
            'update-ignore-cols' => [],
            'update-only-null'   => [],
            'transaction'        => true,
            'transaction'        => true,  // Utilisation de transactions
            'id-column'          => $bdd->getOption(Bdd::OPTION_ID_COLUMN),
            'has-historique'     => $hasHistorique,
            'histo-user-id'      => null,
@@ -596,7 +597,7 @@ class Table
                    }
                }
            } else {
                if ($options['has-historique']) {
                if ($options['has-historique'] && !$options['hard-delete']) {
                    if (null === $o[$options['histo-destruction-column']]) {
                        // opération de soft-delete
                        if ($options['soft-delete']) {
@@ -666,11 +667,19 @@ class Table
        foreach ($new as $k => $n) {
            if ($options['insert']) {
                if ($hasHistorique) {
                    if (!array_key_exists($options['histo-creation-column'], $n)) {
                        $n[$options['histo-creation-column']] = $options['histo-date'];
                    }
                    if (!array_key_exists($options['histo-createur-id-column'], $n)) {
                        $n[$options['histo-createur-id-column']] = $options['histo-user-id'];
                    }
                    if (!array_key_exists($options['histo-modification-column'], $n)) {
                        $n[$options['histo-modification-column']] = $options['histo-date'];
                    }
                    if (!array_key_exists($options['histo-modificateur-id-column'], $n)) {
                        $n[$options['histo-modificateur-id-column']] = $options['histo-user-id'];
                    }
                }
                $callbackProgress++;
                $this->insert($n);
                if ($doCallback) call_user_func($callback, 'insert', $callbackProgress, $callbackCount, $n);