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