| Line 10... |
Line 10... |
| 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 Observation extends aControleur {
|
14 |
class Observation extends aControleur {
|
| 15 |
|
15 |
|
| 16 |
private $id_observation_en_cours = null;
|
16 |
private $id_observation_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_observation'])) {
|
26 |
if(isset($_GET['$id_observation'])) {
|
| 27 |
$this->id_observation_en_cours = $_GET['id_observation'];
|
27 |
$this->id_observation_en_cours = $_GET['id_observation'];
|
| 28 |
}
|
28 |
}
|
| 29 |
$this->setNavigation();
|
29 |
$this->setNavigation();
|
| 30 |
}
|
30 |
}
|
| 31 |
|
31 |
|
| 32 |
public function executerActionParDefaut() {
|
32 |
public function executerActionParDefaut() {
|
| 33 |
return $this->afficherFormulaireAjoutIndividu();
|
33 |
return $this->afficherFormulaireAjoutIndividu();
|
| 34 |
}
|
34 |
}
|
| 35 |
|
35 |
|
| 36 |
|
36 |
|
| 37 |
public function afficherFormulaireAjoutObservation($id_individu) {
|
37 |
public function afficherFormulaireAjoutObservation($id_individu) {
|
| 38 |
$donnees = array();
|
38 |
$donnees = array();
|
| 39 |
$formulaire = $this->getVue('formulaires/observation_saisie',$donnees);
|
39 |
$formulaire = $this->getVue('formulaires/observation_saisie',$donnees);
|
| 40 |
$this->setSortie(self::RENDU_CORPS, $formulaire);
|
40 |
$this->setSortie(self::RENDU_CORPS, $formulaire);
|
| 41 |
}
|
41 |
}
|
| 42 |
|
42 |
|
| 43 |
public function afficherFormulaireModificationObservation() {
|
43 |
public function afficherFormulaireModificationObservation() {
|
| 44 |
|
44 |
|
| 45 |
$id_individu_a_modifier_observation = $_GET['id_individu'];
|
45 |
$id_individu_a_modifier_observation = $_GET['id_individu'];
|
| 46 |
|
46 |
|
| 47 |
$id_espece = $_GET['id_espece'];
|
47 |
$id_espece = $_GET['id_espece'];
|
| 48 |
$id_station = $_GET['id_station'];
|
48 |
$id_station = $_GET['id_station'];
|
| 49 |
|
49 |
|
| 50 |
$id_utilisateur = AppControleur::getUtilisateur()->getIdentifiantNumerique();
|
50 |
$id_utilisateur = AppControleur::getUtilisateur()->getIdentifiantNumerique();
|
| 51 |
|
51 |
|
| 52 |
$espece = new Espece();
|
52 |
$espece = new Espece();
|
| 53 |
$evenements = $espece->getListeEvenementPourEspece($id_espece);
|
53 |
$evenements = $espece->getListeEvenementPourEspece($id_espece);
|
| 54 |
|
54 |
|
| 55 |
$station = new Station();
|
55 |
$station = new Station();
|
| 56 |
|
56 |
|
| 57 |
$individus = $station->getIndividusStationPourEspece($id_station,$id_espece);
|
57 |
$individus = $station->getIndividusStationPourEspece($id_station,$id_espece);
|
| 58 |
foreach($individus as &$individu) {
|
58 |
foreach($individus as &$individu) {
|
| 59 |
|
59 |
|
| 60 |
$observation = new Observation();
|
60 |
$observation = new Observation();
|
| 61 |
$individu['observations'] = $observation->getListeObservationsPourIndividu($individu['id_individu']);
|
61 |
$individu['observations'] = $observation->getListeObservationsPourIndividu($individu['id_individu']);
|
| 62 |
$individu['url'] = Liens::getUrlConsultationFicheIndividu($id_station,$id_espece, $individu['id_individu']);
|
62 |
$individu['url'] = Liens::getUrlConsultationFicheIndividu($id_station,$id_espece, $individu['id_individu']);
|
| 63 |
|
63 |
|
| 64 |
}
|
64 |
}
|
| 65 |
|
65 |
|
| 66 |
$donnees['evenements'] = $evenements;
|
66 |
$donnees['evenements'] = $evenements;
|
| 67 |
$donnees['stades'] = $this->aplatirListeEvenementHierachiseeEnListeParStades($evenements);
|
67 |
$donnees['stades'] = $this->aplatirListeEvenementHierachiseeEnListeParStades($evenements);
|
| 68 |
$donnees['individus'] = $individus;
|
68 |
$donnees['individus'] = $individus;
|
| 69 |
$donnees['id_station'] = $_GET['id_station'];
|
69 |
$donnees['id_station'] = $_GET['id_station'];
|
| 70 |
$donnees['id_espece'] = $_GET['id_espece'];
|
70 |
$donnees['id_espece'] = $_GET['id_espece'];
|
| 71 |
|
71 |
|
| 72 |
if(isset($_GET['annee'])) {
|
72 |
if(isset($_GET['annee'])) {
|
| 73 |
$donnees['annee'] = $_GET['annee'];
|
73 |
$donnees['annee'] = $_GET['annee'];
|
| 74 |
} else {
|
74 |
} else {
|
| 75 |
$donnees['annee'] = date('Y');
|
75 |
$donnees['annee'] = date('Y');
|
| 76 |
}
|
76 |
}
|
| 77 |
|
77 |
|
| 78 |
$donnees['id_individu_a_modifier_observation'] = $id_individu_a_modifier_observation;
|
78 |
$donnees['id_individu_a_modifier_observation'] = $id_individu_a_modifier_observation;
|
| Line 79... |
Line 79... |
| 79 |
|
79 |
|
| 80 |
$this->setSortie(self::RENDU_CORPS, $this->getVue('formulaires/evenement_modification', $donnees));
|
80 |
$this->setSortie(self::RENDU_CORPS, $this->getVue('formulaires/evenement_modification', $donnees));
|
| 81 |
}
|
81 |
}
|
| 82 |
|
82 |
|
| 83 |
// +---------------------------------------------------------------------------------------------------------------+
|
83 |
// +---------------------------------------------------------------------------------------------------------------+
|
| 84 |
// METHODES POUR FABRIQUER LE MENU
|
84 |
// METHODES POUR FABRIQUER LE MENU
|
| 85 |
public function setNavigation() {
|
85 |
public function setNavigation() {
|
| 86 |
|
86 |
|
| 87 |
$station = new Station();
|
87 |
$station = new Station();
|
| 88 |
$this->setSortie(self::RENDU_NAVIGATION, $station->construireMenuNavigation());
|
88 |
$this->setSortie(self::RENDU_NAVIGATION, $station->construireMenuNavigation());
|
| 89 |
}
|
89 |
}
|
| 90 |
|
90 |
|
| 91 |
// +---------------------------------------------------------------------------------------------------------------+
|
91 |
// +---------------------------------------------------------------------------------------------------------------+
|
| 92 |
// METHODES APPELEES LORS DE LA VALIDATION D'UN FORMULAIRE
|
92 |
// METHODES APPELEES LORS DE LA VALIDATION D'UN FORMULAIRE
|
| 93 |
public function validerFormulaireAjoutObservation() {
|
93 |
public function validerFormulaireAjoutObservation() {
|
| 94 |
|
94 |
|
| 95 |
$valeurs_formulaires = $_POST;
|
95 |
$valeurs_formulaires = $_POST;
|
| 96 |
|
96 |
|
| 97 |
$valeurs_verifiees = array();
|
97 |
$valeurs_verifiees = array();
|
| 98 |
|
98 |
|
| 99 |
$observation_dao = new ObservationDao();
|
99 |
$observation_dao = new ObservationDao();
|
| 100 |
$observation_dao->ajouterObservation($valeurs_verifiees);
|
100 |
$observation_dao->ajouterObservation($valeurs_verifiees);
|
| 101 |
|
101 |
|
| 102 |
}
|
102 |
}
|
| 103 |
|
103 |
|
| 104 |
public function validerFormulaireModificationObservation() {
|
104 |
public function validerFormulaireModificationObservation() {
|
| 105 |
|
105 |
|
| 106 |
$valeurs_verifiees = $this->collecterValeursFormulaireModificationObservation();
|
106 |
$valeurs_verifiees = $this->collecterValeursFormulaireModificationObservation();
|
| 107 |
|
107 |
|
| 108 |
$observation_dao = new ObservationDao();
|
108 |
$observation_dao = new ObservationDao();
|
| 109 |
$observation_dao->modifierObservation($valeurs_verifiees['id_individu'], $valeurs_verifiees);
|
109 |
$observation_dao->modifierObservation($valeurs_verifiees['id_individu'], $valeurs_verifiees);
|
| 110 |
|
110 |
|
| 111 |
$individu = new Individu();
|
111 |
$individu = new Individu();
|
| 112 |
|
112 |
|
| 113 |
$this->setSortie(self::RENDU_CORPS, $individu->getListeIndividu());
|
113 |
$this->setSortie(self::RENDU_CORPS, $individu->getListeIndividu());
|
| 114 |
|
114 |
|
| 115 |
}
|
115 |
}
|
| 116 |
|
116 |
|
| 117 |
public function validerFormulaireModificationObservationAjax() {
|
117 |
public function validerFormulaireModificationObservationAjax() {
|
| 118 |
|
118 |
|
| 119 |
$valeurs_verifiees = $this->collecterValeursFormulaireModificationObservation();
|
119 |
$valeurs_verifiees = $this->collecterValeursFormulaireModificationObservation();
|
| 120 |
|
120 |
|
| 121 |
$observation_dao = new ObservationDao();
|
121 |
$observation_dao = new ObservationDao();
|
| 122 |
$observation_dao->modifierObservation($valeurs_verifiees['id_individu'],$valeurs_verifiees);
|
122 |
$data = $observation_dao->modifierObservation($valeurs_verifiees['id_individu'],$valeurs_verifiees);
|
| 123 |
|
123 |
|
| Line 124... |
Line 124... |
| 124 |
$retour = array('reponse' => 'OK');
|
124 |
$retour = array('reponse' => 'OK', 'data' => $data);
|
| 125 |
|
125 |
|
| 126 |
header('Content-type: text/json');
|
126 |
header('Content-type: text/json');
|
| 127 |
echo json_encode($retour);
|
127 |
echo json_encode($retour);
|
| 128 |
exit;
|
128 |
exit;
|
| 129 |
}
|
129 |
}
|
| 130 |
|
130 |
|
| 131 |
private function collecterValeursFormulaireModificationObservation() {
|
131 |
private function collecterValeursFormulaireModificationObservation() {
|
| 132 |
|
- |
|
| 133 |
$valeurs_verifiees = array();
|
- |
|
| 134 |
|
- |
|
| 135 |
foreach($_POST as $nom_champ => $valeur) {
|
- |
|
| 136 |
|
- |
|
| 137 |
$id_si_est_champ_observation = $this->renvoyerIdEvenementSiChampDeFormulaireObservation($nom_champ);
|
- |
|
| 138 |
|
- |
|
| 139 |
if($id_si_est_champ_observation && trim($valeur) != '') {
|
- |
|
| 140 |
$valeurs_verifiees[$nom_champ] = $valeur;
|
- |
|
| 141 |
}
|
132 |
|
| 142 |
}
|
133 |
$valeurs_verifiees = array();
|
| 143 |
|
134 |
|
| 144 |
$valeurs_verifiees['id_individu'] = $_POST['id_individu'];
|
135 |
$valeurs_verifiees['id_individu'] = $_POST['id_individu'];
|
| 145 |
$valeurs_verifiees['annee_en_cours'] = $_POST['annee_en_cours'];
|
136 |
$valeurs_verifiees['annee_en_cours'] = $_POST['annee_en_cours'];
|
| - |
|
137 |
|
| - |
|
138 |
$valeurs_verifiees['id_evenement'] = $_POST['id_evenement'];
|
| - |
|
139 |
$valeurs_verifiees['date_evenement'] = $_POST['date_evenement'];
|
| - |
|
140 |
|
| - |
|
141 |
if(!empty($_POST['id_observation'])) {
|
| 146 |
|
142 |
$valeurs_verifiees['id_observation'] = $_POST['id_observation'];
|
| 147 |
//TODO: verifier valeurs plus complètement
|
143 |
}
|
| 148 |
|
- |
|
| 149 |
return $valeurs_verifiees;
|
- |
|
| 150 |
|
- |
|
| 151 |
}
|
- |
|
| 152 |
|
- |
|
| 153 |
private function renvoyerIdEvenementSiChampDeFormulaireObservation($champ) {
|
- |
|
| 154 |
|
- |
|
| 155 |
$tab_champ = explode('observation_',$champ);
|
- |
|
| 156 |
|
- |
|
| 157 |
if(count($tab_champ) > 1 && is_numeric($tab_champ[1])) {
|
- |
|
| 158 |
return $tab_champ[1];
|
- |
|
| 159 |
}
|
- |
|
| 160 |
|
144 |
|
| 161 |
return false;
|
145 |
return $valeurs_verifiees;
|
| 162 |
}
|
146 |
}
|
| 163 |
|
147 |
|
| 164 |
// +---------------------------------------------------------------------------------------------------------------+
|
148 |
// +---------------------------------------------------------------------------------------------------------------+
|
| 165 |
// METHODES DE RECHERCHE DE DONNEES
|
149 |
// METHODES DE RECHERCHE DE DONNEES
|
| 166 |
public function getListeObservationsPourIndividu($id_individu, $annee = null) {
|
150 |
public function getListeObservationsPourIndividu($id_individu, $annee = null) {
|
| 167 |
|
151 |
|
| 168 |
$observation_dao = new ObservationDao();
|
152 |
$observation_dao = new ObservationDao();
|
| 169 |
$observations_pour_individu = $observation_dao->getListeObservationsPourIndividu($id_individu, $annee);
|
153 |
$observations_pour_individu = $observation_dao->getListeObservationsPourIndividu($id_individu, $annee);
|
| 170 |
|
154 |
|
| 171 |
return $observations_pour_individu;
|
155 |
return $observations_pour_individu;
|
| 172 |
}
|
156 |
}
|
| 173 |
|
157 |
|
| 174 |
|
158 |
|
| 175 |
private function aplatirListeEvenementHierachiseeEnListeParStades($liste_evenements_hierarchisee) {
|
159 |
private function aplatirListeEvenementHierachiseeEnListeParStades($liste_evenements_hierarchisee) {
|
| 176 |
|
160 |
|
| 177 |
$liste_evenements_plate_par_stade = array();
|
161 |
$liste_evenements_plate_par_stade = array();
|
| 178 |
|
162 |
|
| 179 |
foreach($liste_evenements_hierarchisee as $evenement_hierarchise) {
|
163 |
foreach($liste_evenements_hierarchisee as $evenement_hierarchise) {
|
| 180 |
foreach($evenement_hierarchise['stades'] as $id_stade => $stade) {
|
164 |
foreach($evenement_hierarchise['stades'] as $id_stade => $stade) {
|
| 181 |
$liste_evenements_plate_par_stade[$id_stade] = $stade;
|
165 |
$liste_evenements_plate_par_stade[$id_stade] = $stade;
|
| 182 |
}
|
166 |
}
|
| 183 |
}
|
167 |
}
|
| 184 |
|
168 |
|
| 185 |
return $liste_evenements_plate_par_stade;
|
169 |
return $liste_evenements_plate_par_stade;
|
| 186 |
}
|
170 |
}
|
| 187 |
|
171 |
|
| 188 |
// +---------------------------------------------------------------------------------------------------------------+
|
172 |
// +---------------------------------------------------------------------------------------------------------------+
|
| 189 |
// METHODES UTILITAIRES STATIQUES (UTILES POUR LES FORMULAIRES)
|
173 |
// METHODES UTILITAIRES STATIQUES (UTILES POUR LES FORMULAIRES)
|
| 190 |
public static function individuAObservationValidePourStade($individu, $annee, $evenement, $id_stade) {
|
174 |
public static function individuAObservationValidePourStade($individu, $annee, $evenement, $id_stade) {
|
| 191 |
|
175 |
|
| 192 |
return (isset($individu['observations'][$annee][$evenement][$id_stade]) && trim($individu['observations'][$annee][$evenement][$id_stade]) != '');
|
176 |
return (isset($individu['observations'][$annee][$evenement][$id_stade]) && trim($individu['observations'][$annee][$evenement][$id_stade]) != '');
|
| 193 |
}
|
177 |
}
|
| 194 |
|
178 |
|
| 195 |
public static function renvoyerObservationStadePourIndividu($individu, $annee, $evenement, $id_stade) {
|
179 |
public static function renvoyerObservationStadePourIndividu($individu, $annee, $evenement, $id_stade) {
|
| 196 |
|
180 |
|
| 197 |
if(self::individuAObservationValidePourStade($individu, $annee, $evenement, $id_stade)) {
|
181 |
if(self::individuAObservationValidePourStade($individu, $annee, $evenement, $id_stade)) {
|
| 198 |
return $individu['observations'][$annee][$evenement][$id_stade];
|
182 |
return $individu['observations'][$annee][$evenement][$id_stade];
|
| 199 |
}
|
183 |
}
|
| 200 |
|
184 |
|
| 201 |
return '';
|
185 |
return '';
|
| 202 |
}
|
- |
|
| 203 |
}
|
186 |
}
|
| - |
|
187 |
}
|