Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 11 | Rev 249 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11 jpm 1
<?php
242 jpm 2
class Chorodep extends EfloreScript {
11 jpm 3
	protected $nbre_dep = 0;
4
	private $type_donnee = '';
5
	protected $aso_num_nomenc = array();
6
	protected $nbre_ligne = 0;
7
	protected $nbre_plte_presente = 0;
8
	protected $nbre_plte_a_confirmer = 0;
9
	protected $nbre_plte_douteux = 0;
10
	protected $nbre_plte_erreur = 0;
11
	protected $nbre_plte_disparue = 0;
242 jpm 12
	protected $nbre_plte_erreur_a_confirmer = 0;
11 jpm 13
	protected $nc_autres_valeur_champ = 0;
242 jpm 14
	protected $nc_nbre_plte_presente = 0;
15
	protected $nc_nbre_plte_a_confirmer = 0;
16
	protected $nc_nbre_plte_douteux = 0;
17
	protected $nc_nbre_plte_disparue = 0;
18
	protected $nc_nbre_plte_erreur = 0;
19
	protected $nc_nbre_plte_erreur_a_confirmer = 0;
20
 
11 jpm 21
	protected $aso_totaux_dep = array();
242 jpm 22
	private $fichier_verif = './chorodep_verif.html';
11 jpm 23
 
242 jpm 24
	public function executer() {
25
		try {
26
			$this->initialiserProjet('chorodep');
11 jpm 27
 
242 jpm 28
			// Lancement de l'action demandée
29
			$cmd = $this->getParametre('a');
30
			switch ($cmd) {
31
 
32
				case 'chargerTous' :
33
					$this->chargerStructureSql();
34
					$this->chargerVersions();
35
					$this->chargerChorodepContributeurs();
36
					$this->chargerChorodepSources();
37
					$this->chargerChorodepOntologies();
38
					break;
39
				case 'chargerStructureSql' :
40
					$this->chargerStructureSql();
41
					break;
42
				case 'chargerVersions' :
43
					$this->chargerVersions();
44
					break;
45
				case 'chargerChorodep' :
46
					$this->chargerChorodepContributeurs();
47
					$this->chargerChorodepSources();
48
					$this->chargerChorodepOntologies();
49
					break;
50
				case 'verifierDonnees' :
51
					$this->initialiserTraitement();
52
					$this->verifierDonnees();
53
					break;
54
				case 'supprimerTous' :
55
					$this->supprimerTous();
56
					break;
57
				default :
58
					throw new Exception("Erreur : la commande '$cmd' n'existe pas!");
59
			}
60
		} catch (Exception $e) {
61
			$this->traiterErreur($e->getMessage());
62
		}
11 jpm 63
	}
64
 
242 jpm 65
	private function chargerChorodepContributeurs() {
66
		$chemin = Config::get('chemins.chorodepContributeurs');
67
		$table = Config::get('tables.chorodepContributeurs');
68
		$requete = "LOAD DATA INFILE '$chemin' ".
69
						"REPLACE INTO TABLE $table ".
70
						'CHARACTER SET utf8 '.
71
						'FIELDS '.
72
						"	TERMINATED BY '\t' ".
73
						"	ENCLOSED BY '' ".
74
						"	ESCAPED BY '\\\' ".
75
						'IGNORE 2 LINES';
76
		$this->getBdd()->requeter($requete);
77
	}
11 jpm 78
 
242 jpm 79
	private function chargerChorodepSources() {
80
		$chemin = Config::get('chemins.chorodepSources');
81
		$table = Config::get('tables.chorodepSources');
82
		$requete = "LOAD DATA INFILE '$chemin' ".
83
							"REPLACE INTO TABLE $table ".
84
							'CHARACTER SET utf8 '.
85
							'FIELDS '.
86
							"	TERMINATED BY '\t' ".
87
							"	ENCLOSED BY '' ".
88
							"	ESCAPED BY '\\\' ".
89
							'IGNORE 2 LINES';
90
		$this->getBdd()->requeter($requete);
91
	}
11 jpm 92
 
242 jpm 93
	private function chargerChorodepOntologies() {
94
		$chemin = Config::get('chemins.chorodepOntologies');
95
		$table = Config::get('tables.chorodepOntologies');
96
		$requete = "LOAD DATA INFILE '$chemin' ".
97
								"REPLACE INTO TABLE $table ".
98
								'CHARACTER SET utf8 '.
99
								'FIELDS '.
100
								"	TERMINATED BY '\t' ".
101
								"	ENCLOSED BY '' ".
102
								"	ESCAPED BY '\\\' ".
103
								'IGNORE 1 LINES';
104
		$this->getBdd()->requeter($requete);
11 jpm 105
	}
106
 
242 jpm 107
	private function chargerVersions() {
108
		$versions = explode(',', Config::get('versions'));
109
		$versionsDonnees = explode(',', Config::get('versionsDonnees'));
110
		$tableTpl = Config::get('tables.chorodepTpl');
111
		$fichierSqlTpl = Config::get('chemins.structureSqlVersionTpl');
112
		$fichierTsvTpl = Config::get('chemins.chorodepTpl');
113
 
114
		foreach ($versions as $id => $version) {
115
			$versionDonnees = $versionsDonnees[$id];
116
 
117
			$this->chargerStructureSqlVersion($versionDonnees);
118
			$this->chargerDonneesVersion($versionDonnees, $version);
11 jpm 119
		}
120
	}
242 jpm 121
 
122
	private function chargerStructureSqlVersion($versionDonnees) {
123
		$fichierSql = sprintf($fichierSqlTpl, $versionDonnees, $versionDonnees);
124
		$contenuSql = $this->recupererContenu($fichierSql);
125
		$this->executerScripSql($contenuSql);
126
	}
127
 
128
	private function chargerDonneesVersion($versionDonnees, $version) {
129
		$fichierTsv = sprintf($fichierTsvTpl, $versionDonnees, $versionDonnees);
130
		$table = sprintf($tableTpl, $version);
131
		$champs = Config::get('chorodepChamps');
132
		$requete = "LOAD DATA INFILE '$fichierTsv' ".
133
						"REPLACE INTO TABLE $table ".
134
						'CHARACTER SET utf8 '.
135
						'FIELDS '.
136
						"	TERMINATED BY '\t' ".
137
						"	ENCLOSED BY '' ".
138
						"	ESCAPED BY '\\\' ".
139
						'IGNORE 1 LINES '.
140
						"($champs) ";
141
		$this->getBdd()->requeter($requete);
142
	}
143
 
11 jpm 144
	private function initialiserTraitement() {
145
		//------------------------------------------------------------------------------------------------------------//
146
		// Récupération des informations à vérifier
242 jpm 147
		$table = $this->getNomTableDernierVersion();
11 jpm 148
		$requete = 	'SELECT * '.
242 jpm 149
					"FROM $table ";
150
		$taxons = $this->getBdd()->recupererTous($requete);
11 jpm 151
		$tax_col = $taxons[1];
152
		$col = array_keys($tax_col);
153
		$this->initialiserTableaux($col);
154
		//------------------------------------------------------------------------------------------------------------//
155
		// Analyse des données
156
		echo 'Traitement de la ligne n° :';
157
		$i = 0;
158
		$j = 0;
159
		$aso_departements_analyses = array();
160
		$this->nbre_ligne_avec_guillemet = 0;
161
		foreach ($taxons as $aso_champs) {
162
			$nom = $aso_champs['nom_sci'];
163
			$num_taxo = $aso_champs['num_tax'];
164
			$num_nomenc = $aso_champs['num_nom'];
165
			if ($num_nomenc == 'nc') {
166
				$this->nc_nbre_nom++;
167
			} else if ($num_nomenc != 'nc') {
168
				$this->nbre_nom++;
169
				// Vérification de la nom duplication des numéros nomenclaturaux
170
				if ( !array_key_exists($num_nomenc, (array) $this->aso_num_nomenc) ) {
171
					$this->aso_num_nomenc[$num_nomenc]['compteur'] = 1;
172
					$this->aso_num_nomenc[$num_nomenc]['ligne'] = ($this->nbre_ligne+1);
173
				} else {
174
					$this->aso_num_nomenc[$num_nomenc]['compteur']++;
175
					$this->aso_num_nomenc[$num_nomenc]['ligne'] .= ' - '.($this->nbre_ligne+1);
176
				}
177
			}
178
			foreach ($aso_champs as $cle => $val ) {# Pour chaque département du taxon, on regarde la valeur
179
				$this->nbre_ligne_avec_guillemet += preg_match('/"/', $val);
180
				if ( preg_match('/^\d{2}$/', $cle) ) {# Nous vérifions que le nom du champs comprend bien le numéro du département entre ()
181
					$nd = $cle;# Numéro du département
182
					// Nous comptons le nombre de département en base de données
183
					if (!isset($aso_departements_analyses[$nd])) {
184
						$this->nbre_dep_analyse++;
185
						$aso_departements_analyses[$nd] = $nd;
186
					}
187
					if ( $num_nomenc != 'nc' && isset($val) && $val != '') {# Si le taxon n'est pas abscent du département
188
						if ($val == '1') {# Présent
189
							// Calcul du nombre de plante ayant un statut "Présent"
190
							$this->nbre_plte_presente++;
191
							// Stockage par département du nombre de plante ayant un statut "Présent"
192
							$this->aso_totaux_dep[$nd]['plte_presente']++;
193
							// Stockage des informations
194
							$this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 3, $this->id_donnee_choro++);
195
						} else if ($val == '1?') {# Présence à confirmer
196
							// Calcul du nombre de plante ayant un statut "Présence à confirmer"
197
							$this->nbre_plte_a_confirmer++;
198
							// Stockage par département du nombre de plante ayant un statut "Présence à confirmer"
199
							$this->aso_totaux_dep[$nd]['plte_a_confirmer']++;
200
							// Stockage des informations
201
							$this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 4, $this->id_donnee_choro++);
202
						} else if (preg_match('/^\s*(?:\?)\s*$/', $val)) {# Douteux
203
							// Calcul du nombre de plante ayant un statut "Disparu ou douteux"
204
							$this->nbre_plte_douteux++;
205
							// Stockage par département du nombre de plante ayant un statut "Douteux"
206
							$this->aso_totaux_dep[$nd]['plte_douteux']++;
207
							// Stockage des informations
208
							$this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 5, $this->id_donnee_choro++);
209
							if (preg_match('/(?: \?|\? | \? )/', $val)) {# Douteux
210
								// Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "?".
211
								$this->autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
212
														' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
213
							}
214
						} elseif (preg_match('/^\s*(?:#)\s*$/', $val)) {# Erreur
215
	                        # Calcul du nombre de plante ayant un statut "Erreur"
216
	                        $this->nbre_plte_erreur++;
217
	                        # Stockage par département du nombre de plante ayant un statut "Erreur"
218
	                        $this->aso_totaux_dep[$nd]['plte_erreur']++;
219
	                        # Stockage des informations
220
	                        $this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 6, $this->id_donnee_choro++);
221
	                        if (preg_match('/(?: #|# | # )/', $val)) {# Erreur avec espace
222
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "#".
223
	                            $autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
224
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
225
	                        }
226
                    	} elseif (preg_match('/^\s*(?:-\|-)\s*$/', $val)) {# Disparu
227
	                        # Calcul du nombre de plante ayant un statut "Disparu"
228
	                        $this->nbre_plte_disparue++;
229
	                        # Stockage par département du nombre de plante ayant un statut "Disparu"
230
	                        $this->aso_totaux_dep[$nd]['plte_disparue']++;
231
	                        # Stockage des informations
232
	                        $this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 6, $this->id_donnee_choro++);
233
	                        if (preg_match('/(?: -\|-|-\|- | -\|- )/', $val)) {# Disparu avec espace
234
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "-|-".
235
	                            $autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
236
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
237
	                        }
242 jpm 238
                    	} elseif (preg_match('/^\s*(?:#\?)\s*$/', $val)) {# Erreur à confirmer
239
	                        # Calcul du nombre de plante ayant un statut "Erreur à confirmer"
240
	                        $this->nbre_plte_erreur_a_confirmer++;
241
	                        # Stockage par département du nombre de plante ayant un statut "Erreur à confirmer"
242
	                        $this->aso_totaux_dep[$nd]['plte_erreur_a_confirmer']++;
243
	                        # Stockage des informations
244
	                        $this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 6, $this->id_donnee_choro++);
245
                    		if (preg_match('/^(?:\s+#\?|#\?\s+|\s+#\?\s+)$/', $val)) {# Erreur à confirmer avec espace
246
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "#?".
247
	                            $autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
248
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
249
	                        }
11 jpm 250
                    	} else {
251
							// Ajout de la valeur dans une variable car elle n'est pas conforme.
252
							$this->autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
253
													' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
254
						}
255
						$j++;
256
					} else if (isset($val) && $val != '') {
257
						if ($val == '1') {# Présent
258
							// Calcul du nombre de plante 'nc' ayant un statut "Présent"
259
							$this->nc_nbre_plte_presente++;
260
							// Stockage par département du nombre de plante 'nc' ayant un statut "Présent"
261
							$this->aso_totaux_dep[$nd]['nc_plte_presente']++;
262
						} elseif ($val == '1?') {# Présence à confirmer
263
							// Calcul du nombre de plante 'nc' ayant un statut "Présence à confirmer"
264
							$this->nc_nbre_plte_a_confirmer++;
265
							// Stockage par département du nombre de plante 'nc' ayant un statut "Présence à confirmer"
266
							$this->aso_totaux_dep[$nd]['nc_plte_a_confirmer']++;
267
						} elseif (preg_match('/^(?:\?| \?|\? | \?)$/', $val)) {# Douteux
268
							// Calcul du nombre de plante 'nc' ayant un statut "Douteux"
269
							$this->nc_nbre_plte_douteux++;
270
							// Stockage par département du nombre de plante 'nc' ayant un statut "Douteux"
271
							$this->aso_totaux_dep[$nd]['nc_plte_douteux']++;
272
							if (preg_match('/(?: \?|\? | \? )/', $val)) {# Douteux
273
								// Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "?".
274
								$this->nc_autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
275
														' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
276
							}
277
						} elseif (preg_match('/^(?:#| #|# | # )$/', $val)) {# Erreur
278
	                        # Calcul du nombre de plante 'nc' ayant un statut "Erreur"
279
	                        $this->nc_nbre_plte_erreur++;
280
	                        # Stockage par département du nombre de plante 'nc' ayant un statut "Erreur"
281
	                        $this->aso_totaux_dep[$nd]['nc_plte_erreur']++;
282
	                        if (preg_match('/(?: #|# | # )/', $val)) {# Erreur avec espace
283
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "#".
284
	                            $nc_autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
285
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
286
	                        }
287
                    	} elseif (preg_match('/^\s*(?:-\|-)\s*$/', $val)) {# Disparu
288
	                        # Calcul du nombre de plante 'nc' ayant un statut "Disparu"
289
	                        $this->nc_nbre_plte_disparue++;
290
	                        # Stockage par département du nombre de plante 'nc' ayant un statut "Disparu"
291
	                        $this->aso_totaux_dep[$nd]['nc_plte_disparue']++;
292
	                        if (preg_match('/(?: -\|-|-\|- | -\|- )/', $val)) {# Disparu avec espace
293
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "-|-".
294
	                            $nc_autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
295
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
296
	                        }
242 jpm 297
                    	} elseif (preg_match('/^\s*(?:#\?)\s*$/', $val)) {# Erreur à confirmer
298
	                        # Calcul du nombre de plante 'nc' ayant un statut "Erreur à confirmer"
299
	                        $this->nc_nbre_plte_erreur_a_confirmer++;
300
	                        # Stockage par département du nombre de plante 'nc' ayant un statut "Erreur à confirmer"
301
	                        $this->aso_totaux_dep[$nd]['nc_plte_erreur_a_confirmer']++;
302
	                        if (preg_match('/^(?:\s+#\?|#\?\s+|\s+#\?\s+)$/', $val)) {# Erreur à confirmer avec espace
303
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "#?".
304
	                            $nc_autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
305
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
306
	                        }
11 jpm 307
                    	} else {
308
							// Ajout de la valeur dans une variable car elle n'est pas conforme.
309
							$this->nc_autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
310
													' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
311
						}
312
					}
313
					// Affichage dans la console du numéro de l'enregistrement analysé.
314
					//echo str_repeat(chr(8), ( strlen( $i ) + 1 ))."\t".$i++;
315
				}
316
			}// fin du foreach
317
			// Affichage dans la console du numéro de l'enregistrement analysé.
318
			echo str_repeat(chr(8), ( strlen( $this->nbre_ligne ) + 1 ))."\t".$this->nbre_ligne++;
319
		}
320
		echo "\n";
321
	}
322
 
242 jpm 323
	private function initialiserTableaux($dep) {
324
		foreach ($dep as $code_dep) {
325
			if ( preg_match('/^\d{2}$/', $code_dep) ) {
326
				$this->aso_totaux_dep[$code_dep]['plte_presente'] = 0;
327
				$this->aso_totaux_dep[$code_dep]['plte_a_confirmer'] = 0;
328
				$this->aso_totaux_dep[$code_dep]['plte_douteux'] = 0;
329
				$this->aso_totaux_dep[$code_dep]['plte_erreur'] = 0;
330
				$this->aso_totaux_dep[$code_dep]['plte_disparue'] = 0;
331
				$this->aso_totaux_dep[$code_dep]['plte_erreur_a_confirmer'] = 0;
332
				$this->aso_totaux_dep[$code_dep]['autres_valeur_champ'] = 0;
333
				$this->aso_totaux_dep[$code_dep]['nc_plte_presente'] = 0;
334
				$this->aso_totaux_dep[$code_dep]['nc_plte_a_confirmer'] = 0;
335
				$this->aso_totaux_dep[$code_dep]['nc_plte_douteux'] = 0;
336
				$this->aso_totaux_dep[$code_dep]['nc_plte_erreur'] = 0;
337
				$this->aso_totaux_dep[$code_dep]['nc_plte_disparue'] = 0;
338
				$this->aso_totaux_dep[$code_dep]['nc_plte_erreur_a_confirmer'] = 0;
339
				$this->aso_totaux_dep[$code_dep]['nc_autres_valeur_champ'] = 0;
340
			}
341
		}
342
	}
343
 
344
	private function verifierDonnees() {
11 jpm 345
		// Ouverture du fichier contenant les résultats (sortie)
346
		if (!$handle = fopen($this->fichier_verif, 'w')) {
347
			echo "Impossible d'ouvrir le fichier ($this->fichier_verif)";
348
			exit;
349
		}
350
 
351
		// Création de la page
352
		$page = '<html>'."\n";
353
		$page .= '<head>'."\n";
242 jpm 354
		$page .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'."\n";
11 jpm 355
		$page .= '<title>RESULTAT DE LA VERIFICATION DU FICHIER TABULE DE LA CHOROLOGIE</title>'."\n";
356
		$page .= '</head>'."\n";
357
		$page .= '<body>'."\n";
358
		$page .= '<h1>RESULTAT DE LA VERIFICATION DU FICHIER TABULE DE LA CHOROLOGIE</h1>'."\n";
359
		$page .= '<hr/>'."\n";
360
		$page .= 	'<p>'.
361
						'Adresse fichier analysé : '.'<br />'."\n".
362
						'</p>'."\n";
363
		$page .= '<hr/>'."\n";
364
		$page .= '<h2>RESULTATS PROGRAMME DE VERIFICATION</h2>'."\n";
365
		$page .= 	'<p>'.
366
						'Nom du programme générant ce fichier : '.__FILE__.'<br />'."\n".
367
						'Nombre de lignes analysées : '.$this->nbre_ligne.'<br />'."\n".
368
						'Nbre de départements analysés : '.$this->nbre_dep_analyse.'<br />'."\n".
242 jpm 369
						'Date d\'exécution du programme : '.date('d.m.Y').'<br />'."\n".
11 jpm 370
						'</p>'."\n";
371
		$page .= '<hr/>'."\n";
372
		$page .= '<h2>RESULTATS ANALYSE CHOROLOGIE</h2>'."\n";
373
		$page .= 	'<p>'.
374
						'Nombre de nom "nc" : '.$this->nc_nbre_nom.'<br />'."\n".
375
						'Nombre de nom : '.$this->nbre_nom.'<br />'."\n".
242 jpm 376
						'Valeurs autres que 1, 1?, ?, #, #? et -|- : '.$this->autres_valeur_champ.'<br />'."\n".
377
						'Valeurs autres que 1, 1?, ?, #, #? et -|- pour les plantes nc : <br />'."\n".$this->nc_autres_valeur_champ.'</br>'."\n".
11 jpm 378
						'</p>'."\n";
379
		$page .= '<hr/>'."\n";
380
		$page .= '<h2>RESULTATS ANALYSE des CHAMPS</h2>'."\n";
381
		$page .= 	'<p>'.
382
						'Nombre de guillemets antislashés: '.$this->nbre_ligne_avec_guillemet.'<br />'."\n".
383
						'</p>'."\n";
384
		$page .= '<hr/>'."\n";
385
		$page .= '<h2>TABLEAUX</h2>'."\n";
386
 
387
		// Tableau des numéros nomenclaturaux dupliqués
388
		$table = '<table><thead><tr><th colspan="3">Tableau des numéros nomenclaturaux dupliqués </th></tr>';
389
		$table .= '<tr><th>Numéro nomenclatural</th><th>Nbre d\'itération</th><th>Lignes</th></tr></thead>';
390
		$afficher_tab_num_duplique = 0;
391
		ksort($this->aso_num_nomenc);
392
		$table .= '<tbody style="text-align: center;">';
393
		foreach ($this->aso_num_nomenc as $cle_nomenc => $val ) {
394
			$ligne = '<tr><td>'.$cle_nomenc.'</td><td>'.$val['compteur'].'</td><td>'.$val['ligne'].'</td></tr>';
395
			if ($val['compteur'] > 1) {
396
				$table .= $ligne;
397
				$afficher_tab_num_duplique = 1;
398
			}
399
		}
400
		if ( $afficher_tab_num_duplique == 1 ) {
401
			$page .= $table.'</tbody></table>';
402
		}
403
 
404
		// Tableau des résultats par départements
242 jpm 405
		$table = '<table><thead><tr><th colspan="14">Tableau des résulats par départements</th></tr>';
11 jpm 406
		$table .= '<tr><th>Département</th><th>Nbre pltes présentes</th><th>Nbre pltes à confirmer</th>'.
242 jpm 407
			'<th>Nbre pltes douteuses</th><th>Nbre pltes disparues</th><th>Nbre pltes erreur</th><th>Nbre pltes erreur à confirmer</th>'.
11 jpm 408
			'<th>Total</th><th>Nbre pltes nc présentes</th><th>Nbre pltes nc à confirmer</th>'.
242 jpm 409
			'<th>Nbre nc pltes douteuses</th><th>Nbre nc pltes disparues</th><th>Nbre nc pltes erreur</th><th>Nbre nc pltes erreur à confirmer</th></tr></thead>';
11 jpm 410
		$table .= '<tbody style="text-align: center;">';
411
		ksort($this->aso_totaux_dep);
412
		foreach ($this->aso_totaux_dep as $cle_dep => $val ) {
242 jpm 413
			$plt_total = $val{'plte_presente'} + $val{'plte_a_confirmer'} + $val{'plte_douteux'} + $val{'plte_disparue'} + $val{'plte_erreur'} + $val{'plte_erreur_a_confirmer'};
11 jpm 414
			$table .= '<tr><td>'.ZgFrDepartements::getNom($cle_dep).' ('.ZgFrDepartements::getIdChaine($cle_dep).') </td>'.
415
				'<td>'.$val{'plte_presente'}.'</td><td>'.$val{'plte_a_confirmer'}.'</td><td>'.$val{'plte_douteux'}.'</td>'.
242 jpm 416
				'<td>'.$val{'plte_disparue'}.'</td><td>'.$val{'plte_erreur'}.'</td><td>'.$val{'plte_erreur_a_confirmer'}.'</td><td>'.$plt_total.'</td>'.
11 jpm 417
				'<td>'.$val{'nc_plte_presente'}.'</td><td>'.$val{'nc_plte_a_confirmer'}.'</td><td>'.$val{'nc_plte_douteux'}.'</td>'.
242 jpm 418
				'<td>'.$val{'nc_plte_disparue'}.'</td><td>'.$val{'nc_plte_erreur'}.'</td><td>'.$val{'nc_plte_erreur_a_confirmer'}.'</td></tr>';
11 jpm 419
		}
420
 
242 jpm 421
		$table .= '<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
422
				'<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
423
		$plt_total = $this->nbre_plte_presente + $this->nbre_plte_a_confirmer + $this->nbre_plte_douteux + $this->nbre_plte_disparue + $this->nbre_plte_erreur + $this->nbre_plte_erreur_a_confirmer;
11 jpm 424
		$table .= '<tr><td>Totaux : '.$this->nbre_dep_analyse.' départements</td><td>'.$this->nbre_plte_presente.'</td>'.
425
			'<td>'.$this->nbre_plte_a_confirmer.'</td><td>'.$this->nbre_plte_douteux.'</td><td>'.$this->nbre_plte_disparue.'</td>'.
242 jpm 426
			'<td>'.$this->nbre_plte_erreur.'</td><td>'.$this->nbre_plte_erreur_a_confirmer.'</td><td>'.$plt_total.'</td>'.
11 jpm 427
			'<td>'.$this->nc_nbre_plte_presente.'</td>'.'<td>'.$this->nc_nbre_plte_a_confirmer.'</td>'.
242 jpm 428
			'<td>'.$this->nc_nbre_plte_douteux.'</td><td>'.$this->nc_nbre_plte_disparue.'</td><td>'.$this->nc_nbre_plte_erreur.'</td><td>'.$this->nc_nbre_plte_erreur_a_confirmer.'</td></tr>';
11 jpm 429
 
430
		$table .= '<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
431
				'<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
242 jpm 432
		$total_nbre_plte = ($this->nbre_plte_presente + $this->nbre_plte_a_confirmer + $this->nbre_plte_douteux + $this->nbre_plte_disparue + $this->nbre_plte_erreur + $this->nbre_plte_erreur_a_confirmer);
433
		$total_nbre_plte_nc = ($this->nc_nbre_plte_presente + $this->nc_nbre_plte_a_confirmer + $this->nc_nbre_plte_douteux + $this->nc_nbre_plte_disparue + $this->nc_nbre_plte_erreur + $this->nc_nbre_plte_erreur_a_confirmer);
434
		$table .= '<tr><td>Totaux plante / plante nc</td><td colspan="7">'.$total_nbre_plte.'</td>'.
435
			'<td colspan="6">'.$total_nbre_plte_nc.'</td></tr>';
11 jpm 436
 
242 jpm 437
		$table .= '<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
438
				'<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
11 jpm 439
		$plt_total = $this->nbre_plte_presente + $this->nc_nbre_plte_presente + $this->nc_nbre_plte_a_confirmer + $this->nbre_plte_a_confirmer;
242 jpm 440
		$table .= '<tr><td>Total plantes présentes et à confirmer</td><td colspan="13">'.$plt_total.'</td></tr>';
11 jpm 441
 
242 jpm 442
		$table .= '<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
443
				'<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
11 jpm 444
		$plt_total = $this->nbre_plte_presente + $this->nc_nbre_plte_presente;
242 jpm 445
		$table .= '<tr><td>Total plantes présentes</td><td colspan="13">'.$plt_total.'</td></tr>';
11 jpm 446
 
242 jpm 447
		$table .= '<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
448
				'<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
11 jpm 449
		$plt_total = $total_nbre_plte + $total_nbre_plte_nc;
242 jpm 450
		$table .= '<tr><td>Total données chorologiques</td><td colspan="13">'.$plt_total.'</td></tr>';
11 jpm 451
 
452
		$table .= '</tbody></table>';
453
		$page .= $table;
454
 
455
		$page .= '<hr/>'."\n";
456
		$page .= '<h2>NOTES</h2>'."\n";
457
		$page .= 	'<p>'.
458
						'1.- Chaque champ précédé par "ATTENTION" doit être vide.'."\n".
459
						'S\'il ne l\'est pas, il y a une erreur'."\n".
460
						'</p>'."\n";
461
		$page .= '</body>'."\n";
462
		$page .= '</html>'."\n";
463
		// Fermeture de la poignée sur le fichier de sortie
464
		if (fwrite($handle, $page) === FALSE) {
465
			echo "Impossible d'écrire dans le fichier ($this->fichier_verif)";
466
			exit;
467
		}
468
		echo 'Ecriture du fichier de vérification de la chorologie réalisée!'."\n";
469
		fclose($handle);
470
	}
471
 
242 jpm 472
	private function supprimerTous() {
473
		$tablesChorodep = implode(',', $this->getNomsTablesChorodep());
474
		$tableContributeurs = Config::get('tables.chorodepContributeurs');
475
		$tableSources = Config::get('tables.chorodepSources');
476
		$tableOntologies = Config::get('tables.chorodepOntologies');
477
		$requete = "DROP TABLE chorodep_meta, $tablesChorodep, $tableContributeurs, $tableSources, $tableOntologies";
478
		$this->getBdd()->requeter($requete);
479
	}
480
 
481
	private function getNomsTablesChorodep() {
482
		$versions = explode(',', Config::get('versions'));
483
		$tableTpl = Config::get('tables.chorodepTpl');
484
		$tablesChorodep = array();
485
		foreach ($versions as $version) {
486
			$tablesChorodep[] = sprintf($tableTpl, $version);
487
		}
488
		return $tablesChorodep;
489
	}
490
 
491
	private function getNomTableDernierVersion() {
492
		$version = $this->getDerniereVersion();
493
		$table = sprintf(Config::get('tables.chorodepTpl'), $version);
494
		return $table;
495
	}
496
 
497
	private function getDerniereVersion() {
498
		$version = array_pop(explode(',', Config::get('versions')));
499
		return $version;
500
	}
11 jpm 501
}
502
 
503
class ZgFrDepartements {
504
	static private $departements =
505
        array(
506
        "01" => array("Ain", "01", 1),
507
        "02" => array("Aisne", "02", 2),
508
        "03" => array("Allier", "03", 3),
509
        "04" => array("Alpes-de-Haute-Provence", "04", 4),
510
        "05" => array("Hautes-Alpes", "05", 5),
511
        "06" => array("Alpes-Maritimes", "06", 6),
512
        "07" => array("Ardèche", "07", 7),
513
        "08" => array("Ardennes", "08", 8),
514
        "09" => array("Ariège", "09", 9),
515
        "10" => array("Aube", "10", 10),
516
        "11" => array("Aude", "11", 11),
517
        "12" => array("Aveyron", "12", 12),
518
        "13" => array("Bouches-du-Rhône", "13", 13),
519
        "14" => array("Calvados", "14", 14),
520
        "15" => array("Cantal", "15", 15),
521
        "16" => array("Charente", "16", 16),
522
        "17" => array("Charente-Maritime", "17", 17),
523
        "18" => array("Cher", "18", 18),
524
        "19" => array("Corrèze", "19", 19),
525
        "20" => array("Corse", "20", 20),
526
        "2A" => array("Haute-Corse", "2A", 20),
527
        "2B" => array("Corse-du-Sud", "2B", 20),
528
        "21" => array("Côte-d'Or", "21", 21),
529
        "22" => array("Côtes-d'Armor", "22", 22),
530
        "23" => array("Creuse", "23", 23),
531
        "24" => array("Dordogne", "24", 24),
532
        "25" => array("Doubs","25", 25),
533
        "26" => array("Drôme", "26", 26),
534
        "27" => array("Eure", "27", 27),
535
        "28" => array("Eure-et-Loir", "28", 28),
536
        "29" => array("Finistère", "29", 29),
537
        "30" => array("Gard", "30", 30),
538
        "31" => array("Haute-Garonne", "31", 31),
539
        "32" => array("Gers", "32", 32),
540
        "33" => array("Gironde", "33", 33),
541
        "34" => array("Hérault", "34", 34),
542
        "35" => array("Ille-et-Vilaine", "35", 35),
543
        "36" => array("Indre", "36", 36),
544
        "37" => array("Indre-et-Loire", "37", 37),
545
        "38" => array("Isère", "38", 38),
546
        "39" => array("Jura", "39", 39),
547
        "40" => array("Landes", "40", 40),
548
        "41" => array("Loir-et-Cher", "41", 41),
549
        "42" => array("Loire", "42", 42),
550
        "43" => array("Haute-Loire", "43", 43),
551
        "44" => array("Loire-Atlantique", "44", 44),
552
        "45" => array("Loiret", "45", 45),
553
        "46" => array("Lot", "46", 46),
554
        "47" => array("Lot-et-Garonne", "47", 47),
555
        "48" => array("Lozére ", "48", 48),
556
        "49" => array("Maine-et-Loire", "49", 49),
557
        "50" => array("Manche", "50", 50),
558
        "51" => array("Marne", "51", 51),
559
        "52" => array("Haute-Marne", "52", 52),
560
        "53" => array("Mayenne", "53", 53),
561
        "54" => array("Meurthe-et-Moselle", "54", 54),
562
        "55" => array("Meuse", "55", 55),
563
        "56" => array("Morbihan", "56", 56),
564
        "57" => array("Moselle", "57", 57),
565
        "58" => array("Nièvre", "58", 58),
566
        "59" => array("Nord", "59", 59),
567
        "60" => array("Oise", "60", 60),
568
        "61" => array("Orne", "61", 61),
569
        "62" => array("Pas-de-Calais", "62", 62),
570
        "63" => array("Puy-de-Dôme", "63", 63),
571
        "64" => array("Pyrénées-Atlantiques", "64", 64),
572
        "65" => array("Hautes-Pyrénées", "65", 65),
573
        "66" => array("Pyrénées-Orientales", "66", 66),
574
        "67" => array("Bas-Rhin", "67", 67),
575
        "68" => array("Haut-Rhin", "68", 68),
576
        "69" => array("Rhône", "69", 69),
577
        "70" => array("Haute-Saône", "70", 70),
578
        "71" => array("Saône-et-Loire", "71", 71),
579
        "72" => array("Sarthe", "72", 72),
580
        "73" => array("Savoie", "73", 73),
581
        "74" => array("Haute-Savoie", "74", 74),
582
        "75" => array("Paris", "75", 75),
583
        "76" => array("Seine-Maritime", "76", 76),
584
        "77" => array("Seine-et-Marne", "77", 77),
585
        "78" => array("Yvelines", "78", 78),
586
        "79" => array("Deux-Sèvres", "79", 79),
587
        "80" => array("Somme", "80", 80),
588
        "81" => array("Tarn", "81", 81),
589
        "82" => array("Tarn-et-Garonne", "82", 82),
590
        "83" => array("Var", "83", 83),
591
        "84" => array("Vaucluse", "84", 84),
592
        "85" => array("Vendée", "85", 85),
593
        "86" => array("Vienne", "86", 86),
594
        "87" => array("Haute-Vienne", "87", 87),
595
        "88" => array("Vosges", "88", 88),
596
        "89" => array("Yonne", "89", 89),
597
        "90" => array("Territoire-de-Belfort", "90", 90),
598
        "91" => array("Essonne", "91", 91),
599
        "92" => array("Hauts-de-Seine", "92", 92),
600
        "93" => array("Seine-Saint-Denis", "93", 93),
601
        "94" => array("Val-de-Marne", "94", 94),
602
        "95" => array("Val-d'Oise", "95", 95),
603
        "96" => array("aaa", "96", 96),
604
        "971" => array("Guadeloupe", "971", 971),
605
        "972" => array("Martinique", "972", 972),
606
        "973" => array("Guyane", "973", 973),
607
        "974" => array("Réunion", "974", 974),
608
        "99" => array("Etranger", "99", 99),
609
        );
610
 
611
	static public function get() {
612
		return self::$departements;
613
	}
614
 
615
    static public function getNom($n) {
616
		return self::$departements[$n][0];
617
	}
618
 
619
	static public function getIdChaine($n) {
620
		return self::$departements[$n][1];
621
	}
622
 
623
	static public function getIdNumerique($n) {
624
		return (int)self::$departements[$n][2];
625
	}
626
 
627
	static public function getIdEflore($n) {
628
		return (int)self::$departements[$n][3];
629
	}
630
}
631
?>