0337d704 |
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 | tel = {?}, |
49 | fax = {?}, |
50 | pub = {?}, |
51 | tel_pub = {?}, |
52 | datemaj = NOW(), |
53 | statut = {?}, |
54 | uid = {?}, adrid = {?}", |
55 | $adr['adr1'], |
56 | $adr['adr2'], |
57 | $adr['adr3'], |
58 | $adr['postcode'], |
59 | $adr['city'], |
60 | $adr['cityid'], |
61 | $adr['country'], |
62 | $adr['region'], |
63 | $adr['tel'], |
64 | $adr['fax'], |
65 | $adr['pub'], |
66 | $adr['tel_pub'], |
67 | $statut, |
68 | Session::getInt('uid', -1), $adrid); |
69 | } |
70 | |
71 | else{ |
72 | //c'est une mise à jour |
73 | $globals->xdb->execute( |
74 | "UPDATE adresses SET |
75 | adr1 = {?}, |
76 | adr2 = {?}, |
77 | adr3 = {?}, |
78 | postcode = {?}, |
79 | city = {?}, |
80 | cityid = {?}, |
81 | country = {?}, |
82 | region = {?}, |
83 | tel = {?}, |
84 | fax = {?}, |
85 | pub = {?}, |
86 | tel_pub = {?}, |
87 | datemaj = NOW(), |
88 | statut = {?} |
89 | WHERE uid = {?} AND adrid = {?}", |
90 | $adr['adr1'], |
91 | $adr['adr2'], |
92 | $adr['adr3'], |
93 | $adr['postcode'], |
94 | $adr['city'], |
95 | $adr['cityid'], |
96 | $adr['country'], |
97 | $adr['region'], |
98 | $adr['tel'], |
99 | $adr['fax'], |
100 | $adr['pub'], |
101 | $adr['tel_pub'], |
102 | $statut, |
103 | Session::getInt('uid', -1), $adrid |
104 | ); |
105 | }// fin nouvelle / ancienne adresse |
106 | }//fin if nouvellement crée |
107 | }//fin foreach |
108 | ?> |