Commit d9aeb12a authored by joriot221's avatar joriot221
Browse files

Merge branch 'master' into FJ_Contrat_Sans_Avenant

parents 89c59428 60efb6ee
Loading
Loading
Loading
Loading
+4 −1
Changes for CHANGELOG.md: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ Objectif : Plafonds personnalisables & refonte gestion des statuts
* Fiche Intervenant
  * Le grade devient modifiable dans la fiche pour les anciens intervenants #40369
  * Ajout d'un privilège 'Edition avancée' au niveau de l'intervenant pour donner le droit de modifier manuellement le code intervenant et la source de l'intervenant
  * Le code de l'intervenant peut devenir cliquable pour vous rediriger vers une page de gestion des comptes d'accès au SI ou autre (cf. notes de mise à jour, paramètre ldap>systemeInformationUrl)

* Export des intervenants vers Siham
  * Possiblité de récupérer plusieurs typeUO pour alimenter la liste des structures pour la PEC et la REN (#41454)
@@ -72,6 +73,7 @@ Objectif : Plafonds personnalisables & refonte gestion des statuts
    * Les paramétrages de statuts sont maintenant annualisés
  
* En bref
  * Il est maintenant possible de choisir si on veut être connecté avec le CAS ou avec un compte LDAP ou local au moment du login
  * Nouvel état de sortie sur l'export des agréments, rendant celui-ci maintenant paramétrable par les établissements (#42944)
  * Les paramétrages de pièces justificatives par statut sont maintenant annualisés: il n'y a plus de notion d'année de début/année de fin
  * Les paramétrages des types d'intervention par statut sont également annualisés
@@ -87,6 +89,7 @@ Objectif : Plafonds personnalisables & refonte gestion des statuts
* Export CSV des agréments : inversion de colonnes (#41513)
* Correction sur la suppression de service lorsque la clôture de service a été historisé (#42046)
* Le calcul des choix minimum/maximum est de nouveau fiable (#42080)
* Liens inactifs lors du changement d'année universitaire (#40992)

## Notes de mise à jour

@@ -94,7 +97,7 @@ Objectif : Plafonds personnalisables & refonte gestion des statuts
* **ATTENTION : PHP 8.0** est requis
* La mise à jour des vues matérialisées MV_EXT_* ne se fait plus à la mise à jour. Il faut maintenant lancer la commande `./bin/ose maj-exports` tous les jours et donc ajouter une ligne à votre _CronTab_ (cf. [Doc INSTALL mise à jour](install.md))
* Pour bénéficier de la ventilation des heures par types d'intervention vous pouvez vous inspirer du [modèle de contrat de Caen](https://git.unicaen.fr/open-source/OSE/-/blob/master/data/modele_contrat_ventile.odt) pour adapter votre propre modèle de contrat.

* Au niveau du fichier de configuration [config.local.php](config.local.php.default), vous pouvez remplir le paramètre (facultatif) ldap>systemeInformationUrl.


# OSE 17.3 (17/03/2022)
+1 −1
Changes for admin/actions/test.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -5,4 +5,4 @@ require_once dirname(__DIR__) . '/migration/v18Plafonds.php';
$mm  = new MigrationManager($oa, new \BddAdmin\Ddl\Ddl(), []);
$v18 = new v18Plafonds($mm);

$v18->before();
 No newline at end of file
$v18->migrationParamsStatut();
 No newline at end of file
+8 −1
Changes for admin/migration/v18Divers.php: 8 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -41,8 +41,15 @@ class v18Divers extends AbstractMigration
        $c   = $this->manager->getOseAdmin()->getConsole();

        try {
            $bdd->exec("ALTER TABLE TYPE_INTERVENANT DROP CONSTRAINT TYPE_INTERVENANT_CODE_UN");
            $c->msg('Suppression de la contrainte TYPE_INTERVENANT_CODE_UN en prévision de sa recréation');
            $bdd->exec("DELETE FROM AFFECTATION_RECHERCHE WHERE structure_id NOT IN (SELECT ID FROM STRUCTURE)");
        } catch (\Exception $e) {
            // rien à faire : la contrainte a déjà du être supprimée
        }

        try {
            $c->msg('Suppression de la contrainte TYPE_INTERVENANT_CODE_UN en prévision de sa recréation');
            $bdd->exec("ALTER TABLE TYPE_INTERVENANT DROP CONSTRAINT TYPE_INTERVENANT_CODE_UN");
        } catch (\Exception $e) {
            // rien à faire : la contrainte a déjà du être supprimée
        }
+442 −2
Changes for admin/migration/v18Plafonds.php: 442 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ class v18Plafonds extends AbstractMigration

    public function utile(): bool
    {
        return $this->manager->hasNew('table', 'PLAFOND_PERIMETRE');
        return $this->manager->hasNew('table', 'PLAFOND_PERIMETRE') || $this->manager->hasTable('SAVE_V18_PLAFOND');
    }


@@ -71,7 +71,7 @@ class v18Plafonds extends AbstractMigration
        }

        if (!empty($bdd->table()->get('PLAFOND'))) {
            $bdd->exec('DROP TABLE PLAFOND');
            $bdd->exec('DROP TABLE PLAFOND CASCADE CONSTRAINTS');
            $c->msg('Suppression des anciens plafonds');
        }
    }
@@ -80,7 +80,24 @@ class v18Plafonds extends AbstractMigration

    protected function after()
    {
        $c = $this->manager->getOseAdmin()->getConsole();
        try {
            $this->migrationParamsStructure();
        } catch (\Exception $e) {
            $c->println($e->getMessage(), $c::COLOR_RED);
        }

        try {
            $this->migrationParamsReferentiel();
        } catch (\Exception $e) {
            $c->println($e->getMessage(), $c::COLOR_RED);
        }

        try {
            $this->migrationParamsStatut();
        } catch (\Exception $e) {
            $c->println($e->getMessage(), $c::COLOR_RED);
        }
    }


@@ -95,4 +112,427 @@ class v18Plafonds extends AbstractMigration
        $c->end('Préparation à la migration des indicateurs terminée');
    }



    public function migrationParamsStructure()
    {
        $bdd = $this->manager->getBdd();
        $c   = $this->manager->getOseAdmin()->getConsole();

        $sql = "
        SELECT
          s.id entite_id,
          p.id plafond_id,
          CASE WHEN tvh.code = 'PREVU' THEN pa.plafond_etat_id ELSE NULL END plafond_etat_prevu_id,
          CASE WHEN tvh.code = 'REALISE' THEN pa.plafond_etat_id ELSE NULL END plafond_etat_realise_id,
          s.plafond_referentiel heures,
          pa.annee_debut_id annee_id,
          pa.annee_fin_id annee_fin_id
        FROM
          save_v18_structure s
          JOIN plafond p ON p.numero = 15
          JOIN save_v18_plafond_app pa ON pa.plafond_id = p.id
          JOIN type_volume_horaire tvh ON tvh.id = pa.type_volume_horaire_id
        WHERE
          s.histo_destruction IS NULL
          AND s.plafond_referentiel IS NOT NULL
          AND pa.plafond_etat_id > 1
        ";


        $data = [];
        $qr   = $bdd->select($sql);
        foreach ($qr as $r) {
            $anneeDebut = (int)$r['ANNEE_ID'];
            $anneeFin   = (int)$r['ANNEE_FIN_ID'];
            if ($anneeFin == 0) $anneeFin = 2099;

            $plafondId = (int)$r['PLAFOND_ID'];
            $entiteId  = (int)$r['ENTITE_ID'];

            $etatPrevuId   = $r['PLAFOND_ETAT_PREVU_ID'] ? (int)$r['PLAFOND_ETAT_PREVU_ID'] : null;
            $etatRealiseId = $r['PLAFOND_ETAT_REALISE_ID'] ? (int)$r['PLAFOND_ETAT_REALISE_ID'] : null;
            $heures        = $r['HEURES'] ? (int)$r['HEURES'] : 0;

            for ($a = $anneeDebut; $a <= $anneeFin; $a++) {
                if (!isset($data[$a][$plafondId][$entiteId])) {
                    $data[$a][$plafondId][$entiteId] = [
                        'saisie'                  => $a == $anneeDebut,
                        'PLAFOND_ETAT_PREVU_ID'   => 1, // désactivé
                        'PLAFOND_ETAT_REALISE_ID' => 1, // désactivé
                        'HEURES'                  => 0,
                    ];
                }

                if ($etatPrevuId !== null) {
                    $data[$a][$plafondId][$entiteId]['PLAFOND_ETAT_PREVU_ID'] = $etatPrevuId;
                }

                if ($etatRealiseId !== null) {
                    $data[$a][$plafondId][$entiteId]['PLAFOND_ETAT_REALISE_ID'] = $etatRealiseId;
                }

                if ($heures !== null) {
                    $data[$a][$plafondId][$entiteId]['HEURES'] = $heures;
                }
            }
        }

        /* On supprime ce qui a déjà été créé */
        $sql = "SELECT * FROM PLAFOND_STRUCTURE WHERE histo_destruction IS NULL";
        $des = $bdd->select($sql);
        foreach ($des as $de) {
            $a = (int)$de['ANNEE_ID'];
            $p = (int)$de['PLAFOND_ID'];
            $e = (int)$de['STRUCTURE_ID'];
            unset($data[$a][$p][$e]);
        }

        $inserts = [];
        foreach ($data as $anneeId => $data2) {
            foreach ($data2 as $plafondId => $data3) {
                foreach ($data3 as $entiteId => $d) {
                    $insert                          = $d;
                    $insert['ANNEE_ID']              = $anneeId;
                    $insert['PLAFOND_ID']            = $plafondId;
                    $insert['ENTITE_ID']             = $entiteId;
                    $insert['HISTO_CREATION']        = new \DateTime();
                    $insert['HISTO_CREATEUR_ID']     = $this->manager->getOseAdmin()->getOseAppliId();
                    $insert['HISTO_MODIFICATION']    = new \DateTime();
                    $insert['HISTO_MODIFICATEUR_ID'] = $d['saisie'] ? $this->manager->getOseAdmin()->getOseAppliId() : null;
                    unset($insert['saisie']);
                    $inserts[] = $insert;
                }
            }
        }


        $c->begin('Convertion des paramètres de plafonds pour les structures');
        $count = count($inserts);
        foreach ($inserts as $current => $insert) {
            $insert['STRUCTURE_ID'] = $insert['ENTITE_ID'];
            unset($insert['ENTITE_ID']);
            $c->msg('Ajout du paramètre ' . ($current + 1) . ' sur ' . $count . ' ...', true);
            $bdd->getTable('PLAFOND_STRUCTURE')->insert($insert);
        }
        $c->end('Fin de la convertion des paramètres de plafonds pour les structures');
    }



    public function migrationParamsReferentiel()
    {
        $bdd = $this->manager->getBdd();
        $c   = $this->manager->getOseAdmin()->getConsole();

        $sql  = "
        SELECT
          r.id entite_id,
          p.id plafond_id,
          pa.annee_debut_id annee_id,
          CASE WHEN tvh.code = 'PREVU' THEN pa.plafond_etat_id ELSE NULL END plafond_etat_prevu_id,
          CASE WHEN tvh.code = 'REALISE' THEN pa.plafond_etat_id ELSE NULL END plafond_etat_realise_id,
          r.plafond heures,
          pa.annee_fin_id annee_fin_id
        FROM
          save_v18_referentiel r
          JOIN plafond p ON p.numero = 17
          JOIN save_v18_plafond_app pa ON pa.plafond_id = p.id
          JOIN type_volume_horaire tvh ON tvh.id = pa.type_volume_horaire_id
          LEFT JOIN plafond_referentiel pr ON pr.fonction_referentiel_id = r.id AND pr.plafond_id = p.id AND pr.annee_id = pa.annee_debut_id
        WHERE
          r.histo_destruction IS NULL
          AND r.plafond IS NOT NULL
          AND pr.id IS NULL
          AND pa.plafond_etat_id > 1
        ";
        $data = [];
        $qr   = $bdd->select($sql);
        foreach ($qr as $r) {
            $anneeDebut = (int)$r['ANNEE_ID'];
            $anneeFin   = (int)$r['ANNEE_FIN_ID'];
            if ($anneeFin == 0) $anneeFin = 2099;

            $plafondId = (int)$r['PLAFOND_ID'];
            $entiteId  = (int)$r['ENTITE_ID'];

            $etatPrevuId   = $r['PLAFOND_ETAT_PREVU_ID'] ? (int)$r['PLAFOND_ETAT_PREVU_ID'] : null;
            $etatRealiseId = $r['PLAFOND_ETAT_REALISE_ID'] ? (int)$r['PLAFOND_ETAT_REALISE_ID'] : null;
            $heures        = $r['HEURES'] ? (int)$r['HEURES'] : 0;

            for ($a = $anneeDebut; $a <= $anneeFin; $a++) {
                if (!isset($data[$a][$plafondId][$entiteId])) {
                    $data[$a][$plafondId][$entiteId] = [
                        'saisie'                  => $a == $anneeDebut,
                        'PLAFOND_ETAT_PREVU_ID'   => 1, // désactivé
                        'PLAFOND_ETAT_REALISE_ID' => 1, // désactivé
                        'HEURES'                  => 0,
                    ];
                }

                if ($etatPrevuId !== null) {
                    $data[$a][$plafondId][$entiteId]['PLAFOND_ETAT_PREVU_ID'] = $etatPrevuId;
                }

                if ($etatRealiseId !== null) {
                    $data[$a][$plafondId][$entiteId]['PLAFOND_ETAT_REALISE_ID'] = $etatRealiseId;
                }

                if ($heures !== null) {
                    $data[$a][$plafondId][$entiteId]['HEURES'] = $heures;
                }
            }
        }

        /* On supprime ce qui a déjà été créé */
        $sql = "SELECT * FROM PLAFOND_REFERENTIEL WHERE histo_destruction IS NULL";
        $des = $bdd->select($sql);
        foreach ($des as $de) {
            $a = (int)$de['ANNEE_ID'];
            $p = (int)$de['PLAFOND_ID'];
            $e = (int)$de['FONCTION_REFERENTIEL_ID'];
            unset($data[$a][$p][$e]);
        }

        $inserts = [];
        foreach ($data as $anneeId => $data2) {
            foreach ($data2 as $plafondId => $data3) {
                foreach ($data3 as $entiteId => $d) {
                    $insert                          = $d;
                    $insert['ANNEE_ID']              = $anneeId;
                    $insert['PLAFOND_ID']            = $plafondId;
                    $insert['ENTITE_ID']             = $entiteId;
                    $insert['HISTO_CREATION']        = new \DateTime();
                    $insert['HISTO_CREATEUR_ID']     = $this->manager->getOseAdmin()->getOseAppliId();
                    $insert['HISTO_MODIFICATION']    = new \DateTime();
                    $insert['HISTO_MODIFICATEUR_ID'] = $d['saisie'] ? $this->manager->getOseAdmin()->getOseAppliId() : null;
                    unset($insert['saisie']);
                    $inserts[] = $insert;
                }
            }
        }


        $c->begin('Convertion des paramètres de plafonds pour les fonctions référentielles');
        $count = count($inserts);
        foreach ($inserts as $current => $insert) {
            $insert['FONCTION_REFERENTIEL_ID'] = $insert['ENTITE_ID'];
            unset($insert['ENTITE_ID']);
            $c->msg('Ajout du paramètre ' . ($current + 1) . ' sur ' . $count . ' ...', true);
            $bdd->getTable('PLAFOND_REFERENTIEL')->insert($insert);
        }
        $c->end('Fin de la convertion des paramètres de plafonds pour les fonctions référentielles');
    }



    public function migrationParamsStatut()
    {
        $bdd = $this->manager->getBdd();
        $c   = $this->manager->getOseAdmin()->getConsole();

        $sql  = "
        SELECT
          s.code entite_id,
          p.id plafond_id,
          CASE WHEN tvh.code = 'PREVU' THEN pa.plafond_etat_id ELSE NULL END plafond_etat_prevu_id,
          CASE WHEN tvh.code = 'REALISE' THEN pa.plafond_etat_id ELSE NULL END plafond_etat_realise_id,
          os.plafond_hc_remu_fc heures,
          pa.annee_debut_id annee_id,
          pa.annee_fin_id annee_fin_id
        FROM
          save_v18_statut os
          JOIN plafond p ON p.numero = 12
          JOIN save_v18_plafond_app pa ON pa.plafond_id = p.id
          JOIN statut s ON s.code = os.code AND s.annee_id = pa.annee_debut_id
          JOIN type_volume_horaire tvh ON tvh.id = pa.type_volume_horaire_id
          LEFT JOIN plafond_statut ps ON ps.statut_id = s.id AND ps.plafond_id = p.id AND ps.annee_id = pa.annee_debut_id
        WHERE
          os.histo_destruction IS NULL
          AND os.plafond_hc_remu_fc IS NOT NULL
          AND ps.id IS NULL
          AND pa.plafond_etat_id > 1
        
        UNION ALL
        
        SELECT
          s.code entite_id,
          p.id plafond_id,
          CASE WHEN tvh.code = 'PREVU' THEN pa.plafond_etat_id ELSE NULL END plafond_etat_prevu_id,
          CASE WHEN tvh.code = 'REALISE' THEN pa.plafond_etat_id ELSE NULL END plafond_etat_realise_id,
          os.plafond_referentiel heures,
          pa.annee_debut_id annee_id,
          pa.annee_fin_id annee_fin_id
        FROM
          save_v18_statut os
          JOIN plafond p ON p.numero = 18
          JOIN save_v18_plafond_app pa ON pa.plafond_id = p.id
          JOIN statut s ON s.code = os.code AND s.annee_id = pa.annee_debut_id
          JOIN type_volume_horaire tvh ON tvh.id = pa.type_volume_horaire_id
          LEFT JOIN plafond_statut ps ON ps.statut_id = s.id AND ps.plafond_id = p.id AND ps.annee_id = pa.annee_debut_id
        WHERE
          os.histo_destruction IS NULL
          AND os.plafond_referentiel IS NOT NULL
          AND ps.id IS NULL
          AND pa.plafond_etat_id > 1
        
        UNION ALL
        
        SELECT
          s.code entite_id,
          p.id plafond_id,
          CASE WHEN tvh.code = 'PREVU' THEN pa.plafond_etat_id ELSE NULL END plafond_etat_prevu_id,
          CASE WHEN tvh.code = 'REALISE' THEN pa.plafond_etat_id ELSE NULL END plafond_etat_realise_id,
          os.maximum_hetd heures,
          pa.annee_debut_id annee_id,
          pa.annee_fin_id annee_fin_id
        FROM
          save_v18_statut os
          JOIN plafond p ON p.numero = 11
          JOIN save_v18_plafond_app pa ON pa.plafond_id = p.id
          JOIN statut s ON s.code = os.code AND s.annee_id = pa.annee_debut_id
          JOIN type_volume_horaire tvh ON tvh.id = pa.type_volume_horaire_id
          LEFT JOIN plafond_statut ps ON ps.statut_id = s.id AND ps.plafond_id = p.id AND ps.annee_id = pa.annee_debut_id
        WHERE
          os.histo_destruction IS NULL
          AND os.maximum_hetd IS NOT NULL
          AND ps.id IS NULL    
          AND pa.plafond_etat_id > 1              

        UNION ALL
        
        SELECT
          s.code entite_id,
          p.id plafond_id,
          CASE WHEN tvh.code = 'PREVU' THEN pa.plafond_etat_id ELSE NULL END plafond_etat_prevu_id,
          CASE WHEN tvh.code = 'REALISE' THEN pa.plafond_etat_id ELSE NULL END plafond_etat_realise_id,
          os.plafond_hc_hors_remu_fc heures,
          pa.annee_debut_id annee_id,
          pa.annee_fin_id annee_fin_id
        FROM
          save_v18_statut os
          JOIN plafond p ON p.numero = 10
          JOIN save_v18_plafond_app pa ON pa.plafond_id = p.id
          JOIN statut s ON s.code = os.code AND s.annee_id = pa.annee_debut_id
          JOIN type_volume_horaire tvh ON tvh.id = pa.type_volume_horaire_id
          LEFT JOIN plafond_statut ps ON ps.statut_id = s.id AND ps.plafond_id = p.id AND ps.annee_id = pa.annee_debut_id
        WHERE
          os.histo_destruction IS NULL
          AND os.plafond_hc_hors_remu_fc IS NOT NULL
          AND ps.id IS NULL
          AND pa.plafond_etat_id > 1
        
        UNION ALL
        
        SELECT
          s.code entite_id,
          p.id plafond_id,
          CASE WHEN tvh.code = 'PREVU' THEN pa.plafond_etat_id ELSE NULL END plafond_etat_prevu_id,
          CASE WHEN tvh.code = 'REALISE' THEN pa.plafond_etat_id ELSE NULL END plafond_etat_realise_id,
          os.plafond_hc_fi_hors_ead heures,
          pa.annee_debut_id annee_id,
          pa.annee_fin_id annee_fin_id
        FROM
          save_v18_statut os
          JOIN plafond p ON p.numero = 13
          JOIN save_v18_plafond_app pa ON pa.plafond_id = p.id
          JOIN statut s ON s.code = os.code AND s.annee_id = pa.annee_debut_id
          JOIN type_volume_horaire tvh ON tvh.id = pa.type_volume_horaire_id
          LEFT JOIN plafond_statut ps ON ps.statut_id = s.id AND ps.plafond_id = p.id AND ps.annee_id = pa.annee_debut_id
        WHERE
          os.histo_destruction IS NULL
          AND os.plafond_hc_fi_hors_ead IS NOT NULL
          AND ps.id IS NULL
          AND pa.plafond_etat_id > 1
        ";
        $data = [];
        $qr   = $bdd->select($sql);
        foreach ($qr as $r) {
            $anneeDebut = (int)$r['ANNEE_ID'];
            $anneeFin   = (int)$r['ANNEE_FIN_ID'];
            if ($anneeFin == 0) $anneeFin = 2099;

            $plafondId = (int)$r['PLAFOND_ID'];
            $entiteId  = $r['ENTITE_ID'];

            $etatPrevuId   = $r['PLAFOND_ETAT_PREVU_ID'] ? (int)$r['PLAFOND_ETAT_PREVU_ID'] : null;
            $etatRealiseId = $r['PLAFOND_ETAT_REALISE_ID'] ? (int)$r['PLAFOND_ETAT_REALISE_ID'] : null;
            $heures        = $r['HEURES'] ? (int)$r['HEURES'] : 0;

            for ($a = $anneeDebut; $a <= $anneeFin; $a++) {
                if (!isset($data[$a][$plafondId][$entiteId])) {
                    $data[$a][$plafondId][$entiteId] = [
                        'saisie'                  => $a == $anneeDebut,
                        'PLAFOND_ETAT_PREVU_ID'   => 1, // désactivé
                        'PLAFOND_ETAT_REALISE_ID' => 1, // désactivé
                        'HEURES'                  => 0,
                    ];
                }

                if ($etatPrevuId !== null) {
                    $data[$a][$plafondId][$entiteId]['PLAFOND_ETAT_PREVU_ID'] = $etatPrevuId;
                }

                if ($etatRealiseId !== null) {
                    $data[$a][$plafondId][$entiteId]['PLAFOND_ETAT_REALISE_ID'] = $etatRealiseId;
                }

                if ($heures !== null) {
                    $data[$a][$plafondId][$entiteId]['HEURES'] = $heures;
                }
            }
        }

        /* On supprime ce qui a déjà été créé */
        $sql = "SELECT * FROM PLAFOND_STATUT WHERE histo_destruction IS NULL";
        $des = $bdd->select($sql);
        foreach ($des as $de) {
            $a = (int)$de['ANNEE_ID'];
            $p = (int)$de['PLAFOND_ID'];
            $e = (int)$de['STATUT_ID'];
            unset($data[$a][$p][$e]);
        }

        /* On récupère les statuts */
        $sql     = "SELECT code, annee_id, id FROM statut WHERE histo_destruction IS NULL";
        $statuts = [];
        $rs      = $bdd->select($sql);
        foreach ($rs as $r) {
            $statuts[$r['CODE']][(int)$r['ANNEE_ID']] = (int)$r['ID'];
        }

        $inserts = [];
        foreach ($data as $anneeId => $data2) {
            foreach ($data2 as $plafondId => $data3) {
                foreach ($data3 as $entiteId => $d) {
                    $statutId = $statuts[$entiteId][$anneeId] ?? null;

                    $insert                          = $d;
                    $insert['ANNEE_ID']              = $anneeId;
                    $insert['PLAFOND_ID']            = $plafondId;
                    $insert['ENTITE_ID']             = $statutId;
                    $insert['HISTO_CREATION']        = new \DateTime();
                    $insert['HISTO_CREATEUR_ID']     = $this->manager->getOseAdmin()->getOseAppliId();
                    $insert['HISTO_MODIFICATION']    = new \DateTime();
                    $insert['HISTO_MODIFICATEUR_ID'] = $d['saisie'] ? $this->manager->getOseAdmin()->getOseAppliId() : null;
                    unset($insert['saisie']);

                    if ($statutId) {
                        $inserts[] = $insert;
                    }
                }
            }
        }


        $c->begin('Convertion des paramètres de plafonds pour les statuts');
        $count = count($inserts);
        foreach ($inserts as $current => $insert) {
            $insert['STATUT_ID'] = $insert['ENTITE_ID'];
            unset($insert['ENTITE_ID']);
            $c->msg('Ajout du paramètre ' . ($current + 1) . ' sur ' . $count . ' ...', true);
            $bdd->getTable('PLAFOND_STATUT')->insert($insert);
        }
        $c->end('Fin de la convertion des paramètres de plafonds pour les statuts');
    }
}
 No newline at end of file
+5 −2
Changes for admin/migration/v18Statuts.php: 5 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -78,8 +78,11 @@ class v18Statuts extends AbstractMigration

        $ddl = $bdd->table()->get('TBL_WORKFLOW')['TBL_WORKFLOW'];
        if (!isset($ddl['columns']['STATUT_ID'])) {
            $bdd->exec('DROP TABLE TBL_WORKFLOW');
            $c->msg('Vidage temporaire de WF_DEP_BLOQUANTE (dépendances du Workflow)');
            $bdd->exec('DELETE FROM WF_DEP_BLOQUANTE');

            $c->msg('Suppression de la table TBL_WORKFLOW, qui sera recréée au nouveau format');
            $bdd->exec('DROP TABLE TBL_WORKFLOW CASCADE CONSTRAINTS');
        }

        $ddl = $bdd->table()->get('MODELE_CONTRAT')['MODELE_CONTRAT'];
@@ -417,7 +420,7 @@ class v18Statuts extends AbstractMigration
                'CONSEIL_RESTREINT_DUREE_VIE'    => $statut['agrements']['CONSEIL_RESTREINT'] ?? 1, // NUMBER DEFAULT 1 NOT NULL ENABLE,
                'CONSEIL_ACA'                    => isset($statut['agrements']['CONSEIL_ACADEMIQUE']) ? 1 : 0, // NUMBER(1) DEFAULT 1 NOT NULL ENABLE,
                'CONSEIL_ACA_VISUALISATION'      => in_array('agrement-conseil-academique-visualisation', $statut['privileges']) ? 1 : 0, // NUMBER(1) DEFAULT 1 NOT NULL ENABLE,
                'CONSEIL_ACA_DUREE_VIE'          => $statut['agrements']['CONSEIL_RESTREINT'] ?? 5, // NUMBER DEFAULT 5 NOT NULL ENABLE,
                'CONSEIL_ACA_DUREE_VIE'          => $statut['agrements']['CONSEIL_ACADEMIQUE'] ?? 5, // NUMBER DEFAULT 5 NOT NULL ENABLE,
                'CONTRAT'                        => $statut['PEUT_AVOIR_CONTRAT'], // NUMBER(1) DEFAULT 1 NOT NULL ENABLE,
                'CONTRAT_VISUALISATION'          => in_array('contrat-visualisation', $statut['privileges']) ? 1 : 0, // NUMBER(1) DEFAULT 1 NOT NULL ENABLE,
                'CONTRAT_DEPOT'                  => in_array('contrat-depot-retour-signe', $statut['privileges']) ? 1 : 0, // NUMBER(1) DEFAULT 1 NOT NULL ENABLE,
Loading