Subversion Repositories Sites.obs-saisons.fr

Rev

Rev 31 | Rev 43 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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