| Line 36... |
Line 36... |
| 36 |
|
36 |
|
| 37 |
// +---------------------------------------------------------------------------------------------------------------+
|
37 |
// +---------------------------------------------------------------------------------------------------------------+
|
| 38 |
// METHODES D'AFFICHAGE DE FORMULAIRE
|
38 |
// METHODES D'AFFICHAGE DE FORMULAIRE
|
| Line 39... |
Line 39... |
| 39 |
public function afficherFormulaireSaisieStation($donnees = array()) {
|
39 |
public function afficherFormulaireSaisieStation($donnees = array()) {
|
| 40 |
|
- |
|
| 41 |
if($donnees == array()) {
|
40 |
|
| 42 |
|
41 |
if($donnees == array()) {
|
| 43 |
$donnees['station_commune'] = '';
|
42 |
$donnees['station_commune'] = '';
|
| 44 |
$donnees['station_milieu'] = '';
|
43 |
$donnees['station_milieu'] = '';
|
| 45 |
$donnees['station_nom'] = '';
|
44 |
$donnees['station_nom'] = '';
|
| 46 |
$donnees['station_lat'] = '';
|
45 |
$donnees['station_lat'] = '';
|
| 47 |
$donnees['station_lon'] = '';
|
46 |
$donnees['station_lon'] = '';
|
| 48 |
$donnees['station_alt'] = '';
|
47 |
$donnees['station_alt'] = '';
|
| Line 49... |
Line 48... |
| 49 |
$donnees['station_code_insee'] = '';
|
48 |
$donnees['station_code_insee'] = '';
|
| - |
|
49 |
}
|
| 50 |
}
|
50 |
|
| 51 |
|
51 |
$donnees['milieux'] = $this->getListeMilieux();
|
| 52 |
$donnees['milieux'] = $this->getListeMilieux();
|
52 |
$donnees['corps_formulaire_saisie_modif'] = $this->getVue('formulaires/station_saisie_modification',$donnees);
|
| Line 53... |
Line 53... |
| 53 |
$formulaire = $this->getVue('formulaires/station_saisie',$donnees);
|
53 |
$formulaire = $this->getVue('formulaires/station_saisie',$donnees);
|
| Line 54... |
Line 54... |
| 54 |
$this->setSortie(self::RENDU_CORPS, $formulaire);
|
54 |
$this->setSortie(self::RENDU_CORPS, $formulaire);
|
| - |
|
55 |
}
|
| - |
|
56 |
|
| - |
|
57 |
public function afficherFormulaireModificationStation($donnees = array()) {
|
| - |
|
58 |
|
| - |
|
59 |
$id_station = $this->id_station_en_cours;
|
| - |
|
60 |
if(empty($donnees)) {
|
| - |
|
61 |
$infos_station = $this->getInformationsStation($id_station);
|
| - |
|
62 |
$donnees['station_id'] = $id_station;
|
| - |
|
63 |
$donnees['station_commune'] = $infos_station['commune'];
|
| - |
|
64 |
$donnees['station_milieu'] = $infos_station['milieu'];
|
| - |
|
65 |
$donnees['station_nom'] = $infos_station['nom'];
|
| - |
|
66 |
$donnees['station_lat'] = $infos_station['latitude'];
|
| 55 |
}
|
67 |
$donnees['station_lon'] = $infos_station['longitude'];
|
| 56 |
|
68 |
$donnees['station_alt'] = $infos_station['altitude'];
|
| Line 57... |
Line 69... |
| 57 |
public function afficherFormulaireModificationStation($donnees = array()) {
|
69 |
$donnees['station_code_insee'] = $infos_station['code_insee'];
|
| 58 |
|
70 |
}
|
| 59 |
$id_station = $this->id_station_en_cours;
|
71 |
|
| Line 60... |
Line 72... |
| 60 |
$donnees['milieux'] = $this->getListeMilieux();
|
72 |
$donnees['milieux'] = $this->getListeMilieux();
|
| 61 |
$donnees['infos_station'] = $this->getInformationsStation($id_station);
|
73 |
$donnees['corps_formulaire_saisie_modif'] = $this->getVue('formulaires/station_saisie_modification',$donnees);
|
| 62 |
|
74 |
|
| Line 63... |
Line 75... |
| 63 |
$formulaire = $this->getVue('formulaires/station_modification',$donnees);
|
75 |
$formulaire = $this->getVue('formulaires/station_modification',$donnees);
|
| 64 |
$this->setSortie(self::RENDU_CORPS, $formulaire);
|
- |
|
| 65 |
}
|
76 |
$this->setSortie(self::RENDU_CORPS, $formulaire);
|
| Line 66... |
Line 77... |
| 66 |
|
77 |
}
|
| 67 |
// +---------------------------------------------------------------------------------------------------------------+
|
- |
|
| 68 |
// METHODES APPELEES LORS DE LA VALIDATION D'UN FORMULAIRE
|
78 |
|
| 69 |
public function validerFormulaireSaisieStation() {
|
- |
|
| 70 |
|
79 |
// +---------------------------------------------------------------------------------------------------------------+
|
| 71 |
$valeurs_collectees = $this->collecterValeursFormulaireSaisieStation();
|
80 |
// METHODES APPELEES LORS DE LA VALIDATION D'UN FORMULAIRE
|
| 72 |
|
81 |
public function validerFormulaireSaisieStation() {
|
| 73 |
$verification_ou_erreurs = $this->verifierValeursStation($valeurs_collectees);
|
82 |
|
| Line 108... |
Line 117... |
| 108 |
$valeurs_collectees['station_milieu'] = $_POST['station_milieu'];
|
117 |
$valeurs_collectees['station_milieu'] = $_POST['station_milieu'];
|
| 109 |
$valeurs_collectees['station_nom'] = $_POST['station_nom'];
|
118 |
$valeurs_collectees['station_nom'] = $_POST['station_nom'];
|
| 110 |
$valeurs_collectees['station_lat'] = $_POST['station_lat'];
|
119 |
$valeurs_collectees['station_lat'] = $_POST['station_lat'];
|
| 111 |
$valeurs_collectees['station_lon'] = $_POST['station_lon'];
|
120 |
$valeurs_collectees['station_lon'] = $_POST['station_lon'];
|
| 112 |
$valeurs_collectees['station_alt'] = $_POST['station_alt'];
|
121 |
$valeurs_collectees['station_alt'] = $_POST['station_alt'];
|
| - |
|
122 |
// à voir de ce que l'on fait de ce champs qui avait été prévu mais jamais utilisé
|
| - |
|
123 |
//$valeurs_collectees['station_description'] = $_POST['station_description'];
|
| 113 |
$valeurs_collectees['station_code_insee'] = $_POST['station_code_insee'];
|
124 |
$valeurs_collectees['station_code_insee'] = $_POST['station_code_insee'];
|
| Line 114... |
Line 125... |
| 114 |
|
125 |
|
| Line 115... |
Line 126... |
| 115 |
return $valeurs_collectees;
|
126 |
return $valeurs_collectees;
|
| Line 116... |
Line 127... |
| 116 |
|
127 |
|
| 117 |
}
|
- |
|
| 118 |
|
- |
|
| 119 |
private function collecterValeursFormulaireModificationStation() {
|
128 |
}
|
| 120 |
|
- |
|
| 121 |
$valeurs_collectees['station_commune'] = $_POST['station_commune'];
|
- |
|
| 122 |
$valeurs_collectees['station_milieu'] = $_POST['station_milieu'];
|
- |
|
| 123 |
$valeurs_collectees['station_nom'] = $_POST['station_nom'];
|
- |
|
| 124 |
$valeurs_collectees['station_lat'] = $_POST['station_lat'];
|
129 |
|
| 125 |
$valeurs_collectees['station_lon'] = $_POST['station_lon'];
|
- |
|
| Line 126... |
Line 130... |
| 126 |
$valeurs_collectees['station_alt'] = $_POST['station_alt'];
|
130 |
private function collecterValeursFormulaireModificationStation() {
|
| Line 127... |
Line 131... |
| 127 |
$valeurs_collectees['station_id'] = $_POST['station_id'];
|
131 |
$valeurs_collectees = $this->collecterValeursFormulaireSaisieStation();
|
| Line 128... |
Line 132... |
| 128 |
$valeurs_collectees['station_code_insee'] = $_POST['station_code_insee'];
|
132 |
$valeurs_collectees['station_id'] = $_POST['station_id'];
|
| Line 129... |
Line 133... |
| 129 |
|
133 |
|
| Line 130... |
Line 134... |
| 130 |
return $valeurs_collectees;
|
134 |
return $valeurs_collectees;
|
| 131 |
|
135 |
|
| 132 |
}
|
136 |
}
|
| 133 |
|
137 |
|
| - |
|
138 |
private function verifierValeursStation($valeurs_a_verifier) {
|
| - |
|
139 |
|
| - |
|
140 |
$erreurs = array();
|
| - |
|
141 |
|
| - |
|
142 |
foreach($valeurs_a_verifier as $champ => $valeur) {
|
| - |
|
143 |
if(trim($valeur) == '') {
|
| 134 |
private function verifierValeursStation($valeurs_a_verifier) {
|
144 |
$erreurs[$champ] .= ' Ce champ ne peut pas être vide.';
|
| Line 135... |
Line 145... |
| 135 |
|
145 |
}
|
| 136 |
$erreurs = array();
|
146 |
|
| 137 |
|
147 |
if($champ == 'station_code_insee' && !$this->estUnCodeInseeOuUnNumDpt($valeur)) {
|
| Line 138... |
Line 148... |
| 138 |
foreach($valeurs_a_verifier as $champ => $valeur) {
|
148 |
$erreurs[$champ] .= ' La valeur de ce champ doit être un numéro de département sur 2 chiffres '.
|
| 139 |
if($champ != 'station_code_insee' && trim($valeur) == '') {
|
149 |
'ou un code INSEE sur 5 chiffres';
|
| Line -... |
Line 150... |
| - |
|
150 |
}
|
| - |
|
151 |
|
| - |
|
152 |
}
|
| - |
|
153 |
|
| - |
|
154 |
if(!empty($erreurs)) {
|
| 140 |
$erreurs[$champ] .= ' Ce champ ne peut pas être vide';
|
155 |
return $erreurs;
|
| Line 141... |
Line 156... |
| 141 |
}
|
156 |
}
|
| - |
|
157 |
|
| - |
|
158 |
return true;
|
| - |
|
159 |
}
|
| - |
|
160 |
|
| - |
|
161 |
private function estUnCodeInseeOuUnNumDpt($code) {
|
| - |
|
162 |
$lg = strlen($code);
|
| - |
|
163 |
return trim($code) != '' && is_numeric($code) && ($lg == 2 || $lg == 5);
|
| - |
|
164 |
}
|
| - |
|
165 |
|
| Line 142... |
Line 166... |
| 142 |
}
|
166 |
public function validerFormulaireModificationStation() {
|
| 143 |
|
167 |
|
| Line 144... |
Line 168... |
| 144 |
if(!empty($erreurs)) {
|
168 |
$valeurs_collectees = $this->collecterValeursFormulaireModificationStation();
|
| 145 |
return $erreurs;
|
169 |
$verification_ou_erreurs = $this->verifierValeursStation($valeurs_collectees);
|
| 146 |
}
|
170 |
|
| 147 |
|
171 |
if($verification_ou_erreurs !== true) {
|