reecriture des adresses dans le bon sens selon le pays
[platal.git] / include / profil / update_adresses.inc.php
1 <?php
2 /***************************************************************************
3 * Copyright (C) 2003-2004 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
5 * *
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. *
10 * *
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. *
15 * *
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 *
18 * Foundation, Inc., *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
21
22
23 reset($adresses);
24
25 foreach($adresses as $adrid => $adr){
26
27 if($adr['nouvelle'] != 'new'){ // test si on vient de creer cette adresse dans verif_adresse.inc.php
28
29 //construction des bits
30 $statut = "";
31 if ($adr["secondaire"]) $statut .= 'res-secondaire,';
32 if ($adr["courrier"]) $statut .= 'courrier,';
33 if ($adr["active"]) $statut .= 'active,';
34 if ($adr["temporaire"]) $statut .= 'temporaire,';
35 if (! empty($statut)) $statut = substr($statut, 0, -1);
36
37 if ($adr["nouvelle"] == 'ajout') {
38 //nouvelle adresse
39 $globals->xdb->execute("INSERT INTO adresses SET
40 adr1 = {?},
41 adr2 = {?},
42 adr3 = {?},
43 postcode = {?},
44 city = {?},
45 cityid = {?},
46 country = {?},
47 region = {?},
48 regiontxt = {?},
49 tel = {?},
50 fax = {?},
51 pub = {?},
52 tel_pub = {?},
53 datemaj = NOW(),
54 statut = {?},
55 uid = {?}, adrid = {?}",
56 $adr['adr1'],
57 $adr['adr2'],
58 $adr['adr3'],
59 $adr['postcode'],
60 $adr['city'],
61 $adr['cityid'],
62 $adr['country'],
63 $adr['region'],
64 $adr['regiontxt'],
65 $adr['tel'],
66 $adr['fax'],
67 $adr['pub'],
68 $adr['tel_pub'],
69 $statut,
70 Session::getInt('uid', -1), $adrid);
71 }
72
73 else{
74 //c'est une mise à jour
75 $globals->xdb->execute(
76 "UPDATE adresses SET
77 adr1 = {?},
78 adr2 = {?},
79 adr3 = {?},
80 postcode = {?},
81 city = {?},
82 cityid = {?},
83 country = {?},
84 region = {?},
85 regiontxt = {?},
86 tel = {?},
87 fax = {?},
88 pub = {?},
89 tel_pub = {?},
90 datemaj = NOW(),
91 statut = {?}
92 WHERE uid = {?} AND adrid = {?}",
93 $adr['adr1'],
94 $adr['adr2'],
95 $adr['adr3'],
96 $adr['postcode'],
97 $adr['city'],
98 $adr['cityid'],
99 $adr['country'],
100 $adr['region'],
101 $adr['regiontxt'],
102 $adr['tel'],
103 $adr['fax'],
104 $adr['pub'],
105 $adr['tel_pub'],
106 $statut,
107 Session::getInt('uid', -1), $adrid
108 );
109 }// fin nouvelle / ancienne adresse
110 }//fin if nouvellement crée
111 }//fin foreach
112 ?>