From: Florent Bruneau Date: Mon, 27 Aug 2007 21:13:13 +0000 (+0200) Subject: Addresses page template X-Git-Tag: xorg/0.9.15~174^2~25 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=7568a515d7e3c4c992dd98b784165aa36b575ff9;p=platal.git Addresses page template Signed-off-by: Florent Bruneau --- diff --git a/htdocs/css/keynote.css b/htdocs/css/keynote.css index deac8c4..6fa6dc3 100644 --- a/htdocs/css/keynote.css +++ b/htdocs/css/keynote.css @@ -341,28 +341,33 @@ div.long td.rt { width: 65%; } 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{ diff --git a/modules/profile/addresses.inc.php b/modules/profile/addresses.inc.php index 1ea8869..34e36af 100644 --- a/modules/profile/addresses.inc.php +++ b/modules/profile/addresses.inc.php @@ -21,17 +21,46 @@ 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; } } @@ -53,28 +82,30 @@ class ProfileAddresses extends ProfilePage 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++; } @@ -83,12 +114,12 @@ class ProfileAddresses extends ProfilePage $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(); } diff --git a/templates/include/flags.radio.tpl b/templates/include/flags.radio.tpl index 55cb846..12c3729 100644 --- a/templates/include/flags.radio.tpl +++ b/templates/include/flags.radio.tpl @@ -19,7 +19,27 @@ {* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} {* *} {**************************************************************************} -{if $display neq "mini"} +{if $display eq "mini"} + + + + + + + + + +{elseif $display eq "div"} + + + + + + + + + +{else} {if !$notable} @@ -53,15 +73,5 @@ {/if} -{else} - - - - - - - - - {/if} {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/profile/adresses.tpl b/templates/profile/adresses.tpl index 4146af5..d1f70fe 100644 --- a/templates/profile/adresses.tpl +++ b/templates/profile/adresses.tpl @@ -34,6 +34,7 @@ function removeAddress(id, pref) {foreach key=i item=adr from=$addresses} {assign var=adpref value="addresses[$i]"} {assign var=adid value="addresses_$i"} + + + +
@@ -51,70 +52,46 @@ function removeAddress(id, pref)
{include file="include/flags.radio.tpl" name="$adpref[pub]" notable=true val=$adr.pub}
-
{include file="geoloc/form.address.tpl" name=$adpref id=$adid adr=$adr}
+
+
{include file="geoloc/form.address.tpl" name=$adpref id=$adid adr=$adr}
+
+
+ + +
+
+ + +
+
+ + +
+
+
+ {foreach from=$adr.tel key=t item=tel} + {assign var=telpref value="`$adpref`[tel][`$t`]"} + {assign var=telid value="`$adid`_tel_`$t`"} +
+
+ {include file="include/flags.radio.tpl" name="`$telpref`[pub]" val=$tel.pub display="div"} +
+ + + +
+ {/foreach}
- {/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} - - - Adresse: - - - - permanente - - temporaire - - - - -   - - - - ma résidence principale - - une résidence secondaire - - - - -   - - - on peut m'y envoyer du courrier par la poste - - - {foreach from=$adr.tels item="tel"} - - - - {if $tel.new_tel && !$tel.tel} - - {/if} - {$tel.tel_type} : - - - - - {if $tel.tel} - {icon name=cross title="Supprimer ce tél."} - {/if} - - {include file="include/flags.radio.tpl" name="tel_pub`$tel.telid`[$adrid]" val=$tel.tel_pub display="mini"} - - {/foreach} -   - {/section} -   - -*} {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}