Skip to content
Snippets Groups Projects
Commit 94c1d3e3 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Merge branch 'master' into module-unicaen-siham

parents 0895da1d 6fb9a437
No related branches found
No related tags found
No related merge requests found
Showing
with 915 additions and 5 deletions
......@@ -35,8 +35,11 @@ Objectif : Connecteur import Actul+ & système différentiel pour comparer des c
* Outil différentiel d'export des charges d'enseignement
# OSE 15.7 (à venir)
## Correction de bugs
* Correction de la validation du numéro INSEE dans le dossier de l'intervenant dans le cas d'un département de naissance en Outre Mer (le numéro de département de naissance de l'INSEE dans ce cas peut être sur 2 ou 3 chiffres)
# OSE 15.6 (à venir)
......
......@@ -4,10 +4,10 @@ $dirname = $oa->getOseDir() . 'data/ddl';
$colPosFile = $oa->getOseDir() . 'data/ddl_columns_pos.php';
$filters = [
'table' => ['excludes' => ['UNICAEN_%', 'SYS_EXPORT_SCHEMA_%']],
'sequence' => ['excludes' => 'UNICAEN_%'],
'primary-constraint' => ['excludes' => 'UNICAEN_%'],
'index' => ['excludes' => 'UNICAEN_%'],
'table' => ['excludes' => ['UNICAEN_%', 'SYS_EXPORT_SCHEMA_%', 'ACT_%']],
'sequence' => ['excludes' => ['UNICAEN_%']],
'primary-constraint' => ['excludes' => ['UNICAEN_%', 'ACT_%']],
'index' => ['excludes' => ['UNICAEN_%', 'ACT_%']],
'view' => ['excludes' => ['SRC_%', 'V_DIFF_%', 'V_SYMPA_%', 'V_UNICAEN_%']],
'materialized-view' => ['includes' => [
'MV_EXT_SERVICE',
......@@ -15,7 +15,7 @@ $filters = [
'MV_EXT_ETAT_PAIEMENT',
'TBL_NOEUD',
]],
'package' => ['excludes' => ['UCBN_LDAP', 'UNICAEN_IMPORT_AUTOGEN_PROCS__']],
'package' => ['excludes' => ['UCBN_LDAP', 'UNICAEN_IMPORT_AUTOGEN_PROCS__', 'OSE_ACTUL']],
];
......
<?php
use BddAdmin\Ddl\Ddl;
$c->begin("\nInstallation ou mise à jour du connecteur ACTUL+");
$c->println('Création de la source de données Actul+ si besoin');
$sql = "BEGIN
unicaen_import.add_source('Actul', 'Actul +');
commit;
END;";
$oa->getBdd()->exec($sql);
// Récupération du schéma de référence
$c->println('Mise en place des structures de données');
$ca = new ConnecteurActul();
$ca->init();
$ddl = $ca->getDdl();
// On ne touche pas à autre chose que la partie ACTUL!!
$filters = $ddl->filterOnlyDdl();
// Mise à jour de la BDD (structures)
$oa->getBdd()->alter($ddl, $filters);
$c->end('Connecteur installé');
$c->println('Le connecteur Actul+ vers OSE est installé. Il vous reste à mettre en place par vous-même les vues sources et à les activer.');
\ No newline at end of file
<?php
$ca = new ConnecteurActul;
$ca->init();
$c->begin('Mise à jour de OSE à partir des données d\'Actul +');
$at = $ca->getActTables();
$c->println('');
$c->begin('Transfert des données depuis Actul');
foreach ($at as $table) {
$c->print('Table ' . $table . '... ');
$ca->majActTable($table);
$c->println('OK');
}
$c->end('Transfert terminé');
$st = $ca->getSyncTables();
$c->println('');
$c->begin('Synchronisation des données vers OSE');
foreach ($st as $table) {
$c->print('Table ' . $table . '... ');
$ca->syncTable($table);
$c->println('OK');
}
$c->end('Synchronisation terminée');
$c->begin('Mise à jour des caches de données');
$c->print('Vue matérialisée TBL_NOEUD ... ');
$ca->ose->exec('BEGIN UNICAEN_IMPORT.REFRESH_MV(\'TBL_NOEUD\'); END;');
$c->println('OK');
$c->print('Calcul de tous les effectifs ... ');
$ca->ose->exec('BEGIN OSE_CHARGENS.CALC_ALL_EFFECTIFS(); END;');
$c->println('OK');
$c->print('Tableau de bord des charges ... ');
$ca->ose->exec('BEGIN UNICAEN_TBL.CALCULER(\'chargens\'); END;');
$c->println('OK');
$c->end('Caches à jour');
$c->end('Ose est maintenant à jour');
\ No newline at end of file
<?php
$ca = new ConnecteurActul();
$filters = [
'explicit' => true,
'table' => ['includes' => $ca->getActTables()],
'primary-constraint' => ['includes' => '%'],
'package' => ['includes' => 'OSE_ACTUL'],
];
$c->begin('Génération de la DDL du connecteur ACTUL+ à partir de la base de données');
$ddl = $oa->getBdd()->getDdl($filters);
/* On retire toutes les clés étrangères qui n'ont rien à voir avec ACTUL+ */
$pc = $ddl->get('primary-constraint');
foreach ($pc as $n => $d) {
if (!in_array($d['table'], $tables)) {
unset($pc[$n]);
}
}
$ddl->set('primary-constraint', $pc);
$ddl->saveToDir($ca->getDdlDir());
$c->end('DDL ACTUL+ mise à jour');
\ No newline at end of file
CREATE OR REPLACE PACKAGE BODY OSE_ACTUL AS
FUNCTION z_to_code ( z_periode_id_semestre VARCHAR2, z_periode_id_ordre NUMERIC ) RETURN VARCHAR2 IS
pcode VARCHAR2(2);
BEGIN
pcode := CASE
WHEN z_periode_id_semestre = '1' AND z_periode_id_ordre < 2 THEN 'S1'
WHEN z_periode_id_semestre = '1' AND z_periode_id_ordre = 2 THEN 'S2'
WHEN z_periode_id_semestre = '3' AND z_periode_id_ordre < 2 THEN 'S1'
WHEN z_periode_id_semestre = '3' AND z_periode_id_ordre = 2 THEN 'S2'
WHEN z_periode_id_semestre = '5' AND z_periode_id_ordre < 2 THEN 'S1'
WHEN z_periode_id_semestre = '5' AND z_periode_id_ordre = 2 THEN 'S2'
WHEN z_periode_id_semestre = '2' THEN 'S2'
WHEN z_periode_id_semestre = '4' THEN 'S2'
WHEN z_periode_id_semestre = '6' THEN 'S2'
ELSE NULL
END;
RETURN pcode;
END;
FUNCTION CALC_SEMESTRE( NOEUD_SOURCE_CODE VARCHAR2, z_periode_id_semestre VARCHAR2, z_periode_id_ordre NUMERIC ) RETURN VARCHAR2 IS
pcode VARCHAR2(2);
p_sup VARCHAR2(2);
is_s1_sup BOOLEAN DEFAULT FALSE;
is_s2_sup BOOLEAN DEFAULT FALSE;
is_an_sup BOOLEAN DEFAULT FALSE;
BEGIN
IF z_periode_id_semestre IS NOT NULL THEN
-- si il est fourni, alors on le convertir en code de période et on le retourne
RETURN z_to_code(z_periode_id_semestre, z_periode_id_ordre);
END IF;
-- sinon on recherche un éventuel semestre dans ses noeuds parents
FOR t IN (
SELECT
n.source_code, n.z_periode_id_semestre, n.z_periode_id_ordre
FROM
act_lien l
JOIN act_noeud n ON n.source_code = l.z_noeud_sup_id
WHERE
l.z_noeud_inf_id = NOEUD_SOURCE_CODE
) LOOP
p_sup := CALC_SEMESTRE(t.source_code, t.z_periode_id_semestre, t.z_periode_id_ordre);
IF p_sup = 'S1' THEN
is_s1_sup := TRUE;
END IF;
IF p_sup = 'S2' THEN
is_s2_sup := TRUE;
END IF;
IF p_sup IS NULL THEN
is_an_sup := TRUE;
END IF;
END LOOP;
IF is_s1_sup AND NOT is_s2_sup AND NOT is_an_sup THEN
RETURN 'S1';
END IF;
IF NOT is_s1_sup AND is_s2_sup AND NOT is_an_sup THEN
RETURN 'S2';
END IF;
RETURN NULL;
END;
END OSE_ACTUL;
\ No newline at end of file
CREATE OR REPLACE PACKAGE OSE_ACTUL AS
FUNCTION CALC_SEMESTRE( NOEUD_SOURCE_CODE VARCHAR2, z_periode_id_semestre VARCHAR2, z_periode_id_ordre NUMERIC ) RETURN VARCHAR2;
END OSE_ACTUL;
\ No newline at end of file
<?php
//@formatter:off
return [
'name' => 'ACT_ETAPE_PK',
'table' => 'ACT_ETAPE',
'index' => 'ACT_ETAPE_PK',
'columns' => [
'ANNEE_ID',
'SOURCE_CODE',
],
];
//@formatter:on
<?php
//@formatter:off
return [
'name' => 'ACT_LIEN_PK',
'table' => 'ACT_LIEN',
'index' => 'ACT_LIEN_PK',
'columns' => [
'Z_NOEUD_SUP_ID',
'Z_NOEUD_INF_ID',
],
];
//@formatter:on
<?php
//@formatter:off
return [
'name' => 'ACT_NOEUD_PK',
'table' => 'ACT_NOEUD',
'index' => 'ACT_NOEUD_PK',
'columns' => [
'SOURCE_CODE',
],
];
//@formatter:on
<?php
//@formatter:off
return [
'name' => 'ACT_VHENS_GROUPES_PK',
'table' => 'ACT_VHENS_GROUPES',
'index' => 'ACT_VHENS_GROUPES_PK',
'columns' => [
'Z_ELEMENT_PEDAGOGIQUE_ID',
'Z_TYPE_INTERVENTION_ID',
],
];
//@formatter:on
<?php
//@formatter:off
return [
'name' => 'ACT_VHENS_HEURES_PK',
'table' => 'ACT_VHENS_HEURES',
'index' => 'ACT_VHENS_HEURES_PK',
'columns' => [
'Z_ELEMENT_PEDAGOGIQUE_ID',
'Z_TYPE_INTERVENTION_ID',
],
];
//@formatter:on
<?php
//@formatter:off
return [
'name' => 'ACT_ETAPE',
'temporary' => FALSE,
'logging' => TRUE,
'commentaire' => NULL,
'sequence' => NULL,
'columns' => [
'ANNEE_ID' => [
'name' => 'ANNEE_ID',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 9,
'commentaire' => NULL,
],
'CODE' => [
'name' => 'CODE',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 50,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 10,
'commentaire' => NULL,
],
'EFFECTIF' => [
'name' => 'EFFECTIF',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => TRUE,
'default' => NULL,
'position' => 14,
'commentaire' => NULL,
],
'FA' => [
'name' => 'FA',
'type' => 'bool',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => 1,
'nullable' => FALSE,
'default' => '0',
'position' => 12,
'commentaire' => NULL,
],
'FC' => [
'name' => 'FC',
'type' => 'bool',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => 1,
'nullable' => FALSE,
'default' => '0',
'position' => 13,
'commentaire' => NULL,
],
'FI' => [
'name' => 'FI',
'type' => 'bool',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => 1,
'nullable' => FALSE,
'default' => '0',
'position' => 11,
'commentaire' => NULL,
],
'LIBELLE' => [
'name' => 'LIBELLE',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 200,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 1,
'commentaire' => NULL,
],
'NIVEAU' => [
'name' => 'NIVEAU',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => TRUE,
'default' => NULL,
'position' => 3,
'commentaire' => NULL,
],
'SOURCE_CODE' => [
'name' => 'SOURCE_CODE',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 7,
'commentaire' => NULL,
],
'SPECIFIQUE_ECHANGES' => [
'name' => 'SPECIFIQUE_ECHANGES',
'type' => 'bool',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => 1,
'nullable' => FALSE,
'default' => '0',
'position' => 4,
'commentaire' => NULL,
],
'Z_DOMAINE_FONCTIONNEL_ID' => [
'name' => 'Z_DOMAINE_FONCTIONNEL_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 8,
'commentaire' => NULL,
],
'Z_SOURCE_ID' => [
'name' => 'Z_SOURCE_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 6,
'commentaire' => NULL,
],
'Z_STRUCTURE_ID' => [
'name' => 'Z_STRUCTURE_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 5,
'commentaire' => NULL,
],
'Z_TYPE_FORMATION_ID' => [
'name' => 'Z_TYPE_FORMATION_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 2,
'commentaire' => NULL,
],
],
];
//@formatter:on
<?php
//@formatter:off
return [
'name' => 'ACT_LIEN',
'temporary' => FALSE,
'logging' => TRUE,
'commentaire' => NULL,
'sequence' => NULL,
'columns' => [
'CHOIX_MAXIMUM' => [
'name' => 'CHOIX_MAXIMUM',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => NULL,
'precision' => NULL,
'nullable' => TRUE,
'default' => NULL,
'position' => 4,
'commentaire' => NULL,
],
'CHOIX_MINIMUM' => [
'name' => 'CHOIX_MINIMUM',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => NULL,
'precision' => NULL,
'nullable' => TRUE,
'default' => NULL,
'position' => 3,
'commentaire' => NULL,
],
'Z_NOEUD_INF_ID' => [
'name' => 'Z_NOEUD_INF_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 2,
'commentaire' => NULL,
],
'Z_NOEUD_SUP_ID' => [
'name' => 'Z_NOEUD_SUP_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 1,
'commentaire' => NULL,
],
'Z_SOURCE_ID' => [
'name' => 'Z_SOURCE_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 5,
'commentaire' => NULL,
],
],
];
//@formatter:on
<?php
//@formatter:off
return [
'name' => 'ACT_NOEUD',
'temporary' => FALSE,
'logging' => TRUE,
'commentaire' => NULL,
'sequence' => NULL,
'columns' => [
'ANNEE_ID' => [
'name' => 'ANNEE_ID',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 3,
'commentaire' => NULL,
],
'CODE' => [
'name' => 'CODE',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 50,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 1,
'commentaire' => NULL,
],
'LIBELLE' => [
'name' => 'LIBELLE',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 200,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 2,
'commentaire' => NULL,
],
'ORDRE' => [
'name' => 'ORDRE',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => '0',
'position' => 13,
'commentaire' => NULL,
],
'SOURCE_CODE' => [
'name' => 'SOURCE_CODE',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 11,
'commentaire' => NULL,
],
'TAUX_FOAD' => [
'name' => 'TAUX_FOAD',
'type' => 'float',
'bdd-type' => 'FLOAT',
'length' => 0,
'scale' => NULL,
'precision' => 126,
'nullable' => FALSE,
'default' => '0',
'position' => 8,
'commentaire' => NULL,
],
'TYPE_NOEUD' => [
'name' => 'TYPE_NOEUD',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 12,
'commentaire' => NULL,
],
'Z_DISCIPLINE_ID' => [
'name' => 'Z_DISCIPLINE_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => TRUE,
'default' => NULL,
'position' => 9,
'commentaire' => NULL,
],
'Z_ETAPE_ID' => [
'name' => 'Z_ETAPE_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 4,
'commentaire' => NULL,
],
'Z_PERIODE_ID_ORDRE' => [
'name' => 'Z_PERIODE_ID_ORDRE',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => TRUE,
'default' => NULL,
'position' => 7,
'commentaire' => NULL,
],
'Z_PERIODE_ID_SEMESTRE' => [
'name' => 'Z_PERIODE_ID_SEMESTRE',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => TRUE,
'default' => NULL,
'position' => 6,
'commentaire' => NULL,
],
'Z_SOURCE_ID' => [
'name' => 'Z_SOURCE_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 10,
'commentaire' => NULL,
],
'Z_STRUCTURE_ID' => [
'name' => 'Z_STRUCTURE_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 5,
'commentaire' => NULL,
],
],
];
//@formatter:on
<?php
//@formatter:off
return [
'name' => 'ACT_VHENS_GROUPES',
'temporary' => FALSE,
'logging' => TRUE,
'commentaire' => NULL,
'sequence' => NULL,
'columns' => [
'GROUPES' => [
'name' => 'GROUPES',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 4,
'commentaire' => NULL,
],
'Z_ELEMENT_PEDAGOGIQUE_ID' => [
'name' => 'Z_ELEMENT_PEDAGOGIQUE_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 3,
'commentaire' => NULL,
],
'Z_SOURCE_ID' => [
'name' => 'Z_SOURCE_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 2,
'commentaire' => NULL,
],
'Z_TYPE_INTERVENTION_ID' => [
'name' => 'Z_TYPE_INTERVENTION_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 1,
'commentaire' => NULL,
],
],
];
//@formatter:on
<?php
//@formatter:off
return [
'name' => 'ACT_VHENS_HEURES',
'temporary' => FALSE,
'logging' => TRUE,
'commentaire' => NULL,
'sequence' => NULL,
'columns' => [
'HEURES' => [
'name' => 'HEURES',
'type' => 'float',
'bdd-type' => 'FLOAT',
'length' => 0,
'scale' => NULL,
'precision' => 126,
'nullable' => FALSE,
'default' => NULL,
'position' => 2,
'commentaire' => NULL,
],
'Z_ELEMENT_PEDAGOGIQUE_ID' => [
'name' => 'Z_ELEMENT_PEDAGOGIQUE_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 4,
'commentaire' => NULL,
],
'Z_SOURCE_ID' => [
'name' => 'Z_SOURCE_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 3,
'commentaire' => NULL,
],
'Z_TYPE_INTERVENTION_ID' => [
'name' => 'Z_TYPE_INTERVENTION_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 1,
'commentaire' => NULL,
],
],
];
//@formatter:on
SELECT
vde.libelle as libelle,
tpd.typ_dip_apo as z_type_formation_id,
CASE etp.prem_sem
WHEN 1 THEN 1 -- semestre 1 => première année
WHEN 3 THEN 2 -- semestre 3 => deuxième année
WHEN 5 THEN 3 -- semestre 5 => troisième année
ELSE NULL
END as niveau,
0 as specifique_echanges,
vde.cod_cip as z_structure_id,
'Actul' as z_source_id,
vde.id as source_code,
case tpd.COD_CURSUS_LMD -- Codification LMD standard
WHEN 'L' THEN 'D101'
WHEN 'M' THEN 'D102'
WHEN 'D' THEN 'D103'
ELSE NULL -- sinon NULL
END as z_domaine_fonctionnel_id,
anu.COD_ANU as annee_id,
CASE WHEN etp.code IS NOT NULL AND MAX(vti.code) IS NOT NULL
THEN concat(ltrim(rtrim(etp.code)), '_', cast(MAX(vti.code) as char(255)))
ELSE concat('act_',vde.id)
END as code,
CASE WHEN SUM(CASE pti.LIBELLE_COURT WHEN 'FI' THEN 1 ELSE 0 END) >= 1 THEN 1 ELSE 0 END fi,
CASE WHEN SUM(CASE pti.LIBELLE_COURT WHEN 'FC' THEN 1 ELSE 0 END) >= 1 THEN 1 ELSE 0 END fc,
CASE WHEN SUM(CASE pti.LIBELLE_COURT WHEN 'FA' THEN 1 ELSE 0 END) >= 1 THEN 1 ELSE 0 END fa,
vde.EFF_PREV as effectif
FROM
PREV_PROJET anu
JOIN PREV_DIPLOME dip on dip.prev_projet_id = anu.cod_anu
JOIN PREV_TYP_DIPLOME tpd on tpd.id = dip.prev_typ_diplome_id
JOIN PREV_VERSION_DIPLOME vdi on vdi.prev_diplome_id = dip.id
JOIN PREV_ETAPE etp on etp.prev_version_diplome_id = vdi.id
JOIN PREV_VERSION_ETAPE vde on vde.prev_etape_id = etp.id
LEFT JOIN PREV_VET_TYPINS vti on vde.id = vti.prev_vet_id
LEFT JOIN PREV_TYP_INS pti ON pti.COD_TYP_INS = vti.PREV_TYPINS_ID
WHERE
anu.temoin_actif = 1 -- on ne sélectionne que les projets actifs
AND vde.STATUT = 'TERMINE' -- on ne récupère que ce qui est terminé
GROUP BY
vde.libelle,
tpd.typ_dip_apo,
etp.prem_sem,
etp.cod_cmp,
vde.id,
tpd.COD_CURSUS_LMD,
anu.COD_ANU,
etp.code
SELECT
COALESCE(epr.prev_elp_reference_id,epr.id) as z_noeud_sup_id,
COALESCE(pep.prev_elp_reference_id,pep.id) as z_noeud_inf_id,
epr.nb_choix as choix_minimum,
epr.nb_choix_max as choix_maximum,
'Actul' as z_source_id
FROM
PREV_ELEMENT_PEDAGOGI pep
JOIN PREV_VERSION_ETAPE pve ON pve.id = pep.PREV_VET_ID
JOIN PREV_ETAPE pe ON pe.id = pve.PREV_ETAPE_ID
JOIN PREV_VERSION_DIPLOME pvd ON pvd.id = pe.PREV_VERSION_DIPLOME_ID
JOIN PREV_DIPLOME pd ON pd.id = pvd.PREV_DIPLOME_ID
JOIN PREV_PROJET pp ON pp.COD_ANU = pd.PREV_PROJET_ID
LEFT JOIN PREV_ELEMENT_PEDAGOGI epr ON epr.id = pep.prev_elp_parent_id
WHERE
pp.TEMOIN_ACTIF = 1 -- on ne sélectionne que les projets actifs
AND pep.prev_elp_parent_id IS NOT NULL
AND pve.STATUT = 'TERMINE' -- on ne récupère que ce qui est terminé
\ No newline at end of file
SELECT
COALESCE(pep.CODE,CONCAT('act_',pep.id)) as code,
pep.LIBELLE_long as libelle,
pp.COD_ANU as annee_id,
pep.PREV_VET_ID as z_etape_id,
pe.COD_CMP as z_structure_id,
CASE WHEN pn.tem_sem = 1 THEN pe.prem_sem ELSE NULL END as z_periode_id_semestre,
CASE WHEN pn.tem_sem = 1 THEN pep.elp_order ELSE NULL END as z_periode_id_ordre,
CASE WHEN elp_ead.PREV_ELP_ID IS NOT NULL THEN 1 ELSE 0 END as taux_foad,
pep.CODE_SECTION_CNU as z_discipline_id,
'Actul' as z_source_id,
pep.id as source_code,
pep.nel as type_noeud,
pep.elp_order as ordre
FROM
PREV_ELEMENT_PEDAGOGI pep
JOIN PREV_VERSION_ETAPE pve ON pve.id = pep.PREV_VET_ID
JOIN PREV_ETAPE pe ON pe.id = pve.PREV_ETAPE_ID
JOIN PREV_VERSION_DIPLOME pvd ON pvd.id = pe.PREV_VERSION_DIPLOME_ID
JOIN PREV_DIPLOME pd ON pd.id = pvd.PREV_DIPLOME_ID
JOIN PREV_PROJET pp ON pp.COD_ANU = pd.PREV_PROJET_ID
LEFT JOIN PREV_NEL pn ON pn.COD_NEL = pep.NEL
LEFT JOIN (
SELECT ph.PREV_ELP_ID
FROM PREV_HEUS ph
WHERE ph.TYP_HEU IN ('EAD') -- EAD => FOAD
GROUP BY ph.PREV_ELP_ID
HAVING SUM(ph.NB_HEURES) > 0
) elp_ead ON elp_ead.PREV_ELP_ID = pep.id
WHERE
pp.TEMOIN_ACTIF = 1 -- on ne sélectionne que les projets actifs
AND pep.PREV_ELP_REFERENCE_ID IS NULL -- on ignore les noeuds "référence"
AND pve.STATUT = 'TERMINE' -- on ne récupère que ce qui est terminé
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment