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