Subversion Repositories Sites.obs-saisons.fr

Rev

Rev 70 | Rev 95 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 70 Rev 83
1
<?php
1
<?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
 * Classe de test des Controleurs.
4
 * Classe de test des Controleurs.
5
 *
5
 *
6
 * @package     Collection
6
 * @package     Collection
7
 * @category    Php 5.2
7
 * @category    Php 5.2
8
 * @author      Jean-Pascal MILCENT <jpm@tela-botanica.org>
8
 * @author      Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @copyright   2010 Tela-Botanica
9
 * @copyright   2010 Tela-Botanica
10
 * @license     http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
10
 * @license     http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
11
 * @license     http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
11
 * @license     http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
12
 * @version     SVN: $Id: Fiche.php 152 2010-09-06 16:19:12Z jpm $
12
 * @version     SVN: $Id: Fiche.php 152 2010-09-06 16:19:12Z jpm $
13
 */
13
 */
14
class Station extends aControleur {
14
class Station extends aControleur {
15
 
15
 
16
	private $id_station_en_cours = null;
16
	private $id_station_en_cours = null;
17
   
17
   
18
    public function __construct()  {
18
    public function __construct()  {
19
    	
19
    	
20
		parent::__construct();
20
		parent::__construct();
21
        $this->initialiser();
21
        $this->initialiser();
22
    }
22
    }
23
    
23
    
24
    public function initialiser() {
24
    public function initialiser() {
25
    	
25
    	
26
    	if(isset($_GET['id_station'])) {
26
    	if(isset($_GET['id_station'])) {
27
    		$this->id_station_en_cours = $_GET['id_station'];
27
    		$this->id_station_en_cours = $_GET['id_station'];
28
    	}
28
    	}
29
    	$this->setNavigation();
29
    	$this->setNavigation();
30
    	
30
    	
31
    }
31
    }
32
    
32
    
33
    public function executerActionParDefaut() {
33
    public function executerActionParDefaut() {
34
    	return $this->afficherFormulaireSaisieStation();
34
    	return $this->afficherFormulaireSaisieStation();
35
    }
35
    }
36
    
36
    
37
   	// +---------------------------------------------------------------------------------------------------------------+
37
   	// +---------------------------------------------------------------------------------------------------------------+
38
    // METHODES D'AFFICHAGE DE FORMULAIRE 
38
    // METHODES D'AFFICHAGE DE FORMULAIRE 
39
    public function afficherFormulaireSaisieStation() {
39
    public function afficherFormulaireSaisieStation() {
40
    	
40
    	
41
    	$donnees = array();
41
    	$donnees = array();
-
 
42
    	
-
 
43
    	$donnees['milieux'] = $this->getListeMilieux();
42
    	$formulaire = $this->getVue('formulaires/station_saisie',$donnees);
44
    	$formulaire = $this->getVue('formulaires/station_saisie',$donnees);
43
    	$this->setSortie(self::RENDU_CORPS, $formulaire);     
45
    	$this->setSortie(self::RENDU_CORPS, $formulaire);     
44
    }
46
    }
45
    
47
    
46
	public function afficherFormulaireModificationStation() {
48
	public function afficherFormulaireModificationStation() {
47
		
49
		
48
    	$donnees = array();
50
    	$donnees = array();
49
    	
51
    	
50
    	$id_station = $this->id_station_en_cours;
52
    	$id_station = $this->id_station_en_cours;
-
 
53
    	$donnees['milieux'] = $this->getListeMilieux();
51
    	$donnees['infos_station'] = $this->getInformationsStation($id_station);
54
    	$donnees['infos_station'] = $this->getInformationsStation($id_station);
-
 
55
    	
52
    	$formulaire = $this->getVue('formulaires/station_modification',$donnees);
56
    	$formulaire = $this->getVue('formulaires/station_modification',$donnees);
53
    	$this->setSortie(self::RENDU_CORPS, $formulaire);     
57
    	$this->setSortie(self::RENDU_CORPS, $formulaire);     
54
    }
58
    }
55
    
59
    
56
    // +---------------------------------------------------------------------------------------------------------------+
60
    // +---------------------------------------------------------------------------------------------------------------+
57
    // METHODES APPELEES LORS DE LA VALIDATION D'UN FORMULAIRE
61
    // METHODES APPELEES LORS DE LA VALIDATION D'UN FORMULAIRE
58
    public function validerFormulaireSaisieStation() {
62
    public function validerFormulaireSaisieStation() {
59
    	
63
    	
60
    	$valeurs_verifiees = $this->collecterValeursFormulaireSaisieStation();
64
    	$valeurs_verifiees = $this->collecterValeursFormulaireSaisieStation();
61
    	
65
    	
62
    	$station_dao = new StationDao();
66
    	$station_dao = new StationDao();
63
    	$retour_ajout_station = $station_dao->ajouterStation($valeurs_verifiees);
67
    	$retour_ajout_station = $station_dao->ajouterStation($valeurs_verifiees);
64
    	
68
    	
65
    	if($id_nouvelle_station = $this->renvoyerIdSiAjoutStationEffectue($retour_ajout_station)) {
69
    	if($id_nouvelle_station = $this->renvoyerIdSiAjoutStationEffectue($retour_ajout_station)) {
66
    		$this->id_station_en_cours = $id_nouvelle_station;
70
    		$this->id_station_en_cours = $id_nouvelle_station;
67
    		$this->afficherInformationsStation();  
71
    		$this->afficherInformationsStation();  
68
    		$this->setNavigation();
72
    		$this->setNavigation();
69
    	}
73
    	}
70
    }
74
    }
71
    
75
    
72
    private function renvoyerIdSiAjoutStationEffectue($donnees_retour_dao) {
76
    private function renvoyerIdSiAjoutStationEffectue($donnees_retour_dao) {
73
    	
77
    	
74
    	if(isset($donnees_retour_dao['id_nouvelle_station'])) {
78
    	if(isset($donnees_retour_dao['id_nouvelle_station'])) {
75
    		return $donnees_retour_dao['id_nouvelle_station'];
79
    		return $donnees_retour_dao['id_nouvelle_station'];
76
    	}
80
    	}
77
    	
81
    	
78
    	return false;
82
    	return false;
79
    }
83
    }
80
    
84
    
81
    private function collecterValeursFormulaireSaisieStation() {
85
    private function collecterValeursFormulaireSaisieStation() {
82
    	
86
    	
83
    	$valeurs_verifiees['station_commune'] = $_POST['station_commune'];
87
    	$valeurs_verifiees['station_commune'] = $_POST['station_commune'];
84
	    $valeurs_verifiees['station_milieu'] =  $_POST['station_milieu'];
88
	    $valeurs_verifiees['station_milieu'] =  $_POST['station_milieu'];
85
	    $valeurs_verifiees['station_nom'] = $_POST['station_nom'];
89
	    $valeurs_verifiees['station_nom'] = $_POST['station_nom'];
86
	    $valeurs_verifiees['station_lat'] =  $_POST['station_lat']; 
90
	    $valeurs_verifiees['station_lat'] =  $_POST['station_lat']; 
87
	    $valeurs_verifiees['station_lon'] = $_POST['station_lon'];
91
	    $valeurs_verifiees['station_lon'] = $_POST['station_lon'];
88
	    
92
	    
89
	    //TODO: verifier valeurs plus complètement
93
	    //TODO: verifier valeurs plus complètement
90
	    
94
	    
91
	    return $valeurs_verifiees;
95
	    return $valeurs_verifiees;
92
    	
96
    	
93
    }
97
    }
94
    
98
    
95
    public function validerFormulaireModificationStation() {
99
    public function validerFormulaireModificationStation() {
96
    	
100
    	
97
    	$valeurs_formulaires = $_POST['form_modif_station'];
101
    	$valeurs_formulaires = $_POST['form_modif_station'];
98
    	
102
    	
99
    	$valeurs_verifiees = array();
103
    	$valeurs_verifiees = array();
100
    	
104
    	
101
    	$station_dao = new StationDao();
105
    	$station_dao = new StationDao();
102
    	$station_dao->modifierStation($valeurs_verifiees);
106
    	$station_dao->modifierStation($valeurs_verifiees);
103
    	
107
    	
104
    }
108
    }
105
        
109
        
106
	// +---------------------------------------------------------------------------------------------------------------+
110
	// +---------------------------------------------------------------------------------------------------------------+
107
    // METHODES D'AFFICHAGES D'INFORMATION
111
    // METHODES D'AFFICHAGES D'INFORMATION
108
    public function afficherlisteStation($param = null) {	
112
    public function afficherlisteStation($param = null) {	
109
    	
113
    	
110
    	$id_utilisateur = AppControleur::getIdUtilisateur();
114
    	$id_utilisateur = AppControleur::getIdUtilisateur();
111
    	
115
    	
112
    	$donnees['stations'] = $this->getListeStations($id_utilisateur);
116
    	$donnees['stations'] = $this->getListeStations($id_utilisateur);
113
        $this->setSortie(self::RENDU_CORPS, $this->getVue('listes/station_liste', $donnees));
117
        $this->setSortie(self::RENDU_CORPS, $this->getVue('listes/station_liste', $donnees));
114
    }
118
    }
115
    
119
    
116
    public function afficherInformationsStation() {
120
    public function afficherInformationsStation() {
117
    	
121
    	
118
    	$id_station = $this->id_station_en_cours;
122
    	$id_station = $this->id_station_en_cours;
119
    	
123
    	
120
    	$donnees['id_station'] = $id_station;
124
    	$donnees['id_station'] = $id_station;
121
    	$donnees['infos_station'] = $this->getInformationsStation($id_station);
125
    	$donnees['infos_station'] = $this->getInformationsStation($id_station);
-
 
126
    	$donnees['milieux'] = $this->getListeMilieux();
122
    	
127
    	
123
    	$this->setSortie(self::RENDU_CORPS, $this->getVue('fiches/station_fiche', $donnees));
128
    	$this->setSortie(self::RENDU_CORPS, $this->getVue('fiches/station_fiche', $donnees));
124
    	
129
    	
125
    }
130
    }
126
   
131
   
127
    // +---------------------------------------------------------------------------------------------------------------+
132
    // +---------------------------------------------------------------------------------------------------------------+
128
    // METHODES POUR FABRIQUER LE MENU
133
    // METHODES POUR FABRIQUER LE MENU
129
    public function construireMenuNavigation($id_espece_en_cours = null) {
134
    public function construireMenuNavigation($id_espece_en_cours = null) {
130
    	    	    	
135
    	    	    	
131
    	$id_station_en_cours = $this->id_station_en_cours;
136
    	$id_station_en_cours = $this->id_station_en_cours;
132
    	
137
    	
133
    	if(isset($_GET['id_espece'])) {
138
    	if(isset($_GET['id_espece'])) {
134
    		$id_espece_en_cours = $_GET['id_espece'];
139
    		$id_espece_en_cours = $_GET['id_espece'];
135
    	}
140
    	}
136
 
141
 
137
    	
142
    	
138
    	$stations = $this->getListeStations();
143
    	$stations = $this->getListeStations();
139
    	    	
144
    	    	
140
    	foreach($stations as &$station) {  
145
    	foreach($stations as &$station) {  
141
    		        	
146
    		        	
142
    		$station['url'] = Liens::getUrlConsultationFicheStation($station['id']);
147
    		$station['url'] = Liens::getUrlConsultationFicheStation($station['id']);
143
    	}
148
    	}
144
    	
149
    	
145
    	if($id_station_en_cours != null) {
150
    	if($id_station_en_cours != null && $id_station_en_cours != 'saisie') {
146
    		$especes_station_en_cours = $this->getEspecesStation($id_station_en_cours);
151
    		$especes_station_en_cours = $this->getEspecesStation($id_station_en_cours);
147
    		
152
    		
148
    	    foreach($especes_station_en_cours as &$espece) {   		
153
    	    foreach($especes_station_en_cours as &$espece) {   		
149
    			$espece['url'] = Liens::getUrlConsultationEspeceStation($id_station_en_cours, $espece['id_espece']);
154
    			$espece['url'] = Liens::getUrlConsultationEspeceStation($id_station_en_cours, $espece['id_espece']);
150
    	    }
155
    	    }
151
    		$stations[$id_station_en_cours]['especes'] = $especes_station_en_cours;
156
    		$stations[$id_station_en_cours]['especes'] = $especes_station_en_cours;
152
    	}
157
    	}
153
    	
158
    	
154
    	$donnees['stations'] = $stations;
159
    	$donnees['stations'] = $stations;
155
    	$donnees['id_station_en_cours'] = $id_station_en_cours;
160
    	$donnees['id_station_en_cours'] = $id_station_en_cours;
156
 
161
 
157
    	$donnees['id_espece_en_cours'] = $id_espece_en_cours;
162
    	$donnees['id_espece_en_cours'] = $id_espece_en_cours;
158
    	
163
    	
159
    	$menu_navigation = $this->getVue('navigation/menu', $donnees);
164
    	$menu_navigation = $this->getVue('navigation/menu', $donnees);
160
    	
165
    	
161
        return $menu_navigation;
166
        return $menu_navigation;
162
        
167
        
163
    }
168
    }
164
    
169
    
165
    public function setNavigation() {
170
    public function setNavigation() {
166
    	$this->setSortie(self::RENDU_NAVIGATION, $this->construireMenuNavigation());
171
    	$this->setSortie(self::RENDU_NAVIGATION, $this->construireMenuNavigation());
167
    }
172
    }
168
    
173
    
169
    // +---------------------------------------------------------------------------------------------------------------+
174
    // +---------------------------------------------------------------------------------------------------------------+
170
    // METHODE D'APPELS AUX DAOS
175
    // METHODE D'APPELS AUX DAOS
171
    protected function getListeStations() { 
176
    protected function getListeStations() { 
172
    	   	
177
    	   	
173
    	$station_dao = new StationDao();
178
    	$station_dao = new StationDao();
174
    	return $station_dao->getListeStations();
179
    	return $station_dao->getListeStations();
175
    }
180
    }
176
    
181
    
177
    private function getInformationsStation($id_station) {
182
    private function getInformationsStation($id_station) {
178
    	
183
    	
179
    	$station_dao = new StationDao();
184
    	$station_dao = new StationDao();
180
    	$infos_station = $station_dao->getInformationsStation($id_station);
185
    	$infos_station = $station_dao->getInformationsStation($id_station);
181
    	
186
    	
182
    	$infos_station['individus'] = $this->getIndividusStation($id_station);
187
    	$infos_station['individus'] = $this->getIndividusStation($id_station);
183
    	
188
    	
184
    	return $infos_station;
189
    	return $infos_station;
185
    }
190
    }
186
    
191
    
187
    private function getEspecesStation($id_station) {
192
    private function getEspecesStation($id_station) {
188
    	
193
    	
189
    	$espece_dao = new EspeceDao();
194
    	$espece_dao = new EspeceDao();
190
    	$liste_especes = $espece_dao->getListeEspecesPourStation($id_station);
195
    	$liste_especes = $espece_dao->getListeEspecesPourStation($id_station);
191
    	
196
    	
192
    	return $liste_especes;
197
    	return $liste_especes;
193
    }
198
    }
194
    
199
    
195
    public function getIndividusStation($id_station) {
200
    public function getIndividusStation($id_station) {
196
    	
201
    	
197
    	$individu_dao = new IndividuDao();
202
    	$individu_dao = new IndividuDao();
198
    	$liste_individus = $individu_dao->getListeIndividusPourStation($id_station);
203
    	$liste_individus = $individu_dao->getListeIndividusPourStation($id_station);
199
    	
204
    	
200
    	return $liste_individus;
205
    	return $liste_individus;
201
    }
206
    }
202
    
207
    
203
	public function getIndividusStationPourEspece($id_station,$id_espece) {
208
	public function getIndividusStationPourEspece($id_station,$id_espece) {
204
    	
209
    	
205
    	$individu_dao = new IndividuDao();
210
    	$individu_dao = new IndividuDao();
206
    	$liste_individus = $individu_dao->getListeIndividusPourStationPourEspece($id_station, $id_espece);
211
    	$liste_individus = $individu_dao->getListeIndividusPourStationPourEspece($id_station, $id_espece);
207
    	
212
    	
208
    	return $liste_individus;
213
    	return $liste_individus;
209
    }
214
    }
-
 
215
    
-
 
216
    public function getListeMilieux() {
-
 
217
    	
-
 
218
    	$triple_dao = new TripleDao();
-
 
219
    	$liste_milieux = $triple_dao->getListeMilieux();
-
 
220
    	
-
 
221
    	return $liste_milieux;
-
 
222
    }
210
}
223
}
211
?>
224
?>