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