6bdc2a49f65d144ebee75d3f5ff8542d8f0e477d
2 /***************************************************************************
3 * Copyright (C) 2003-2006 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 ***************************************************************************/
21 //on génère une éventuelle nouvelle adresse
22 if (!isset($adresses) ||
(count($adresses) < $nb_adr_max)){
23 $adrid = generate_new_adrid();
24 $adresses[$adrid]['adrid'] = $adrid;
25 $adr = &$adresses[$adrid];
29 $adr['postcode'] = '';
31 $adr['country'] = '00';
33 $adr['secondaire'] = 1;
36 $adr['temporaire'] = 1;
37 $adr['pub'] = 'private';
38 $adr['nouvelle'] = 'new'; //n'est pas issue d'un formulaire (sert dans update_adresses...)
45 //on génère un éventuel nouveau tel pour chaque adresse
46 foreach($adresses as $adrid => $adr){
47 if (!isset($adr['tels'])) {
48 $adresses[$adrid]['tels'] = array(
49 array('tel' => '', 'tel_pub' => 'private', 'tel_type' => 'Tél.', 'telid' => 0, 'new_tel' => true
),
50 array('tel' => '', 'tel_pub' => 'private', 'tel_type' => 'Fax', 'telid' => 1, 'new_tel' => true
));
51 } elseif (count($adr['tels']) < $nb_tel_max) {
52 $adresses[$adrid]['tels'][] =
53 array('tel' => '', 'tel_pub' => 'private', 'tel_type' => 'Autre', 'telid' => generate_new_telid($adr), 'new_tel' => true
);
64 foreach($adresses as $adrid_ => $adr_){
65 if(($adresses[$adrid_]['active']) && ($adr_['nouvelle'] != 'new')){
66 $ordre_des_adrid[$i] = $adrid_;
68 $est_attribuee[$adrid_] = 1;
71 $est_attribuee[$adrid_] = 0;
75 foreach($adresses as $adrid_ => $adr_){
76 if(($adresses[$adrid_]['secondaire'] == 0) && ($est_attribuee[$adrid_] == 0) && ($adr_['nouvelle'] != 'new')){ // principale et non attribuee
77 $ordre_des_adrid[$i] = $adrid_;
79 $est_attribuee[$adrid_] = 1;
84 foreach($adresses as $adrid_ => $adr_){
85 if(($adresses[$adrid_]['temporaire'] == 0) && ($est_attribuee[$adrid_] == 0) && ($adr_['nouvelle'] != 'new')){ // permanente et non attribuee
86 $ordre_des_adrid[$i] = $adrid_;
88 $est_attribuee[$adrid_] = 1;
92 foreach($adresses as $adrid_ => $adr_){
93 if($est_attribuee[$adrid_] == 0){ // non attribuee
94 $ordre_des_adrid[$i] = $adrid_;
96 $est_attribuee[$adrid_] = 1;
101 $page->assign_by_ref('ordre_adrid',$ordre_des_adrid);
102 $page->assign('nb_adr',$nb_adr+
1);
104 $page->assign('adresses', $adresses);