Commit d7487578 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Renomage des indicateurs

parent 7234092c
Loading
Loading
Loading
Loading
+105
Changes for admin/migration/v18IndicateursNumRen.php: 105 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php





class v18IndicateursNumRen extends AbstractMigration
{

    public function description(): string
    {
        return "Renomage des indicateurs";
    }



    public function utile(): bool
    {
        $bdd = $this->manager->getBdd();

        $res = $bdd->select("select numero from indicateur where route = 'intervenant/services-prevus'");

        return (int)$res[0]['NUMERO'] == 510;
    }



    public function before()
    {
        $numeros = [
            410 => 110,
            420 => 120,

            1010 => 210,
            1011 => 220,
            1020 => 230,
            1021 => 240,

            200 => 330,
            210 => 310,
            220 => 320,

            310 => 410,
            320 => 420,
            330 => 430,
            340 => 440,
            350 => 450,
            360 => 460,
            361 => 470,
            370 => 480,
            380 => 490,

            610 => 510,
            620 => 520,
            630 => 530,
            640 => 540,
            650 => 550,
            660 => 560,
            670 => 570,

            510 => 610,
            710 => 620,
            720 => 630,
            730 => 640,
            740 => 650,

            110 => 710,
            120 => 720,
            130 => 730,

            1110 => 810,
            1111 => 820,
            1120 => 830,
            1121 => 840,

            910 => 910,
            810 => 920,
            920 => 930,
            820 => 940,
        ];


        $bdd = $this->manager->getBdd();
        $c   = $this->manager->getOseAdmin()->getConsole();


        $ids = [];
        $res = $bdd->select('SELECT ID, NUMERO FROM indicateur');
        foreach ($res as $r) {
            $ids[(int)$r['NUMERO']] = (int)$r['ID'];
        }

        // On gère les suppression d'anciens types d'indicateurs
        if ($this->manager->hasColumn('INDICATEUR', 'TYPE_INDICATEUR_ID')) {
            $bdd->exec("UPDATE indicateur SET type_indicateur_id = 7 WHERE type_indicateur_id = 5");
            $bdd->exec("UPDATE indicateur SET type_indicateur_id = 10 WHERE type_indicateur_id = 11");
        }

        foreach ($numeros as $ancien => $nouveau) {
            $id  = $ids[$ancien];
            $sql = "UPDATE indicateur SET numero = $nouveau WHERE id = $id";
            $bdd->exec($sql);
        }
    }
}
 No newline at end of file
+18 −9
Changes for data/ddl/view/V_INDICATEUR_110.sql: 18 added lines, 9 removed lines.
Original line number Diff line number Diff line
CREATE OR REPLACE FORCE VIEW V_INDICATEUR_110 AS
SELECT DISTINCT
  s.intervenant_id intervenant_id,
  s.structure_id   structure_id
SELECT
  d.intervenant_id,
  i.structure_id
FROM
  tbl_service s
  tbl_dossier d
  JOIN intervenant i ON i.id = d.intervenant_id
WHERE
  s.type_intervenant_code = 'P'
  AND s.type_volume_horaire_code = 'PREVU'
  AND s.intervenant_structure_id <> s.structure_id
  AND s.valide > 0
  AND s.structure_id IS NOT NULL
 No newline at end of file
  d.dossier_id IS NOT NULL
  /*Complétude des différents bloc dossier*/
  AND d.completude_identite = 1
  AND d.completude_identite_comp = 1
  AND d.completude_contact = 1
  AND d.completude_adresse = 1
  AND d.completude_insee = 1
  AND d.completude_banque = 1
  AND d.completude_employeur = 1
  AND d.completude_autres = 1
  AND d.completude_statut = 1
  AND d.validation_id IS NULL
  AND d.actif = 1
 No newline at end of file
−73

File deleted.

−72

File deleted.

+5 −8
Changes for data/ddl/view/V_INDICATEUR_120.sql: 5 added lines, 8 removed lines.
Original line number Diff line number Diff line
CREATE OR REPLACE FORCE VIEW V_INDICATEUR_120 AS
SELECT DISTINCT
  s.intervenant_id intervenant_id,
  s.intervenant_structure_id structure_id
  i.id intervenant_id,
  i.structure_id
FROM
  tbl_service s
  indic_modif_dossier d
  JOIN intervenant i ON i.id = d.intervenant_id
WHERE
  s.type_intervenant_code = 'P'
  AND s.type_volume_horaire_code = 'PREVU'
  AND s.intervenant_structure_id <> s.structure_id
  AND s.valide > 0
  AND s.structure_id IS NOT NULL
 No newline at end of file
  d.histo_destruction IS NULL
 No newline at end of file
Loading