nb de tels variables par adresse, wish 400
[platal.git] / include / profil / assign_adresses.inc.php
CommitLineData
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 ***************************************************************************/
79a5acea 21//on génère une éventuelle nouvelle adresse
22if (!isset($adresses) || (count($adresses) < $nb_adr_max)){
23 $adrid = generate_new_adrid();
24 $adresses[$adrid]['adrid'] = $adrid;
25 $adr = &$adresses[$adrid];
26 $adr['adr1'] = '';
27 $adr['adr2'] = '';
28 $adr['adr3'] = '';
29 $adr['postcode'] = '';
30 $adr['city'] = '';
31 $adr['country'] = '00';
32 $adr['region'] = '';
33 $adr['secondaire'] = 1;
34 $adr['courrier'] = 0;
35 $adr['active'] = 0;
36 $adr['temporaire'] = 1;
37 $adr['pub'] = 'private';
38 $adr['nouvelle'] = 'new'; //n'est pas issue d'un formulaire (sert dans update_adresses...)
39}
40
41unset($adr);
42unset($adrid);
43
44reset($adresses);
45//on génère un éventuel nouveau tel pour chaque adresse
46foreach($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);
54 }
55}
56
57unset($adr);
58unset($adrid);
59
60//tri des adresses :
61
62reset($adresses);
63$i = 1;
64foreach($adresses as $adrid_ => $adr_){
65 if(($adresses[$adrid_]['active']) && ($adr_['nouvelle'] != 'new')){
66 $ordre_des_adrid[$i] = $adrid_;
67 $i++;
68 $est_attribuee[$adrid_] = 1;
69 }
70 else
71 $est_attribuee[$adrid_] = 0;
72}
73
74reset($adresses);
75foreach($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_;
78 $i++;
79 $est_attribuee[$adrid_] = 1;
80 }
81}
82
83reset($adresses);
84foreach($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_;
87 $i++;
88 $est_attribuee[$adrid_] = 1;
89 }
90}
91reset($adresses);
92foreach($adresses as $adrid_ => $adr_){
93 if($est_attribuee[$adrid_] == 0){ // non attribuee
94 $ordre_des_adrid[$i] = $adrid_;
95 $i++;
96 $est_attribuee[$adrid_] = 1;
97 }
98}
99
100$nb_adr = $i - 1;
101$page->assign_by_ref('ordre_adrid',$ordre_des_adrid);
102$page->assign('nb_adr',$nb_adr+1);
0337d704 103
104$page->assign('adresses', $adresses);
105
106?>