margin-left: 16px;
}
-table.flags, tr.flags {
+.flags {
margin: 0.5em 0 0 0;
padding: 0;
}
-table.flags input { margin: 0px 2px; padding: 0px; }
-
-table.flags td.texte, tr.flags td.texte {
+.flags input {
+ margin: 0px 2px;
+ padding: 0px;
+}
+.flags .texte {
font-size: smaller;
font-weight: bold;
padding: 0 8px 0 0;
}
-table.flags td.vert, tr.flags td.vert {
+.flags .vert {
background: url('../images/icons/flag_green.gif') top right no-repeat;
padding: 0 16px 0 0;
+ margin-right: 16px;
}
-table.flags td.orange, tr.flags td.orange {
+.flags .orange {
background: url('../images/icons/flag_orange.gif') top right no-repeat;
padding: 0 16px 0 0;
+ margin-right: 16px;
}
-table.flags td.rouge, tr.flags td.rouge {
+.flags .rouge {
background: url('../images/icons/flag_red.gif') top right no-repeat;
padding: 0 16px 0 0;
+ margin-right: 16px;
}
table.cadre_a_onglet{
class ProfileAddress extends ProfileNoSave
{
+ private function geolocAddress(&$address, &$success)
+ {
+ require_once 'geoloc.inc.php';
+ if (@$address['parsevalid'] || (@$address['text'] && @$address['changed']) || !@$address['cityid']) {
+ $address = array_merge($address, empty_address());
+ $new = get_address_infos(@$address['text']);
+ if (compare_addresses_text(@$adress['text'], $geotxt = get_address_text($new))
+ || @$address['parsevalid']) {
+ $address = array_merge($address, $new);
+ } else {
+ $success = false;
+ $address = array_merge($address, cut_address(@$address['text']));
+ $address['geoloc'] = $geotxt;
+ $address['geoloc_cityid'] = $new['cityid'];
+ }
+ }
+ $address['text'] = get_address_text($address);
+ unset($address['parsevalid']);
+ unset($address['changed']);
+ }
+
public function value(ProfilePage &$page, $field, $value, &$success)
{
- $success = true;
+ $init = false;
if (is_null($value)) {
- return $page->values['addresses'];
+ $value = $page->values['addresses'];
+ $init = true;
}
foreach ($value as $key=>&$adr) {
- if ($adr['removed']) {
+ if (@$adr['removed']) {
unset($value[$key]);
}
}
+ $success = true;
+ foreach ($value as $key=>&$adr) {
+ $this->geolocAddress($adr, $s);
+ if (!$init) {
+ $success = $success && $s;
+ }
+ }
return $value;
}
}
return;
}
// Build the addresses tree
- $res = XDB::query("SELECT adrid AS id, adr1, adr2, adr3,
- postcode, city, cityid, region, regiontxt,
- fax, glat, glng, datemaj, pub,
- FIND_IN_SET('res-secondaire', statut) AS secondaire,
- FIND_IN_SET('courrier', statut) AS mail,
- FIND_IN_SET('temporary', statut) AS temporary,
- FIND_IN_SET('active', statut) AS current,
- FIND_IN_SET('coord-checked', statut) AS checked,
- FIND_IN_SET('coord-valid', statut) AS valid
- FROM adresses
- WHERE uid = {?}
+ $res = XDB::query("SELECT a.adrid AS id, a.adr1, a.adr2, a.adr3,
+ a.postcode, a.city, a.cityid, a.region, a.regiontxt,
+ a.fax, a.glat, a.glng, a.datemaj, a.pub,
+ a.country, gp.pays AS countrytxt, gp.display,
+ FIND_IN_SET('res-secondaire', a.statut) AS secondaire,
+ FIND_IN_SET('courrier', a.statut) AS mail,
+ FIND_IN_SET('temporary', a.statut) AS temporary,
+ FIND_IN_SET('active', a.statut) AS current
+ FROM adresses AS a
+ INNER JOIN geoloc_pays AS gp ON(gp.a2 = a.country)
+ WHERE uid = {?} AND NOT FIND_IN_SET('pro', statut)
ORDER BY adrid",
S::i('uid'));
$this->values['addresses'] = $res->fetchAllAssoc();
- $res = XDB::iterRow("SELECT adrid, telid, tel_type, tel_pub, tel
- FROM tels
- WHERE uid = {?}
- ORDER BY adrid",
- S::i('uid'));
+ $res = XDB::iterator("SELECT adrid, tel_type AS type, tel_pub AS pub, tel
+ FROM tels
+ WHERE uid = {?}
+ ORDER BY adrid",
+ S::i('uid'));
$i = 0;
- while (list($adrid, $telid, $type, $pub, $tel) = $res->next()) {
+ while ($tel = $res->next()) {
+ $adrid = $tel['adrid'];
+ unset($tel['adrid']);
while ($this->values['addresses'][$i]['id'] < $adrid) {
$i++;
}
$address['tel'] = array();
}
if ($address['id'] == $adrid) {
- $address['tel'][] = array('id' => $telid,
- 'type' => $type,
- 'pub' => $pub,
- 'tel' => $tel);
+ $address['tel'][] = $tel;
}
}
+ foreach ($this->values['addresses'] as $id=>&$address) {
+ unset($address['id']);
+ }
parent::fetchData();
}
{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
{* *}
{**************************************************************************}
-{if $display neq "mini"}
+{if $display eq "mini"}
+<td class="vert">
+ <input type="radio" name="{$name}" value="public" {if $val eq 'public'}checked="checked"{/if} />
+</td>
+<td class="orange">
+ <input type="radio" name="{$name}" value="ax" {if $val eq 'ax'}checked="checked"{/if} />
+</td>
+<td class="rouge">
+ <input type="radio" name="{$name}" value="private" {if $val eq 'private'}checked="checked"{/if} />
+</td>
+{elseif $display eq "div"}
+<span class="vert">
+ <input type="radio" name="{$name}" value="public" {if $val eq 'public'}checked="checked"{/if} />
+</span>
+<span class="orange">
+ <input type="radio" name="{$name}" value="ax" {if $val eq 'ax'}checked="checked"{/if} />
+</span>
+<span class="rouge">
+ <input type="radio" name="{$name}" value="private" {if $val eq 'private'}checked="checked"{/if} />
+</span>
+{else}
{if !$notable}
<tr>
<td colspan="5" class="pflags">
</td>
</tr>
{/if}
-{else}
- <td class="vert">
- <input type="radio" name="{$name}" value="public" {if $val eq 'public'}checked="checked"{/if} />
- </td>
- <td class="orange">
- <input type="radio" name="{$name}" value="ax" {if $val eq 'ax'}checked="checked"{/if} />
- </td>
- <td class="rouge">
- <input type="radio" name="{$name}" value="private" {if $val eq 'private'}checked="checked"{/if} />
- </td>
{/if}
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
{foreach key=i item=adr from=$addresses}
{assign var=adpref value="addresses[$i]"}
{assign var=adid value="addresses_$i"}
+<input type="hidden" name="{$adpref}[removed]" value="0"/>
<table class="bicol" id="{$adid}" style="margin-bottom: 1em">
<tr>
<th>
<tr>
<td>
<div>{include file="include/flags.radio.tpl" name="$adpref[pub]" notable=true val=$adr.pub}</div>
- <div {if !$adr.geoloc}class="center"{/if}>{include file="geoloc/form.address.tpl" name=$adpref id=$adid adr=$adr}</div>
+ <div style="clear: both"></div>
+ <div style="float: left">{include file="geoloc/form.address.tpl" name=$adpref id=$adid adr=$adr}</div>
+ <div style="float: right">
+ <div>
+ <input type="radio" name="{$adpref}[temporary]" id="{$adid}_temp_0" value="0"
+ {if !$adr.temporary}checked="checked"{/if} /><label for="{$adid}_temp_0">permanente</label>
+ <input type="radio" name="{$adpref}[temporary]" id="{$adid}_temp_1" value="1"
+ {if $adr.temporary}checked="checked"{/if} /><label for="{$adid}_temp_1">temporaire</label>
+ </div>
+ <div>
+ <input type="radio" name="{$adpref}[secondaire]" id="{$adid}_sec_0" value="0"
+ {if !$adr.secondaire}checked="checked"{/if} /><label for="{$adid}_sec_0">ma résidence principale</label>
+ <input type="radio" name="{$adpref}[secondaire]" id="{$adid}_sec_1" value="1"
+ {if $adr.secondaire}checked="checked"{/if} /><label for="{$adid}_sec_1">une résidence secondaire</label>
+ </div>
+ <div>
+ <input type="checkbox" name="{$adpref}[mail]" id="{$adid}_mail"
+ {if $adr.mail}checked="checked"{/if} />
+ <label for="{$adid}_mail">on peut m'y envoyer du courrier par la poste</label>
+ </div>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {foreach from=$adr.tel key=t item=tel}
+ {assign var=telpref value="`$adpref`[tel][`$t`]"}
+ {assign var=telid value="`$adid`_tel_`$t`"}
+ <div id="{$telid}" style="clear: both">
+ <div style="float: right" class="flags">
+ {include file="include/flags.radio.tpl" name="`$telpref`[pub]" val=$tel.pub display="div"}
+ </div>
+ <input type="hidden" name="{$telpref}[removed]" value="0" />
+ <input type="text" size="10" maxlength="30" name="{$telpref}[type]" value="{$tel.type}" />
+ <input type="text" size="19" maxlength="28" name="{$telpref}[tel]" value="{$tel.tel}" />
+ </div>
+ {/foreach}
</td>
</tr>
</table>
-<input type="hidden" name="{$adpref}[removed]" value="0"/>
{/foreach}
-{*
- {section name=i loop=$nb_adr start=1 max=$nb_adr}
- {assign var='adrid' value=$ordre_adrid[i]}
- {assign var='adr' value=$adresses.$adrid}
- {include file="geoloc/form.address.tpl" adr=$adr titre=$titre}
- <tr>
- <td class="colg">
- <span class="titre">Adresse:</span>
- </td>
- <td class="cold" colspan="4">
- <input type="radio" name="temporaire[{$adrid}]" value="0" {if !$adr.temporaire}checked="checked"{/if} />
- permanente
- <input type="radio" name="temporaire[{$adrid}]" value="1" {if $adr.temporaire}checked="checked"{/if} />
- temporaire
- </td>
- </tr>
- <tr>
- <td class="colg">
-
- </td>
- <td class="cold" colspan="4">
- <input type="radio" name="secondaire[{$adrid}]" value="0" {if !$adr.secondaire}checked="checked"{/if} />
- ma résidence principale
- <input type="radio" name="secondaire[{$adrid}]" value="1" {if $adr.secondaire}checked="checked"{/if} />
- une résidence secondaire
- </td>
- </tr>
- <tr>
- <td class="colg">
-
- </td>
- <td class="cold" colspan="4">
- <input type="checkbox" name="courrier[{$adrid}]" value="1" {if $adr.courrier}checked="checked"{/if} /> on peut m'y envoyer du courrier par la poste
- </td>
- </tr>
- {foreach from=$adr.tels item="tel"}
- <tr class="flags">
- <td class="colg">
- <input type="hidden" name="telid{$tel.telid}[{$adrid}]" value="{$tel.telid}"/>
- {if $tel.new_tel && !$tel.tel}
- <input type="hidden" name="new_tel{$tel.telid}[{$adrid}]" value="1"/>
- {/if}
- <span class="titre" onclick="this.style.display='none';var d = document.getElementById('tel_type{$adrid}_{$tel.telid}');d.style.display='inline';d.select();d.focus();">{$tel.tel_type} :</span>
- <input id="tel_type{$adrid}_{$tel.telid}" style="display:none" type="text" size="5" maxlength="30" name="tel_type{$tel.telid}[{$adrid}]" value="{$tel.tel_type}"/>
- </td>
- <td>
- <input type="text" size="19" maxlength="28" name="tel{$tel.telid}[{$adrid}]" value="{$tel.tel}" />
- {if $tel.tel}
- <a href="profile/edit/{$onglet}?adrid={$adrid}&telid={$tel.telid}&deltel=1">{icon name=cross title="Supprimer ce tél."}</a>
- {/if}
- </td>
- {include file="include/flags.radio.tpl" name="tel_pub`$tel.telid`[$adrid]" val=$tel.tel_pub display="mini"}
- </tr>
- {/foreach}
- <tr><td colspan="5"> </td></tr>
- {/section}
- <tr><td colspan="5"> </td></tr>
- </table>
-*}
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}