Adapts merge to properly take into account M/D.
[platal.git] / modules / fusionax.php
index b4846da..54c7fa2 100644 (file)
@@ -218,9 +218,9 @@ class FusionAxModule extends PLModule
                 XDB::execute('INSERT INTO  profile_education (pid, eduid, degreeid, entry_year, grad_year, flags)
                                    VALUES  ({?}, {?}, {?}, {?}, {?}, {?})',
                              $pid, $eduSchools[Profile::EDU_X], $degreeid, $entry_year, $grad_year, 'primary');
-                XDB::execute('INSERT INTO  accounts (hruid, type, is_admin, state, full_name, directory_name, display_name, sex)
-                                   VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?})',
-                             $hrid, $type, 0, 'active', $fullName, $directoryName, $lastname, $sex);
+                XDB::execute('INSERT INTO  accounts (hruid, type, is_admin, state, full_name, directory_name, display_name, lastname, firstname, sex)
+                                   VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
+                             $hrid, $type, 0, 'active', $fullName, $directoryName, $firstname, $lastname, $firstname, $sex);
                 $uid = XDB::insertId();
                 XDB::execute('INSERT INTO  account_profiles (uid, pid, perms)
                                    VALUES  ({?}, {?}, {?})',
@@ -233,7 +233,7 @@ class FusionAxModule extends PLModule
                                                           SELECT  p.pid, p.ax_id, pd.promo, pd.private_name, pd.public_name,
                                                                   pd.sort_name, pd.short_name, pd.directory_name
                                                             FROM  profiles        AS p
-                                                      INNER JOIN  profile_display AS pd USING(pid)');
+                                                      INNER JOIN  profile_display AS pd ON (pd.pid = p.pid)');
             $next = 'clean';
         } elseif ($action == 'clean') {
             // nettoyage du fichier temporaire
@@ -290,7 +290,7 @@ class FusionAxModule extends PLModule
     }
 
     /* Cherche les les anciens présents dans Xorg avec un matricule_ax ne correspondant à rien dans la base de l'AX
-     * (mises à part les promo 1921 et 1923 qui ne figurent pas dans les données de l'AX)*/
+     * (mises à part les promo 1921, 1923, 1924, 1925 qui ne figurent pas dans les données de l'AX)*/
     private static function find_wrong_in_xorg($limit = 10)
     {
         return XDB::iterator('SELECT  u.promo, u.pid, u.private_name
@@ -298,7 +298,7 @@ class FusionAxModule extends PLModule
                                WHERE  NOT EXISTS (SELECT  *
                                                     FROM  fusionax_anciens AS f
                                                    WHERE  f.ax_id = u.ax_id)
-                                      AND u.ax_id IS NOT NULL AND promo != \'X1921\' AND promo != \'X1923\'');
+                                      AND u.ax_id IS NOT NULL AND promo NOT IN (\'X1921\', \'X1923\', \'X1924\', \'X1925\')');
     }
 
     /** Lier les identifiants d'un ancien dans les deux annuaires
@@ -333,12 +333,12 @@ class FusionAxModule extends PLModule
     {
         $easy_to_link = XDB::iterator("
         SELECT  u.private_name, u.promo, u.pid, ax.ax_id,
-                CONCAT(ax.prenom, ' ', ax.nom_complet, ' (X', ax.promotion_etude, ')') AS display_name_ax,
+                CONCAT(ax.prenom, ' ', ax.nom_complet, ' (', ax.groupe_promo, ax.promotion_etude, ')') AS display_name_ax,
                 COUNT(*) AS nbMatches
           FROM  fusionax_anciens      AS ax
     INNER JOIN  fusionax_import       AS i ON (i.ax_id = ax.ax_id AND i.pid IS NULL)
      LEFT JOIN  fusionax_xorg_anciens AS u ON (u.ax_id IS NULL
-                                               AND u.promo = CONCAT('X', ax.promotion_etude)
+                                               AND u.promo = CONCAT(ax.groupe_promo, ax.promotion_etude)
                                                AND (CONCAT(ax.prenom, ' ', ax.nom_complet) = u.private_name
                                                     OR CONCAT(ax.prenom, ' ', ax.nom_complet) = u.public_name
                                                     OR CONCAT(ax.prenom, ' ', ax.nom_complet) = u.short_name))
@@ -349,7 +349,7 @@ class FusionAxModule extends PLModule
         }
         return XDB::iterator("
         SELECT  u.private_name, u.promo, u.pid, ax.ax_id,
-                CONCAT(ax.prenom, ' ', ax.nom_complet, ' (X', ax.promotion_etude, ')') AS display_name_ax,
+                CONCAT(ax.prenom, ' ', ax.nom_complet, ' (', ax.groupe_promo, ax.promotion_etude, ')') AS display_name_ax,
                 COUNT(*) AS nbMatches
           FROM  fusionax_anciens      AS ax
     INNER JOIN  fusionax_import       AS i ON (i.ax_id = ax.ax_id AND i.pid IS NULL)
@@ -357,8 +357,8 @@ class FusionAxModule extends PLModule
                                                AND (CONCAT(ax.prenom, ' ', ax.nom_complet) = u.private_name
                                                     OR CONCAT(ax.prenom, ' ', ax.nom_complet) = u.public_name
                                                     OR CONCAT(ax.prenom, ' ', ax.nom_complet) = u.short_name)
-                                               AND u.promo < CONCAT('X', ax.promotion_etude + 2)
-                                               AND u.promo > CONCAT('X', ax.promotion_etude - 2))
+                                               AND u.promo < CONCAT(ax.groupe_promo, ax.promotion_etude + 2)
+                                               AND u.promo > CONCAT(ax.groupe_promo, ax.promotion_etude - 2))
       GROUP BY  u.pid
         HAVING  u.pid IS NOT NULL AND nbMatches = 1" . ($limit ? (' LIMIT ' . $limit) : ''));
     }
@@ -374,7 +374,8 @@ class FusionAxModule extends PLModule
             $page->changeTpl('fusionax/idsMissingInAx.tpl');
             $missingInAX = XDB::iterator('SELECT  promo, pid, private_name
                                             FROM  fusionax_xorg_anciens
-                                           WHERE  ax_id IS NULL');
+                                           WHERE  ax_id IS NULL
+                                        ORDER BY  promo');
             $page->assign('missingInAX', $missingInAX);
             return;
         }
@@ -382,10 +383,11 @@ class FusionAxModule extends PLModule
             // locate all persons from AX's database that are not here
             $page->changeTpl('fusionax/idsMissingInXorg.tpl');
             $missingInXorg = XDB::iterator("SELECT  CONCAT(a.prenom, ' ', a.Nom_usuel) AS private_name,
-                                                    a.promotion_etude AS promo, a.ax_id
+                                                    CONCAT(a.groupe_promo, a.promotion_etude) AS promo, a.ax_id
                                               FROM  fusionax_import
                                         INNER JOIN  fusionax_anciens AS a USING (ax_id)
-                                             WHERE  fusionax_import.pid IS NULL");
+                                             WHERE  fusionax_import.pid IS NULL
+                                          ORDER BY  promo");
             $page->assign('missingInXorg', $missingInXorg);
             return;
         }