Updates fusionax scripts for better compliance and to get them working right.
authorStéphane Jacob <jacou@melix.net>
Sun, 14 Sep 2008 17:43:42 +0000 (19:43 +0200)
committerStéphane Jacob <jacou@melix.net>
Sun, 14 Sep 2008 17:43:42 +0000 (19:43 +0200)
modules/fusionax.php
modules/fusionax/Activites.sql
modules/fusionax/Adresses.sql
modules/fusionax/Anciens.sql
modules/fusionax/Entreprises.sql
modules/fusionax/Formations.sql

index a4116a8..9e512eb 100644 (file)
  * Datas are stored in an external server and you need a private key
  * to connect to their server.
  */
-class FusionAxModule extends PLModule{
-
-    /// path ok private key file to connect to AX server
-    var $ax_xorg_rsa_key;
-
+class FusionAxModule extends PLModule
+{
     function __construct()
     {
-        /*$this->ax_xorg_rsa_key =
-            dirname(__FILE__).'/../configs/ax_xorg_rsa.pem';*/
     }
 
     function handlers()
@@ -53,35 +48,28 @@ class FusionAxModule extends PLModule{
 
     function handler_index(&$page)
     {
-        global $globals;
+        $globals = Platal::globals();
+
         $page->changeTpl('fusionax/index.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Fusion des annuaires');
-        if (isset($globals->fusionax) && 
-            isset($globals->fusionax->LastUpdate)) {
-            $page->assign(
-                'lastimport', 
-                date("d-m-Y",$globals->fusionax->LastUpdate));
-        } 
+        $page->assign('xorg_title', 'Polytechnique.org - Fusion des annuaires');
+        if (isset($globals->fusionax) && isset($globals->fusionax->LastUpdate)) {
+            $page->assign('lastimport', date("d-m-Y", $globals->fusionax->LastUpdate));
+        }
     }
 
-    /** Import de l'annuaire de l'AX depuis l'export situé sur leur serveur */
+    /** Import de l'annuaire de l'AX depuis l'export situé dans le home de jacou */
     function handler_import(&$page, $action = 'index', $fileSQL = '')
     {
+        $globals = Platal::globals();
+
         if ($action == 'index') {
             $page->changeTpl('fusionax/import.tpl');
             $page->addJsLink('jquery.js');
-            global $globals;
-            if (isset($globals->fusionax) &&
-                isset($globals->fusionax->LastUpdate)) {
+            if (isset($globals->fusionax) && isset($globals->fusionax->LastUpdate)) {
                 $page->assign(
                     'lastimport',
-                    "le ".date("d/m/Y à H:i",$globals->fusionax->LastUpdate));
+                    "le " . date("d/m/Y à H:i", $globals->fusionax->LastUpdate));
             }
-            /*if (!file_exists($this->ax_xorg_rsa_key)) {
-                $page->assign(
-                    'keymissing',
-                    $this->ax_xorg_rsa_key);
-            }*/
             return;
         }
 
@@ -99,29 +87,19 @@ class FusionAxModule extends PLModule{
             unlink($tmpdir);
             mkdir($tmpdir);
             chmod($tmpdir, 0700);
-            // copie la clef d'authentification (paire de clef RSA dont la
-            // partie publique est sur polytechniciens.com)
-            /*if (!copy(
-                $this->ax_xorg_rsa_key,
-                $tmpdir.'/ax_xorg_rsa'))
-                $report[] = 'Impossible de copier la clef pour se logger '.
-                    'au serveur AX';
-            chmod($tmpdir.'/ax_xorg_rsa', 0600);*/
         }
 
-        $modulepath = realpath(dirname(__FILE__).'/fusionax/').'/';
+        $modulepath = realpath(dirname(__FILE__) . '/fusionax/') . '/';
         $olddir = getcwd();
         chdir($tmpdir);
 
         if ($action == 'launch') {
-            // lancement : connexion en ssh et récupération du fichier depuis
-            // polyechniciens.com, décompression de l'archive et séparation en
-            // fichiers par tables
-            exec($modulepath.'import-ax.sh', $report);
-            $report[] = utf8_decode('Récupération du fichier terminé.');
+            // séparation de l'archive en fichiers par tables
+            exec($modulepath . 'import-ax.sh', $report);
+            $report[] = 'Fichier parsé.';
             $report[] = 'Import dans la base en cours...';
             $next = 'integrateSQL';
-        } else if ($action == 'integrateSQL') {
+        } elseif ($action == 'integrateSQL') {
             // intégration des données dans la base MySQL
             // liste des fichiers sql à exécuter
             $filesSQL = array(
@@ -132,17 +110,19 @@ class FusionAxModule extends PLModule{
                 'Entreprises.sql');
             if ($fileSQL != '') {
                 // récupère le contenu du fichier sql
-                $queries = explode(';',file_get_contents($modulepath.$fileSQL));
-                foreach ($queries as $q) if (trim($q)) {
-                    // coupe le fichier en requêtes individuelles
-                    if (substr($q,0,2) == '--') {
-                        // affiche les commentaires dans le report
-                        $lines = explode("\n",$q);
-                        $l = $lines[0];
-                        $report[] = addslashes(utf8_decode($l));
+                $queries = explode(';', file_get_contents($modulepath . $fileSQL));
+                foreach ($queries as $q) {
+                    if (trim($q)) {
+                        // coupe le fichier en requêtes individuelles
+                        if (substr($q, 0, 2) == '--') {
+                            // affiche les commentaires dans le report
+                            $lines = explode("\n", $q);
+                            $l = $lines[0];
+                            $report[] = addslashes($l);
+                        }
+                        // exécute la requête
+                        XDB::execute($q);
                     }
-                    // exécute la requête
-                    XDB::execute($q);
                 }
                 // trouve le prochain fichier à exécuter
                 $trans = array_flip($filesSQL);
@@ -156,28 +136,25 @@ class FusionAxModule extends PLModule{
                 $next = 'clean';
             } else {
                 // on passe au fichier suivant
-                $next = 'integrateSQL/'.$filesSQL[$nextfile];
+                $next = 'integrateSQL/' . $filesSQL[$nextfile];
             }
-        } else if ($action == 'clean') {
+        } elseif ($action == 'clean') {
             // nettoyage du fichier temporaire
             chdir($olddir);
-            exec("rm -rf $tmpdir", $report);
-            $report[] = 'Fin de l\'import';
-            global $globals;
+            exec("rm -Rf $tmpdir", $report);
+            $report[] = "Fin de l\'import";
             // met à jour la date de dernier import
-            $globals->change_dynamic_config(
-                array('LastUpdate' => time()),
-                'FusionAx');
+            //$globals->change_dynamic_config(array('LastUpdate' => time()), 'FusionAx');
         }
-        $tmpdir = getcwd();
-        chdir($olddir);
-        foreach($report as $t)
+        foreach($report as $t) {
             // affiche les lignes de report
-            echo "$('#fusionax_import').append('".utf8_encode($t)."<br/>');\n";
+            echo "$('#fusionax_import').append('" . $t . "<br/>');\n";
+        }
         if (isset($next)) {
+            $tmpdir = getcwd();
+            chdir($olddir);
             // lance le prochain script s'il y en a un
-            echo "$.getScript('fusionax/import/".$next."?tmpdir=".
-                urlencode($tmpdir)."');";
+            echo "$.getScript('fusionax/import/" . $next . "?tmpdir=" . urlencode($tmpdir) . "');";
         }
         // exit pour ne pas afficher la page template par défaut
         exit;
@@ -190,25 +167,19 @@ class FusionAxModule extends PLModule{
      */
     private static function link_by_ids($user_id, $matricule_ax)
     {
-        if (!XDB::execute("
-        UPDATE fusionax_import AS i 
-            INNER JOIN fusionax_xorg_anciens AS u 
-            SET
-                u.matricule_ax = i.id_ancien,
-                i.user_id = u.user_id,
-                i.date_match_id = NOW()
-            WHERE
-            i.id_ancien = {?} AND u.user_id = {?} AND (
-                u.matricule_ax != {?} OR u.matricule_ax IS NULL OR
-                i.user_id != {?} OR i.user_id IS NULL)",
-            $matricule_ax,
-            $user_id,
-            $matricule_ax,
-            $user_id))
-        {
+        $res = XDB::execute("UPDATE  fusionax_import AS i
+                         INNER JOIN  fusionax_xorg_anciens AS u
+                                SET  u.matricule_ax = i.id_ancien,
+                                     i.user_id = u.user_id,
+                                     i.date_match_id = NOW()
+                              WHERE  i.id_ancien = {?} AND u.user_id = {?}
+                                     AND (u.matricule_ax != {?} OR u.matricule_ax IS NULL
+                                          OR i.user_id != {?} OR i.user_id IS NULL)",
+                            $matricule_ax, $user_id, $matricule_ax, $user_id);
+        if (!$res) {
             return 0;
         }
-        return XDB::affectedRows() / 2;  
+        return XDB::affectedRows() / 2;
     }
 
     /** Recherche automatique d'anciens à lier entre les deux annuaires
@@ -220,137 +191,103 @@ class FusionAxModule extends PLModule{
     private static function find_easy_to_link($limit = 10, $sure = false)
     {
         $easy_to_link = XDB::iterator("
-        SELECT 
-            xorg.display_name, xorg.promo, xorg.user_id, ax.id_ancien,
-            CONCAT(ax.prenom,' ',ax.nom_complet,' (X ',ax.promotion_etude,')')
-                 AS display_name_ax,
-            COUNT(*) AS nbMatches
-        FROM fusionax_anciens AS ax
-        INNER JOIN fusionax_import AS i ON (
-            i.id_ancien = ax.id_ancien AND i.user_id IS NULL)
-        LEFT JOIN fusionax_xorg_anciens AS xorg ON (
-            xorg.matricule_ax IS NULL AND 
-            ax.Nom_complet = xorg.nom AND
-            ax.prenom = xorg.prenom AND
-            xorg.promo = ax.promotion_etude)
-        GROUP BY xorg.user_id
-        HAVING
-            xorg.user_id IS NOT NULL AND
-            nbMatches = 1
-            ".($limit?('LIMIT '.$limit):''));
+        SELECT  xorg.display_name, xorg.promo, xorg.user_id, ax.id_ancien,
+                CONCAT(ax.prenom, ' ', ax.nom_complet, ' (X ', ax.promotion_etude, ')') AS display_name_ax,
+                COUNT(*) AS nbMatches
+          FROM  fusionax_anciens AS ax
+    INNER JOIN  fusionax_import AS i ON (i.id_ancien = ax.id_ancien AND i.user_id IS NULL)
+     LEFT JOIN  fusionax_xorg_anciens AS xorg ON (xorg.matricule_ax IS NULL
+                                                  AND ax.Nom_complet = xorg.nom
+                                                  AND ax.prenom = xorg.prenom
+                                                  AND xorg.promo = ax.promotion_etude)
+      GROUP BY  xorg.user_id
+        HAVING  xorg.user_id IS NOT NULL AND nbMatches = 1" . ($limit ? ('LIMIT ' . $limit) : ''));
         if ($easy_to_link->total() > 0 || $sure) {
             return $easy_to_link;
         }
-        return XDB::iterator(" 
-        SELECT 
-            xorg.display_name, xorg.promo, xorg.user_id, ax.id_ancien,
-            CONCAT(ax.prenom,' ',ax.nom_complet,' (X ',ax.promotion_etude,')')
-                 AS display_name_ax,
-            COUNT(*) AS nbMatches
-        FROM fusionax_anciens AS ax
-        INNER JOIN fusionax_import AS i ON (
-            i.id_ancien = ax.id_ancien AND i.user_id IS NULL)
-        LEFT JOIN fusionax_xorg_anciens AS xorg ON (
-            xorg.matricule_ax IS NULL AND 
-            (ax.Nom_complet = xorg.nom
-                 OR ax.Nom_complet LIKE CONCAT(xorg.nom,' %')
-                 OR ax.Nom_complet LIKE CONCAT(xorg.nom,'-%')
-                 OR ax.Nom_usuel = xorg.nom
-                 OR xorg.nom LIKE CONCAT('% ',ax.Nom_complet)) AND
-            xorg.promo < ax.promotion_etude + 2 AND
-            xorg.promo > ax.promotion_etude - 2)
-        GROUP BY xorg.user_id
-        HAVING
-            xorg.user_id IS NOT NULL AND
-            nbMatches = 1
-        ".($limit?('LIMIT '.$limit):''));
+        return XDB::iterator("
+        SELECT  xorg.display_name, xorg.promo, xorg.user_id, ax.id_ancien,
+                CONCAT(ax.prenom, ' ', ax.nom_complet, ' (X ', ax.promotion_etude, ')') AS display_name_ax,
+                COUNT(*) AS nbMatches
+          FROM  fusionax_anciens AS ax
+    INNER JOIN  fusionax_import AS i ON (i.id_ancien = ax.id_ancien AND i.user_id IS NULL)
+     LEFT JOIN  fusionax_xorg_anciens AS xorg ON (xorg.matricule_ax IS NULL
+                                                  AND (ax.Nom_complet = xorg.nom
+                                                       OR ax.Nom_complet LIKE CONCAT(xorg.nom,' %')
+                                                       OR ax.Nom_complet LIKE CONCAT(xorg.nom,'-%')
+                                                       OR ax.Nom_usuel = xorg.nom
+                                                       OR xorg.nom LIKE CONCAT('% ',ax.Nom_complet))
+                                                  AND xorg.promo < ax.promotion_etude + 2
+                                                  AND xorg.promo > ax.promotion_etude - 2)
+      GROUP BY  xorg.user_id
+        HAVING  xorg.user_id IS NOT NULL AND nbMatches = 1" . ($limit ? ('LIMIT ' . $limit) : ''));
     }
 
     /** Module de mise en correspondance les ids */
-    function handler_ids(
-        &$page,
-        $part = 'main',
-        $user_id = null,
-        $matricule_ax = null)
+    function handler_ids(&$page, $part = 'main', $user_id = null, $matricule_ax = null)
     {
-        global $globals;
-        $page->addJsLink('jquery.js');
+        $globals = Platal::globals();
 
+        $page->addJsLink('jquery.js');
         $page->assign(
             'xorg_title',
             'Polytechnique.org - Fusion - Mise en correspondance simple');
-        if ($part == 'missingInAX')
-        {
+        if ($part == 'missingInAX') {
             // locate all persons from this database that are not in AX's
             $page->changeTpl('fusionax/idsMissingInAx.tpl');
-            $missingInAX = XDB::iterator("SELECT 
-                u.promo, u.user_id, u.display_name
-                FROM fusionax_xorg_anciens AS u
-                    WHERE u.matricule_ax IS NULL
-                    LIMIT 20");
+            $missingInAX = XDB::iterator("SELECT  u.promo, u.user_id, u.display_name
+                                            FROM  fusionax_xorg_anciens AS u
+                                           WHERE  u.matricule_ax IS NULL
+                                           LIMIT  20");
             $page->assign('missingInAX', $missingInAX);
             return;
         }
-        if ($part == 'missingInXorg')
-        {
+        if ($part == 'missingInXorg') {
             // locate all persons from AX's database that are not here
             $page->changeTpl('fusionax/idsMissingInXorg.tpl');
-            $missingInXorg = XDB::iterator("SELECT
-                a.promotion_etude AS promo,
-                CONCAT(a.prenom, ' ',a.Nom_usuel) AS display_name,
-                a.id_ancien 
-                FROM fusionax_import 
-                    INNER JOIN fusionax_anciens AS a USING (id_ancien)
-                    WHERE fusionax_import.user_id IS NULL
-                    LIMIT 20");
+            $missingInXorg = XDB::iterator("SELECT  a.promotion_etude AS promo,
+                                                    CONCAT(a.prenom, ' ', a.Nom_usuel) AS display_name,
+                                                    a.id_ancien
+                                              FROM  fusionax_import
+                                        INNER JOIN  fusionax_anciens AS a USING (id_ancien)
+                                             WHERE  fusionax_import.user_id IS NULL
+                                             LIMIT  20");
             $page->assign('missingInXorg', $missingInXorg);
             return;
         }
-        if ($part == 'link')
-        {
-            FusionAxModule::link_by_ids($user_id,$matricule_ax);
+        if ($part == 'link') {
+            FusionAxModule::link_by_ids($user_id, $matricule_ax);
             exit;
         }
-        if ($part == 'linknext')
-        {
+        if ($part == 'linknext') {
             $linksToDo = FusionAxModule::find_easy_to_link(10);
-            while ($l = $linksToDo->next())
-            {
-                FusionAxModule::link_by_ids($l['user_id'],$l['id_ancien']);
+            while ($l = $linksToDo->next()) {
+                FusionAxModule::link_by_ids($l['user_id'], $l['id_ancien']);
             }
             pl_redirect('fusionax/ids#autolink');
         }
-        if ($part == 'linkall')
-        {
+        if ($part == 'linkall') {
             $linksToDo = FusionAxModule::find_easy_to_link(0);
-            while ($l = $linksToDo->next())
-            {
-                FusionAxModule::link_by_ids($l['user_id'],$l['id_ancien']);
+            while ($l = $linksToDo->next()) {
+                FusionAxModule::link_by_ids($l['user_id'], $l['id_ancien']);
             }
         }
         {
             $page->changeTpl('fusionax/ids.tpl');
-            $missingInAX = XDB::query(
-                'SELECT COUNT(*)
-                FROM fusionax_xorg_anciens AS u
-                WHERE u.matricule_ax IS NULL');
-            if ($missingInAX)
-            {
+            $missingInAX = XDB::query('SELECT  COUNT(*)
+                                         FROM  fusionax_xorg_anciens AS u
+                                        WHERE  u.matricule_ax IS NULL');
+            if ($missingInAX) {
                 $page->assign('nbMissingInAX', $missingInAX->fetchOneCell());
             }
-            $missingInXorg = XDB::query(
-                'SELECT COUNT(*)
-                FROM fusionax_import AS i
-                WHERE i.user_id IS NULL');
-            if ($missingInXorg)
-            {
-                $page->assign(
-                    'nbMissingInXorg',
-                    $missingInXorg->fetchOneCell());
+            $missingInXorg = XDB::query('SELECT  COUNT(*)
+                                           FROM  fusionax_import AS i
+                                          WHERE  i.user_id IS NULL');
+            if ($missingInXorg) {
+                $page->assign('nbMissingInXorg', $missingInXorg->fetchOneCell());
             }
             $easyToLink = FusionAxModule::find_easy_to_link(10);
-            if ($easyToLink->total() > 0)
-            { 
+            if ($easyToLink->total() > 0) { 
                 $page->assign('easyToLink', $easyToLink);
             }
         }
@@ -360,31 +297,27 @@ class FusionAxModule extends PLModule{
     {
         $page->changeTpl('fusionax/misc.tpl');
         // deceased
-        $deceasedErrorsSql = XDB::query(
-            'SELECT COUNT(*) FROM fusionax_deceased');
-        $page->assign('deceasedErrors',$deceasedErrorsSql->fetchOneCell());
-        $page->assign('deceasedMissingInXorg',XDB::iterator(
-            'SELECT
-                d.user_id,d.id_ancien,d.nom,d.prenom,d.promo,d.deces_ax,
-                CONCAT(d.prenom, " ", d.nom) AS display_name
-            FROM fusionax_deceased AS d
-            WHERE d.deces_xorg = "0000-00-00"
-            LIMIT 10'));
-        $page->assign('deceasedMissingInAX',XDB::iterator(
-            'SELECT
-                d.user_id,d.id_ancien,d.nom,d.prenom,d.promo,d.deces_xorg,
-                CONCAT(d.prenom, " ", d.nom) AS display_name
-            FROM fusionax_deceased AD d
-            WHERE d.deces_ax = "0000-00-00"
-            LIMIT 10'));
-        $page->assign('deceasedDifferent',XDB::iterator(
-            'SELECT
-                d.user_id,d.id_ancien,d.nom,d.prenom,d.promo,
-                d.deces_ax,d.deces_xorg,
-                CONCAT(d.prenom, " ", d.nom) AS display_name
-            FROM fusionax_deceased AS d
-            WHERE d.deces_xorg != "0000-00-00" AND d.deces_ax != "0000-00-00"
-            LIMIT 10'));
+        $deceasedErrorsSql = XDB::query('SELECT COUNT(*) FROM fusionax_deceased');
+        $page->assign('deceasedErrors', $deceasedErrorsSql->fetchOneCell());
+        $page->assign('deceasedMissingInXorg',
+                      XDB::iterator('SELECT  d.user_id, d.id_ancien, d.nom, d.prenom, d.promo, d.deces_ax,
+                                             CONCAT(d.prenom, " ", d.nom) AS display_name
+                                       FROM  fusionax_deceased AS d
+                                      WHERE  d.deces_xorg = "0000-00-00"
+                                      LIMIT  10'));
+        $page->assign('deceasedMissingInAX',
+                      XDB::iterator('SELECT  d.user_id, d.id_ancien, d.nom, d.prenom, d.promo, d.deces_xorg,
+                                             CONCAT(d.prenom, " ", d.nom) AS display_name
+                                       FROM  fusionax_deceased AD d
+                                      WHERE  d.deces_ax = "0000-00-00"
+                                      LIMIT  10'));
+        $page->assign('deceasedDifferent',
+                      XDB::iterator('SELECT  d.user_id, d.id_ancien, d.nom, d.prenom, d.promo,
+                                             d.deces_ax, d.deces_xorg,
+                                             CONCAT(d.prenom, " ", d.nom) AS display_name
+                                       FROM  fusionax_deceased AS d
+                                      WHERE  d.deces_xorg != "0000-00-00" AND d.deces_ax != "0000-00-00"
+                                      LIMIT  10'));
     }
 }
 
index 07a3c57..0db6b8d 100644 (file)
@@ -7,12 +7,12 @@ CREATE TABLE IF NOT EXISTS `fusionax_activites` (
   `id_ancien` VARCHAR(8) NOT NULL COMMENT 'Id unique de l''ancien',
   `hash_activite` BINARY(5) NOT NULL COMMENT 'Hash de cette ligne pour la lier à l''adresse',
   `Code_etab` INT(10) NOT NULL COMMENT 'Code de l''établissement',
-  `Raison_sociale` VARCHAR(255) collate utf8_unicode_ci NOT NULL COMMENT 'Raison sociale de l''établissement',
-  `Libelle_fonctio` VARCHAR(255) collate utf8_unicode_ci NOT NULL COMMENT 'Libéllé de la fonction',
+  `Raison_sociale` VARCHAR(255) collate utf8_general_ci NOT NULL COMMENT 'Raison sociale de l''établissement',
+  `Libelle_fonctio` VARCHAR(255) collate utf8_general_ci NOT NULL COMMENT 'Libéllé de la fonction',
   `Annuaire` BOOLEAN NOT NULL COMMENT 'publiable dans l''annuaire papier',
   `Date_maj` DATE NOT NULL COMMENT 'Date de mise à jour de ces informations',
   PRIMARY KEY( `id_ancien` , `hash_activite` )
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
 
 LOAD DATA LOCAL INFILE 'Activites.txt' INTO TABLE `fusionax_activites` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
 (AC, id_ancien, Code_etab, Raison_sociale, Libelle_fonctio, Annuaire, 
index 3ce99f0..23af228 100644 (file)
@@ -19,11 +19,11 @@ CREATE TABLE IF NOT EXISTS fusionax_adresses (
   fax VARCHAR(30) NOT NULL,
   Date_maj DATE NOT NULL,
   PRIMARY KEY  (id_ancien, hash_adresse)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
 
 LOAD DATA LOCAL INFILE 'Adresses.txt' INTO TABLE `fusionax_adresses` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
 (provenance, id_ancien, @Type_adr, Ligne1, Ligne2, Ligne3, code_postal, ville, zip_cedex, etat_distr, pays, tel, fax, @StringDate_maj)
-SET 
+SET
 `Type_adr` = IF(@Type_adr = 'E', 'E', IF(@Type_adr = '', '', 'P')),
 `hash_adresse` = SUBSTRING( MD5( @Type_adr ), 1, 5),
 `Date_maj` = CONCAT(SUBSTRING(@StringDate_maj,7),'-',SUBSTRING(@StringDate_maj,4,2),'-',SUBSTRING(@StringDate_maj,1,2));
@@ -33,7 +33,7 @@ LOAD DATA LOCAL INFILE 'Anciens.txt' INTO TABLE `fusionax_adresses` FIELDS TERMI
     @Nom_complet, @Civilite, @Code_nationalite, @Type_membre, @corps_sortie, @StringDate_deces, @grade, @Mel_usage, @Mel_publiable,
     @tel_mobile, @annee_dernCot, @Representant, @Type_adr, Ligne1, Ligne2, Ligne3, code_postal, ville,
     zip_cedex, etat_distr, pays, tel, fax, @StringDate_maj)
-SET 
+SET
 `Type_adr` = IF(@Type_adr = 'E', 'E', IF(@Type_adr = '', '', 'P')),
 `hash_adresse` = SUBSTRING( MD5( @Type_adr ), 1, 5),
 `Date_maj` = CONCAT(SUBSTRING(@StringDate_maj,7),'-',SUBSTRING(@StringDate_maj,4,2),'-',SUBSTRING(@StringDate_maj,1,2));
@@ -41,7 +41,7 @@ SET
 LOAD DATA LOCAL INFILE 'Activites.txt' INTO TABLE `fusionax_adresses` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
 (provenance, id_ancien, @Code_etab, @Raison_sociale, @Libelle_fonctio, @Annuaire, 
 Ligne1, Ligne2, Ligne3, code_postal, ville, zip_cedex, etat_distr, pays, tel, fax, @StringDate_maj)
-SET 
+SET
 `Type_adr` = 'E',
 `hash_adresse` = SUBSTRING( MD5( CONCAT(@Code_etab, @Libelle_fonctio) ), 1, 5),
 `Date_maj` = CONCAT(SUBSTRING(@StringDate_maj,7),'-',SUBSTRING(@StringDate_maj,4,2),'-',SUBSTRING(@StringDate_maj,1,2));
index dd88f9b..c8bb51e 100644 (file)
@@ -8,28 +8,28 @@ CREATE TABLE IF NOT EXISTS fusionax_anciens (
   Login VARCHAR(15) NOT NULL COMMENT 'Login sur le site de l''AX',
   Password INT(11) NOT NULL COMMENT 'Mot de passe sur le site AX',
   promotion_etude SMALLINT(4) NOT NULL COMMENT 'Promotion avec laquelle il/elle a fait ses études',
-  Groupe_promo ENUM('', 'A', 'B', 'C', 'N', 'S') NOT NULL COMMENT 'Groupe de promotion (code compris seulement par AX)',
-  Nom_patronymique VARCHAR(255) NOT NULL COMMENT 'Nom patronymique (nom de jeune fille) sans la particule',
-  partic_patro VARCHAR(5) NOT NULL COMMENT 'Particule du nom patronymique',
-  prenom VARCHAR(30) NOT NULL COMMENT 'Prénom',
-  Nom_usuel VARCHAR(255) NOT NULL COMMENT 'Nom usuel (nom marital par exemple) sans la particule',
-  partic_nom VARCHAR(5) NOT NULL COMMENT 'Particule du nom usuel',
-  Nom_complet VARCHAR(255) NOT NULL COMMENT 'Nom patronymique complet (avec la particule)',
-  Civilite ENUM('', '.', 'M', 'MME', 'MLLE') NOT NULL COMMENT 'Civilité',
+  Groupe_promo ENUM('', 'A', 'B', 'C', 'N', 'S') character set binary NOT NULL COMMENT 'Groupe de promotion (code compris seulement par AX)',
+  Nom_patronymique VARCHAR(255) character set utf8 NOT NULL COMMENT 'Nom patronymique (nom de jeune fille) sans la particule',
+  partic_patro VARCHAR(5) character set utf8 NOT NULL COMMENT 'Particule du nom patronymique',
+  prenom VARCHAR(30) character set utf8 NOT NULL COMMENT 'Prénom',
+  Nom_usuel VARCHAR(255) character set utf8 NOT NULL COMMENT 'Nom usuel (nom marital par exemple) sans la particule',
+  partic_nom VARCHAR(5) character set utf8 NOT NULL COMMENT 'Particule du nom usuel',
+  Nom_complet VARCHAR(255) character set utf8 NOT NULL COMMENT 'Nom patronymique complet (avec la particule)',
+  Civilite ENUM('', '.', 'M', 'MME', 'MLLE') character set utf8 NOT NULL COMMENT 'Civilité',
   Code_nationalite CHAR(3) NOT NULL COMMENT 'Nationalité (code)',
-  Type_membre ENUM('', '*', 'F', 'FB', 'P', 'PB', 'T', 'TB', 'TA') NOT NULL COMMENT 'Type de membre (code compris seulement par AX)',
-  corps_sortie VARCHAR(50) NOT NULL COMMENT 'Corps de sortie (ou D si aucun)',
+  Type_membre ENUM('', '*', 'F', 'FB', 'P', 'PB', 'T', 'TB', 'TA') character set binary NOT NULL COMMENT 'Type de membre (code compris seulement par AX)',
+  corps_sortie VARCHAR(50) character set utf8 NOT NULL COMMENT 'Corps de sortie (ou D si aucun)',
   Date_deces DATE COMMENT 'Date de décès',
   grade VARCHAR(50) NOT NULL COMMENT 'Grade actuel dans son corps',
   Mel_usage VARCHAR(255) NOT NULL COMMENT 'Adresse e-mail d''usage',
   Mel_publiable TINYINT(4) NOT NULL COMMENT 'Autorisation d''utiliser le mail',
   tel_mobile VARCHAR(30) NOT NULL COMMENT 'Numéro de téléphone mobile',
   annee_dernCot INT(11) NOT NULL COMMENT 'Année de dernière cotisation AX',
-  Representant ENUM('', 'K', 'DE') NOT NULL COMMENT 'Représentant de promotion',
+  Representant ENUM('', 'K', 'DE') character set binary NOT NULL COMMENT 'Représentant de promotion',
   hash_adr_defaut BINARY(5) NOT NULL COMMENT 'Hash de l''adresse par défaut',
   Date_maj DATE NOT NULL,
   PRIMARY KEY  (id_ancien)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
 
 LOAD DATA LOCAL INFILE 'Anciens.txt' INTO TABLE `fusionax_anciens` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
 (`AN`, `id_ancien`, `Login`, `Password`, `promotion_etude`, `Groupe_promo`, `Nom_patronymique`, `partic_patro`, `prenom`, Nom_usuel, partic_nom,
@@ -46,19 +46,19 @@ DROP TABLE IF EXISTS `fusionax_import`;
 
 CREATE TABLE IF NOT EXISTS `fusionax_import` (
   `id_ancien` VARCHAR(8) NOT NULL COMMENT 'identifiant AX de l''ancien',
-  `user_id` INT(11) default NULL COMMENT 'identifiant x.org de l''ancien si on l''a trouvé',
-  `date_match_id` TIMESTAMP NULL default NULL COMMENT 'date de mise en correspondance des identifiants',
+  `user_id` INT(11) DEFAULT NULL COMMENT 'identifiant x.org de l''ancien si on l''a trouvé',
+  `date_match_id` TIMESTAMP NULL DEFAULT NULL COMMENT 'date de mise en correspondance des identifiants',
   PRIMARY KEY  (`id_ancien`),
   KEY `user_id` (`user_id`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
 
 INSERT INTO `fusionax_import` ( SELECT `id_ancien`, NULL, NULL FROM `fusionax_anciens` );
 REPLACE INTO `fusionax_import` ( SELECT `matricule_ax`, `user_id`, NOW() FROM `auth_user_md5` );
 
 DROP VIEW IF EXISTS `fusionax_deceased`;
 
-CREATE VIEW `fusionax_deceased` AS 
-SELECT u.user_id, a.id_ancien, u.nom, u.prenom, u.promo, u.deces AS deces_xorg, a.Date_deces AS deces_ax
-FROM `auth_user_md5` AS u
-INNER JOIN fusionax_anciens AS a ON ( a.id_ancien = u.matricule_ax )
-WHERE u.deces != a.Date_deces;
+CREATE VIEW  fusionax_deceased AS
+     SELECT  u.user_id, a.id_ancien, u.nom, u.prenom, u.promo, u.deces AS deces_xorg, a.Date_deces AS deces_ax
+       FROM  auth_user_md5 AS u
+ INNER JOIN  fusionax_anciens AS a ON (a.id_ancien = u.matricule_ax)
+      WHERE  u.deces != a.Date_deces;
index 886fe49..3e4d471 100644 (file)
@@ -5,11 +5,11 @@ DROP TABLE IF EXISTS `fusionax_entreprises`;
 CREATE TABLE IF NOT EXISTS `fusionax_entreprises` (
   `EN` CHAR(2) NOT NULL COMMENT 'Vaut toujours EN pour cette table',
   `Code_etab` INT(10) NOT NULL COMMENT 'Code de l''établissement',
-  `Raison_sociale` VARCHAR(255) collate utf8_unicode_ci NOT NULL COMMENT 'Raison sociale de l''établissement',
-  `Sigle` VARCHAR(50) collate utf8_unicode_ci NOT NULL COMMENT 'Sigle de l''établissement',
+  `Raison_sociale` VARCHAR(255) collate utf8_general_ci NOT NULL COMMENT 'Raison sociale de l''établissement',
+  `Sigle` VARCHAR(50) collate utf8_general_ci NOT NULL COMMENT 'Sigle de l''établissement',
   `Date_maj` DATE NOT NULL COMMENT 'Date de mise à jour de ces informations',
   PRIMARY KEY(`Code_etab`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
 
 LOAD DATA LOCAL INFILE 'Entreprises.txt' INTO TABLE `fusionax_entreprises` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
 (EN, Code_etab, Raison_sociale, Sigle, @Inconnu, @StringDate_maj)
index d48f18c..fe09ed3 100644 (file)
@@ -5,10 +5,10 @@ DROP TABLE IF EXISTS `fusionax_formations`;
 CREATE TABLE IF NOT EXISTS `fusionax_formations` (
   `FO` CHAR(2) NOT NULL COMMENT 'Vaut toujours FO pour cette table',
   `id_ancien` VARCHAR(8) NOT NULL COMMENT 'Id unique de l''ancien',
-  `Intitule_formation` VARCHAR(60) collate utf8_unicode_ci NOT NULL COMMENT 'Intitulé de la formation',
+  `Intitule_formation` VARCHAR(60) collate utf8_general_ci NOT NULL COMMENT 'Intitulé de la formation',
   `Date_maj` DATE NOT NULL COMMENT 'Date de mise à jour de ces informations',
   PRIMARY KEY (`id_ancien`, `Intitule_formation`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
 
 LOAD DATA LOCAL INFILE 'Formations.txt' INTO TABLE `fusionax_formations` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
 (FO, id_ancien, Intitule_formation, @StringDate_maj)