From cec09e0fb471e01929d9a37ff776af85e4d65d15 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Laurent=20L=C3=A9cluse?= <laurent.lecluse@unicaen.fr>
Date: Wed, 18 Nov 2020 14:26:35 +0100
Subject: [PATCH] =?UTF-8?q?On=20d=C3=A9synchronise=20les=20statuts=20si=20?=
 =?UTF-8?q?un=20dossier=20existe?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 admin/migration/MigrationIntervenants.php | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/admin/migration/MigrationIntervenants.php b/admin/migration/MigrationIntervenants.php
index 67d66f11df..c48f8d1bf7 100644
--- a/admin/migration/MigrationIntervenants.php
+++ b/admin/migration/MigrationIntervenants.php
@@ -68,6 +68,7 @@ class MigrationIntervenants extends AbstractMigration
           i.tel_mobile, i.email,
           i.dep_naissance_id,
           i.ville_naissance_libelle,
+          d.statut_id dossier_statut_id,
           ai.tel_domicile,
           ai.mention_complementaire,
           ai.batiment,
@@ -82,6 +83,7 @@ class MigrationIntervenants extends AbstractMigration
           intervenant_save i
           LEFT JOIN adresse_intervenant_save ai ON ai.intervenant_id = i.id
           LEFT JOIN pays p ON OSE_DIVERS.STR_REDUCE(p.libelle) = OSE_DIVERS.STR_REDUCE(ai.pays_libelle)
+          LEFT JOIN intervenant_dossier d ON d.histo_destruction IS NULL AND d.intervenant_id = i.id AND d.statut_id IS NOT NULL
         ";
         $bdd->trigger()->disable('F_INTERVENANT');
         $bdd->trigger()->disable('F_INTERVENANT_S');
@@ -112,6 +114,9 @@ class MigrationIntervenants extends AbstractMigration
                 'ADRESSE_COMMUNE'          => trim($i['VILLE'] . ' ' . ($i['ADRESSE_PAYS_ID'] ? null : $i['PAYS_LIBELLE'])),
                 'ADRESSE_PAYS_ID'          => $i['ADRESSE_PAYS_ID'],
             ];
+            if ($i['DOSSIER_STATUT_ID']) {
+                $data['SYNC_STATUT'] = false;
+            }
             try {
                 $iTable->update($data, ['ID' => $i['ID']]);
             } catch (\Exception $e) {
-- 
GitLab