Commit | Line | Data |
---|---|---|
b9ad0878 PC |
1 | <?php |
2 | /*************************************************************************** | |
9891bd15 | 3 | * Copyright (C) 2003-2009 Polytechnique.org * |
b9ad0878 PC |
4 | * http://opensource.polytechnique.org/ * |
5 | * * | |
6 | * This program is free software; you can redistribute it and/or modify * | |
7 | * it under the terms of the GNU General Public License as published by * | |
8 | * the Free Software Foundation; either version 2 of the License, or * | |
9 | * (at your option) any later version. * | |
10 | * * | |
11 | * This program is distributed in the hope that it will be useful, * | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
14 | * GNU General Public License for more details. * | |
15 | * * | |
16 | * You should have received a copy of the GNU General Public License * | |
17 | * along with this program; if not, write to the Free Software * | |
18 | * Foundation, Inc., * | |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | |
20 | ***************************************************************************/ | |
21 | ||
c15c0053 PC |
22 | /** |
23 | * @brief Module to merge data from AX database | |
24 | * | |
25 | * Module to import data from another database of alumni that had | |
26 | * different schemas. The organization that used this db is called AX | |
27 | * hence the name of this module. | |
28 | * | |
29 | * Datas are stored in an external server and you need a private key | |
30 | * to connect to their server. | |
31 | */ | |
73be4434 SJ |
32 | class FusionAxModule extends PLModule |
33 | { | |
c15c0053 PC |
34 | function __construct() |
35 | { | |
c15c0053 | 36 | } |
9cb8882b | 37 | |
b9ad0878 PC |
38 | function handlers() |
39 | { | |
40 | return array( | |
29459c49 SJ |
41 | 'fusionax' => $this->make_hook('index', AUTH_MDP, 'admin'), |
42 | 'fusionax/import' => $this->make_hook('import', AUTH_MDP, 'admin'), | |
43 | 'fusionax/view' => $this->make_hook('view', AUTH_MDP, 'admin'), | |
44 | 'fusionax/ids' => $this->make_hook('ids', AUTH_MDP, 'admin'), | |
45 | 'fusionax/deceased' => $this->make_hook('deceased', AUTH_MDP, 'admin'), | |
c7eac294 | 46 | 'fusionax/promo' => $this->make_hook('promo', AUTH_MDP, 'admin'), |
b9ad0878 PC |
47 | ); |
48 | } | |
c15c0053 PC |
49 | |
50 | ||
b9ad0878 PC |
51 | function handler_index(&$page) |
52 | { | |
73be4434 SJ |
53 | $globals = Platal::globals(); |
54 | ||
b9ad0878 | 55 | $page->changeTpl('fusionax/index.tpl'); |
73be4434 SJ |
56 | $page->assign('xorg_title', 'Polytechnique.org - Fusion des annuaires'); |
57 | if (isset($globals->fusionax) && isset($globals->fusionax->LastUpdate)) { | |
58 | $page->assign('lastimport', date("d-m-Y", $globals->fusionax->LastUpdate)); | |
59 | } | |
b9ad0878 | 60 | } |
22f043e4 | 61 | |
73be4434 | 62 | /** Import de l'annuaire de l'AX depuis l'export situé dans le home de jacou */ |
b9ad0878 PC |
63 | function handler_import(&$page, $action = 'index', $fileSQL = '') |
64 | { | |
73be4434 SJ |
65 | $globals = Platal::globals(); |
66 | ||
b9ad0878 PC |
67 | if ($action == 'index') { |
68 | $page->changeTpl('fusionax/import.tpl'); | |
69 | $page->addJsLink('jquery.js'); | |
73be4434 | 70 | if (isset($globals->fusionax) && isset($globals->fusionax->LastUpdate)) { |
e8591429 PC |
71 | $page->assign( |
72 | 'lastimport', | |
73be4434 | 73 | "le " . date("d/m/Y à H:i", $globals->fusionax->LastUpdate)); |
b9ad0878 | 74 | } |
b9ad0878 PC |
75 | return; |
76 | } | |
22f043e4 | 77 | |
cc8ea8b2 | 78 | // toutes les actions sont faites en ajax en utilisant jquery |
b9ad0878 | 79 | header("Content-type: text/javascript; charset=utf-8"); |
22f043e4 | 80 | |
cc8ea8b2 PC |
81 | // log des actions |
82 | $report = array(); | |
22f043e4 | 83 | |
cc8ea8b2 | 84 | // création d'un fichier temporaire si nécessaire |
b9ad0878 PC |
85 | if (Env::has('tmpdir')) { |
86 | $tmpdir = Env::v('tmpdir'); | |
87 | } else { | |
b9ad0878 PC |
88 | $tmpdir = tempnam('/tmp', 'fusionax'); |
89 | unlink($tmpdir); | |
90 | mkdir($tmpdir); | |
cc8ea8b2 | 91 | chmod($tmpdir, 0700); |
b9ad0878 | 92 | } |
22f043e4 | 93 | |
73be4434 | 94 | $modulepath = realpath(dirname(__FILE__) . '/fusionax/') . '/'; |
b9ad0878 PC |
95 | $olddir = getcwd(); |
96 | chdir($tmpdir); | |
22f043e4 | 97 | |
b9ad0878 | 98 | if ($action == 'launch') { |
73be4434 SJ |
99 | // séparation de l'archive en fichiers par tables |
100 | exec($modulepath . 'import-ax.sh', $report); | |
101 | $report[] = 'Fichier parsé.'; | |
b9ad0878 PC |
102 | $report[] = 'Import dans la base en cours...'; |
103 | $next = 'integrateSQL'; | |
73be4434 | 104 | } elseif ($action == 'integrateSQL') { |
cc8ea8b2 PC |
105 | // intégration des données dans la base MySQL |
106 | // liste des fichiers sql à exécuter | |
107 | $filesSQL = array( | |
108 | 'Activites.sql', | |
109 | 'Adresses.sql', | |
110 | 'Anciens.sql', | |
111 | 'Formations.sql', | |
112 | 'Entreprises.sql'); | |
b9ad0878 | 113 | if ($fileSQL != '') { |
cc8ea8b2 | 114 | // récupère le contenu du fichier sql |
73be4434 SJ |
115 | $queries = explode(';', file_get_contents($modulepath . $fileSQL)); |
116 | foreach ($queries as $q) { | |
117 | if (trim($q)) { | |
118 | // coupe le fichier en requêtes individuelles | |
119 | if (substr($q, 0, 2) == '--') { | |
120 | // affiche les commentaires dans le report | |
121 | $lines = explode("\n", $q); | |
122 | $l = $lines[0]; | |
123 | $report[] = addslashes($l); | |
124 | } | |
125 | // exécute la requête | |
126 | XDB::execute($q); | |
b9ad0878 | 127 | } |
b9ad0878 | 128 | } |
cc8ea8b2 PC |
129 | // trouve le prochain fichier à exécuter |
130 | $trans = array_flip($filesSQL); | |
131 | $nextfile = $trans[$fileSQL] + 1; | |
b9ad0878 PC |
132 | } else { |
133 | $nextfile = 0; | |
134 | } | |
135 | if (!isset($filesSQL[$nextfile])) { | |
e8591429 PC |
136 | // tous les fichiers ont été exécutés, on passe à l'étape |
137 | // suivante | |
b9ad0878 PC |
138 | $next = 'clean'; |
139 | } else { | |
cc8ea8b2 | 140 | // on passe au fichier suivant |
73be4434 | 141 | $next = 'integrateSQL/' . $filesSQL[$nextfile]; |
b9ad0878 | 142 | } |
73be4434 | 143 | } elseif ($action == 'clean') { |
cc8ea8b2 | 144 | // nettoyage du fichier temporaire |
b9ad0878 | 145 | chdir($olddir); |
73be4434 SJ |
146 | exec("rm -Rf $tmpdir", $report); |
147 | $report[] = "Fin de l\'import"; | |
cc8ea8b2 | 148 | // met à jour la date de dernier import |
73be4434 | 149 | //$globals->change_dynamic_config(array('LastUpdate' => time()), 'FusionAx'); |
b9ad0878 | 150 | } |
73be4434 | 151 | foreach($report as $t) { |
cc8ea8b2 | 152 | // affiche les lignes de report |
73be4434 SJ |
153 | echo "$('#fusionax_import').append('" . $t . "<br/>');\n"; |
154 | } | |
b9ad0878 | 155 | if (isset($next)) { |
73be4434 SJ |
156 | $tmpdir = getcwd(); |
157 | chdir($olddir); | |
cc8ea8b2 | 158 | // lance le prochain script s'il y en a un |
73be4434 | 159 | echo "$.getScript('fusionax/import/" . $next . "?tmpdir=" . urlencode($tmpdir) . "');"; |
b9ad0878 | 160 | } |
cc8ea8b2 | 161 | // exit pour ne pas afficher la page template par défaut |
b9ad0878 PC |
162 | exit; |
163 | } | |
22f043e4 | 164 | |
29459c49 SJ |
165 | /** Import de l'annuaire de l'AX depuis l'export situé dans le home de jacou */ |
166 | function handler_view(&$page, $action = '') | |
167 | { | |
168 | $globals = Platal::globals(); | |
169 | ||
170 | $page->changeTpl('fusionax/view.tpl'); | |
171 | if ($action == 'create') { | |
172 | XDB::execute('DROP VIEW IF EXISTS fusionax_deceased'); | |
173 | XDB::execute('CREATE VIEW fusionax_deceased AS | |
174 | SELECT u.user_id, a.id_ancien, u.nom, u.prenom, u.promo, u.deces AS deces_xorg, a.Date_deces AS deces_ax | |
c7eac294 | 175 | FROM auth_user_md5 AS u |
29459c49 SJ |
176 | INNER JOIN fusionax_anciens AS a ON (a.id_ancien = u.matricule_ax) |
177 | WHERE u.deces != a.Date_deces'); | |
178 | XDB::execute('DROP VIEW IF EXISTS fusionax_promo'); | |
179 | XDB::execute('CREATE VIEW fusionax_promo AS | |
c7eac294 | 180 | SELECT u.user_id, u.matricule_ax, CONCAT(u.nom, " ", u.prenom) AS display_name, u.promo AS promo_etude_xorg, |
29459c49 SJ |
181 | f.promotion_etude AS promo_etude_ax, u.promo_sortie AS promo_sortie_xorg |
182 | FROM auth_user_md5 AS u | |
183 | INNER JOIN fusionax_anciens AS f ON (u.matricule_ax = f.id_ancien) | |
184 | WHERE u.promo != f.promotion_etude AND !(f.promotion_etude = u.promo + 1 AND u.promo_sortie = u.promo + 4)'); | |
185 | } | |
186 | } | |
187 | ||
188 | /* Mets à NULL le matricule_ax de ces camarades pour marquer le fait qu'ils ne figurent pas dans l'annuaire de l'AX */ | |
189 | private static function clear_wrong_in_xorg($user_id) | |
190 | { | |
191 | $res = XDB::execute("UPDATE fusionax_xorg_anciens | |
192 | SET matricule_ax = NULL | |
193 | WHERE user_id = {?}", $user_id); | |
194 | if (!$res) { | |
195 | return 0; | |
196 | } | |
197 | return XDB::affectedRows() / 2; | |
198 | } | |
199 | ||
200 | /* Cherche les les anciens présents dans Xorg avec un matricule_ax ne correspondant à rien dans la base de l'AX | |
201 | * (mises à part les promo 1921 et 1923 qui ne figurent pas dans les données de l'AX)*/ | |
202 | private static function find_wrong_in_xorg($limit = 10) | |
203 | { | |
204 | return XDB::iterator("SELECT u.promo, u.user_id, u.display_name | |
205 | FROM fusionax_xorg_anciens AS u | |
206 | WHERE NOT EXISTS (SELECT * | |
207 | FROM fusionax_anciens AS f | |
208 | WHERE f.id_ancien = u.matricule_ax) | |
209 | AND u.matricule_ax IS NOT NULL AND promo != 1921 AND promo != 1923"); | |
210 | } | |
211 | ||
b65beb64 PC |
212 | /** Lier les identifiants d'un ancien dans les deux annuaires |
213 | * @param user_id identifiant dans l'annuaire X.org | |
214 | * @param matricule_ax identifiant dans l'annuaire de l'AX | |
215 | * @return 0 si la liaison a échoué, 1 sinon | |
22f043e4 | 216 | */ |
b9ad0878 PC |
217 | private static function link_by_ids($user_id, $matricule_ax) |
218 | { | |
29459c49 | 219 | $res = XDB::execute("UPDATE fusionax_import AS i |
73be4434 SJ |
220 | INNER JOIN fusionax_xorg_anciens AS u |
221 | SET u.matricule_ax = i.id_ancien, | |
222 | i.user_id = u.user_id, | |
223 | i.date_match_id = NOW() | |
224 | WHERE i.id_ancien = {?} AND u.user_id = {?} | |
225 | AND (u.matricule_ax != {?} OR u.matricule_ax IS NULL | |
226 | OR i.user_id != {?} OR i.user_id IS NULL)", | |
227 | $matricule_ax, $user_id, $matricule_ax, $user_id); | |
228 | if (!$res) { | |
b9ad0878 PC |
229 | return 0; |
230 | } | |
73be4434 | 231 | return XDB::affectedRows() / 2; |
b9ad0878 | 232 | } |
22f043e4 | 233 | |
b65beb64 PC |
234 | /** Recherche automatique d'anciens à lier entre les deux annuaires |
235 | * @param limit nombre d'anciens à trouver au max | |
236 | * @param sure si true, ne trouve que des anciens qui sont quasi sûrs | |
e8591429 PC |
237 | * @return un XOrgDBIterator sur les entrées avec display_name, promo, |
238 | * user_id, id_ancien et display_name_ax | |
22f043e4 | 239 | */ |
b65beb64 | 240 | private static function find_easy_to_link($limit = 10, $sure = false) |
b9ad0878 | 241 | { |
e8591429 | 242 | $easy_to_link = XDB::iterator(" |
29459c49 | 243 | SELECT u.display_name, u.promo, u.user_id, ax.id_ancien, |
73be4434 SJ |
244 | CONCAT(ax.prenom, ' ', ax.nom_complet, ' (X ', ax.promotion_etude, ')') AS display_name_ax, |
245 | COUNT(*) AS nbMatches | |
29459c49 SJ |
246 | FROM fusionax_anciens AS ax |
247 | INNER JOIN fusionax_import AS i ON (i.id_ancien = ax.id_ancien AND i.user_id IS NULL) | |
248 | LEFT JOIN fusionax_xorg_anciens AS u ON (u.matricule_ax IS NULL | |
249 | AND ax.Nom_patronymique = u.nom | |
250 | AND ax.prenom = u.prenom | |
251 | AND u.promo = ax.promotion_etude) | |
252 | GROUP BY u.user_id | |
253 | HAVING u.user_id IS NOT NULL AND nbMatches = 1 " . ($limit ? ('LIMIT ' . $limit) : '')); | |
b65beb64 PC |
254 | if ($easy_to_link->total() > 0 || $sure) { |
255 | return $easy_to_link; | |
256 | } | |
73be4434 | 257 | return XDB::iterator(" |
29459c49 | 258 | SELECT u.display_name, u.promo, u.user_id, ax.id_ancien, |
73be4434 SJ |
259 | CONCAT(ax.prenom, ' ', ax.nom_complet, ' (X ', ax.promotion_etude, ')') AS display_name_ax, |
260 | COUNT(*) AS nbMatches | |
29459c49 SJ |
261 | FROM fusionax_anciens AS ax |
262 | INNER JOIN fusionax_import AS i ON (i.id_ancien = ax.id_ancien AND i.user_id IS NULL) | |
263 | LEFT JOIN fusionax_xorg_anciens AS u ON (u.matricule_ax IS NULL | |
264 | AND (ax.Nom_patronymique = u.nom | |
265 | OR ax.Nom_patronymique LIKE CONCAT(u.nom, ' %') | |
266 | OR ax.Nom_patronymique LIKE CONCAT(u.nom, '-%') | |
267 | OR ax.Nom_usuel = u.nom | |
268 | OR u.nom LIKE CONCAT('% ', ax.Nom_patronymique)) | |
269 | AND u.promo < ax.promotion_etude + 2 | |
270 | AND u.promo > ax.promotion_etude - 2) | |
271 | GROUP BY u.user_id | |
272 | HAVING u.user_id IS NOT NULL AND nbMatches = 1 " . ($limit ? ('LIMIT ' . $limit) : '')); | |
b9ad0878 | 273 | } |
22f043e4 | 274 | |
b65beb64 | 275 | /** Module de mise en correspondance les ids */ |
73be4434 | 276 | function handler_ids(&$page, $part = 'main', $user_id = null, $matricule_ax = null) |
b9ad0878 | 277 | { |
73be4434 | 278 | $globals = Platal::globals(); |
29459c49 | 279 | $nbToLink = 100; |
22f043e4 | 280 | |
73be4434 | 281 | $page->addJsLink('jquery.js'); |
29459c49 | 282 | $page->assign('xorg_title', 'Polytechnique.org - Fusion - Mise en correspondance simple'); |
73be4434 | 283 | if ($part == 'missingInAX') { |
b9ad0878 PC |
284 | // locate all persons from this database that are not in AX's |
285 | $page->changeTpl('fusionax/idsMissingInAx.tpl'); | |
29459c49 SJ |
286 | $missingInAX = XDB::iterator("SELECT promo, user_id, display_name |
287 | FROM fusionax_xorg_anciens | |
288 | WHERE matricule_ax IS NULL"); | |
b9ad0878 PC |
289 | $page->assign('missingInAX', $missingInAX); |
290 | return; | |
291 | } | |
73be4434 | 292 | if ($part == 'missingInXorg') { |
b9ad0878 PC |
293 | // locate all persons from AX's database that are not here |
294 | $page->changeTpl('fusionax/idsMissingInXorg.tpl'); | |
73be4434 SJ |
295 | $missingInXorg = XDB::iterator("SELECT a.promotion_etude AS promo, |
296 | CONCAT(a.prenom, ' ', a.Nom_usuel) AS display_name, | |
297 | a.id_ancien | |
298 | FROM fusionax_import | |
299 | INNER JOIN fusionax_anciens AS a USING (id_ancien) | |
29459c49 | 300 | WHERE fusionax_import.user_id IS NULL"); |
b9ad0878 PC |
301 | $page->assign('missingInXorg', $missingInXorg); |
302 | return; | |
303 | } | |
29459c49 SJ |
304 | if ($part == 'wrongInXorg') { |
305 | // locate all persons from Xorg database that have a bad AX id | |
306 | $page->changeTpl('fusionax/idswrongInXorg.tpl'); | |
307 | $wrongInXorg = FusionAxModule::find_wrong_in_xorg($nbToLink); | |
308 | $page->assign('wrongInXorg', $wrongInXorg); | |
309 | return; | |
310 | } | |
311 | if ($part == 'cleanwronginxorg') { | |
312 | $linksToDo = FusionAxModule::find_wrong_in_xorg($nbToLink); | |
313 | while ($l = $linksToDo->next()) { | |
314 | FusionAxModule::clear_wrong_in_xorg($l['user_id']); | |
315 | } | |
316 | pl_redirect('fusionax/ids/wrongInXorg'); | |
317 | } | |
318 | if ($part == 'lier') { | |
319 | if (Post::has('user_id') && Post::has('matricule_ax')) { | |
320 | FusionAxModule::link_by_ids(Post::i('user_id'), Post::v('matricule_ax')); | |
321 | } | |
322 | } | |
73be4434 SJ |
323 | if ($part == 'link') { |
324 | FusionAxModule::link_by_ids($user_id, $matricule_ax); | |
b65beb64 | 325 | exit; |
b9ad0878 | 326 | } |
73be4434 | 327 | if ($part == 'linknext') { |
29459c49 | 328 | $linksToDo = FusionAxModule::find_easy_to_link($nbToLink); |
73be4434 SJ |
329 | while ($l = $linksToDo->next()) { |
330 | FusionAxModule::link_by_ids($l['user_id'], $l['id_ancien']); | |
b9ad0878 | 331 | } |
b65beb64 | 332 | pl_redirect('fusionax/ids#autolink'); |
b9ad0878 | 333 | } |
73be4434 | 334 | if ($part == 'linkall') { |
b9ad0878 | 335 | $linksToDo = FusionAxModule::find_easy_to_link(0); |
73be4434 SJ |
336 | while ($l = $linksToDo->next()) { |
337 | FusionAxModule::link_by_ids($l['user_id'], $l['id_ancien']); | |
b9ad0878 PC |
338 | } |
339 | } | |
340 | { | |
341 | $page->changeTpl('fusionax/ids.tpl'); | |
73be4434 SJ |
342 | $missingInAX = XDB::query('SELECT COUNT(*) |
343 | FROM fusionax_xorg_anciens AS u | |
344 | WHERE u.matricule_ax IS NULL'); | |
345 | if ($missingInAX) { | |
b9ad0878 PC |
346 | $page->assign('nbMissingInAX', $missingInAX->fetchOneCell()); |
347 | } | |
73be4434 SJ |
348 | $missingInXorg = XDB::query('SELECT COUNT(*) |
349 | FROM fusionax_import AS i | |
350 | WHERE i.user_id IS NULL'); | |
351 | if ($missingInXorg) { | |
352 | $page->assign('nbMissingInXorg', $missingInXorg->fetchOneCell()); | |
b9ad0878 | 353 | } |
29459c49 SJ |
354 | $wrongInXorg = FusionAxModule::find_wrong_in_xorg($nbToLink); |
355 | if ($wrongInXorg->total() > 0) { | |
356 | $page->assign('wrongInXorg', $wrongInXorg->total()); | |
357 | } | |
358 | $easyToLink = FusionAxModule::find_easy_to_link($nbToLink); | |
359 | if ($easyToLink->total() > 0) { | |
360 | $page->assign('nbMatch', $easyToLink->total()); | |
b9ad0878 PC |
361 | $page->assign('easyToLink', $easyToLink); |
362 | } | |
363 | } | |
364 | } | |
22f043e4 | 365 | |
29459c49 | 366 | function handler_deceased(&$page, $action = '') |
b9ad0878 | 367 | { |
29459c49 SJ |
368 | if ($action == 'updateXorg') { |
369 | XDB::execute('UPDATE fusionax_deceased | |
370 | SET deces_xorg = deces_ax | |
371 | WHERE deces_xorg = "0000-00-00"'); | |
372 | } | |
373 | if ($action == 'updateAX') { | |
374 | XDB::execute('UPDATE fusionax_deceased | |
375 | SET deces_ax = deces_xorg | |
376 | WHERE deces_ax = "0000-00-00"'); | |
377 | } | |
378 | if ($action == 'update') { | |
379 | if (Post::has('user_id') && Post::has('date')) { | |
380 | XDB::execute('UPDATE fusionax_deceased | |
381 | SET deces_ax = {?}, deces_xorg = {?} | |
382 | WHERE user_id = {?}', | |
383 | Post::v('date'), Post::v('date'), Post::i('user_id')); | |
384 | } | |
385 | } | |
386 | $page->changeTpl('fusionax/deceased.tpl'); | |
b9ad0878 | 387 | // deceased |
73be4434 SJ |
388 | $deceasedErrorsSql = XDB::query('SELECT COUNT(*) FROM fusionax_deceased'); |
389 | $page->assign('deceasedErrors', $deceasedErrorsSql->fetchOneCell()); | |
29459c49 SJ |
390 | $res = XDB::iterator('SELECT d.user_id, d.id_ancien, d.nom, d.prenom, d.promo, d.deces_ax, |
391 | CONCAT(d.prenom, " ", d.nom) AS display_name | |
392 | FROM fusionax_deceased AS d | |
393 | WHERE d.deces_xorg = "0000-00-00" | |
394 | LIMIT 10'); | |
395 | $page->assign('nbDeceasedMissingInXorg', $res->total()); | |
396 | $page->assign('deceasedMissingInXorg', $res); | |
397 | $res = XDB::iterator('SELECT d.user_id, d.id_ancien, d.nom, d.prenom, d.promo, d.deces_xorg, | |
398 | CONCAT(d.prenom, " ", d.nom) AS display_name | |
399 | FROM fusionax_deceased AS d | |
400 | WHERE d.deces_ax = "0000-00-00" | |
401 | LIMIT 10'); | |
402 | $page->assign('nbDeceasedMissingInAX', $res->total()); | |
403 | $page->assign('deceasedMissingInAX', $res); | |
404 | $res = XDB::iterator('SELECT d.user_id, d.id_ancien, d.nom, d.prenom, d.promo, | |
405 | d.deces_ax, d.deces_xorg, | |
406 | CONCAT(d.prenom, " ", d.nom, " ", d.user_id) AS display_name | |
407 | FROM fusionax_deceased AS d | |
408 | WHERE d.deces_xorg != "0000-00-00" AND d.deces_ax != "0000-00-00"'); | |
409 | $page->assign('nbDeceasedDifferent', $res->total()); | |
410 | $page->assign('deceasedDifferent', $res); | |
b9ad0878 | 411 | } |
c7eac294 SJ |
412 | |
413 | function handler_promo(&$page, $action = '') | |
414 | { | |
415 | $page->changeTpl('fusionax/promo.tpl'); | |
416 | $res = XDB::iterator('SELECT user_id, display_name, promo_etude_xorg, promo_sortie_xorg, promo_etude_ax | |
417 | FROM fusionax_promo | |
418 | WHERE !(promo_etude_ax + 1 = promo_etude_xorg AND promo_etude_xorg + 3 = promo_sortie_xorg)'); | |
419 | $nbMissmatchingPromos = $res->total(); | |
420 | $page->assign('nbMissmatchingPromos1', $res->total()); | |
421 | $page->assign('missmatchingPromos1', $res); | |
422 | $res = XDB::iterator('SELECT user_id, display_name, promo_etude_xorg, promo_sortie_xorg, promo_etude_ax | |
423 | FROM fusionax_promo | |
424 | WHERE promo_etude_ax + 1 = promo_etude_xorg AND promo_etude_xorg + 3 = promo_sortie_xorg'); | |
425 | $nbMissmatchingPromos += $res->total(); | |
426 | $page->assign('nbMissmatchingPromos2', $res->total()); | |
427 | $page->assign('missmatchingPromos2', $res); | |
428 | $page->assign('nbMissmatchingPromos', $nbMissmatchingPromos); | |
429 | } | |
b9ad0878 | 430 | } |
e8591429 | 431 | |
b9ad0878 | 432 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:?> |