74bd2aba3959657dbc2416ee6e90f5b057c2090e
2 /***************************************************************************
3 * Copyright (C) 2003-2004 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 require_once('geoloc.inc.php');
24 // on limite à 6 adresses personnelles par utilisateur
25 $nb_adr_max = 6; // ( = max(adrid possibles)
27 //les adresses sont stockées dans un tableau global indéxé par adrid;
29 function is_adr_empty($adrid){
30 $adr = &$GLOBALS['adresses'][$adrid];
32 ($adr['adr1'] == '') && ($adr['adr2'] == '') && ($adr['adr3'] == '') &&
33 ($adr['postcode'] == '') && ($adr['city'] == '') && ($adr['country'] == '00') &&
34 ($adr['tel'] == '') && ($adr['fax'] == '')
38 function delete_address($adrid, $in_request_array = false
){
40 $globals->xdb
->execute("DELETE FROM adresses WHERE uid = {?} AND adrid = {?}",Session
::getInt('uid', -1), $adrid);
41 if($in_request_array == true
){
42 unset($_REQUEST['adrid'][$adrid]);
45 unset($GLOBALS['adresses'][$adrid]);
49 //on verifie si on nous a demande une suppression
50 $req_adrid_del = Env
::getMixed('adrid_del', Array());
51 for($i = 1; $i <= $nb_adr_max; $i++
){
52 if( isset( $req_adrid_del[$i] ) ) {
53 delete_address($i,true
);
57 //$sql_order = "ORDER BY (NOT FIND_IN_SET('active', statut)), FIND_IN_SET('temporaire', statut)";
60 //recuperation des adrid
61 $res = $globals->xdb
->query("SELECT adrid FROM adresses WHERE uid = {?} AND NOT FIND_IN_SET('pro', statut) ".$sql_order, Session
::getInt('uid', -1));
62 $adrids = $res->fetchColumn();
64 //recuperation des donnees de la bd
65 $res = $globals->xdb
->iterRow(
67 FIND_IN_SET('res-secondaire', statut), FIND_IN_SET('courrier', statut),
68 FIND_IN_SET('active', statut), FIND_IN_SET('temporaire', statut),
69 adr1, adr2, adr3, postcode, city, cityid,
70 a.country, region, regiontxt, tel, fax, pub, tel_pub,
71 gp.pays AS countrytxt, gp.display
72 FROM adresses AS a INNER JOIN geoloc_pays AS gp ON(gp.a2 = a.country)
73 WHERE uid = {?} AND NOT FIND_IN_SET('pro',statut) ".$sql_order
74 , Session
::getInt('uid', -1)
77 $nb_adr = $res->total();
79 for ($i = 0; $i < $nb_adr; $i++
) {
81 $adresses[$adrid]['adrid'] = $adrid;
83 $adresses[$adrid]['secondaire'], $adresses[$adrid]['courrier'],
84 $adresses[$adrid]['active'], $adresses[$adrid]['temporaire'],
85 $adresses[$adrid]['adr1'], $adresses[$adrid]['adr2'], $adresses[$adrid]['adr3'], $adresses[$adrid]['postcode'], $adresses[$adrid]['city'], $adresses[$adrid]['cityid'],
86 $adresses[$adrid]['country'], $adresses[$adrid]['region'], $adresses[$adrid]['regiontxt'], $adresses[$adrid]['tel'], $adresses[$adrid]['fax'],
87 $adresses[$adrid]['pub'],
88 $adresses[$adrid]['tel_pub'],$adresses[$adrid]['countrytxt'],$adresses[$adrid]['display']) = $res->next();
89 $adresses[$adrid]['nouvelle'] = 'modif';
90 $adresses[$adrid]['numero_formulaire'] = -1;
91 require_once('geoloc.inc.php');
92 $adresses[$adrid]['txt'] = get_address_text($adresses[$adrid]);