1 |
aurelien |
1 |
<script language="javascript">
|
|
|
2 |
function gotoEtape (numetape) {
|
|
|
3 |
document.navigation.etape.value=numetape;
|
|
|
4 |
document.navigation.submit();
|
|
|
5 |
}
|
|
|
6 |
</script>
|
|
|
7 |
<?
|
|
|
8 |
include("login.php");
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
if (!function_exists("redirect")) {
|
|
|
12 |
function redirect($filename) {
|
|
|
13 |
if (!headers_sent())
|
|
|
14 |
header('Location: '.$filename);
|
|
|
15 |
else {
|
|
|
16 |
echo '<script type="text/javascript">';
|
|
|
17 |
echo 'window.location.href="'.$filename.'";';
|
|
|
18 |
echo '</script>';
|
|
|
19 |
echo '<noscript>';
|
|
|
20 |
echo '<meta http-equiv="refresh" content="0;url='.$filename.'" />';
|
|
|
21 |
echo '</noscript>';
|
|
|
22 |
}
|
|
|
23 |
}
|
|
|
24 |
}
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
$url_page = $_SERVER['REQUEST_URI'];
|
|
|
28 |
while (is_numeric($i = strpos($url_page,"/"))) {
|
|
|
29 |
$url_page = substr($url_page, $i+1);
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
function estDate($j,$m,$a) {
|
|
|
33 |
return (is_numeric($j) && strlen($j)==2) &&
|
|
|
34 |
(is_numeric($m) && strlen($m)==2) &&
|
|
|
35 |
(is_numeric($a) && strlen($a)==4);
|
|
|
36 |
}
|
|
|
37 |
function estDateEnAttente($j,$m,$a) {
|
|
|
38 |
return ($j=='jj' && $m=='mm') || (sizeof($j)==0 && sizeof($m)==0);
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
function etape($nom_etape,$num_etape) {
|
|
|
42 |
global $url_page;
|
|
|
43 |
|
|
|
44 |
return"<a href='javascript:gotoEtape($num_etape);'>$nom_etape</a>";
|
|
|
45 |
}
|
|
|
46 |
function afficherErreurs($tab_erreurs) {
|
|
|
47 |
if (sizeof($tab_erreurs)>0) {
|
|
|
48 |
echo "<div class='erreurs'>";
|
|
|
49 |
foreach ($tab_erreurs as $err)
|
|
|
50 |
echo $err."<br>";
|
|
|
51 |
echo "</div><br>";
|
|
|
52 |
}
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
if ($_SESSION['participant']) {
|
|
|
56 |
|
|
|
57 |
$erreurs = array();
|
|
|
58 |
|
|
|
59 |
include("connect.php");
|
|
|
60 |
include("messages.php");
|
|
|
61 |
|
|
|
62 |
$choixCommune = false;
|
|
|
63 |
|
|
|
64 |
$nbEtapes = 4;
|
|
|
65 |
|
|
|
66 |
if (isset($_POST['etape']))
|
|
|
67 |
$etape = $_POST['etape'];
|
|
|
68 |
else if (isset($_GET['etape']))
|
|
|
69 |
$etape = $_GET['etape'];
|
|
|
70 |
else
|
|
|
71 |
$etape = 1;
|
|
|
72 |
|
|
|
73 |
if (isset($_SESSION['obsOK'])) {
|
|
|
74 |
echo "<div class='erreurs'>Vos informations ont bien été prises en compte!</div>";
|
|
|
75 |
unset($_SESSION['obsOK']);
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
//echo "Proposez de nouvelles observations ci-dessous...<br>";
|
|
|
79 |
|
|
|
80 |
echo "<form name='navigation' method='post' action='$url_page'><input type='hidden' name='etape'></form>";
|
|
|
81 |
|
|
|
82 |
if (isset($_POST['annul_modif'])) {
|
|
|
83 |
$etape = 1;
|
|
|
84 |
redirect("article.php3?id_article=2");
|
|
|
85 |
exit;
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
if ($etape==1) {
|
|
|
89 |
|
|
|
90 |
//si on arrive à peine sur la page
|
|
|
91 |
$tableau_flippe=array_flip($_POST);
|
|
|
92 |
if (!isset($_GET['station_id']) && !isset($tableau_flippe['Modifier']) ) {
|
|
|
93 |
|
|
|
94 |
//si on n'a pas posté de séquence (=observation) à modifier
|
|
|
95 |
if (!isset($_GET['sequence_id'])) {
|
|
|
96 |
} else //on a posté une séquence (=observation) à modifier
|
|
|
97 |
$numseq = $_GET['sequence_id'];
|
|
|
98 |
if ($numseq) {
|
|
|
99 |
$query_seq="select STATION_NOM, ESPECE_NOM_VERNACULAIRE, ENVIRONNEMENT_NOM , STATION_ALTITUDE, " .
|
|
|
100 |
" CARACTERISTIQUE_ESP_VALEUR_LIB " .
|
|
|
101 |
" from ESPECE, STATION, SEQUENCE , ENVIRONNEMENT, CARACTERISTIQUE_ESP_LIEN, CARACTERISTIQUE_ESP_VALEUR where SEQUENCE.STATION_ID=STATION.STATION_ID " .
|
|
|
102 |
"and STATION_ENVIRONNEMENT_ID=ENVIRONNEMENT.ENVIRONNEMENT_ID and ESPECE.ESPECE_ID=SEQUENCE.ESPECE_ID " .
|
|
|
103 |
"and ESPECE.ESPECE_ID=CARACTERISTIQUE_ESP_LIEN.ESPECE_ID " .
|
|
|
104 |
"and CARACTERISTIQUE_ESP_LIEN.CARACTERISTIQUE_ESP_VALEUR_ID=CARACTERISTIQUE_ESP_VALEUR.CARACTERISTIQUE_ESP_VALEUR_ID " .
|
|
|
105 |
"and SEQUENCE.SEQUENCE_ID=$numseq";
|
|
|
106 |
|
|
|
107 |
$requete_seq = mysql_query($query_seq);
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
$seq = mysql_fetch_row($requete_seq);
|
|
|
112 |
|
|
|
113 |
$_SESSION['observation']['station']=$seq[0];
|
|
|
114 |
$_SESSION['observation']['environnement']=$seq[2];
|
|
|
115 |
$_SESSION['observation']['altitude']=$seq[3];
|
|
|
116 |
$_SESSION['observation']['espece']=$seq[1];
|
|
|
117 |
$_SESSION['observation']['type_espece']=$seq[4];
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
echo "<div class='recap'>";
|
|
|
121 |
echo "Station d'observation : <a href=\"article.php3?id_article=2\">".$_SESSION['observation']['station']."</a><br>";
|
|
|
122 |
echo "Environnement d'observation : <a href=\"article.php3?id_article=2\">".$_SESSION['observation']['environnement']."</a><br>";
|
|
|
123 |
echo "Altitude d'observation : <a href=\"article.php3?id_article=2\">".$_SESSION['observation']['altitude']."</a><br>";
|
|
|
124 |
echo "Type d'espèce observé: ".$_SESSION['observation']['type_espece']."<br>";
|
|
|
125 |
echo "Espèce observée: ".$_SESSION['observation']['espece']."<br>";
|
|
|
126 |
echo "</div><br>";
|
|
|
127 |
|
|
|
128 |
|
|
|
129 |
include("observations/modif_encours.php");
|
|
|
130 |
}else
|
|
|
131 |
{ // Affiché la premiere fois
|
|
|
132 |
|
|
|
133 |
//include("observations/commune.php");
|
|
|
134 |
|
|
|
135 |
// DD
|
|
|
136 |
include("observations/station.php");
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
// include("observations/encours.php");
|
|
|
140 |
}
|
|
|
141 |
} // valid_station present
|
|
|
142 |
else {
|
|
|
143 |
|
|
|
144 |
|
|
|
145 |
// TODO : supprimer de ici jusqua
|
|
|
146 |
/*
|
|
|
147 |
if (strlen($_POST['commune'])==0) { // Pas de commune choisi, commune par defaut.
|
|
|
148 |
$requete_comm = mysql_query("select COMMUNE.COMMUNE_ID, COMMUNE_NOM from COMMUNE,PARTICIPANT where COMMUNE.COMMUNE_ID=PARTICIPANT.COMMUNE_ID and PARTICIPANT_ID=".$_SESSION['participant']);
|
|
|
149 |
//$requete_comm = mysql_query("select COMMUNE_ID, COMMUNE_NOM from COMMUNE where COMMUNE_CODEPOSTAL=".$_POST['code_postal']);
|
|
|
150 |
$comm_ligne = mysql_fetch_row($requete_comm);
|
|
|
151 |
$_SESSION['observation']['commune_id'] = $comm_ligne[0];
|
|
|
152 |
$_SESSION['observation']['commune'] = $comm_ligne[1];
|
|
|
153 |
} else {
|
|
|
154 |
$requete_comm = mysql_query("select COMMUNE_NOM from COMMUNE where COMMUNE_ID=".$_POST['commune']);
|
|
|
155 |
$comm_ligne = mysql_fetch_row($requete_comm);
|
|
|
156 |
$_SESSION['observation']['commune_id'] = $_POST['commune'];
|
|
|
157 |
$_SESSION['observation']['commune'] = $comm_ligne[0];
|
|
|
158 |
|
|
|
159 |
}
|
|
|
160 |
*/
|
|
|
161 |
// Jusqu'a ici
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
// Recuperation identifiant station (il est unique)
|
|
|
165 |
|
|
|
166 |
|
|
|
167 |
$station_choisie=$_GET['station_id'];
|
|
|
168 |
|
|
|
169 |
if (isset($station_choisie)) { // choix d'une station pour ajout d'espece
|
|
|
170 |
$requete_station = mysql_query("select STATION_NOM, STATION_ALTITUDE, STATION_ENVIRONNEMENT_ID, ENVIRONNEMENT_NOM from STATION,ENVIRONNEMENT where STATION.STATION_ENVIRONNEMENT_ID=ENVIRONNEMENT.ENVIRONNEMENT_ID AND STATION_ID=".$station_choisie);
|
|
|
171 |
|
|
|
172 |
$comm_station = mysql_fetch_row($requete_station);
|
|
|
173 |
|
|
|
174 |
$_SESSION['observation']['station_id'] = $station_choisie;
|
|
|
175 |
$_SESSION['observation']['station'] = $comm_station[0];
|
|
|
176 |
$_SESSION['observation']['altitude'] = $comm_station[1];
|
|
|
177 |
$_SESSION['observation']['environnement_id'] = $comm_station[2];
|
|
|
178 |
$_SESSION['observation']['environnement'] = $comm_station[3];
|
|
|
179 |
|
|
|
180 |
|
|
|
181 |
|
|
|
182 |
$etape++; // passage à l'etape 2
|
|
|
183 |
}
|
|
|
184 |
else { //modification de station sans observation pour deplacement
|
|
|
185 |
|
|
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
|
189 |
$requete_station = mysql_query("select STATION_NOM from STATION where STATION_ID=".$tableau_flippe['Modifier']);
|
|
|
190 |
$comm_station = mysql_fetch_row($requete_station);
|
|
|
191 |
|
|
|
192 |
$_SESSION['observation']['station_id'] = $tableau_flippe['Modifier'];
|
|
|
193 |
$_SESSION['observation']['station'] = $comm_station[0];
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
include("observations/modif_station.php");
|
|
|
197 |
|
|
|
198 |
}
|
|
|
199 |
|
|
|
200 |
|
|
|
201 |
// $_SESSION['observation']['commune'] = $comm_ligne[0];
|
|
|
202 |
|
|
|
203 |
|
|
|
204 |
|
|
|
205 |
|
|
|
206 |
}
|
|
|
207 |
} // etape 1
|
|
|
208 |
if ($etape >1)
|
|
|
209 |
echo "<div class='erreurs'>Pour revenir en arrière, n'utilisez pas le bouton \"précédent\" de votre navigateur, mais cliquez sur le nom à modifier.</div>";
|
|
|
210 |
|
|
|
211 |
/*
|
|
|
212 |
if ($etape==3) {
|
|
|
213 |
if (isset($_POST['valid_alt'])) {
|
|
|
214 |
if (strlen($_POST['altitude'])==0)
|
|
|
215 |
$erreurs[] = $altitude_manquant;
|
|
|
216 |
else if (!is_numeric(str_replace(",",".",$_POST['altitude'])))
|
|
|
217 |
$erreurs[] = $altitude_invalide;
|
|
|
218 |
}
|
|
|
219 |
if (!isset($_POST['valid_alt']) || sizeof($erreurs)>0) {
|
|
|
220 |
echo "<div class='recap'>";
|
|
|
221 |
echo "Station d'observation : ".etape($_SESSION['observation']['station'],1)."<br>";
|
|
|
222 |
echo "Environnement d'observation : ".etape($_SESSION['observation']['environnement'],2)."<br>";
|
|
|
223 |
echo "</div><br>";
|
|
|
224 |
include("observations/altitude.php");
|
|
|
225 |
}
|
|
|
226 |
else {
|
|
|
227 |
$_SESSION['observation']['altitude'] = $_POST['altitude'];
|
|
|
228 |
$etape++;
|
|
|
229 |
}
|
|
|
230 |
}
|
|
|
231 |
*/
|
|
|
232 |
|
|
|
233 |
|
|
|
234 |
|
|
|
235 |
if ($etape==2) {
|
|
|
236 |
if (!isset($_POST['valid_typesp'])) {
|
|
|
237 |
echo "<div class='recap'>";
|
|
|
238 |
echo "Station d'observation : <a href=\"article.php3?id_article=2\">".$_SESSION['observation']['station']."</a><br>";
|
|
|
239 |
echo "Environnement d'observation : <a href=\"article.php3?id_article=2\">".$_SESSION['observation']['environnement']."</a><br>";
|
|
|
240 |
echo "Altitude d'observation : <a href=\"article.php3?id_article=2\">".$_SESSION['observation']['altitude']."</a><br>";
|
|
|
241 |
echo "</div><br>";
|
|
|
242 |
include("observations/type_espece.php");
|
|
|
243 |
}
|
|
|
244 |
else {
|
|
|
245 |
$requete_comm = mysql_query("select CARACTERISTIQUE_ESP_VALEUR_LIB from CARACTERISTIQUE_ESP_VALEUR where CARACTERISTIQUE_ESP_VALEUR_ID=".$_POST['typespece']);
|
|
|
246 |
$comm_ligne = mysql_fetch_row($requete_comm);
|
|
|
247 |
$_SESSION['observation']['type_espece_id'] = $_POST['typespece'];
|
|
|
248 |
$_SESSION['observation']['type_espece'] = $comm_ligne[0];
|
|
|
249 |
$etape++;
|
|
|
250 |
}
|
|
|
251 |
}
|
|
|
252 |
if ($etape==3) {
|
|
|
253 |
if (isset($_POST['valid_espece'])) {
|
|
|
254 |
//on vérifie qu'il n'y a pas déjà d'observations de ce participant sur la même espèce et la même la même année
|
|
|
255 |
// $requete_verif = mysql_query("select SEQUENCE.SEQUENCE_ID FROM SEQUENCE,MESURE where COMMUNE_ID=".$_SESSION['observation']['commune_id']." and MESURE.SEQUENCE_ID=SEQUENCE.SEQUENCE_ID and SEQUENCE.PARTICIPANT_ID=".$_SESSION['participant']." and ESPECE_ID=".$_POST['espece']." and DATE_FORMAT(MESURE_DATE,'%Y')=DATE_FORMAT(NOW(),'%Y')");
|
|
|
256 |
|
|
|
257 |
$annee = date('Y');
|
|
|
258 |
|
|
|
259 |
$requete_verif = mysql_query("select distinct SEQUENCE.SEQUENCE_ID from SEQUENCE,MESURE ".
|
|
|
260 |
"where ESPECE_ID=".$_POST['espece'].
|
|
|
261 |
" and SEQUENCE.PARTICIPANT_ID=".$_SESSION['participant'].
|
|
|
262 |
" and MESURE.SEQUENCE_ID=SEQUENCE.SEQUENCE_ID".
|
|
|
263 |
" and STATION_ID=".$_SESSION['observation']['station_id'].
|
|
|
264 |
" and MESURE.SEQUENCE_ID=SEQUENCE.SEQUENCE_ID".
|
|
|
265 |
" AND MESURE_DATE!='0000-00-00' and MESURE_DATE>'".$annee."-$mois-01'".
|
|
|
266 |
" and MESURE_DATE<'".($annee+1)."-$mois-01'");
|
|
|
267 |
|
|
|
268 |
if ($obs_verif = mysql_fetch_row($requete_verif))
|
|
|
269 |
$erreurs[] = $observation_existant;
|
|
|
270 |
}
|
|
|
271 |
|
|
|
272 |
if (!isset($_POST['valid_espece']) || sizeof($erreurs)>0) {
|
|
|
273 |
echo "<div class='recap'>";
|
|
|
274 |
echo "Station d'observation : <a href=\"article.php3?id_article=2\">".$_SESSION['observation']['station']."</a><br>";
|
|
|
275 |
echo "Environnement d'observation : <a href=\"article.php3?id_article=2\">".$_SESSION['observation']['environnement']."</a><br>";
|
|
|
276 |
echo "Altitude d'observation : <a href=\"article.php3?id_article=2\">".$_SESSION['observation']['altitude']."</a><br>";
|
|
|
277 |
echo "Type d'espèce observé: ".etape($_SESSION['observation']['type_espece'],2)."<br>";
|
|
|
278 |
echo "</div><br>";
|
|
|
279 |
include("observations/espece.php");
|
|
|
280 |
}
|
|
|
281 |
else {
|
|
|
282 |
$requete_comm = mysql_query("select ESPECE_NOM_VERNACULAIRE from ESPECE where ESPECE_ID=".$_POST['espece']);
|
|
|
283 |
$comm_ligne = mysql_fetch_row($requete_comm);
|
|
|
284 |
$_SESSION['observation']['espece_id'] = $_POST['espece'];
|
|
|
285 |
$_SESSION['observation']['espece'] = $comm_ligne[0];
|
|
|
286 |
$etape++;
|
|
|
287 |
}
|
|
|
288 |
}
|
|
|
289 |
if ($etape==4) {
|
|
|
290 |
if (isset($_POST['valid_saisie'])) {
|
|
|
291 |
|
|
|
292 |
$evenements = $_POST['evenements'];
|
|
|
293 |
|
|
|
294 |
/* foreach ($evenements as $numev => $individu) {
|
|
|
295 |
echo "e".$numev;
|
|
|
296 |
if (is_array($individu)) {
|
|
|
297 |
foreach ($individu as $numind => $datev) {
|
|
|
298 |
echo "i".$numind;
|
|
|
299 |
}
|
|
|
300 |
}
|
|
|
301 |
}
|
|
|
302 |
for ($i=0; $i<sizeof($evenements); $i++) {
|
|
|
303 |
echo $evenements[$i];
|
|
|
304 |
for ($j=0; $j<sizeof($evenements[$i]); $j++) {
|
|
|
305 |
echo $evenements[$i][$j]."<br>";
|
|
|
306 |
}
|
|
|
307 |
/*foreach ($evenements[$i] as $n => $d)
|
|
|
308 |
echo "$n -> $d";
|
|
|
309 |
|
|
|
310 |
}
|
|
|
311 |
exit();
|
|
|
312 |
*/
|
|
|
313 |
$nbCases = 0;
|
|
|
314 |
$nbDatesNulles = 0;
|
|
|
315 |
foreach ($evenements as $numind => $individu) {
|
|
|
316 |
if (is_array($individu)) {
|
|
|
317 |
$numev = 1;
|
|
|
318 |
foreach ($individu as $indev => $datev) {
|
|
|
319 |
if (is_numeric($indev)) {
|
|
|
320 |
//soit on a une vraie date, soit on a un jjmmaaaa
|
|
|
321 |
if (!estDate($datev[0],$datev[1],$datev[2]) && !estDateEnAttente($datev[0],$datev[1],$datev[2])) {
|
|
|
322 |
/*if (!is_numeric($datev[0]) || strlen($datev[0])!=2)
|
|
|
323 |
$erreurs[] = "Jour du ".$numev."e évènement inscrit : ".$jour_invalide;
|
|
|
324 |
if (!is_numeric($datev[1]) || strlen($datev[1])!=2)
|
|
|
325 |
$erreurs[] = "Mois du ".$numev."e évènement inscrit : ".$mois_invalide;
|
|
|
326 |
if (!is_numeric($datev[2]) || strlen($datev[2])!=4)
|
|
|
327 |
$erreurs[] = "Année du ".$numev."e évènement inscrit : ".$annee_invalide;*/
|
|
|
328 |
$erreurs[] = "Le ".$numind."e évènement inscrit pour le ".$numev."e individu n'est pas une date valide.";
|
|
|
329 |
} else if (estDateEnAttente($datev[0],$datev[1],$datev[2]))
|
|
|
330 |
$nbsDatesNulles++;
|
|
|
331 |
$numev++; $nbCases++;
|
|
|
332 |
}
|
|
|
333 |
}
|
|
|
334 |
}
|
|
|
335 |
}
|
|
|
336 |
//echo $nbCases.",".$nbsDatesNulles;
|
|
|
337 |
if ($nbCases == $nbsDatesNulles)
|
|
|
338 |
$erreurs[] = "Il faut entrer au moins une date.";
|
|
|
339 |
}
|
|
|
340 |
|
|
|
341 |
if (!isset($_POST['valid_saisie']) || sizeof($erreurs)>0) {
|
|
|
342 |
echo "<div class='recap'>";
|
|
|
343 |
echo "Station d'observation : <a href=\"article.php3?id_article=2\">".$_SESSION['observation']['station']."</a><br>";
|
|
|
344 |
echo "Environnement d'observation : <a href=\"article.php3?id_article=2\">".$_SESSION['observation']['environnement']."</a><br>";
|
|
|
345 |
echo "Altitude d'observation : <a href=\"article.php3?id_article=2\">".$_SESSION['observation']['altitude']."</a><br>";
|
|
|
346 |
echo "Type d'espèce observé: ".etape($_SESSION['observation']['type_espece'],2)."<br>";
|
|
|
347 |
echo "Espèce observée: ".etape($_SESSION['observation']['espece'],3)."<br>";
|
|
|
348 |
echo "</div><br>";
|
|
|
349 |
include("observations/saisie.php");
|
|
|
350 |
}
|
|
|
351 |
else {
|
|
|
352 |
|
|
|
353 |
$evenements = $_POST['evenements'];
|
|
|
354 |
|
|
|
355 |
//on vérifie une ultime fois que la séquence n'a pas déjà été saisie
|
|
|
356 |
// $requete_verif = mysql_query("select SEQUENCE.SEQUENCE_ID FROM SEQUENCE,MESURE where COMMUNE_ID=".$_SESSION['observation']['commune_id']." and MESURE.SEQUENCE_ID=SEQUENCE.SEQUENCE_ID and SEQUENCE.PARTICIPANT_ID=".$_SESSION['participant']." and ESPECE_ID=".$_SESSION['observation']['espece_id']." and DATE_FORMAT(MESURE_DATE,'%Y')=DATE_FORMAT(NOW(),'%Y')");
|
|
|
357 |
//$requete_verif = mysql_query("select SEQUENCE_ID from SEQUENCE where ESPECE_ID=".$_SESSION['observation']['espece_id'].
|
|
|
358 |
|
|
|
359 |
$annee = date('Y');
|
|
|
360 |
|
|
|
361 |
$requete_verif = mysql_query("select distinct SEQUENCE.SEQUENCE_ID from SEQUENCE,MESURE ".
|
|
|
362 |
"where ESPECE_ID=".$_SESSION['observation']['espece_id'].
|
|
|
363 |
" and SEQUENCE.PARTICIPANT_ID=".$_SESSION['participant'].
|
|
|
364 |
" and MESURE.SEQUENCE_ID=SEQUENCE.SEQUENCE_ID".
|
|
|
365 |
" and STATION_ID=".$_SESSION['observation']['station_id'].
|
|
|
366 |
" and MESURE.SEQUENCE_ID=SEQUENCE.SEQUENCE_ID".
|
|
|
367 |
" AND MESURE_DATE!='0000-00-00' and MESURE_DATE>='$annee-01-01'".
|
|
|
368 |
" and MESURE_DATE<'".($annee+1)."-01-01'");
|
|
|
369 |
//" and COMMUNE_ID=".$_SESSION['observation']['commune_id'].
|
|
|
370 |
//" and PARTICIPANT_ID=".$_SESSION['participant']);
|
|
|
371 |
if ($verif = mysql_fetch_row($requete_verif)) {
|
|
|
372 |
$erreurs[] = "$observation_existant";
|
|
|
373 |
}
|
|
|
374 |
//c'est bon, cette séquence n'a pas encore été introduite
|
|
|
375 |
else {
|
|
|
376 |
$requete_seq = mysql_query("insert into SEQUENCE (ESPECE_ID, STATION_ID, ENVIRONNEMENT_ID, PARTICIPANT_ID, SEQUENCE_ALTITUDE) values (".$_SESSION['observation']['espece_id'].",".$_SESSION['observation']['station_id'].",".$_SESSION['observation']['environnement_id'].",".$_SESSION['participant'].", ".str_replace(",",".",$_SESSION['observation']['altitude']).")");
|
|
|
377 |
|
|
|
378 |
//on récupère l'identifiant de la séquence qui vient d'être introduite
|
|
|
379 |
$requete_idseq = mysql_query("select SEQUENCE_ID from SEQUENCE where ESPECE_ID=".$_SESSION['observation']['espece_id']." and STATION_ID=".$_SESSION['observation']['station_id']." and PARTICIPANT_ID=".$_SESSION['participant']);
|
|
|
380 |
|
|
|
381 |
$idseq_ligne = mysql_fetch_row($requete_idseq);
|
|
|
382 |
if ($idseq_ligne)
|
|
|
383 |
$idseq = $idseq_ligne[0];
|
|
|
384 |
|
|
|
385 |
foreach ($evenements as $numind => $individu) {
|
|
|
386 |
if (is_array($individu)) {
|
|
|
387 |
foreach ($individu as $numev => $datev) {
|
|
|
388 |
if (is_numeric($numev) && !estDateEnAttente($datev[0],$datev[1],$datev[2])) {
|
|
|
389 |
if (!mysql_query("insert into MESURE (SEQUENCE_ID, EVENEMENT_ID, MESURE_DATE, MESURE_INDIVIDU) values ($idseq, $numind, '".$datev[2]."-".$datev[1]."-".$datev[0]."',($numev+1))"))
|
|
|
390 |
$erreurs[] = "La prise en compte de vos observations a échoué, merci de réessayer.";
|
|
|
391 |
}
|
|
|
392 |
}
|
|
|
393 |
}
|
|
|
394 |
}
|
|
|
395 |
}
|
|
|
396 |
if (sizeof($erreurs)==0) {
|
|
|
397 |
$_SESSION['obsOK'] = 'ok';
|
|
|
398 |
|
|
|
399 |
redirect("article.php3?id_article=2");
|
|
|
400 |
//header("Location: article.php3?id_article=3");
|
|
|
401 |
}
|
|
|
402 |
// echo "Tes dates d'observation ont bien été prises en compte.";
|
|
|
403 |
else {
|
|
|
404 |
foreach($erreurs as $err)
|
|
|
405 |
echo $err."<br>";
|
|
|
406 |
}
|
|
|
407 |
|
|
|
408 |
}
|
|
|
409 |
}
|
|
|
410 |
|
|
|
411 |
}
|
|
|
412 |
|
|
|
413 |
?>
|