From: Pascal Corpet Date: Tue, 18 Jan 2005 16:43:20 +0000 (+0000) Subject: whish 151 : mise a jour depuis l'AX X-Git-Tag: xorg/old~378 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=7e4b0ba4c91e92e33acc4ba6036d78e48e6e6a9b;p=platal.git whish 151 : mise a jour depuis l'AX git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-379 --- diff --git a/htdocs/synchro_ax.php b/htdocs/synchro_ax.php index 7e9e8f4..4aba88a 100644 --- a/htdocs/synchro_ax.php +++ b/htdocs/synchro_ax.php @@ -26,10 +26,6 @@ new_admin_page('synchro_ax.tpl'); require_once('user.func.inc.php'); require_once('synchro_ax.inc.php'); -if (!Env::has('user') && !Env::has('mat')) { - $page->kill("cette page n'existe pas"); -} - if (Env::has('user')) { $login = get_user_forlife(Env::get('user')); if ($login === false) { @@ -44,17 +40,41 @@ if (Env::has('mat')) { INNER JOIN auth_user_md5 AS u ON (a.id=u.user_id AND a.type='a_vie') WHERE matricule={?}", Env::getInt('mat')); $login = $res->fetchOneCell(); - if (empty($login)) { - $page->kill("cette page n'existe pas"); - } } -$new = Env::get('modif') == 'new'; +if ($login) { + $new = Env::get('modif') == 'new'; + $user = get_user_details($login, Session::getInt('uid')); + $userax= get_user_ax($user['user_id']); + +if (Env::has('importe')) { + + $adr_dels = array(); + foreach ($user['adr'] as $adr) + if (Env::has('del_address'.$adr['adrid'])) $adr_dels[] = $adr['adrid']; + + $adr_adds = array(); + foreach ($userax['adr'] as $i => $adr) + if (Env::has('add_address'.$i)) $adr_adds[] = $i; + + $pro_dels = array(); + foreach ($user['adr_pro'] as $pro) + if (Env::has('del_pro'.$pro['entrid'])) $pro_dels[] = $pro['proid']; + + $pro_adds = array(); + foreach ($userax['adr_pro'] as $i => $pro) + if (Env::has('add_pro'.$i)) $pro_adds[] = $i; + + import_from_ax($userax, Env::has('epouse'), Env::has('mobile'), $adr_dels, $adr_adds, $pro_dels, $pro_adds); + +} + $user = get_user_details($login, Session::getInt('uid')); $page->assign('x', $user); -$page->assign('ax', get_user_ax($user['user_id'])); - +$page->assign('ax', $userax); +} $page->run(); +// vim:set et sts=4 sws=4 sw=4: ?> diff --git a/include/synchro_ax.inc.php b/include/synchro_ax.inc.php index 5b710e0..b9351ef 100644 --- a/include/synchro_ax.inc.php +++ b/include/synchro_ax.inc.php @@ -94,7 +94,7 @@ function import_from_ax($userax, $epouse=false, $mobile=false, $del_address=null global $globals; if ($epouse) { - $globals->xdb->execute("UPDATE auth_user_md5 SET epouse = {?} WHERE user_id = {?}", $userax['epouse'], $userax['uid']); + $globals->xdb->execute("UPDATE auth_user_md5 SET epouse = {?} WHERE user_id = {?}", strtoupper($userax['epouse']), $userax['uid']); } if ($mobile) { @@ -105,10 +105,14 @@ function import_from_ax($userax, $epouse=false, $mobile=false, $del_address=null $globals->xdb->execute("DELETE FROM adresses WHERE uid = {?} AND adrid = {?}", $userax['uid'], $adrid); } + if (is_array($del_pro)) foreach($del_pro as $entrid) { + $globals->xdb->execute("DELETE FROM entreprises WHERE uid = {?} AND entrid = {?}", $userax['uid'], $entrid); + } + if (is_array($add_address)) { - $res = $globals->xdb->query("SELECT adrid FROM adresses WHERE uid = {?} ORDER BY adrid", $userax['uid']); - $adrids = $res->fetchOneColumn(); + $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; @@ -131,12 +135,55 @@ function import_from_ax($userax, $epouse=false, $mobile=false, $del_address=null adr1 = {?}, adr2 = {?}, adr3 = {?}, cp = {?}, ville = {?}, pays = {?}, + tel = {?}, fax = {?}, datemaj = NOW(), visibilite = 'adr_ax,tel_ax'", $userax['uid'], $new_adrid, $adr['adr1'], $adr['adr2'], $adr['adr3'], $adr['cp'], $adr['ville'], - $a2); + $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) { + + $nb_entr++; + + $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 = {?}, + adr1 = {?}, adr2 = {?}, adr3 = {?}, + cp = {?}, ville = {?}, + pays = {?}, + tel = {?}, fax = {?}, + entreprise = {?}, fonction = {?}, + visibilite = 'entreprise_ax,adr_ax,tel_ax'", + $userax['uid'], $new_entrid, + $pro['adr1'], $pro['adr2'], $pro['adr3'], + $pro['cp'], $pro['ville'], + $a2, + $pro['tel'], $pro['fax'], + $pro['entreprise'], $pro['fonction']); }} } diff --git a/include/user.func.inc.php b/include/user.func.inc.php index 974d3bd..8410932 100644 --- a/include/user.func.inc.php +++ b/include/user.func.inc.php @@ -157,7 +157,7 @@ function &get_user_details($login, $from_uid = '') global $globals; $reqsql = "SELECT u.user_id, u.promo, u.prenom, u.nom, u.epouse, u.date, u.cv, u.mobile, u.web, u.libre, u.perms IN ('admin','user') AS inscrit, FIND_IN_SET('femme', u.flags) AS sexe, u.deces != 0 AS dcd, u.deces, - q.profile_nick AS nickname, + q.profile_nick AS nickname, q.profile_from_ax, IF(gp.nat='',gp.pays,gp.nat) AS nationalite, gp.a2 AS iso3166, a.alias AS forlife, a2.alias AS bestalias, c.uid IS NOT NULL AS is_contact, @@ -180,7 +180,7 @@ function &get_user_details($login, $from_uid = '') $sql = "SELECT e.entreprise, s.label as secteur , ss.label as sous_secteur , f.fonction_fr as fonction, e.poste, e.adr1, e.adr2, e.adr3, e.cp, e.ville, - gp.pays, gr.name, e.tel, e.fax, e.mobile + gp.pays, gr.name, e.tel, e.fax, e.mobile, e.entrid FROM entreprises AS e LEFT JOIN emploi_secteur AS s ON(e.secteur = s.id) LEFT JOIN emploi_ss_secteur AS ss ON(e.ss_secteur = ss.id AND e.secteur = ss.secteur) @@ -194,7 +194,7 @@ function &get_user_details($login, $from_uid = '') $sql = "SELECT a.adr1,a.adr2,a.adr3,a.cp,a.ville, gp.pays,gr.name AS region,a.tel,a.fax, - FIND_IN_SET('active', a.statut) AS active, + FIND_IN_SET('active', a.statut) AS active, a.adrid, FIND_IN_SET('res-secondaire', a.statut) AS secondaire FROM adresses AS a LEFT JOIN geoloc_pays AS gp ON (gp.a2=a.pays) diff --git a/templates/geoloc/address.tpl b/templates/geoloc/address.tpl index 4b80d84..dbb548a 100644 --- a/templates/geoloc/address.tpl +++ b/templates/geoloc/address.tpl @@ -20,7 +20,9 @@ {if $address.adr1 || $address.pays || $geoloc_address.ville || $address.tel || $address.fax || $address.mobile} + {if $no_div neq 1}
+ {/if} {if $titre && ($address.adr1 || $address.ville || $address.pays)} {if $titre_div}
@@ -59,7 +61,9 @@
{/if} + {if $no_div neq 1}
{/if} + {/if} {* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/synchro_ax.tpl b/templates/synchro_ax.tpl index 3b696ab..f06ca57 100644 --- a/templates/synchro_ax.tpl +++ b/templates/synchro_ax.tpl @@ -22,36 +22,146 @@ Synchronisation depuis l'AX - + +
+ + + + + + +
Synchroniser un utilisateur
+ + +
+ + +
+{if $x.profile_from_ax} +
+Cet utilisateur a accpeté la synchronisation +
+{else} +
+ATTENTION ! Cet utilisateur n'a pas accepté la synchronisation +
+{/if} + - + {foreach from=$ax item='val' key='i'} - + {if ($i neq 'adr') and ($i neq 'adr_pro')} + + + + + + {/if} +{/foreach} + + + + + + -{/foreach}
champAX x.orgAX
+ {$i} + + {$x[$i]} + + {if ($i eq 'epouse') or ($i eq 'mobile')} +
+ +
+ {/if} + {$val} +
- {$i} + adresses - {if ($i neq 'adr') and ($i neq 'adr_pro')} - {$val} - {else} - {foreach from=$val item='sval' key='j'} - {include file='geoloc/address.tpl' address=$sval} - {/foreach}{/if} + {foreach from=$x.adr item='adr'} +
+
+ +
+ {include file='geoloc/address.tpl' address=$adr no_div=1} +
+ {/foreach}
- {if ($i neq 'adr') and ($i neq 'adr_pro')} - {$x[$i]} - {else} - {foreach from=$x[$i] item='sval' key='j'} - {include file='geoloc/address.tpl' address=$sval} - {/foreach}{/if} + {foreach from=$ax.adr item='adr' key='adrid'} +
+
+ +
+ {include file='geoloc/address.tpl' address=$adr no_div=1} +
+ {/foreach} +
+ adr_pro + + {foreach from=$x.adr_pro item='pro'} + {if ($pro.poste) or ($pro.fonction) or ($pro.entreprise)} +
+
+ +
+ {if $pro.entreprise} +
+ Entreprise/Organisme : {$pro.entreprise} +
+ {/if} + {if $pro.secteur} +
+ Secteur : + {$pro.secteur}{if $pro.ss_secteur} ({$pro.ss_secteur}){/if} +
+ {/if} + {if $pro.fonction} +
+ Fonction : {$pro.fonction} +
+ {/if} + {if $pro.poste} +
+ Poste : {$pro.poste} +
+ {/if} + {include file='geoloc/address.tpl' address=$pro no_div=1} +
+ {/if} + {/foreach} +
+ {foreach from=$ax.adr_pro item='pro' key='proid'} + {if ($pro.poste) or ($pro.fonction) or ($pro.entreprise)} +
+
+ +
+ {if $pro.entreprise} +
+ Entreprise/Organisme : {$pro.entreprise} +
+ {/if} + {if $pro.fonction} +
+ Fonction : {$pro.fonction} +
+ {/if} + {include file='geoloc/address.tpl' address=$pro no_div=1} +
+ {/if} + {/foreach}
- +
+ + +
+
{* vim:set et sw=2 sts=2 sws=2: *}