Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

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