+
+ $res = XDB::iterator('SELECT pid, private_name, promo_etude_xorg, promo_sortie_xorg, promo_etude_ax, promo
+ FROM fusionax_promo
+ WHERE promo_etude_ax + 1 = promo_etude_xorg AND promo_etude_xorg + 4 = promo_sortie_xorg
+ ORDER BY promo_etude_xorg');
+ $nbMissmatchingPromos += $res->total();
+ $page->assign('nbMissmatchingPromos3', $res->total());
+ $page->assign('missmatchingPromos3', $res);
+
+ $page->assign('nbMissmatchingPromosTotal', $nbMissmatchingPromos);
+ }
+
+ function handler_names(&$page, $action = '')
+ {
+ $page->changeTpl('fusionax/names.tpl');
+
+ $res = XDB::query('SELECT COUNT(*)
+ FROM fusionax_anciens AS f
+ INNER JOIN profiles AS p ON (f.ax_id = p.ax_id)');
+ $page->assign('total', $res->fetchOneCell());
+
+ // To be checked:
+ // | lastname | 1 |
+ // | lastname_marital | 2 |
+ // | lastname_ordinary | 3 |
+ // | firstname | 4 |
+ // | firstname_ordinary | 7 |
+ // | firstname_other | 8 |
+ // | name_other | 9 |
+ // | name_ini | 10 |
+ // | firstname_ini | 11 |
+ $res = XDB::query("SELECT COUNT(*)
+ FROM fusionax_anciens AS f
+ INNER JOIN profiles AS p ON (f.ax_id = p.ax_id)
+ LEFT JOIN profile_name AS pnp ON (p.pid = pnp.pid AND pnp.typeid = 1)
+ LEFT JOIN profile_name AS pnm ON (p.pid = pnm.pid AND pnm.typeid = 2)
+ LEFT JOIN profile_name AS pno ON (p.pid = pno.pid AND pno.typeid = 3)
+ LEFT JOIN profile_name AS pne ON (p.pid = pne.pid AND pne.typeid = 9)
+ LEFT JOIN profile_name AS pni ON (p.pid = pni.pid AND pni.typeid = 10)
+ WHERE IF(f.partic_patro, CONCAT(f.partic_patro, CONCAT(' ', f.Nom_patronymique)), f.Nom_patronymique) NOT IN (pnp.name, pno.name, pnm.name, pne.name, pni.name)
+ OR IF(f.partic_nom, CONCAT(f.partic_nom, CONCAT(' ', f.Nom_usuel)), f.Nom_usuel) NOT IN (pnp.name, pno.name, pnm.name, pne.name, pni.name)
+ OR f.Nom_complet NOT IN (pnp.name, pno.name, pnm.name, pne.name, pni.name)");
+ $page->assign('lastnameIssues', $res->fetchOneCell());
+
+ $res = XDB::query('SELECT COUNT(*)
+ FROM fusionax_anciens AS f
+ INNER JOIN profiles AS p ON (f.ax_id = p.ax_id)
+ LEFT JOIN profile_name AS pnf ON (p.pid = pnf.pid AND pnf.typeid = 4)
+ LEFT JOIN profile_name AS pno ON (p.pid = pno.pid AND pno.typeid = 7)
+ LEFT JOIN profile_name AS pne ON (p.pid = pne.pid AND pne.typeid = 8)
+ LEFT JOIN profile_name AS pni ON (p.pid = pni.pid AND pni.typeid = 11)
+ WHERE f.prenom NOT IN (pnf.name, pno.name, pne.name, pni.name)');
+ $page->assign('firstnameIssues', $res->fetchOneCell());
+
+ }
+
+ function handler_edu(&$page, $action = '')
+ {
+ $page->changeTpl('fusionax/education.tpl');
+
+ $missingEducation = XDB::rawIterator("SELECT DISTINCT(f.Intitule_diplome)
+ 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)
+ 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
+ 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)
+ WHERE f.Intitule_diplome != '' AND f.Intitule_formation != ''
+ AND NOT EXISTS (SELECT *
+ FROM profile_education_degree AS d
+ WHERE ee.id = d.eduid AND de.id = d.degreeid)");
+
+ $page->assign('missingEducation', $missingEducation);
+ $page->assign('missingDegree', $missingDegree);
+ $page->assign('missingCouple', $missingCouple);
+ $page->assign('missingEducationCount', $missingEducation->total());
+ $page->assign('missingDegreeCount', $missingDegree->total());
+ $page->assign('missingCoupleCount', $missingCouple->total());
+ }
+
+ function handler_issues_deathdate(&$page, $action = '')
+ {
+ $page->changeTpl('fusionax/deathdate_issues.tpl');
+ if ($action == 'edit') {
+ S::assert_xsrf_token();
+
+ $issues = XDB::rawIterRow('SELECT p.pid, pd.directory_name, pd.promo, pm.deathdate_ax, p.deathdate
+ FROM profile_merge_issues AS pm
+ INNER JOIN profiles AS p ON (pm.pid = p.pid)
+ INNER JOIN profile_display AS pd ON (pd.pid = p.pid)
+ WHERE FIND_IN_SET(\'deathdate\', pm.issues)
+ ORDER BY pd.directory_name');
+ while (list($pid, $name, $promo, $deathAX, $deathXorg) = $issues->next()) {
+ $choiceAX = Post::has('AX_' . $pid);
+ $choiceXorg = Post::has('XORG_' . $pid);
+ if (!($choiceAX || $choiceXorg)) {
+ continue;
+ }
+
+ if ($choiceAX) {
+ XDB::execute('UPDATE profiles AS p
+ INNER JOIN profile_merge_issues AS pm ON (pm.pid = p.pid)
+ SET p.deathdate = pm.deathdate_ax, p.deathdate_rec = NOW()
+ WHERE p.pid = {?}', $pid);
+ }
+ XDB::execute("UPDATE profile_merge_issues
+ SET issues = REPLACE(issues, 'deathdate', '')
+ WHERE pid = {?}", $pid());
+ $page->trigSuccess("La date de décès de $name ($promo) a bien été corrigée.");
+ }
+ }
+
+ $issues = XDB::rawFetchAllAssoc('SELECT p.pid, p.hrpid, pd.directory_name, pd.promo, pm.deathdate_ax, p.deathdate
+ FROM profile_merge_issues AS pm
+ INNER JOIN profiles AS p ON (pm.pid = p.pid)
+ INNER JOIN profile_display AS pd ON (pd.pid = p.pid)
+ WHERE FIND_IN_SET(\'deathdate\', pm.issues)
+ ORDER BY pd.directory_name');
+ $page->assign('issues', $issues);
+ $page->assign('total', count($issues));
+ }
+
+ function handler_issues_promo(&$page, $action = '')
+ {
+ $page->changeTpl('fusionax/promo_issues.tpl');
+ if ($action == 'edit') {
+ S::assert_xsrf_token();
+
+ $issues = XDB::rawIterRow('SELECT p.pid, pd.directory_name, pd.promo, pm.entry_year_ax, pe.entry_year, pe.grad_year
+ FROM profile_merge_issues AS pm
+ INNER JOIN profiles AS p ON (pm.pid = p.pid)
+ INNER JOIN profile_display AS pd ON (pd.pid = p.pid)
+ INNER JOIN profile_education AS pe ON (pe.pid = p.pid AND FIND_IN_SET(\'primary\', pe.flags))
+ WHERE FIND_IN_SET(\'promo\', pm.issues)
+ ORDER BY pd.directory_name');
+ while (list($pid, $name, $promo, $deathAX, $deathXorgEntry, $deathXorgGrad) = $issues->next()) {
+ $choiceXorg = Post::has('XORG_' . $pid);
+ if (!(Post::has('display_' . $pid) && Post::has('entry_' . $pid) && Post::has('grad_' . $pid))) {
+ continue;
+ }
+
+ $display = Post::i('display_' . $pid);
+ $entry = Post::i('entry_' . $pid);
+ $grad = Post::i('grad_' . $pid);
+ if (!(($grad <= $entry + 5 && $grad >= $entry + 3) && ($display >= $entry && $display <= $grad - 3))) {
+ $page->trigError("La promotion de $name n'a pas été corrigée.");
+ continue;
+ }
+ XDB::execute('UPDATE profile_display
+ SET promo = {?}
+ WHERE pid = {?}', 'X' . $display, $pid);
+ XDB::execute('UPDATE profile_education
+ SET entry_year = {?}, grad_year = {?}
+ WHERE pid = {?} AND FIND_IN_SET(\'primary\', flags)', $entry, $grad, $pid);
+ $page->trigSuccess("La promotion de $name a bien été corrigée.");
+ }
+ }
+
+ $issues = XDB::rawFetchAllAssoc('SELECT p.pid, p.hrpid, pd.directory_name, pd.promo, pm.entry_year_ax, pe.entry_year, pe.grad_year
+ FROM profile_merge_issues AS pm
+ INNER JOIN profiles AS p ON (pm.pid = p.pid)
+ INNER JOIN profile_display AS pd ON (pd.pid = p.pid)
+ INNER JOIN profile_education AS pe ON (pe.pid = p.pid AND FIND_IN_SET(\'primary\', pe.flags))
+ WHERE FIND_IN_SET(\'promo\', pm.issues)
+ ORDER BY pd.directory_name');
+ $page->assign('issues', $issues);
+ $page->assign('total', count($issues));
+ }
+
+ function handler_issues(&$page, $action = '')
+ {
+ static $issueList = array(
+ 'name' => 'noms',
+ 'phone' => 'téléphones',
+ 'education' => 'formations',
+ 'address' => 'adresses',
+ 'job' => 'emplois'
+ );
+ static $typeList = array(
+ 'name' => 'general',
+ 'phone' => 'general',
+ 'education' => 'general',
+ 'address' => 'adresses',
+ 'job' => 'emploi'
+ );
+
+ if (!array_key_exists($action, $issueList)) {
+ pl_redirect('fusionax');
+ } else {
+ $total = XDB::fetchOneCell('SELECT COUNT(*)
+ FROM profile_merge_issues
+ WHERE FIND_IN_SET({?}, issues)', $action);
+ if ($total == 0) {
+ pl_redirect('fusionax');
+ }
+
+ $issues = XDB::fetchAllAssoc('SELECT p.hrpid, pd.directory_name, pd.promo
+ FROM profile_merge_issues AS pm
+ INNER JOIN profiles AS p ON (pm.pid = p.pid)
+ INNER JOIN profile_display AS pd ON (pd.pid = p.pid)
+ WHERE FIND_IN_SET({?}, pm.issues)
+ ORDER BY pd.directory_name
+ LIMIT 100', $action);
+
+ $page->changeTpl('fusionax/other_issues.tpl');
+ $page->assign('issues', $issues);
+ $page->assign('issue', $issueList[$action]);
+ $page->assign('type', $typeList[$action]);
+ $page->assign('total', $total);
+ }