diff --git a/admin/src/BddAdmin/Table.php b/admin/src/BddAdmin/Table.php index a7206067ea15308ef62c01ffebda092c5591c357..edc01246b84f8fa12114d5147da260ac8691fba3 100644 --- a/admin/src/BddAdmin/Table.php +++ b/admin/src/BddAdmin/Table.php @@ -240,7 +240,9 @@ class Table 'delete' => true, 'insert' => true, 'update' => true, + 'update-cols' => [], 'update-ignore-cols' => [], + 'update-only-null' => [], ]; $options = array_merge($defaultOptions, $options); @@ -274,7 +276,7 @@ class Table } $traitementOptions = []; - if (isset($options['histo-user-id'])){ + if (isset($options['histo-user-id'])) { $traitementOptions['histo-user-id'] = $options['histo-user-id']; } @@ -300,8 +302,16 @@ class Table $oldc = isset($old[$c]) ? $old[$c] : null; if ($newc instanceof \DateTime) $newc = $newc->format('Y-m-d'); if ($oldc instanceof \DateTime) $oldc = $oldc->format('Y-m-d'); - if (!in_array($c, $options['update-ignore-cols']) && $c != 'ID' && array_key_exists($c, $new) && $newc !== $oldc) { - $toUpdate[$c] = $new[$c]; + if ($newc !== $oldc && array_key_exists($c, $new) && $c != 'ID') { + $ok = empty($options['update-cols']); // OK par défaut si une liste n'a pas été établie manuellement + + if (in_array($c, $options['update-cols'])) $ok = true; + if (in_array($c, $options['update-ignore-cols'])) $ok = false; + if (in_array($c, $options['update-only-null']) && $oldc !== null) $ok = false; + + if ($ok) { + $toUpdate[$c] = $new[$c]; + } } } if (!empty($toUpdate)) { diff --git a/admin/src/DataGen.php b/admin/src/DataGen.php index e4ea696ed29a495960df8e77036906f4d7767bca..46a223ebf1a973e9eaae0ba06f7263c471129fe5 100644 --- a/admin/src/DataGen.php +++ b/admin/src/DataGen.php @@ -190,7 +190,10 @@ class DataGen 'table' => 'ETAT_SORTIE', 'context' => ['install', 'update'], 'key' => 'CODE', - 'options' => ['update' => false, 'delete' => false], + 'options' => ['update' => true, 'delete' => false, + 'update-cols' => ['CSV_PARAMS', 'CSV_TRAITEMENT', 'PDF_TRAITEMENT'], + 'update-only-null' => ['CSV_PARAMS', 'CSV_TRAITEMENT', 'PDF_TRAITEMENT'], + ], ], [ 'table' => 'MODELE_CONTRAT', diff --git a/data/etats_sortie.php b/data/etats_sortie.php index 3bb68e0a2563a87beab9b9df9b1a43f29e3f4016..bcefcb64d4f9bc8b4a90e34034d863d133893660 100644 --- a/data/etats_sortie.php +++ b/data/etats_sortie.php @@ -99,6 +99,7 @@ return [ 'CODE' => 'export_services', 'LIBELLE' => 'Export des services', 'PDF_TRAITEMENT' => '/data/Etats de sortie/export_services.php', + 'CSV_TRAITEMENT' => '/data/Etats de sortie/export_services_csv.php', 'AUTO_BREAK' => true, 'REQUETE' => 'SELECT *