$user['adr'][$i]['city'] = '';
$user['adr'][$i]['postcode'] = '';
$user['adr'][$i]['region'] = '';
+ $user['adr'][$i]['regiontxt'] = '';
$user['adr'][$i]['country'] = '00';
$user['adr'][$i]['countrytxt'] = '';
}
return;
return geoloc_country($params['country']);
}
-$page->register_function('geoloc_country', '_geoloc_country_smarty');
+$GLOBALS['page']->register_function('geoloc_country', '_geoloc_country_smarty');
/** donne la liste deroulante des regions pour un pays
* @param $pays le pays dont on veut afficher les regions
return;
return geoloc_region($params['country'], $params['region']);
}
-$page->register_function('geoloc_region', '_geoloc_region_smarty');
+$GLOBALS['page']->register_function('geoloc_region', '_geoloc_region_smarty');
// }}}
// {{{ get_address_infos($txt)
global $globals;
if ($infos['sql'])
$globals->xdb->execute("REPLACE INTO geoloc_city VALUES ".$infos['sql']);
+ if ($infos['display'])
+ $globals->xdb->execute("UPDATE geoloc_pays SET display = {?} WHERE a2 = {?}", $infos['display'], $infos['country']);
return $infos;
}
// }}}
if ($adr['adr2']) $t.= "\n".$adr['adr2'];
if ($adr['adr3']) $t.= "\n".$adr['adr3'];
$l = "";
- if ($adr['country'] == 'US' || $adr['country'] == 'CA') {
- if ($adr['city']) $l .= $adr['city'].",\n";
- if ($adr['region']) $l .= $adr['region']." ";
- if ($adr['postcode']) $l .= $adr['postcode'];
- } else {
- if ($adr['postcode']) $l .= $adr['postcode']." ";
- if ($adr['city']) $l .= $adr['city'];
+ if ($adr['display']) {
+ $keys = explode(' ', $adr['display']);
+ foreach ($keys as $key) {
+ if (isset($adr[$key]))
+ $l .= " ".$adr[$key];
+ else
+ $l .= " ".$key;
+ }
+ if ($l) $l = substr($l, 1);
+ }
+ else
+ {
+ if ($adr['country'] == 'US' || $adr['country'] == 'CA' || $adr['country'] == 'GB') {
+ if ($adr['city']) $l .= $adr['city'].",\n";
+ if ($adr['region']) $l .= $adr['region']." ";
+ if ($adr['postcode']) $l .= $adr['postcode'];
+ } else {
+ if ($adr['postcode']) $l .= $adr['postcode']." ";
+ if ($adr['city']) $l .= $adr['city'];
+ }
}
if ($l) $t .= "\n".trim($l);
if ($adr['country'] != '00' && (!$adr['countrytxt'] || $adr['countrytxt'] == strtoupper($adr['countrytxt']))) {
"city" => "",
"postcode" => "",
"region" => "",
+ "regiontxt" => "",
"country" => "00",
"countrytxt" => "");
}
$globals->xdb->execute("UPDATE adresses SET
adr1 = {?}, adr2 = {?}, adr3 = {?},
cityid = {?}, city = {?}, postcode = {?},
- region = {?}, country = {?}
+ region = {?}, regiontxt = {?}, country = {?}
WHERE uid = {?} AND adrid = {?}",
$new['adr1'], $new['adr2'], $new['adr3'],
$new['cityid'], $new['city'], $new['postcode'],
- $new['region'], $new['country'],
+ $new['region'], $new['regiontxt'], $new['country'],
$uid, $a['adrid']);
$new['store'] = true;
if (!$new['cityid']) $erreur[$a['adrid']] = $new;
FIND_IN_SET('res-secondaire', statut), FIND_IN_SET('courrier', statut),
FIND_IN_SET('active', statut), FIND_IN_SET('temporaire', statut),
adr1, adr2, adr3, postcode, city, cityid,
- a.country, region, tel, fax, pub, tel_pub,
- gp.pays AS countrytxt
+ a.country, region, regiontxt, tel, fax, pub, tel_pub,
+ gp.pays AS countrytxt, gp.display
FROM adresses AS a INNER JOIN geoloc_pays AS gp ON(gp.a2 = a.country)
WHERE uid = {?} AND NOT FIND_IN_SET('pro',statut) ".$sql_order
, Session::getInt('uid', -1)
$adresses[$adrid]['secondaire'], $adresses[$adrid]['courrier'],
$adresses[$adrid]['active'], $adresses[$adrid]['temporaire'],
$adresses[$adrid]['adr1'], $adresses[$adrid]['adr2'], $adresses[$adrid]['adr3'], $adresses[$adrid]['postcode'], $adresses[$adrid]['city'], $adresses[$adrid]['cityid'],
- $adresses[$adrid]['country'], $adresses[$adrid]['region'], $adresses[$adrid]['tel'], $adresses[$adrid]['fax'],
+ $adresses[$adrid]['country'], $adresses[$adrid]['region'], $adresses[$adrid]['regiontxt'], $adresses[$adrid]['tel'], $adresses[$adrid]['fax'],
$adresses[$adrid]['pub'],
- $adresses[$adrid]['tel_pub'],$adresses[$adrid]['countrytxt']) = $res->next();
+ $adresses[$adrid]['tel_pub'],$adresses[$adrid]['countrytxt'],$adresses[$adrid]['display']) = $res->next();
$adresses[$adrid]['nouvelle'] = 'modif';
$adresses[$adrid]['numero_formulaire'] = -1;
require_once('geoloc.inc.php');
cityid = {?},
country = {?},
region = {?},
+ regiontxt = {?},
tel = {?},
fax = {?},
pub = {?},
$adr['cityid'],
$adr['country'],
$adr['region'],
+ $adr['regiontxt'],
$adr['tel'],
$adr['fax'],
$adr['pub'],
cityid = {?},
country = {?},
region = {?},
+ regiontxt = {?},
tel = {?},
fax = {?},
pub = {?},
$adr['cityid'],
$adr['country'],
$adr['region'],
+ $adr['regiontxt'],
$adr['tel'],
$adr['fax'],
$adr['pub'],
$user['adr_pro'] = get_user_details_pro($uid);
$sql = "SELECT a.adr1,a.adr2,a.adr3,a.postcode,a.city,
- gp.pays AS countrytxt,gr.name AS region,a.tel,a.fax,
+ gp.pays AS countrytxt,a.region, a.regiontxt, a.tel,a.fax,
FIND_IN_SET('active', a.statut) AS active, a.adrid,
FIND_IN_SET('res-secondaire', a.statut) AS secondaire,
- a.pub, a.tel_pub
+ a.pub, a.tel_pub, gp.display
FROM adresses AS a
LEFT JOIN geoloc_pays AS gp ON (gp.a2=a.country)
- LEFT JOIN geoloc_region AS gr ON (gr.a2=a.country and gr.region=a.region)
WHERE uid= {?} AND NOT FIND_IN_SET('pro',a.statut)
ORDER BY NOT FIND_IN_SET('active',a.statut), FIND_IN_SET('temporaire',a.statut), FIND_IN_SET('res-secondaire',a.statut)";
$res = $globals->xdb->query($sql, $uid);
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2004 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************/
+
+
+function smarty_function_display_address($param, &$smarty) {
+ require_once('geoloc.inc.php');
+ $txtad = get_address_text($param['adr']);
+ if (!$txtad && !$param['adr']['tel'] && !$param['adr']['fax'] && !$param['adr']['mobile']) return "";
+
+ $lines = explode("\n",$txtad);
+ $txthtml = "";
+ if ($param['titre'])
+ {
+ if ($param['titre_div'])
+ $txthtml .= "<div class='titre'>".$param['titre']."</div>\n";
+ else
+ $txthtml .= "<em>".$param['titre']."</em><br />\n";
+ }
+ foreach ($lines as $line)
+ {
+ $txthtml .= "<strong>".$line."</strong><br/>\n";
+ }
+ if ($param['adr']['tel'])
+ $txthtml .= "<div>\n<em>Tél : </em>\n<strong>".$param['adr']['tel']."</strong>\n</div>\n";
+ if ($param['adr']['fax'])
+ $txthtml .= "<div>\n<em>Fax : </em>\n<strong>".$param['adr']['fax']."</strong>\n</div>\n";
+ if ($param['adr']['mobile'])
+ $txthtml .= "<div>\n<em>Tél : </em>\n<strong>".$param['adr']['mobile']."</strong>\n</div>\n";
+ if (!$params['nodiv'])
+ {
+ $txthtml = "<div class='adresse'>\n".$txthtml."</div>\n";
+ }
+ return $txthtml;
+}
+
+?>
{* *}
{**************************************************************************}
-
- {if $address.adr1 || $address.countrytxt || $geoloc_address.city || $address.tel || $address.fax || $address.mobile}
- {if $no_div neq 1}
- <div class="adresse">
- {/if}
- {if $titre && ($address.adr1 || $address.city || $address.countrytxt)}
- {if $titre_div}
- <div class="titre">
- {$titre}
- </div>
- {else}
- <em>{$titre}</em><br />
- {/if}
- {/if}
- {if $address.adr1}<strong>{$address.adr1}</strong><br />{/if}
- {if $address.adr2}<strong>{$address.adr2}</strong><br />{/if}
- {if $address.adr3}<strong>{$address.adr3}</strong><br />{/if}
- {if $address.city}<strong>{$address.postcode} {$address.city}</strong><br />{/if}
- {if $address.countrytxt}
- <strong>{$address.countrytxt}{if $address.region && $address.countrytxt != 'France'} ({$address.region}){/if}</strong>
- {/if}
-
- {if $address.tel}
- <div>
- <em>Tél : </em>
- <strong>{$address.tel}</strong>
- </div>
- {/if}
-
- {if $address.fax}
- <div>
- <em>Fax : </em>
- <strong>{$address.fax}</strong>
- </div>
- {/if}
-
- {if $address.mobile}
- <div>
- <em>Mobile : </em>
- <strong>{$address.mobile}</strong>
- </div>
- {/if}
-
- {if $no_div neq 1}
- </div>
- {/if}
- {/if}
+{display_address adr=$address titre=$titre titre_div=$titre_div no_div=$no_div}
{* vim:set et sw=2 sts=2 sws=2: *}
--- /dev/null
+ALTER TABLE adresses ADD regiontxt VARCHAR(80) NOT NULL AFTER region;
+ALTER TABLE geoloc_pays ADD display VARCHAR(50) NOT NULL;
+