- $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);
- $globals->xdb->execute("DELETE FROM tels 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 = {?},
- datemaj = NOW(),
- pub = 'ax'",
- $userax['uid'], $new_adrid,
- $adr['adr1'], $adr['adr2'], $adr['adr3'],
- $adr['postcode'], $adr['city'],
- $a2);
- // import tels
- if ($adr['tel'])
- $globals->xdb->execute(
- "INSERT INTO adresses
- SET uid = {?}, adrid = {?}, tel = {?},
- telid = 0, tel_type = 'Tel.', tel_pub = 'ax'",
- $userax["uid"], $new_adrid, $adr['tel']);
- if ($adr['fax'])
- $globals->xdb->execute(
- "INSERT INTO adresses
- SET uid = {?}, adrid = {?}, tel = {?},
- telid = 1, tel_type = 'Fax', tel_pub = 'ax'",
- $userax["uid"], $new_adrid, $adr['fax']);