<?php
/***************************************************************************
- * Copyright (C) 2003-2010 Polytechnique.org *
+ * Copyright (C) 2003-2011 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
'fusionax/deceased' => $this->make_hook('deceased', AUTH_MDP, 'admin'),
'fusionax/promo' => $this->make_hook('promo', AUTH_MDP, 'admin'),
'fusionax/names' => $this->make_hook('names', AUTH_MDP, 'admin'),
- 'fusionax/edu' => $this->make_hook('edu', AUTH_MDP, 'admin')
+ 'fusionax/edu' => $this->make_hook('edu', AUTH_MDP, 'admin'),
+ 'fusionax/corps' => $this->make_hook('corps', AUTH_MDP, 'admin')
);
} elseif (Platal::globals()->merge->state == 'done') {
return array(
}
- function handler_index(&$page)
+ function handler_index($page)
{
if (Platal::globals()->merge->state == 'pending') {
$page->changeTpl('fusionax/index.tpl');
}
/** Import de l'annuaire de l'AX depuis l'export situé dans le home de jacou */
- function handler_import(&$page, $action = 'index', $file = '')
+ function handler_import($page, $action = 'index', $file = '')
{
if ($action == 'index') {
$page->changeTpl('fusionax/import.tpl');
} else {
// séparation de l'archive en fichiers par tables
$file = $spoolpath . $file;
- // Removes master and doctorate students
- exec('grep -v "^[A-Z]\{2\}.[0-9]\{4\}[MD][0-9]\{3\}" ' . $file . ' > ' . $file . '.tmp');
- exec('mv -f ' . $file . '.tmp ' . $file);
// Split export into specialised files
exec('grep "^AD" ' . $file . ' > ' . $spoolpath . 'Adresses.txt');
exec('grep "^AN" ' . $file . ' > ' . $spoolpath . 'Anciens.txt');
+ exec('grep "^FO.[0-9]\{4\}[MD][0-9]\{3\}.Etudiant" ' . $file . ' > ' . $spoolpath . 'Formations_MD.txt');
+ exec('grep "^FO.[0-9]\{4\}[MD][0-9]\{3\}.Doct. de" ' . $file . ' >> ' . $spoolpath . 'Formations_MD.txt');
exec('grep "^FO" ' . $file . ' > ' . $spoolpath . 'Formations.txt');
exec('grep "^AC" ' . $file . ' > ' . $spoolpath . 'Activites.txt');
exec('grep "^EN" ' . $file . ' > ' . $spoolpath . 'Entreprises.txt');
exec($modulepath . 'formation.pl');
exec('mv -f ' . $spoolpath . 'Formations_out.txt ' . $spoolpath . 'Formations.txt');
+ exec('mv -f ' . $spoolpath . 'Formations_MD_out.txt ' . $spoolpath . 'Formations_MD.txt');
$report[] = 'Fichier parsé.';
$report[] = 'Import dans la base en cours...';
$next = 'integrateSQL';
1 => 'Adresses.sql',
2 => 'Anciens.sql',
3 => 'Formations.sql',
- 4 => 'Entreprises.sql'
+ 4 => 'Entreprises.sql',
+ 5 => 'Formations_MD.sql'
);
if ($file != '') {
// récupère le contenu du fichier sql
} else {
$nextfile = 0;
}
- if ($nextfile > 4) {
+ if ($nextfile > 5) {
// tous les fichiers ont été exécutés, on passe à l'étape suivante
$next = 'adds1920';
} else {
$next = 'clean';
} elseif ($action == 'clean') {
// nettoyage du fichier temporaire
- exec('rm -Rf ' . $spoolpath);
+ //exec('rm -Rf ' . $spoolpath);
$report[] = 'Import finit.';
}
foreach($report as $t) {
exit;
}
- function handler_view(&$page, $action = '')
+ function handler_view($page, $action = '')
{
$page->changeTpl('fusionax/view.tpl');
if ($action == 'create') {
XDB::execute('DROP VIEW IF EXISTS fusionax_deceased');
- XDB::execute('CREATE VIEW fusionax_deceased AS
+ XDB::execute("CREATE VIEW fusionax_deceased AS
SELECT p.pid, a.ax_id, pd.private_name, pd.promo, p.deathdate AS deces_xorg, a.Date_deces AS deces_ax
FROM profiles AS p
INNER JOIN profile_display AS pd ON (p.pid = pd.pid)
INNER JOIN fusionax_anciens AS a ON (a.ax_id = p.ax_id)
- WHERE p.deathdate != a.Date_deces');
+ WHERE p.deathdate != a.Date_deces OR (p.deathdate IS NULL AND a.Date_deces != '0000-00-00')");
XDB::execute('DROP VIEW IF EXISTS fusionax_promo');
XDB::execute('CREATE VIEW fusionax_promo AS
SELECT p.pid, p.ax_id, pd.private_name, pd.promo, pe.entry_year AS promo_etude_xorg,
}
/** Module de mise en correspondance les ids */
- function handler_ids(&$page, $part = 'main', $pid = null, $ax_id = null)
+ function handler_ids($page, $part = 'main', $pid = null, $ax_id = null)
{
$nbToLink = 100;
$page->assign('xorg_title', 'Polytechnique.org - Fusion - Mise en correspondance simple');
}
}
- function handler_deceased(&$page, $action = '')
+ function handler_deceased($page, $action = '')
{
if ($action == 'updateXorg') {
XDB::execute('UPDATE fusionax_deceased
SET deces_xorg = deces_ax
- WHERE deces_xorg = "0000-00-00"');
+ WHERE deces_xorg IS NULL');
}
if ($action == 'updateAX') {
XDB::execute('UPDATE fusionax_deceased
$page->assign('deceasedErrors', $deceasedErrorsSql->fetchOneCell());
$res = XDB::iterator('SELECT pid, ax_id, promo, private_name, deces_ax
FROM fusionax_deceased
- WHERE deces_xorg = "0000-00-00"
+ WHERE deces_xorg IS NULL
LIMIT 10');
$page->assign('nbDeceasedMissingInXorg', $res->total());
$page->assign('deceasedMissingInXorg', $res);
$page->assign('deceasedDifferent', $res);
}
- function handler_promo(&$page, $action = '')
+ function handler_promo($page, $action = '')
{
$page->changeTpl('fusionax/promo.tpl');
$res = XDB::iterator('SELECT pid, private_name, promo_etude_xorg, promo_sortie_xorg, promo_etude_ax, promo
$page->assign('nbMissmatchingPromosTotal', $nbMissmatchingPromos);
}
- function handler_names(&$page, $action = '')
+ function handler_names($page, $action = '')
{
$page->changeTpl('fusionax/names.tpl');
}
- function handler_edu(&$page, $action = '')
+ function handler_edu($page, $action = '')
{
$page->changeTpl('fusionax/education.tpl');
- $missingEducation = XDB::rawIterator("SELECT DISTINCT(f.Intitule_diplome)
+ $missingEducation = XDB::rawIterator("SELECT DISTINCT(f.Intitule_formation)
FROM fusionax_formations AS f
- WHERE f.Intitule_diplome != '' AND NOT EXISTS (SELECT *
- FROM profile_education_enum AS e
- WHERE f.Intitule_diplome = e.name)");
- $missingDegree = XDB::rawIterator("SELECT DISTINCT(f.Intitule_formation)
+ WHERE f.Intitule_formation != '' AND NOT EXISTS (SELECT *
+ FROM profile_education_enum AS e
+ WHERE f.Intitule_formation = e.name)");
+ $missingDegree = XDB::rawIterator("SELECT DISTINCT(f.Intitule_diplome)
FROM fusionax_formations AS f
- WHERE f.Intitule_formation != '' AND NOT EXISTS (SELECT *
- FROM profile_education_degree_enum AS e
- WHERE f.Intitule_formation = e.abbreviation)");
- $missingCouple = XDB::rawIterator("SELECT DISTINCT(f.Intitule_diplome) AS edu, f.Intitule_formation AS degree, ee.id AS eduid, de.id AS degreeid
+ WHERE f.Intitule_diplome != '' AND NOT EXISTS (SELECT *
+ FROM profile_education_degree_enum AS e
+ WHERE f.Intitule_diplome = e.abbreviation)");
+ $missingCouple = XDB::rawIterator("SELECT DISTINCT(f.Intitule_formation) AS edu, f.Intitule_diplome AS degree, ee.id AS eduid, de.id AS degreeid
FROM fusionax_formations AS f
- INNER JOIN profile_education_enum AS ee ON (f.Intitule_diplome = ee.name)
- INNER JOIN profile_education_degree_enum AS de ON (f.Intitule_formation = de.abbreviation)
+ INNER JOIN profile_education_enum AS ee ON (f.Intitule_formation = ee.name)
+ INNER JOIN profile_education_degree_enum AS de ON (f.Intitule_diplome = de.abbreviation)
WHERE f.Intitule_diplome != '' AND f.Intitule_formation != ''
AND NOT EXISTS (SELECT *
FROM profile_education_degree AS d
$page->assign('missingCoupleCount', $missingCouple->total());
}
- function handler_issues_deathdate(&$page, $action = '')
+ function handler_corps($page)
+ {
+ $page->changeTpl('fusionax/corps.tpl');
+
+ $missingCorps = XDB::rawIterator('SELECT DISTINCT(f.corps_sortie) AS name
+ FROM fusionax_anciens AS f
+ WHERE NOT EXISTS (SELECT *
+ FROM profile_corps_enum AS c
+ WHERE f.corps_sortie = c.abbreviation)');
+ $missingGrade = XDB::rawIterator('SELECT DISTINCT(f.grade) AS name
+ FROM fusionax_anciens AS f
+ WHERE NOT EXISTS (SELECT *
+ FROM profile_corps_rank_enum AS c
+ WHERE f.grade = c.name)');
+
+ $page->assign('missingCorps', $missingCorps);
+ $page->assign('missingGrade', $missingGrade);
+ $page->assign('missingCorpsCount', $missingCorps->total());
+ $page->assign('missingGradeCount', $missingGrade->total());
+ }
+
+ function handler_issues_deathdate($page, $action = '')
{
$page->changeTpl('fusionax/deathdate_issues.tpl');
if ($action == 'edit') {
$page->assign('total', count($issues));
}
- function handler_issues_promo(&$page, $action = '')
+ function handler_issues_promo($page, $action = '')
{
$page->changeTpl('fusionax/promo_issues.tpl');
if ($action == 'edit') {
$page->assign('total', count($issues));
}
- function handler_issues(&$page, $action = '')
+ function handler_issues($page, $action = '')
{
static $issueList = array(
'name' => 'noms',