- $adrax['country'] = $ancien->Pays($i);
- $adrax['tel'] = $ancien->Tel($i);
- $adrax['fax'] = $ancien->Fax($i);
- $userax['adr'][] = $adrax;
- }
- if ($raw) {
- $userax['raw'] = $ancien;
- }
-
- return $userax;
-}
-
-function import_from_ax($userax, $nom_usage=false, $mobile=false, $del_address=null, $add_address=null, $del_pro=null, $add_pro=null, $nationalite=false)
-{
- global $globals;
-
- if ($nom_usage) {
- $globals->xdb->execute("UPDATE auth_user_md5 SET nom_usage = {?} WHERE user_id = {?}", strtoupper($userax['nom_usage']), $userax['uid']);
- }
-
- if ($mobile) {
- $globals->xdb->execute("UPDATE auth_user_quick SET profile_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);
- }
-
- 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 = {?} 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];
-
- // find the next adrid not used
- while ($adrids[$i_adrid] == $new_adrid) {
- $i_adrid++;
- $new_adrid++;
- }
-
- if ($adr['city']) {
-
- $res = $globals->xdb->query(
- "SELECT a2 FROM geoloc_pays
- WHERE pays LIKE {?} OR country LIKE {?}",
- $adr['country'], $adr['country']);
-
- $a2 = $res->fetchOneCell();
- }
- if (!$a2) { $a2 = '00'; }
-
- $globals->xdb->execute(
- "INSERT INTO adresses
- SET uid = {?}, adrid = {?},
- adr1 = {?}, adr2 = {?}, adr3 = {?},
- postcode = {?}, city = {?},
- country = {?},
- tel = {?}, fax = {?},
- datemaj = NOW(),
- pub = 'ax',
- tel_pub = 'ax'",
- $userax['uid'], $new_adrid,
- $adr['adr1'], $adr['adr2'], $adr['adr3'],
- $adr['postcode'], $adr['city'],
- $a2,
- $adr['tel'], $adr['fax']);
+ $adrax['countrytxt'] = ucwords(strtolower($ancien->Pays($i)));
+ $adrax['pub'] = 'ax';
+ if ($ancien->Tel($i) || $ancien->Fax($i)) {
+ $adrax['tels'] = array();
+ if ($tel = $ancien->Tel($i))
+ $adrax['tels'][] = array('tel' => $tel, 'tel_type' => 'Tél.', 'tel_pub' => 'ax');
+ if ($tel = $ancien->Fax($i))
+ $adrax['tels'][] = array('tel' => $tel, 'tel_type' => 'Fax', 'tel_pub' => 'ax');