Subversion Repositories Sites.obs-saisons.fr

Rev

Rev 63 | Rev 83 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 63 Rev 70
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'])) {
-
 
27
    		$this->id_station_en_cours = $_GET['id_station'];
26
    	$this->id_station_en_cours = $_GET['id_station'];
28
    	}
27
    	$this->setNavigation();
29
    	$this->setNavigation();
28
    	
30
    	
29
    }
31
    }
30
    
32
    
31
    public function executerActionParDefaut() {
33
    public function executerActionParDefaut() {
32
    	return $this->afficherFormulaireSaisieStation();
34
    	return $this->afficherFormulaireSaisieStation();
33
    }
35
    }
34
    
36
    
35
   	// +---------------------------------------------------------------------------------------------------------------+
37
   	// +---------------------------------------------------------------------------------------------------------------+
36
    // METHODES D'AFFICHAGE DE FORMULAIRE 
38
    // METHODES D'AFFICHAGE DE FORMULAIRE 
37
    public function afficherFormulaireSaisieStation() {
39
    public function afficherFormulaireSaisieStation() {
38
    	
40
    	
39
    	$donnees = array();
41
    	$donnees = array();
40
    	$formulaire = $this->getVue('formulaires/station_saisie',$donnees);
42
    	$formulaire = $this->getVue('formulaires/station_saisie',$donnees);
41
    	$this->setSortie(self::RENDU_CORPS, $formulaire);     
43
    	$this->setSortie(self::RENDU_CORPS, $formulaire);     
42
    }
44
    }
43
    
45
    
44
	public function afficherFormulaireModificationStation() {
46
	public function afficherFormulaireModificationStation() {
45
		
47
		
46
    	$donnees = array();
48
    	$donnees = array();
47
    	
49
    	
48
    	$id_station = $this->id_station_en_cours;
50
    	$id_station = $this->id_station_en_cours;
49
    	$donnees['infos_station'] = $this->getInformationsStation($id_station);
51
    	$donnees['infos_station'] = $this->getInformationsStation($id_station);
50
    	$formulaire = $this->getVue('formulaires/station_modification',$donnees);
52
    	$formulaire = $this->getVue('formulaires/station_modification',$donnees);
51
    	$this->setSortie(self::RENDU_CORPS, $formulaire);     
53
    	$this->setSortie(self::RENDU_CORPS, $formulaire);     
52
    }
54
    }
53
    
55
    
54
    // +---------------------------------------------------------------------------------------------------------------+
56
    // +---------------------------------------------------------------------------------------------------------------+
55
    // METHODES APPELEES LORS DE LA VALIDATION D'UN FORMULAIRE
57
    // METHODES APPELEES LORS DE LA VALIDATION D'UN FORMULAIRE
56
    public function validerFormulaireSaisieStation() {
58
    public function validerFormulaireSaisieStation() {
57
    	
59
    	
58
    	$valeurs_verifiees = $this->collecterValeursFormulaireSaisieStation();
60
    	$valeurs_verifiees = $this->collecterValeursFormulaireSaisieStation();
59
    	
61
    	
60
    	$station_dao = new StationDao();
62
    	$station_dao = new StationDao();
61
    	$retour_ajout_station = $station_dao->ajouterStation($valeurs_verifiees);
63
    	$retour_ajout_station = $station_dao->ajouterStation($valeurs_verifiees);
62
    	
64
    	
63
    	if($id_nouvelle_station = $this->renvoyerIdSiAjoutStationEffectue($retour_ajout_station)) {
65
    	if($id_nouvelle_station = $this->renvoyerIdSiAjoutStationEffectue($retour_ajout_station)) {
64
    		$this->id_station_en_cours = $id_nouvelle_station;
66
    		$this->id_station_en_cours = $id_nouvelle_station;
65
    		$this->afficherInformationsStation();  
67
    		$this->afficherInformationsStation();  
66
    		$this->setNavigation();
68
    		$this->setNavigation();
67
    	}
69
    	}
68
    }
70
    }
69
    
71
    
70
    private function renvoyerIdSiAjoutStationEffectue($donnees_retour_dao) {
72
    private function renvoyerIdSiAjoutStationEffectue($donnees_retour_dao) {
71
    	
73
    	
72
    	if(isset($donnees_retour_dao['id_nouvelle_station'])) {
74
    	if(isset($donnees_retour_dao['id_nouvelle_station'])) {
73
    		return $donnees_retour_dao['id_nouvelle_station'];
75
    		return $donnees_retour_dao['id_nouvelle_station'];
74
    	}
76
    	}
75
    	
77
    	
76
    	return false;
78
    	return false;
77
    }
79
    }
78
    
80
    
79
    private function collecterValeursFormulaireSaisieStation() {
81
    private function collecterValeursFormulaireSaisieStation() {
80
    	
82
    	
81
    	$valeurs_verifiees['station_commune'] = $_POST['station_commune'];
83
    	$valeurs_verifiees['station_commune'] = $_POST['station_commune'];
82
	    $valeurs_verifiees['station_milieu'] =  $_POST['station_milieu'];
84
	    $valeurs_verifiees['station_milieu'] =  $_POST['station_milieu'];
83
	    $valeurs_verifiees['station_nom'] = $_POST['station_nom'];
85
	    $valeurs_verifiees['station_nom'] = $_POST['station_nom'];
84
	    $valeurs_verifiees['station_lat'] =  $_POST['station_lat']; 
86
	    $valeurs_verifiees['station_lat'] =  $_POST['station_lat']; 
85
	    $valeurs_verifiees['station_lon'] = $_POST['station_lon'];
87
	    $valeurs_verifiees['station_lon'] = $_POST['station_lon'];
86
	    
88
	    
87
	    //TODO: verifier valeurs plus complètement
89
	    //TODO: verifier valeurs plus complètement
88
	    
90
	    
89
	    return $valeurs_verifiees;
91
	    return $valeurs_verifiees;
90
    	
92
    	
91
    }
93
    }
92
    
94
    
93
    public function validerFormulaireModificationStation() {
95
    public function validerFormulaireModificationStation() {
94
    	
96
    	
95
    	$valeurs_formulaires = $_POST['form_modif_station'];
97
    	$valeurs_formulaires = $_POST['form_modif_station'];
96
    	
98
    	
97
    	$valeurs_verifiees = array();
99
    	$valeurs_verifiees = array();
98
    	
100
    	
99
    	$station_dao = new StationDao();
101
    	$station_dao = new StationDao();
100
    	$station_dao->modifierStation($valeurs_verifiees);
102
    	$station_dao->modifierStation($valeurs_verifiees);
101
    	
103
    	
102
    }
104
    }
103
        
105
        
104
	// +---------------------------------------------------------------------------------------------------------------+
106
	// +---------------------------------------------------------------------------------------------------------------+
105
    // METHODES D'AFFICHAGES D'INFORMATION
107
    // METHODES D'AFFICHAGES D'INFORMATION
106
    public function afficherlisteStation($param = null) {	
108
    public function afficherlisteStation($param = null) {	
107
    	
109
    	
108
    	$id_utilisateur = AppControleur::getIdUtilisateur();
110
    	$id_utilisateur = AppControleur::getIdUtilisateur();
109
    	
111
    	
110
    	$donnees['stations'] = $this->getListeStations($id_utilisateur);
112
    	$donnees['stations'] = $this->getListeStations($id_utilisateur);
111
        $this->setSortie(self::RENDU_CORPS, $this->getVue('listes/station_liste', $donnees));
113
        $this->setSortie(self::RENDU_CORPS, $this->getVue('listes/station_liste', $donnees));
112
    }
114
    }
113
    
115
    
114
    public function afficherInformationsStation() {
116
    public function afficherInformationsStation() {
115
    	
117
    	
116
    	$id_station = $this->id_station_en_cours;
118
    	$id_station = $this->id_station_en_cours;
117
    	
119
    	
118
    	$donnees['id_station'] = $id_station;
120
    	$donnees['id_station'] = $id_station;
119
    	$donnees['infos_station'] = $this->getInformationsStation($id_station);
121
    	$donnees['infos_station'] = $this->getInformationsStation($id_station);
120
    	
122
    	
121
    	$this->setSortie(self::RENDU_CORPS, $this->getVue('fiches/station_fiche', $donnees));
123
    	$this->setSortie(self::RENDU_CORPS, $this->getVue('fiches/station_fiche', $donnees));
122
    	
124
    	
123
    }
125
    }
124
   
126
   
125
    // +---------------------------------------------------------------------------------------------------------------+
127
    // +---------------------------------------------------------------------------------------------------------------+
126
    // METHODES POUR FABRIQUER LE MENU
128
    // METHODES POUR FABRIQUER LE MENU
127
    public function construireMenuNavigation($espece_en_cours = null) {
129
    public function construireMenuNavigation($id_espece_en_cours = null) {
128
    	    	    	
130
    	    	    	
129
    	$id_station_en_cours = $this->id_station_en_cours;
-
 
130
    	$id_espece_en_cours = null;
131
    	$id_station_en_cours = $this->id_station_en_cours;
131
    	
132
    	
132
    	if(isset($_GET['id_espece'])) {
133
    	if(isset($_GET['id_espece'])) {
133
    		$id_espece_en_cours = $_GET['id_espece'];
134
    		$id_espece_en_cours = $_GET['id_espece'];
134
    	}
135
    	}
135
 
136
 
136
    	
137
    	
137
    	$stations = $this->getListeStations();
138
    	$stations = $this->getListeStations();
138
    	    	
139
    	    	
139
    	foreach($stations as &$station) {  
140
    	foreach($stations as &$station) {  
140
    		        	
141
    		        	
141
    		$station['url'] = Liens::instance()->getUrlConsultationFicheStation($station['id']);
142
    		$station['url'] = Liens::getUrlConsultationFicheStation($station['id']);
142
    	}
143
    	}
143
    	
144
    	
144
    	if($id_station_en_cours != null) {
145
    	if($id_station_en_cours != null) {
145
    		$especes_station_en_cours = $this->getEspecesStation($id_station_en_cours);
146
    		$especes_station_en_cours = $this->getEspecesStation($id_station_en_cours);
146
    		
147
    		
147
    	    foreach($especes_station_en_cours as &$espece) {   		
148
    	    foreach($especes_station_en_cours as &$espece) {   		
148
    			$espece['url'] = Liens::instance()->getUrlConsultationEspeceStation($id_station_en_cours, $espece['id_espece']);
149
    			$espece['url'] = Liens::getUrlConsultationEspeceStation($id_station_en_cours, $espece['id_espece']);
149
    	    }
150
    	    }
150
    		$stations[$id_station_en_cours]['especes'] = $especes_station_en_cours;
151
    		$stations[$id_station_en_cours]['especes'] = $especes_station_en_cours;
151
    	}
152
    	}
152
    	
153
    	
153
    	$donnees['stations'] = $stations;
154
    	$donnees['stations'] = $stations;
154
    	$donnees['id_station_en_cours'] = $id_station_en_cours;
155
    	$donnees['id_station_en_cours'] = $id_station_en_cours;
155
    	
-
 
156
    	if($id_espece_en_cours != null) {
156
 
157
    		$donnees['id_espece_en_cours'] = $id_espece_en_cours;
-
 
158
    	}
157
    	$donnees['id_espece_en_cours'] = $id_espece_en_cours;
159
    	
158
    	
160
    	$menu_navigation = $this->getVue('navigation/menu', $donnees);
159
    	$menu_navigation = $this->getVue('navigation/menu', $donnees);
161
    	
160
    	
162
        return $menu_navigation;
161
        return $menu_navigation;
163
        
162
        
164
    }
163
    }
165
    
164
    
166
    public function setNavigation() {
165
    public function setNavigation() {
167
    	$this->setSortie(self::RENDU_NAVIGATION, $this->construireMenuNavigation());
166
    	$this->setSortie(self::RENDU_NAVIGATION, $this->construireMenuNavigation());
168
    }
167
    }
169
    
168
    
170
    // +---------------------------------------------------------------------------------------------------------------+
169
    // +---------------------------------------------------------------------------------------------------------------+
171
    // METHODE D'APPELS AUX DAOS
170
    // METHODE D'APPELS AUX DAOS
172
    protected function getListeStations() { 
171
    protected function getListeStations() { 
173
    	   	
172
    	   	
174
    	$station_dao = new StationDao();
173
    	$station_dao = new StationDao();
175
    	return $station_dao->getListeStations();
174
    	return $station_dao->getListeStations();
176
    }
175
    }
177
    
176
    
178
    private function getInformationsStation($id_station) {
177
    private function getInformationsStation($id_station) {
179
    	
178
    	
180
    	$station_dao = new StationDao();
179
    	$station_dao = new StationDao();
181
    	$infos_station = $station_dao->getInformationsStation($id_station);
180
    	$infos_station = $station_dao->getInformationsStation($id_station);
182
    	
181
    	
183
    	$infos_station['individus'] = $this->getIndividusStation($id_station);
182
    	$infos_station['individus'] = $this->getIndividusStation($id_station);
184
    	
183
    	
185
    	return $infos_station;
184
    	return $infos_station;
186
    }
185
    }
187
    
186
    
188
    private function getEspecesStation($id_station) {
187
    private function getEspecesStation($id_station) {
189
    	
188
    	
190
    	$espece_dao = new EspeceDao();
189
    	$espece_dao = new EspeceDao();
191
    	$liste_especes = $espece_dao->getListeEspecesPourStation($id_station);
190
    	$liste_especes = $espece_dao->getListeEspecesPourStation($id_station);
192
    	
191
    	
193
    	return $liste_especes;
192
    	return $liste_especes;
194
    }
193
    }
195
    
194
    
196
    public function getIndividusStation($id_station) {
195
    public function getIndividusStation($id_station) {
197
    	
196
    	
198
    	$individu_dao = new IndividuDao();
197
    	$individu_dao = new IndividuDao();
199
    	$liste_individus = $individu_dao->getListeIndividusPourStation($id_station);
198
    	$liste_individus = $individu_dao->getListeIndividusPourStation($id_station);
200
    	
199
    	
201
    	return $liste_individus;
200
    	return $liste_individus;
202
    }
201
    }
203
    
202
    
204
	public function getIndividusStationPourEspece($id_station,$id_espece) {
203
	public function getIndividusStationPourEspece($id_station,$id_espece) {
205
    	
204
    	
206
    	$individu_dao = new IndividuDao();
205
    	$individu_dao = new IndividuDao();
207
    	$liste_individus = $individu_dao->getListeIndividusPourStationPourEspece($id_station, $id_espece);
206
    	$liste_individus = $individu_dao->getListeIndividusPourStationPourEspece($id_station, $id_espece);
208
    	
207
    	
209
    	return $liste_individus;
208
    	return $liste_individus;
210
    }
209
    }
211
} 
210
}
212
211
?>
-
 
212
213
213