From 41668ee7adfef4d900ce7acaa9cc890c820436c4 Mon Sep 17 00:00:00 2001 From: Pascal Corpet Date: Tue, 18 Jan 2005 23:49:24 +0000 Subject: [PATCH] ergonomie synchro_x + coding rules git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-387 --- htdocs/admin/synchro_ax.php | 7 +- include/synchro_ax.inc.php | 131 +++++++++++++++++++++-------------- templates/admin/synchro_ax.tpl | 152 +++++++++++++++++++++++++---------------- 3 files changed, 178 insertions(+), 112 deletions(-) diff --git a/htdocs/admin/synchro_ax.php b/htdocs/admin/synchro_ax.php index 3820c12..9bc3332 100644 --- a/htdocs/admin/synchro_ax.php +++ b/htdocs/admin/synchro_ax.php @@ -77,7 +77,7 @@ if ($login) { } } - import_from_ax($userax, Env::has('epouse'), Env::has('mobile'), $adr_dels, $adr_adds, $pro_dels, $pro_adds); + import_from_ax($userax, Env::has('epouse'), Env::has('mobile'), $adr_dels, $adr_adds, $pro_dels, $pro_adds, Env::has('nationalite')); } @@ -86,8 +86,13 @@ if ($login) { if ($userax) { $user['matricule_ax'] = $userax['matricule_ax']; unset($userax['matricule_ax']); + $user['nom'] = ucwords(strtolower($user['nom'])); + $user['epouse'] = ucwords(strtolower($user['epouse'])); } + $page->assign('watch_champs',array('nom', 'epouse', 'prenom', 'nationalite', 'mobile')); + $page->assign('modifiables', array(0,1,0,1,1)); + $page->assign('x', $user); $page->assign('ax', $userax); } diff --git a/include/synchro_ax.inc.php b/include/synchro_ax.inc.php index da96161..f2e626f 100644 --- a/include/synchro_ax.inc.php +++ b/include/synchro_ax.inc.php @@ -38,14 +38,12 @@ function get_user_ax($uid, $raw=false) $matricule_ax = $res->fetchOneCell(); $array = get_annuaire_infos(2, $matricule_ax, 0); - - $ancien = $array['dump']['ancien']; $userax = Array(); - $userax['matricule_ax'] = $matricule_ax; $userax['uid'] = $uid; + $ancien = $array['dump']['ancien']; $userax['nom'] = $ancien[0]; // ancien1 = ? $userax['epouse'] = ($ancien[2] != $ancien[0])?$ancien[2]:""; @@ -56,6 +54,7 @@ function get_user_ax($uid, $raw=false) // ancien7 = Type de membre à l'AX // ancien8 = dernière année de cotisation $userax['nationalite'] = $ancien[9]; + if ($userax['nationalite'] == 'F') $userax['nationalite'] = 'Français'; // ancien10 = ? // ancine11 = ? $userax['date'] = substr($ancien[12], 0, 10); @@ -130,7 +129,7 @@ function get_user_ax($uid, $raw=false) return $userax; } -function import_from_ax($userax, $epouse=false, $mobile=false, $del_address=null, $add_address=null, $del_pro=null, $add_pro=null) +function import_from_ax($userax, $epouse=false, $mobile=false, $del_address=null, $add_address=null, $del_pro=null, $add_pro=null, $nationalite=false) { global $globals; @@ -142,6 +141,12 @@ function import_from_ax($userax, $epouse=false, $mobile=false, $del_address=null $globals->xdb->execute("UPDATE auth_user_md5 SET mobile = {?} WHERE user_id = {?}", $userax['mobile'], $userax['uid']); } + if ($nationalite) { + if ($userax['nationalite'] == 'Français') { + $userax['nationalite'] = 'FR'; + } + $globals->xdb->execute("UPDATE auth_user_md5 SET nationalite = {?} WHERE user_id = {?}", $userax['nationalite'], $userax['uid']); + } if (is_array($del_address)) foreach($del_address as $adrid) { $globals->xdb->execute("DELETE FROM adresses WHERE uid = {?} AND adrid = {?}", $userax['uid'], $adrid); } @@ -152,31 +157,42 @@ function import_from_ax($userax, $epouse=false, $mobile=false, $del_address=null if (is_array($add_address)) { - $res = $globals->xdb->query("SELECT adrid FROM adresses WHERE uid = {?} AND adrid >= 1 ORDER BY adrid", $userax['uid']); - $adrids = $res->fetchColumn(); - $i_adrid = 0; - $new_adrid = 1; + $res = $globals->xdb->query( + "SELECT adrid + FROM adresses + WHERE uid = {?} AND adrid >= 1 + ORDER BY adrid", + $userax['uid']); + $adrids = $res->fetchColumn(); + $i_adrid = 0; + $new_adrid = 1; - foreach($add_address as $adrid) { - - $adr = $userax['adr'][$adrid]; + foreach($add_address as $adrid) { - // find the next adrid not used - while ($adrids[$i_adrid] == $new_adrid) { $i_adrid++; $new_adrid++; } - - if ($adr['pays']) { - $res = $globals->xdb->query("SELECT a2 FROM geoloc_pays WHERE pays LIKE {?} OR country LIKE {?}", $adr['pays'], $adr['pays']); - $a2 = $res->fetchOneCell(); - } - if (!$a2) { - $a2 = '00'; - } - - $globals->xdb->execute( - "INSERT INTO adresses - SET uid = {?}, adrid = {?}, - adr1 = {?}, adr2 = {?}, adr3 = {?}, - cp = {?}, ville = {?}, + $adr = $userax['adr'][$adrid]; + + // find the next adrid not used + while ($adrids[$i_adrid] == $new_adrid) { + $i_adrid++; + $new_adrid++; + } + + if ($adr['pays']) { + + $res = $globals->xdb->query( + "SELECT a2 FROM geoloc_pays + WHERE pays LIKE {?} OR country LIKE {?}", + $adr['pays'], $adr['pays']); + + $a2 = $res->fetchOneCell(); + } + if (!$a2) { $a2 = '00'; } + + $globals->xdb->execute( + "INSERT INTO adresses + SET uid = {?}, adrid = {?}, + adr1 = {?}, adr2 = {?}, adr3 = {?}, + cp = {?}, ville = {?}, pays = {?}, tel = {?}, fax = {?}, datemaj = NOW(), @@ -186,37 +202,45 @@ function import_from_ax($userax, $epouse=false, $mobile=false, $del_address=null $adr['cp'], $adr['ville'], $a2, $adr['tel'], $adr['fax']); - }} + } + } if (is_array($add_pro)) { - $res = $globals->xdb->query("SELECT entrid FROM entreprises WHERE uid = {?} AND entrid >= 1 ORDER BY entrid", $userax['uid']); - $entrids = $res->fetchColumn(); - $i_entrid = 0; - $new_entrid = 1; - - $nb_entr = count($entrids); - - foreach($add_pro as $entrid) if ($nb_entr < 2) { + $res = $globals->xdb->query( + "SELECT entrid FROM entreprises + WHERE uid = {?} AND entrid >= 1 ORDER BY entrid", + $userax['uid']); + $entrids = $res->fetchColumn(); + $i_entrid = 0; + $new_entrid = 1; + + $nb_entr = count($entrids); - $nb_entr++; - - $pro = $userax['adr_pro'][$entrid]; + foreach($add_pro as $entrid) if ($nb_entr < 2) { - // find the next adrid not used - while ($entrids[$i_entrid] == $new_entrid) { $i_entrid++; $new_entrid++; } + $nb_entr++; - if ($pro['pays']) { - $res = $globals->xdb->query("SELECT a2 FROM geoloc_pays WHERE pays LIKE {?} OR country LIKE {?}", $pro['pays'], $pro['pays']); - $a2 = $res->fetchOneCell(); - } - if (!$a2) { - $a2 = '00'; - } - - $globals->xdb->execute( - "INSERT INTO entreprises - SET uid = {?}, entrid = {?}, + $pro = $userax['adr_pro'][$entrid]; + + // find the next adrid not used + while ($entrids[$i_entrid] == $new_entrid) { + $i_entrid++; + $new_entrid++; + } + + if ($pro['pays']) { + $res = $globals->xdb->query( + "SELECT a2 FROM geoloc_pays + WHERE pays LIKE {?} OR country LIKE {?}", + $pro['pays'], $pro['pays']); + $a2 = $res->fetchOneCell(); + } + if (!$a2) { $a2 = '00'; } + + $globals->xdb->execute( + "INSERT INTO entreprises + SET uid = {?}, entrid = {?}, entreprise = {?}, poste = {?}, adr1 = {?}, adr2 = {?}, adr3 = {?}, cp = {?}, ville = {?}, @@ -229,7 +253,8 @@ function import_from_ax($userax, $epouse=false, $mobile=false, $del_address=null $pro['cp'], $pro['ville'], $a2, $pro['tel'], $pro['fax']); - }} + } + } } // vim:set et sw=4 sts=4 sws=4: diff --git a/templates/admin/synchro_ax.tpl b/templates/admin/synchro_ax.tpl index 7ef50cb..fad0f38 100644 --- a/templates/admin/synchro_ax.tpl +++ b/templates/admin/synchro_ax.tpl @@ -51,81 +51,103 @@ champ x.org - supprimer - AX importer + AX - - fiches - + + fiche + polytechnique.org - + + + polytechniciens.com -{foreach from=$ax item='val' key='i'} - {if ($i neq 'adr') and ($i neq 'adr_pro')} - {if $x[$i] neq $val} - +{foreach from=$watch_champs item='i'} + {if $x[$i] or $ax[$i]} + {$i} - + {$x[$i]} - - {if (($i eq 'epouse') or ($i eq 'mobile')) and $val} -
- -
+ + {if $x[$i] eq $ax[$i]} + == + {else} + {if $ax[$i]} + + {/if} {/if} - {$val} + + + {$ax[$i]} - {/if} {/if} {/foreach} - - - adresses - - + + + + + + + +
+{if $ax.adr[0]} +{if $x.adr} +
+ Supprimer les adresses suivantes : +
+ {foreach from=$x.adr item='adr'} -
- {if $ax.adr[0]} -
+
+ + + {/foreach} - -
- - {/if} - {include file='geoloc/address.tpl' address=$adr no_div=1} - + + {include file='geoloc/address.tpl' address=$adr no_div=1} +
+
+
+ et les remplacer par les adresses suivantes de l'AX : +
+{else} +
+ Importer les adresses AX suivantes : +
+{/if} + {foreach from=$ax.adr item='adr' key='adrid'} -
-
+
+ + + {/foreach} - - - - -
- - {include file='geoloc/address.tpl' address=$adr no_div=1} - + + {include file='geoloc/address.tpl' address=$adr no_div=1} +
- adr_pro - +
+{/if} +
+{if $ax.adr_pro[0].entreprise} +{if $x.adr_pro} +
+ Supprimer les emplois suivants : +
+ {foreach from=$x.adr_pro item='pro'} {if ($pro.poste) or ($pro.fonction) or ($pro.entreprise)} -
- {if $ax.adr_pro[0]} -
+
+ + + {/if} {/foreach} - -
- - {/if} + {if $pro.entreprise}
Entreprise/Organisme : {$pro.entreprise} @@ -148,17 +170,28 @@
{/if} {include file='geoloc/address.tpl' address=$pro no_div=1} - +
+
+ +
+ et les remplacer par les emplois suivants de l'AX : +
+{else} +
+ Importer les emplois suivants depuis l'AX : +
+{/if} + {foreach from=$ax.adr_pro item='pro' key='proid'} {if ($pro.poste) or ($pro.fonction) or ($pro.entreprise)} -
-
+
+ + + {/if} {/foreach} - - +
- + {if $pro.entreprise}
Entreprise/Organisme : {$pro.entreprise} @@ -170,11 +203,14 @@
{/if} {include file='geoloc/address.tpl' address=$pro no_div=1} - +
+{/if} +
-- 2.1.4