Commit a340f701 authored by Laurent Lécluse's avatar Laurent Lécluse
Browse files

Mise en place du nouveau DataGen, qui permet de mettre à jour les données de...

Mise en place du nouveau DataGen, qui permet de mettre à jour les données de la BDD, de la même manière que le DdlSchema permet de mettre à jour la DDL
parent ffc7c1d8
<?php
$bdd = new \BddAdmin\Bdd( Config::get()['bdds']['deploy-local'] );
$bdd = new \BddAdmin\Bdd(Config::get()['bdds']['deploy-local']);
$bdd->debug = true;
$schema = new \BddAdmin\Schema($bdd);
/* Récupération du schéma de référence */
$ref = $schema->loadFromFile($oa->getOseDir() . 'bdd/ddl.php');
/* Construction de la config de DDL pour filtrer */
$ddlConfig = require $oa->getOseDir().'/data/ddl_config.php';
$classes = [ // Tous les objets de ces classes seront int&égralement pris en compte dans la MAJ
\BddAdmin\Ddl\DdlView::class,
\BddAdmin\Ddl\DdlPackage::class,
\BddAdmin\Ddl\DdlTrigger::class,
];
foreach ($classes as $ddlClass) {
if (isset($ref[$ddlClass])){
$objects = array_keys($ref[$ddlClass]);
foreach($objects as $object){
$ddlConfig[$ddlClass]['includes'][] = $object;
}
}
$oa = new OseAdmin();
$oa->setBdd($bdd);
$dataGen = new DataGen($oa);
$dataGen->update();
/*
$bddp = new \BddAdmin\Bdd(Config::get()['bdds']['dev-local']);
$i = $bddp->select('SELECT * FROM formule order by libelle');
$indicateurs = [];
foreach( $i as $indic ){
$indicateurs[] = $indic;
}
var_dump($indicateurs);
var_dump($ddlConfig);
\ No newline at end of file
file_put_contents($oa->getOseDir().'/data/formules.php', var_export($indicateurs,true));
*/
\ No newline at end of file
......@@ -42,13 +42,8 @@ $schema->alter($ref, $ddlConfig, true);
$c->println('');
$c->println('Mise à jour des données', $c::COLOR_LIGHT_PURPLE);
$c->println(' * Privilèges ...');
$oa->majPrivileges();
$c->println(' * États de sortie ...');
$esData = require $oa->getOseDir() . 'data/etats_sortie.php';
$bdd->getTable('ETAT_SORTIE')->merge($esData, 'CODE', ['update' => false, 'delete' => false]);
$dataGen = new DataGen($oa);
$dataGen->update();
$c->println('');
$oa->migration('post');
......
<?php
class DataGen
{
/**
* @var OseAdmin
*/
private $oseAdmin;
private $config = [
'ANNEE' => [
'title' => 'Années',
'key' => 'ID',
'options' => ['update-ignore-cols' => ['ACTIVE', 'TAUX_HETD']],
],
'ETAT_SORTIE' => [
'title' => 'États de sortie',
'key' => 'CODE',
'options' => ['update' => false, 'delete' => false],
],
'CATEGORIE_PRIVILEGE' => [
'title' => 'Catégories de privilèges',
'key' => 'CODE',
],
'PRIVILEGE' => [
'title' => 'Privilèges',
'key' => ['CATEGORIE_ID', 'CODE'],
'options' => ['columns' => ['CATEGORIE_ID' => ['transformer' => 'SELECT id FROM categorie_privilege WHERE code = %s']]],
],
'INDICATEUR' => [
'title' => 'Indicateurs',
'key' => ['NUMERO'],
],
'CIVILITE' => [
'title' => 'Civilités',
'key' => ['LIBELLE_COURT'],
'options' => ['delete' => false],
],
'FORMULE' => [
'title' => 'Formules',
'key' => ['ID'],
],
'PLAFOND' => [
'title' => 'Plafonds',
'key' => 'CODE',
],
];
/*
'AFFECTATION' => "utilisateur_id IN (SELECT id FROM utilisateur WHERE username='" . self::OSE_USER . "')",
'CC_ACTIVITE' => '',
'CORPS' => '',
'DEPARTEMENT' => '',
'DISCIPLINE' => '',
'DOMAINE_FONCTIONNEL' => '',
'ETABLISSEMENT' => '',
'ETAT_VOLUME_HORAIRE' => '',
'FONCTION_REFERENTIEL' => '',
'FORMULE_TEST_INTERVENANT' => '',
'FORMULE_TEST_STRUCTURE' => '',
'FORMULE_TEST_VOLUME_HORAIRE' => '',
'GRADE' => 'corps_id in (select c.id from corps c where c.histo_destruction is null)',
'GROUPE' => '',
'IMPORT_TABLES' => '',
'MESSAGE' => '',
'MODELE_CONTRAT' => "libelle = 'Modèle par défaut'",
'MOTIF_MODIFICATION_SERVICE' => '',
'MOTIF_NON_PAIEMENT' => '',
'PARAMETRE' => '',
'PAYS' => '',
'PERIMETRE' => '',
'PERIODE' => '',
'PLAFOND' => '',
'PLAFOND_ETAT' => '',
'REGLE_STRUCTURE_VALIDATION' => '',
'ROLE' => '',
'ROLE_PRIVILEGE' => '',
'SCENARIO' => 'structure_id IS NULL',
'SOURCE' => "code='OSE'",
'STATUT_INTERVENANT' => '',
'STATUT_PRIVILEGE' => 'statut_id IN (SELECT si.id FROM statut_intervenant si WHERE si.histo_destruction IS NULL)',
'TAUX_HORAIRE_HETD' => '',
'TBL' => '',
'TYPE_AGREMENT' => '',
'TYPE_AGREMENT_STATUT' => '',
'TYPE_CONTRAT' => '',
'TYPE_HEURES' => '',
'TYPE_INTERVENANT' => '',
'TYPE_INTERVENTION' => "code IN ('CM','TD','TP')",
'TYPE_PIECE_JOINTE' => '',
'TYPE_PIECE_JOINTE_STATUT' => '',
'TYPE_RESSOURCE' => '',
'TYPE_VALIDATION' => '',
'TYPE_VOLUME_HORAIRE' => '',
'UTILISATEUR' => "username = '" . self::OSE_USER . "'",
'WF_ETAPE' => '',
'WF_ETAPE_DEP' => '',
*/
public function __construct(OseAdmin $oseAdmin)
{
$this->oseAdmin = $oseAdmin;
}
public function update()
{
foreach ($this->config as $table => $params) {
$this->oseAdmin->getConsole()->println(' * ' . $params['title'] . ' ...');
$data = $this->$table();
$this->oseAdmin->getBdd()->getTable($table)->merge(
$data,
$params['key'],
isset($params['options']) ? $params['options'] : []
);
}
}
public function ANNEE()
{
$annees = [];
for ($a = 1950; $a < 2100; $a++) {
$dateDebut = \DateTime::createFromFormat('Y-m-d:H:i:s', $a . '-09-01:00:00:00');
$dateFin = \DateTime::createFromFormat('Y-m-d:H:i:s', ($a + 1) . '-08-31:00:00:00');
$now = new \DateTime();
$year = (int)$now->format('Y');
$mois = (int)$now->format('m');
$anneeRef = $year;
if ($mois < 9) $anneeRef--;
$active = ($a >= $anneeRef && $a < $anneeRef + 3);
$annees[$a] = [
'ID' => $a,
'LIBELLE' => $a . '/' . ($a + 1),
'DATE_DEBUT' => $dateDebut,
'DATE_FIN' => $dateFin,
'ACTIVE' => $active,
'TAUX_HETD' => null,
];
}
return $annees;
}
public function CIVILITE()
{
return require $this->oseAdmin->getOseDir() . 'data/civilites.php';
}
public function ETAT_SORTIE()
{
return require $this->oseAdmin->getOseDir() . 'data/etats_sortie.php';
}
public function CATEGORIE_PRIVILEGE()
{
$data = require $this->oseAdmin->getOseDir() . 'data/privileges.php';
$categories = [];
foreach ($data as $code => $record) {
$categories[] = [
'CODE' => $code,
'LIBELLE' => $record['libelle'],
'ORDRE' => count($categories) + 1,
];
}
return $categories;
}
public function FORMULE()
{
$data = require $this->oseAdmin->getOseDir() . 'data/formules.php';
$formules = [];
foreach ($data as $id => $formule) {
$formule['ID'] = $id;
$formule['PROCEDURE_NAME'] = 'CALCUL_RESULTAT';
for ($i = 1; $i < 6; $i++) {
if (!isset($formule['I_PARAM_' . $i . '_LIBELLE'])) $formule['I_PARAM_' . $i . '_LIBELLE'] = null;
if (!isset($formule['VH_PARAM_' . $i . '_LIBELLE'])) $formule['VH_PARAM_' . $i . '_LIBELLE'] = null;
}
$formules[] = $formule;
}
return $formules;
}
public function PLAFOND()
{
$data = require $this->oseAdmin->getOseDir() . 'data/plafonds.php';
$plafonds = [];
foreach( $data['plafonds'] as $code => $libelle ){
$plafond = [
'CODE' => $code,
'LIBELLE' => $libelle,
];
$plafonds[] = $plafond;
}
return $plafonds;
}
public function PRIVILEGE()
{
$data = require $this->oseAdmin->getOseDir() . 'data/privileges.php';
$privileges = [];
foreach ($data as $code => $record) {
$io = 0;
foreach ($record['privileges'] as $pcode => $plib) {
$io++;
$privileges[] = [
'CATEGORIE_ID' => $code,
'CODE' => $pcode,
'LIBELLE' => $plib,
'ORDRE' => $io,
];
}
}
return $privileges;
}
public function INDICATEUR()
{
$data = require $this->oseAdmin->getOseDir() . 'data/indicateurs.php';
$indicateurs = [];
$ordre = 0;
foreach ($data as $numero => $indicateur) {
$indicateur['NUMERO'] = $numero;
$indicateur['ORDRE'] = $ordre++;
$indicateurs[] = $indicateur;
}
return $indicateurs;
}
}
\ No newline at end of file
......@@ -196,6 +196,9 @@ CREATE SEQUENCE PLAFOND_APPLICATION_ID_SEQ INCREMENT BY 1 MINVALUE 1 NOCACHE;
CREATE SEQUENCE PLAFOND_ETAT_ID_SEQ INCREMENT BY 1 MINVALUE 1 NOCACHE;
/
 
CREATE SEQUENCE PLAFOND_ID_SEQ INCREMENT BY 1 MINVALUE 1 NOCACHE;
/
CREATE SEQUENCE PRIVILEGE_ID_SEQ INCREMENT BY 1 MINVALUE 1 NOCACHE;
/
 
<?php
return [
[
'LIBELLE_COURT' => 'M.',
'LIBELLE_LONG' => 'Monsieur',
'SEXE' => 'M',
],
[
'LIBELLE_COURT' => 'Mme',
'LIBELLE_LONG' => 'Madame',
'SEXE' => 'F',
],
];
\ No newline at end of file
<?php
return [
'etats' => [
'desactive' => 'Désactivé',
'informatif' => 'Informatif',
'bloquant' => 'Bloquant',
],
'plafonds' => [
'ref-par-structure' => 'Heures max. de référentiel par structure',
'remu-d714-60' => 'Montant maximal par intervenant de la prime D714-60 du code de l\'éducation',
'ref-par-statut' => 'Heures max. de référentiel par intervenant selon son statut',
'ref-par-fonction' => 'Heures max. de référentiel par intervenant et par fonction référentielle',
'hetd' => 'Nombre maximum d\'heures équivalent TD par intervenant selon son statut',
'hc-hors-d71460' => 'Nombre d\'heures complémentaires maximum (hors rémunération au titre de l\'article d714-60 du code de l\'éducation)',
'ref-par-fonction-mere' => 'Heures max. de référentiel par intervenant et par type de fonction référentielle',
],
];
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment