Skip to content
Snippets Groups Projects
Commit f09a2b7d authored by joriot221's avatar joriot221
Browse files

Merge branch 'master' into FJ_Contrat_Sans_Avenant

# Conflicts:
#	data/ddl/view/V_TBL_PLAFOND_STRUCTURE.sql
parents d9aeb12a 922ddd13
No related branches found
No related tags found
No related merge requests found
Showing
with 356 additions and 196 deletions
...@@ -2,11 +2,14 @@ ...@@ -2,11 +2,14 @@
[OSE 17.3](#ose-173-17032022) [OSE 17.3](#ose-173-17032022)
# Version de test
[OSE 18.0-beta3](#ose-18-beta-3-06052022)
# OSE 18 (à venir)
# OSE 18 BETA 3 (06/05/2022)
Objectif : Plafonds personnalisables & refonte gestion des statuts Objectif : Plafonds personnalisables & refonte gestion des statuts
## Nouveautés ## Nouveautés
...@@ -90,14 +93,28 @@ Objectif : Plafonds personnalisables & refonte gestion des statuts ...@@ -90,14 +93,28 @@ Objectif : Plafonds personnalisables & refonte gestion des statuts
* Correction sur la suppression de service lorsque la clôture de service a été historisé (#42046) * 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) * Le calcul des choix minimum/maximum est de nouveau fiable (#42080)
* Liens inactifs lors du changement d'année universitaire (#40992) * Liens inactifs lors du changement d'année universitaire (#40992)
* Dans certains cas avec des motifs de non paiements, le détail des services n'affichait pas toutes les heures
## Notes de mise à jour ## Notes de mise à jour
* **ATTENTION : OSE 18** ne pourra être mis à jour **qu'à partir de OSE 17.x**. Si vous utilisez une version plus ancienne de OSE, veuillez **d'abord** mettre à jour en version 17. * Les indicateurs portant sur les anciens plafonds ayant été supprimés et remplacés par de tous nouveaux indicateurs, les notifications par mail et abonnements correspondants seront résiliés
* **ATTENTION : PHP 8.0** est requis * En raison de l'ampleur de la mise à jour, l'opération de maintenance va prendre du temps. Prévoyez une journée d'interruption de service.
* 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. ## Procédure de mise à jour spécifique à la version 18
* Au niveau du fichier de configuration [config.local.php](config.local.php.default), vous pouvez remplir le paramètre (facultatif) ldap>systemeInformationUrl.
1. Mettez l'aplication en maintenance
2. Si votre version de OSE est antérieure à la version 17, mettez **d'abord** à jour en version **17.3**
3. Installez **PHP8.0** sur votre serveur ainsi que [toutes ses dépendances nécessaires](install.md)
4. Dans le répertoire de OSE, lancez `php composer.phar self-update --2`
5. Mettez ensuite OSE à jour en version 18 `./bin/ose update` (attention, ce traitement est long, il pourra prendre plusieurs heures)
6. Recalculez toutes les forules de calcul : `./bin/ose formule-calcul` (attention, ce traitement dure plusieurs heures)
7. Pour votre instance de production, la nouvelle commande `./bin/ose maj-exports` doit être lancée régulièrement (cf. [procédure d'installation](install.md)). Ceci met à jour toutes les vues matérialisées dédiées à l'export MV_EXT_*.
8. Mettez à jour votre vue source [SRC_INTERVENANT](doc/Connecteurs-Import/Générique/SRC_INTERVENANT.sql)
9. Réactivez la synchronisation en import pour la table INTERVENANT, que la mise à jour a volontairement désactivée (en production).
10. Mettez à jour votre [modèle de contrat de travail](data/modele_contrat_ventile.odt) si vous voulez bénéficier de la ventilation par CM/TD/TP/Autres des heures.
11. Si vous utilisez l'export RH Siham, renseignez un nouveau paramètre dans Administration > paramètres généraux > Gestion export RH, en sélectionnant l'étape de la feuille de route franchie à partir de laquelle l'intervenant peut être exporté dans SIHAM.
12. Au niveau du fichier de configuration [config.local.php](config.local.php.default), vous pouvez remplir le paramètre (facultatif) ldap>systemeInformationUrl.
13. Sortez du mode maintenance
# OSE 17.3 (17/03/2022) # OSE 17.3 (17/03/2022)
......
...@@ -4,7 +4,7 @@ OSE est une application web qui exploite une base de données Oracle. ...@@ -4,7 +4,7 @@ OSE est une application web qui exploite une base de données Oracle.
Il faut donc installer : Il faut donc installer :
* Une base de données Oracle * Une base de données Oracle
* Un serveur web Apache + PHP >= 7.4 * Un serveur web Apache + PHP
Le serveur web peut être installé manuellement ou bien déployé via une image Docker. Le serveur web peut être installé manuellement ou bien déployé via une image Docker.
Le serveur web n'héberge aucune donnée, hormis des fichiers de configuration et de cache. Toutes les données d'explloitation sont donc Le serveur web n'héberge aucune donnée, hormis des fichiers de configuration et de cache. Toutes les données d'explloitation sont donc
...@@ -81,7 +81,7 @@ Dépendances requises : ...@@ -81,7 +81,7 @@ Dépendances requises :
* git * git
* wget * wget
* Apache 2 avec le module de réécriture d'URL (*rewrite*) activé * Apache 2 avec le module de réécriture d'URL (*rewrite*) activé
* PHP 7.4 minimum avec les modules suivants : * PHP 8.0 avec les modules suivants :
* cli * cli
* curl * curl
* intl * intl
......
...@@ -7,9 +7,15 @@ try { ...@@ -7,9 +7,15 @@ try {
$c->exec([ $c->exec([
"cd $osedir", "cd $osedir",
"rm -Rf cache/*", "rm -Rf cache/*",
"php public/index.php orm:generate-proxies", ], false);
$oa->exec("generate-proxies");
$c->exec([
"cd $osedir",
"chmod -R 777 cache", "chmod -R 777 cache",
], false); ], false);
$c->println('Cache nettoyé, proxies actualisés', $c::COLOR_GREEN); $c->println('Cache nettoyé, proxies actualisés', $c::COLOR_GREEN);
} catch (\Exception $e) { } catch (\Exception $e) {
$c->println($e->getMessage()); $c->println($e->getMessage());
......
<?php
// à supprimer pour la v19
\ No newline at end of file
<?php <?php
if ($oa->inMaintenance()) {
$c->println("OSE est en maintenance. La synchronisation est coupée pendant ce temps");
} else {
$job = $c->getArg(2); $job = $c->getArg(2);
$oa->exec('UnicaenImport SyncJob ' . $job); $oa->exec('UnicaenImport SyncJob ' . $job);
$c->println("Opération terminée"); $c->println("Opération terminée");
}
\ No newline at end of file
...@@ -42,7 +42,7 @@ foreach ($tablesDep as $tableDep) { ...@@ -42,7 +42,7 @@ foreach ($tablesDep as $tableDep) {
// Initialisation et lancement de la pré-migration // Initialisation et lancement de la pré-migration
$mm = new MigrationManager($oa, $ref, $filters); $mm = new MigrationManager($oa, $ref, $filters);
$mm->migration('pre'); $mm->migration('before');
// Mise à jour de la BDD (structures) // Mise à jour de la BDD (structures)
...@@ -66,7 +66,7 @@ $c->end(); ...@@ -66,7 +66,7 @@ $c->end();
// Post-migration // Post-migration
$c->println(''); $c->println('');
$mm->migration('post'); $mm->migration('after');
// Néttoyage des caches // Néttoyage des caches
$oa->run('clear-cache'); $oa->run('clear-cache');
\ No newline at end of file
<?php
$osedir = $oa->getOseDir();
// Récupération des dépendances
$c->println("\nMise à jour des dépendances à l'aide de Composer", $c::COLOR_LIGHT_CYAN);
$c->passthru([
"export COMPOSER_ALLOW_SUPERUSER=1",
"cd $osedir",
"php composer.phar self-update --2",
"php composer.phar install --optimize-autoloader",
]);
...@@ -13,7 +13,6 @@ $filters = [ ...@@ -13,7 +13,6 @@ $filters = [
'MV_EXT_SERVICE', 'MV_EXT_SERVICE',
'MV_EXT_DOTATION_LIQUIDATION', 'MV_EXT_DOTATION_LIQUIDATION',
'MV_EXT_ETAT_PAIEMENT', 'MV_EXT_ETAT_PAIEMENT',
'TBL_NOEUD',
]], ]],
'package' => ['excludes' => ['UCBN_LDAP', 'UNICAEN_IMPORT_AUTOGEN_PROCS__', 'OSE_ACTUL']], 'package' => ['excludes' => ['UCBN_LDAP', 'UNICAEN_IMPORT_AUTOGEN_PROCS__', 'OSE_ACTUL']],
]; ];
......
...@@ -49,25 +49,15 @@ $c->passthru([ ...@@ -49,25 +49,15 @@ $c->passthru([
$updcmd, $updcmd,
]); ]);
// Récupération des dépendances
$c->println("\nMise à jour des dépendances à l'aide de Composer", $c::COLOR_LIGHT_CYAN);
$c->passthru([
"cd $osedir",
"php composer.phar self-update --2",
"php composer.phar install --optimize-autoloader",
]);
// Conclusion
$oa->writeVersion($version); $oa->writeVersion($version);
$c->println("\nMise à jour des fichiers OK : la version installée est désormais la " . $version, $c::COLOR_LIGHT_GREEN); $c->println("\nMise à jour du code source OK : la version installée est désormais la " . $version, $c::COLOR_LIGHT_GREEN);
// Mise à jour des dépendances du projet
$oa->run('update-composer', true);
// Mise à jour de la base de données à partir d'un nouveau processus // Mise à jour de la base de données à partir d'un nouveau processus
$oa->run('update-bdd', true); $oa->run('update-bdd', true);
//Conclusion //Conclusion
$c->println("\nFin de la mise à jour."); $c->println("\nFin de la mise à jour.");
if ($c->getOption('maintenance') != 'no') { if ($c->getOption('maintenance') != 'no') {
......
<?php
class OrdonnancementColonnesTbl extends AbstractMigration
{
protected $tbls = [];
public function description(): string
{
return "Suppression de tableaux de bord dont l'ordonnancement des colonnes a changé";
}
public function utile(): bool
{
if (count($this->tbls) > 0) return true;
$bdd = $this->manager->getBdd();
$sql = "SELECT
tbl.table_name,
tc.column_name,
tc.column_id position
FROM
tbl
JOIN user_tab_columns tc ON tc.table_name = tbl.table_name
WHERE
tbl.table_name IS NOT NULL AND tbl.view_name IS NOT NULL";
$tblcs = $bdd->select($sql);
$this->tbls = [];
$tables = $this->manager->getRef()->get('table');
foreach ($tblcs as $tc) {
$table = $tc['TABLE_NAME'];
$col = $tc['COLUMN_NAME'];
$pos = (int)$tc['POSITION'];
if (isset($tables[$table]['columns'][$col])) {
if ($pos != $tables[$table]['columns'][$col]['position']) {
$this->tbls[$table] = true; // Position différente => la table sera recréée
}
} else {
$this->tbls[$table] = true; // Nouvelle colonne => la table sera recréée
}
}
return count($this->tbls) > 0;
}
public function before()
{
$bdd = $this->manager->getBdd();
$console = $this->manager->getOseAdmin()->getConsole();
$console->println('');
foreach ($this->tbls as $table => $null) {
$console->println("Suppression de la table $table");
$bdd->table()->drop($table);
}
}
public function after()
{
$console = $this->manager->getOseAdmin()->getConsole();
$console->begin("Recalcul de tous les tableaux de bord");
$this->manager->getOseAdmin()->exec('calcul-tableaux-bord');
$console->end("Tableaux de bord recalculés");
}
}
...@@ -6,9 +6,6 @@ ...@@ -6,9 +6,6 @@
class v18Divers extends AbstractMigration class v18Divers extends AbstractMigration
{ {
protected $contexte = self::CONTEXTE_PRE;
public function description(): string public function description(): string
{ {
...@@ -24,24 +21,27 @@ class v18Divers extends AbstractMigration ...@@ -24,24 +21,27 @@ class v18Divers extends AbstractMigration
public function action(string $contexte)
{
if ($contexte == self::CONTEXTE_PRE) {
$this->before();
} else {
$this->after();
}
}
public function before() public function before()
{ {
$bdd = $this->manager->getBdd(); $bdd = $this->manager->getBdd();
$c = $this->manager->getOseAdmin()->getConsole(); $c = $this->manager->getOseAdmin()->getConsole();
// test pour savoir si on est bien en V17 minimum
if (!$this->manager->hasColumn('INTERVENANT', 'EXPORT_DATE')) {
$c->printDie('Attention : vous devez d\'abord mettre à jour en version 17.3 AVANT de mettre à jour en version 18');
}
try { try {
$c->msg('Suppression de la contrainte TYPE_INTERVENANT_CODE_UN en prévision de sa recréation'); $c->msg('Coupure forcée de la synchronisation sur la table INTERVENANT');
$bdd->exec("UPDATE IMPORT_TABLES SET SYNC_ENABLED = 0 WHERE TABLE_NAME = 'INTERVENANT'");
} catch (\Exception $e) {
// rien à faire : la contrainte a déjà du être supprimée
}
$this->sauvegardes();
try {
$c->msg('Suppression des affectations de recherche ayant des structures invalides');
$bdd->exec("DELETE FROM AFFECTATION_RECHERCHE WHERE structure_id NOT IN (SELECT ID FROM STRUCTURE)"); $bdd->exec("DELETE FROM AFFECTATION_RECHERCHE WHERE structure_id NOT IN (SELECT ID FROM STRUCTURE)");
} catch (\Exception $e) { } catch (\Exception $e) {
// rien à faire : la contrainte a déjà du être supprimée // rien à faire : la contrainte a déjà du être supprimée
...@@ -55,4 +55,42 @@ class v18Divers extends AbstractMigration ...@@ -55,4 +55,42 @@ class v18Divers extends AbstractMigration
} }
} }
protected function sauvegardes()
{
$bdd = $this->manager->getBdd();
$c = $this->manager->getOseAdmin()->getConsole();
$tables = [
'INTERVENANT' => 'SAVE_V18_INTERVENANT',
'INTERVENANT_DOSSIER' => 'SAVE_V18_DOSSIER',
'TYPE_PIECE_JOINTE_STATUT' => 'SAVE_V18_TPJS',
'TYPE_INTERVENTION_STATUT' => 'SAVE_V18_TIS',
'STATUT_INTERVENANT' => 'SAVE_V18_STATUT',
'PRIVILEGE' => 'SAVE_V18_PRIVILEGE',
'ROLE_PRIVILEGE' => 'SAVE_V18_ROLE_PRIVILEGE',
'STATUT_PRIVILEGE' => 'SAVE_V18_STATUT_PRIVILEGE',
'TYPE_AGREMENT_STATUT' => 'SAVE_V18_TA_STATUT',
'DOSSIER_CHAMP_AUTRE_PAR_STATUT' => 'SAVE_V18_DOSSIER_AUTRE_STATUT',
'STRUCTURE' => 'SAVE_V18_STRUCTURE',
'FONCTION_REFERENTIEL' => 'SAVE_V18_REFERENTIEL',
'PLAFOND_APPLICATION' => 'SAVE_V18_PLAFOND_APP',
'PLAFOND' => 'SAVE_V18_PLAFOND',
];
foreach ($tables as $table => $saveTable) {
if (!$this->manager->hasTable($table) || $this->manager->hasTable($saveTable)) {
unset($tables[$table]);
}
}
$c->begin('Sauvegarde des anciennes données');
foreach ($tables as $table => $saveTable) {
$c->msg('Table "' . $table . '" sauvegardée en "' . $saveTable . '".');
$this->manager->sauvegarderTable($table, $saveTable);
}
$c->end();
}
} }
\ No newline at end of file
<?php
class v18Indicateurs extends AbstractMigration
{
public function description(): string
{
return "Migration des indicateurs de OSE 17 vers OSE 18";
}
public function utile(): bool
{
return true;
return $this->manager->hasNew('table', 'TYPE_INDICATEUR');
}
public function before()
{
$bdd = $this->manager->getBdd();
$c = $this->manager->getOseAdmin()->getConsole();
$c->begin('Préparation à la mise à jour des indicateurs');
$bdd->exec('ALTER TABLE INDICATEUR ADD (TYPE_INDICATEUR_ID NUMBER)');
$bdd->exec('CREATE TABLE TYPE_INDICATEUR (
ID NUMBER NOT NULL ENABLE,
LIBELLE VARCHAR2(60 CHAR) NOT NULL ENABLE,
ORDRE NUMBER DEFAULT 1 NOT NULL ENABLE
)');
$indicateurs = require $this->manager->getOseAdmin()->getOseDir() . '/data/indicateurs.php';
foreach ($indicateurs as $libelle => $type) {
$data = ['ID' => $type['id'], 'LIBELLE' => $libelle];
$bdd->getTable('TYPE_INDICATEUR')->insert($data);
foreach ($type['indicateurs'] as $numero => $indicateur) {
$bdd->getTable('INDICATEUR')->update(['TYPE_INDICATEUR_ID' => $type['id']], ['NUMERO' => $numero]);
}
}
$bdd->exec('DELETE FROM INDICATEUR WHERE TYPE_INDICATEUR_ID IS NULL');
$c->end('Préparation à la migration des indicateurs terminée');
}
}
\ No newline at end of file
...@@ -6,9 +6,6 @@ ...@@ -6,9 +6,6 @@
class v18Plafonds extends AbstractMigration class v18Plafonds extends AbstractMigration
{ {
protected $contexte = self::CONTEXTE_ALL;
public function description(): string public function description(): string
{ {
...@@ -24,52 +21,11 @@ class v18Plafonds extends AbstractMigration ...@@ -24,52 +21,11 @@ class v18Plafonds extends AbstractMigration
public function action(string $contexte)
{
if ($contexte == self::CONTEXTE_PRE) {
$this->before();
} else {
$this->after();
}
}
public function before() public function before()
{ {
$bdd = $this->manager->getBdd(); $bdd = $this->manager->getBdd();
$c = $this->manager->getOseAdmin()->getConsole(); $c = $this->manager->getOseAdmin()->getConsole();
if (empty($bdd->table()->get('SAVE_V18_STATUT'))) {
$this->manager->sauvegarderTable('STATUT_INTERVENANT', 'SAVE_V18_STATUT');
$c->msg('Anciens statuts "STATUT_INTERVENANT" sauvegardés dans "SAVE_V18_STATUT".');
}
if (empty($bdd->table()->get('SAVE_V18_STRUCTURE'))) {
$this->manager->sauvegarderTable('STRUCTURE', 'SAVE_V18_STRUCTURE');
$c->msg('Anciennes structures "STRUCTURE" sauvegardés dans "SAVE_V18_STRUCTURE".');
}
if (empty($bdd->table()->get('SAVE_V18_REFERENTIEL'))) {
$this->manager->sauvegarderTable('FONCTION_REFERENTIEL', 'SAVE_V18_REFERENTIEL');
$c->msg('Anciennes fonctions référentielles "FONCTION_REFERENTIEL" sauvegardées dans "SAVE_V18_REFERENTIEL".');
}
if (empty($bdd->table()->get('SAVE_V18_PLAFOND_APP'))) {
$this->manager->sauvegarderTable('PLAFOND_APPLICATION', 'SAVE_V18_PLAFOND_APP');
$c->msg('Anciens paramétrages des plafonds "PLAFOND_APPLICATION" sauvegardées dans "SAVE_V18_PLAFOND_APP".');
}
if (!empty($bdd->table()->get('PLAFOND_APPLICATION'))) {
$bdd->exec('DROP TABLE PLAFOND_APPLICATION');
$c->msg('Suppression des anciens paramétrages de plafonds');
}
if (empty($bdd->table()->get('SAVE_V18_PLAFOND'))) {
$this->manager->sauvegarderTable('PLAFOND', 'SAVE_V18_PLAFOND');
$c->msg('Anciens plafonds "PLAFOND" sauvegardées dans "SAVE_V18_PLAFOND".');
}
if (!empty($bdd->table()->get('PLAFOND'))) { if (!empty($bdd->table()->get('PLAFOND'))) {
$bdd->exec('DROP TABLE PLAFOND CASCADE CONSTRAINTS'); $bdd->exec('DROP TABLE PLAFOND CASCADE CONSTRAINTS');
$c->msg('Suppression des anciens plafonds'); $c->msg('Suppression des anciens plafonds');
...@@ -78,7 +34,7 @@ class v18Plafonds extends AbstractMigration ...@@ -78,7 +34,7 @@ class v18Plafonds extends AbstractMigration
protected function after() public function after()
{ {
$c = $this->manager->getOseAdmin()->getConsole(); $c = $this->manager->getOseAdmin()->getConsole();
try { try {
...@@ -102,18 +58,6 @@ class v18Plafonds extends AbstractMigration ...@@ -102,18 +58,6 @@ class v18Plafonds extends AbstractMigration
public function preMigrationIndicateurs()
{
$bdd = $this->manager->getBdd();
$c = $this->manager->getOseAdmin()->getConsole();
$c->begin('Préparation à la mise à jour des indicateurs');
$c->end('Préparation à la migration des indicateurs terminée');
}
public function migrationParamsStructure() public function migrationParamsStructure()
{ {
$bdd = $this->manager->getBdd(); $bdd = $this->manager->getBdd();
......
<?php
class v18Privileges extends AbstractMigration
{
public function description(): string
{
return "Migration des privilèges de OSE 17 vers OSE 18";
}
public function utile(): bool
{
return $this->manager->hasTable('SAVE_V18_PRIVILEGE');
}
public function after()
{
$c = $this->manager->getOseAdmin()->getConsole();
$bdd = $this->manager->getBdd();
$sql = "
INSERT INTO ROLE_PRIVILEGE (privilege_id,role_id)
SELECT
np.id privilege_id, r.id role_id
FROM
save_v18_privilege p
JOIN categorie_privilege cp ON cp.id = p.categorie_id
JOIN save_v18_role_privilege rp ON rp.privilege_id = p.id
JOIN role r ON r.id = rp.role_id AND r.code <> 'administrateur'
JOIN (SELECT 'prevu' code FROM dual UNION ALL SELECT 'realise' code FROM dual) tvh ON 1=1
JOIN privilege np ON np.categorie_id = cp.id AND np.code = tvh.code || '-' || p.code
LEFT JOIN role_privilege nrp ON nrp.privilege_id = np.id AND nrp.role_id = r.id
WHERE
cp.code IN ('enseignement','referentiel')
AND p.code IN ('visualisation','edition', 'validation', 'autovalidation')
AND rp.role_id <> COALESCE(nrp.role_id,0)
";
$bdd->exec($sql);
$c->msg('Transfert d\'anciens privilèges vers le nouveau système');
}
}
\ No newline at end of file
...@@ -6,9 +6,6 @@ ...@@ -6,9 +6,6 @@
class v18Statuts extends AbstractMigration class v18Statuts extends AbstractMigration
{ {
protected $contexte = self::CONTEXTE_ALL;
public function description(): string public function description(): string
{ {
...@@ -24,28 +21,11 @@ class v18Statuts extends AbstractMigration ...@@ -24,28 +21,11 @@ class v18Statuts extends AbstractMigration
public function action(string $contexte)
{
if ($contexte == self::CONTEXTE_PRE) {
$this->before();
} else {
$this->after();
}
}
public function before() public function before()
{ {
$bdd = $this->manager->getBdd(); $bdd = $this->manager->getBdd();
$c = $this->manager->getOseAdmin()->getConsole(); $c = $this->manager->getOseAdmin()->getConsole();
try {
$this->preMigrationIndicateurs();
} catch (\Exception $e) {
$c->println($e->getMessage(), $c::COLOR_RED);
}
try { try {
$this->preMigrationStatuts(); $this->preMigrationStatuts();
} catch (\Exception $e) { } catch (\Exception $e) {
...@@ -122,7 +102,7 @@ class v18Statuts extends AbstractMigration ...@@ -122,7 +102,7 @@ class v18Statuts extends AbstractMigration
protected function after() public function after()
{ {
$bdd = $this->manager->getBdd(); $bdd = $this->manager->getBdd();
$c = $this->manager->getOseAdmin()->getConsole(); $c = $this->manager->getOseAdmin()->getConsole();
...@@ -138,27 +118,6 @@ class v18Statuts extends AbstractMigration ...@@ -138,27 +118,6 @@ class v18Statuts extends AbstractMigration
public function preMigrationIndicateurs()
{
$bdd = $this->manager->getBdd();
$c = $this->manager->getOseAdmin()->getConsole();
$c->begin('Préparation à la mise à jour des indicateurs');
if (empty($bdd->table()->get('TYPE_INDICATEUR'))) {
$bdd->exec('ALTER TABLE INDICATEUR ADD (TYPE_INDICATEUR_ID NUMBER)');
$bdd->exec('CREATE TABLE TYPE_INDICATEUR (
ID NUMBER NOT NULL ENABLE,
LIBELLE VARCHAR2(60 CHAR) NOT NULL ENABLE,
ORDRE NUMBER DEFAULT 1 NOT NULL ENABLE
)');
$bdd->exec('INSERT INTO TYPE_INDICATEUR (ID, LIBELLE, ORDRE) VALUES (1,\'provisoire\', 1)');
$bdd->exec('UPDATE INDICATEUR SET TYPE_INDICATEUR_ID = 1');
}
$c->end('Préparation à la migration des indicateurs terminée');
}
public function preMigrationStatuts() public function preMigrationStatuts()
{ {
$bdd = $this->manager->getBdd(); $bdd = $this->manager->getBdd();
...@@ -166,27 +125,6 @@ class v18Statuts extends AbstractMigration ...@@ -166,27 +125,6 @@ class v18Statuts extends AbstractMigration
$c->begin('Mise à jour de la liste des statuts'); $c->begin('Mise à jour de la liste des statuts');
if (empty($bdd->table()->get('SAVE_V18_STATUT'))) {
$this->manager->sauvegarderTable('STATUT_INTERVENANT', 'SAVE_V18_STATUT');
$c->msg('Anciens statuts "STATUT_INTERVENANT" sauvegardés dans "SAVE_V18_STATUT".');
}
if (empty($bdd->table()->get('SAVE_V18_STATUT_PRIVILEGE'))) {
$this->manager->sauvegarderTable('STATUT_PRIVILEGE', 'SAVE_V18_STATUT_PRIVILEGE');
$c->msg('Anciens statuts "STATUT_PRIVILEGE" sauvegardés dans "SAVE_V18_STATUT_PRIVILEGE".');
}
if (empty($bdd->table()->get('SAVE_V18_TA_STATUT'))) {
$this->manager->sauvegarderTable('TYPE_AGREMENT_STATUT', 'SAVE_V18_TA_STATUT');
$c->msg('Anciens statuts "TYPE_AGREMENT_STATUT" sauvegardés dans "SAVE_V18_TA_STATUT".');
}
if (!$this->manager->hasTable('SAVE_V18_DOSSIER_AUTRE_STATUT') && $this->manager->hasTable('DOSSIER_CHAMP_AUTRE_PAR_STATUT')) {
$this->manager->sauvegarderTable('DOSSIER_CHAMP_AUTRE_PAR_STATUT', 'SAVE_V18_DOSSIER_AUTRE_STATUT');
$c->msg('Anciens statuts "DOSSIER_CHAMP_AUTRE_PAR_STATUT" sauvegardés dans "SAVE_V18_DOSSIER_AUTRE_STATUT".');
}
/* Modifications préalables à faire en BDD */ /* Modifications préalables à faire en BDD */
if (empty($bdd->sequence()->get('STATUT_ID_SEQ'))) { if (empty($bdd->sequence()->get('STATUT_ID_SEQ'))) {
$bdd->exec('CREATE SEQUENCE STATUT_ID_SEQ INCREMENT BY 1 MINVALUE 1 NOCACHE'); $bdd->exec('CREATE SEQUENCE STATUT_ID_SEQ INCREMENT BY 1 MINVALUE 1 NOCACHE');
...@@ -331,7 +269,7 @@ class v18Statuts extends AbstractMigration ...@@ -331,7 +269,7 @@ class v18Statuts extends AbstractMigration
SELECT SELECT
max(si.id) id, i.annee_id max(si.id) id, i.annee_id
FROM FROM
intervenant i SAVE_V18_INTERVENANT i
JOIN SAVE_V18_STATUT si ON si.id = i.statut_id JOIN SAVE_V18_STATUT si ON si.id = i.statut_id
GROUP BY GROUP BY
si.code, i.annee_id si.code, i.annee_id
...@@ -506,7 +444,7 @@ class v18Statuts extends AbstractMigration ...@@ -506,7 +444,7 @@ class v18Statuts extends AbstractMigration
osi.id old_statut_id, osi.id old_statut_id,
nsi.id new_statut_id nsi.id new_statut_id
FROM FROM
intervenant i SAVE_V18_INTERVENANT i
JOIN SAVE_V18_STATUT osi ON osi.id = i.statut_id JOIN SAVE_V18_STATUT osi ON osi.id = i.statut_id
LEFT JOIN statut nsi ON nsi.code = osi.code AND nsi.annee_id = i.annee_id LEFT JOIN statut nsi ON nsi.code = osi.code AND nsi.annee_id = i.annee_id
WHERE WHERE
...@@ -556,7 +494,7 @@ class v18Statuts extends AbstractMigration ...@@ -556,7 +494,7 @@ class v18Statuts extends AbstractMigration
osi.id old_statut_id, osi.id old_statut_id,
nsi.id new_statut_id nsi.id new_statut_id
FROM FROM
intervenant_dossier d SAVE_V18_DOSSIER d
JOIN intervenant i ON i.id = d.intervenant_id JOIN intervenant i ON i.id = d.intervenant_id
JOIN SAVE_V18_STATUT osi ON osi.id = d.statut_id JOIN SAVE_V18_STATUT osi ON osi.id = d.statut_id
LEFT JOIN statut nsi ON nsi.code = osi.code AND nsi.annee_id = i.annee_id LEFT JOIN statut nsi ON nsi.code = osi.code AND nsi.annee_id = i.annee_id
...@@ -595,14 +533,6 @@ class v18Statuts extends AbstractMigration ...@@ -595,14 +533,6 @@ class v18Statuts extends AbstractMigration
$c->begin('Application des nouveaux statuts aux paramétrages de PJ'); $c->begin('Application des nouveaux statuts aux paramétrages de PJ');
if (empty($bdd->table()->get('SAVE_V18_TPJS'))) {
$this->manager->sauvegarderTable('TYPE_PIECE_JOINTE_STATUT', 'SAVE_V18_TPJS');
$c->msg('Anciens paramètres "TYPE_PIECE_JOINTE_STATUT" sauvegardés dans "SAVE_V18_TPJS".');
$bdd->exec('DELETE FROM TYPE_PIECE_JOINTE_STATUT');
$c->msg("Vidage de la table \"TYPE_PIECE_JOINTE_STATUT\" avant d'insérer les nouveaux paramètres");
}
try { try {
$bdd->exec("ALTER TABLE TYPE_PIECE_JOINTE_STATUT DROP CONSTRAINT TPJS_STATUT_INTERVENANT_FK"); $bdd->exec("ALTER TABLE TYPE_PIECE_JOINTE_STATUT DROP CONSTRAINT TPJS_STATUT_INTERVENANT_FK");
} catch (\Exception $e) { } catch (\Exception $e) {
...@@ -612,6 +542,9 @@ class v18Statuts extends AbstractMigration ...@@ -612,6 +542,9 @@ class v18Statuts extends AbstractMigration
/* Modifications au niveau de la table TPJS */ /* Modifications au niveau de la table TPJS */
$ddl = $bdd->table()->get('TYPE_PIECE_JOINTE_STATUT')['TYPE_PIECE_JOINTE_STATUT']; $ddl = $bdd->table()->get('TYPE_PIECE_JOINTE_STATUT')['TYPE_PIECE_JOINTE_STATUT'];
if (!isset($ddl['columns']['ANNEE_ID'])) { if (!isset($ddl['columns']['ANNEE_ID'])) {
$bdd->exec('DELETE FROM TYPE_PIECE_JOINTE_STATUT');
$c->msg("Vidage de la table \"TYPE_PIECE_JOINTE_STATUT\" avant d'insérer les nouveaux paramètres");
$bdd->exec("ALTER TABLE TYPE_PIECE_JOINTE_STATUT ADD(ANNEE_ID NUMBER)"); $bdd->exec("ALTER TABLE TYPE_PIECE_JOINTE_STATUT ADD(ANNEE_ID NUMBER)");
} }
if (!isset($ddl['columns']['NUM_REGLE'])) { if (!isset($ddl['columns']['NUM_REGLE'])) {
...@@ -689,17 +622,12 @@ class v18Statuts extends AbstractMigration ...@@ -689,17 +622,12 @@ class v18Statuts extends AbstractMigration
$c->begin('Application des nouveaux statuts aux paramétrages des types d\'intervention'); $c->begin('Application des nouveaux statuts aux paramétrages des types d\'intervention');
if (empty($bdd->table()->get('SAVE_V18_TIS'))) {
$this->manager->sauvegarderTable('TYPE_INTERVENTION_STATUT', 'SAVE_V18_TIS');
$c->msg('Anciens paramètres "TYPE_INTERVENTION_STATUT" sauvegardés dans "SAVE_V18_TIS".');
$bdd->exec('DELETE FROM TYPE_INTERVENTION_STATUT');
$c->msg("Vidage de la table \"TYPE_INTERVENTION_STATUT\" avant d'insérer les nouveaux paramètres");
}
/* Modifications au niveau de la table TIS */ /* Modifications au niveau de la table TIS */
$ddl = $bdd->table()->get('TYPE_INTERVENTION_STATUT')['TYPE_INTERVENTION_STATUT']; $ddl = $bdd->table()->get('TYPE_INTERVENTION_STATUT')['TYPE_INTERVENTION_STATUT'];
if (!isset($ddl['columns']['ANNEE_ID'])) { if (!isset($ddl['columns']['ANNEE_ID'])) {
$bdd->exec('DELETE FROM TYPE_INTERVENTION_STATUT');
$c->msg("Vidage de la table \"TYPE_INTERVENTION_STATUT\" avant d'insérer les nouveaux paramètres");
$bdd->exec("ALTER TABLE TYPE_INTERVENTION_STATUT ADD(ANNEE_ID NUMBER)"); $bdd->exec("ALTER TABLE TYPE_INTERVENTION_STATUT ADD(ANNEE_ID NUMBER)");
} }
if (!isset($ddl['columns']['STATUT_ID'])) { if (!isset($ddl['columns']['STATUT_ID'])) {
......
...@@ -6,14 +6,6 @@ ...@@ -6,14 +6,6 @@
abstract class AbstractMigration abstract class AbstractMigration
{ {
CONST CONTEXTE_PRE = 'pre';
CONST CONTEXTE_POST = 'post';
CONST CONTEXTE_ALL = 'all';
/**
* @var string
*/
protected $contexte = self::CONTEXTE_POST;
/** /**
* @var MigrationManager * @var MigrationManager
...@@ -42,7 +34,11 @@ abstract class AbstractMigration ...@@ -42,7 +34,11 @@ abstract class AbstractMigration
abstract public function utile(): bool; abstract public function utile(): bool;
/*
Ajouter uniquement si nécessaire :
- une méthode publique before() qui s'exécutera AVANT la mise à jour
- une méthode publique after() qui s'exécutera APRES la mise à jour
abstract public function action(string $contexte); */
} }
...@@ -258,11 +258,16 @@ class MigrationManager ...@@ -258,11 +258,16 @@ class MigrationManager
if ( if (
$migration $migration
&& $migration instanceof AbstractMigration && $migration instanceof AbstractMigration
&& ($contexte == $migration->getContexte() || AbstractMigration::CONTEXTE_ALL == $migration->getContexte()) && (method_exists($migration, $contexte))
) { ) {
$console->print("[$contexte MIGRATION] " . $migration->description() . ' ... '); $traducs = [
'before' => 'AVANT',
'after' => 'APRES',
];
$contexteLib = $traducs[$contexte] ?? $contexte;
$console->print("[$contexteLib MIGRATION] " . $migration->description() . ' ... ');
try { try {
$migration->action($contexte); $migration->$contexte();
$console->println('OK', $console::COLOR_GREEN); $console->println('OK', $console::COLOR_GREEN);
} catch (\Throwable $e) { } catch (\Throwable $e) {
$console->println('Erreur : ' . $e->getMessage(), $console::COLOR_RED); $console->println('Erreur : ' . $e->getMessage(), $console::COLOR_RED);
......
...@@ -238,6 +238,8 @@ class OseAdmin ...@@ -238,6 +238,8 @@ class OseAdmin
} elseif (is_dir($cible . $action)) { } elseif (is_dir($cible . $action)) {
$sousAction = $this->getConsole()->getArg(2); $sousAction = $this->getConsole()->getArg(2);
$filename = $cible . $action . '/actions/' . $sousAction . '.php'; $filename = $cible . $action . '/actions/' . $sousAction . '.php';
} else {
$filename = null;
} }
if ($filename) { if ($filename) {
...@@ -307,6 +309,27 @@ class OseAdmin ...@@ -307,6 +309,27 @@ class OseAdmin
public function getConfig(): array
{
$configFilename = $this->getOseDir() . '/config.local.php';
if (file_exists($configFilename)) {
return require $configFilename;
} else {
return [];
}
}
public function inMaintenance(): bool
{
$config = $this->getConfig();
return $config['maintenance']['modeMaintenance'] ?? true;
}
/** /**
* @return \BddAdmin\Bdd * @return \BddAdmin\Bdd
*/ */
......
...@@ -114,7 +114,15 @@ if ($intVersion > 0 && $intVersion < 18) { ...@@ -114,7 +114,15 @@ if ($intVersion > 0 && $intVersion < 18) {
// Récupération des dépendances // Récupération des dépendances
$c->println("\nChargement des dépendances à l'aide de Composer", $c::COLOR_LIGHT_CYAN); $c->println("\nChargement des dépendances à l'aide de Composer", $c::COLOR_LIGHT_CYAN);
if ($intVersion === 0) {
// à partir d'une branche, on ignore les prérequis pour composer, afin de tester
$c->passthru("cd $osedir;php composer.phar install --optimize-autoloader --ignore-platform-reqs");
} else {
// à partir de la v18, et toutes les branches
$c->passthru("cd $osedir;php composer.phar install --optimize-autoloader"); $c->passthru("cd $osedir;php composer.phar install --optimize-autoloader");
}
if ($intVersion > 0 && $intVersion < 18) { if ($intVersion > 0 && $intVersion < 18) {
// Création des liens symboliques // Création des liens symboliques
......
...@@ -30,7 +30,9 @@ ...@@ -30,7 +30,9 @@
"config": { "config": {
"allow-plugins": { "allow-plugins": {
"laminas/laminas-dependency-plugin": true, "laminas/laminas-dependency-plugin": true,
"composer/package-versions-deprecated": true "composer/package-versions-deprecated": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"laminas-api-tools/api-tools-asset-manager": true
} }
}, },
"scripts" : { "scripts" : {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment