From 0b14f91d0a35ef3228101b9740164582a266ce04 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Mon, 27 Aug 2007 17:32:54 +0200 Subject: [PATCH] First version of the addresses page Signed-off-by: Florent Bruneau --- htdocs/css/keynote.css | 8 +++ modules/profile.php | 2 +- modules/profile/addresses.inc.php | 107 ++++++++++++++++++++++++++++++++++++++ modules/profile/page.inc.php | 1 + modules/profile/tabs.inc.php | 54 ------------------- templates/core/plwizard.tpl | 2 +- templates/geoloc/form.address.tpl | 62 +++++++++++----------- templates/include/flags.radio.tpl | 4 ++ templates/profile/adresses.tpl | 81 ++++++++++++++--------------- 9 files changed, 189 insertions(+), 132 deletions(-) create mode 100644 modules/profile/addresses.inc.php delete mode 100644 modules/profile/tabs.inc.php diff --git a/htdocs/css/keynote.css b/htdocs/css/keynote.css index 1672ed6..deac8c4 100644 --- a/htdocs/css/keynote.css +++ b/htdocs/css/keynote.css @@ -105,6 +105,14 @@ input.error, textarea.error { background-color: #faa; } +input.valid, textarea.valid { + background-color: #afa; +} + +input.warning, textarea.warning { + background-color: #fda; +} + h1 { background-color: inherit; margin: 0.5em 0 0.5em -8px; diff --git a/modules/profile.php b/modules/profile.php index 5a3f125..b649045 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -313,7 +313,7 @@ class ProfileModule extends PLModule $wiz = new PlWizard('Profil', 'core/plwizard.tpl', true); require_once dirname(__FILE__) . '/profile/page.inc.php'; $wiz->addPage('ProfileGeneral', 'Général', 'general'); - $wiz->addPage('ProfileAddress', 'Adresses personnelles', 'adresses'); + $wiz->addPage('ProfileAddresses', 'Adresses personnelles', 'adresses'); $wiz->addPage('ProfileGroups', 'Groupes X - Binets', 'poly'); $wiz->addPage('ProfileDeco', 'Décorations - Medals', 'deco'); $wiz->addPage('ProfilePro', 'Informations professionnelles', 'emploi'); diff --git a/modules/profile/addresses.inc.php b/modules/profile/addresses.inc.php new file mode 100644 index 0000000..1ea8869 --- /dev/null +++ b/modules/profile/addresses.inc.php @@ -0,0 +1,107 @@ +values['addresses']; + } + foreach ($value as $key=>&$adr) { + if ($adr['removed']) { + unset($value[$key]); + } + } + return $value; + } +} + +class ProfileAddresses extends ProfilePage +{ + protected $pg_template = 'profile/adresses.tpl'; + + public function __construct(PlWizard &$wiz) + { + parent::__construct($wiz); + $this->settings['addresses'] = new ProfileAddress(); + } + + protected function fetchData() + { + if (count($this->orig) > 0) { + $this->values = $this->orig; + 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 = {?} + 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')); + $i = 0; + while (list($adrid, $telid, $type, $pub, $tel) = $res->next()) { + while ($this->values['addresses'][$i]['id'] < $adrid) { + $i++; + } + $address =& $this->values['addresses'][$i]; + if (!isset($address['tel'])) { + $address['tel'] = array(); + } + if ($address['id'] == $adrid) { + $address['tel'][] = array('id' => $telid, + 'type' => $type, + 'pub' => $pub, + 'tel' => $tel); + } + } + parent::fetchData(); + } + + protected function saveData() + { + parent::saveData(); + } + + public function prepare(PlatalPage &$page) + { + parent::prepare($page); + } +} + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +?> diff --git a/modules/profile/page.inc.php b/modules/profile/page.inc.php index d014989..d85bfce 100644 --- a/modules/profile/page.inc.php +++ b/modules/profile/page.inc.php @@ -224,6 +224,7 @@ abstract class ProfilePage implements PlWizardPage } require_once dirname(__FILE__) . '/general.inc.php'; +require_once dirname(__FILE__) . '/addresses.inc.php'; // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?> diff --git a/modules/profile/tabs.inc.php b/modules/profile/tabs.inc.php deleted file mode 100644 index 34b74ae..0000000 --- a/modules/profile/tabs.inc.php +++ /dev/null @@ -1,54 +0,0 @@ - "Général", - "adresses" => "Adresses\npersonnelles", - "poly" => "Groupes X\nBinets", - "deco" => "Décorations\nMédailles", - "emploi" => "Informations\nprofessionnelles", - "skill" => "Compétences\ndiverses", - "mentor" => "Mentoring" -); - -$page->assign('onglets', $GLOBALS['tabname_array']); - -function get_next_tab($tabname) { - $tabname_array = $GLOBALS['tabname_array']; - - reset ($tabname_array); - while (list($current_tab, ) = each($tabname_array)) { - if ($current_tab == $tabname){ - $res = key($tabname_array);// each() sets key to the next element - if (is_null($res)) { - reset($tabname_array); - return key($tabname_array); - } - return $res; - } - } - - return null; -} - -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: -?> diff --git a/templates/core/plwizard.tpl b/templates/core/plwizard.tpl index 138bc3f..3a0d2ad 100644 --- a/templates/core/plwizard.tpl +++ b/templates/core/plwizard.tpl @@ -32,7 +32,7 @@ {/foreach}
-
+
{foreach from=$xorg_errors item=err}
{$err|smarty:nodefaults}
{/foreach} diff --git a/templates/geoloc/form.address.tpl b/templates/geoloc/form.address.tpl index 4a14a05..ef72a4c 100644 --- a/templates/geoloc/form.address.tpl +++ b/templates/geoloc/form.address.tpl @@ -20,37 +20,33 @@ {* *} {**************************************************************************} - {if $adr.geoloc} - - - - La geolocalisation n'a pas donné un résultat certain, valide la nouvelle adresse ou modifie l'ancienne pour que ton adresse puisse être prise en compte.
- - -

- [Valider] -

- {else} - - - - - {/if} - - - - - - - - - - + +{if $adr.geoloc} +
+ La geolocalisation n'a pas donné un résultat certain, valide la nouvelle adresse + ou modifie l'ancienne pour que ton adresse puisse être prise en compte. +
+ +{/if} + +{if $adr.geoloc} + +

+ +

+{/if} + + + + + + + + {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/include/flags.radio.tpl b/templates/include/flags.radio.tpl index ab32d54..55cb846 100644 --- a/templates/include/flags.radio.tpl +++ b/templates/include/flags.radio.tpl @@ -20,8 +20,10 @@ {* *} {**************************************************************************} {if $display neq "mini"} + {if !$notable} + {/if}
@@ -47,8 +49,10 @@
+ {if !$notable} + {/if} {else} diff --git a/templates/profile/adresses.tpl b/templates/profile/adresses.tpl index 2f7b9da..4146af5 100644 --- a/templates/profile/adresses.tpl +++ b/templates/profile/adresses.tpl @@ -20,52 +20,48 @@ {* *} {**************************************************************************} + +{foreach key=i item=adr from=$addresses} +{assign var=adpref value="addresses[$i]"} +{assign var=adid value="addresses_$i"} + + + + + + + +
+
+ + +
+ + Adresse n°{$i + 1} +
+
{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}
+
+ +{/foreach} + +{* {section name=i loop=$nb_adr start=1 max=$nb_adr} - {* - $adrid = $ordre_adrid[$i]; - $adr = &$adresses[$adrid]; - *} {assign var='adrid' value=$ordre_adrid[i]} {assign var='adr' value=$adresses.$adrid} - - - - {if $adr.nouvelle != 'new'}Adresse n°{$smarty.section.i.index}{else}Rentre ici une nouvelle adresse{/if} - - {if $adr.nouvelle == 'new'} - - {else} - - {/if} - {if $adr.nouvelle != 'new'} - {icon name=cross title="Supprimer cette adresse"} - {/if} - - - {include file="include/flags.radio.tpl" name="pub[$adrid]" val=$adr.pub} - - -   - - - c'est à cette adresse que je suis actuellement - - - - {if $adr.nouvelle != 'new'} - {assign var="titre" value="Adresse n°`$smarty.section.i.index` :"} - {else} - {assign var="titre" value="Nouvelle adresse :"} - {/if} {include file="geoloc/form.address.tpl" adr=$adr titre=$titre} @@ -120,6 +116,5 @@ {/section}   -
- +*} {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} -- 2.1.4