Subversion Repositories Sites.obs-saisons.fr

Rev

Rev 235 | Rev 248 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 235 Rev 246
Line 4... Line 4...
4
	
4
	
5
	const PREFIXE = 'get';
5
	const PREFIXE = 'get';
6
	const ABBR_LISTE_EVENEMENTS = 'evenement';
6
	const ABBR_LISTE_EVENEMENTS = 'evenement';
Line -... Line 7...
-
 
7
	const ABBR_LISTE_ESPECES = 'espece';
-
 
8
	
7
	const ABBR_LISTE_ESPECES = 'espece';
9
	private $type_mime = 'text/html';
8
	
10
	
9
	/**
11
	/**
Line 10... Line 12...
10
 	* Méthodes d'extractions d'informations
12
 	* Méthodes d'extractions d'informations
Line 28... Line 30...
28
            } else {
30
            } else {
29
                $this->messages[] = "Le type d'information demandé '$type' n'est pas disponible.";
31
                $this->messages[] = "Le type d'information demandé '$type' n'est pas disponible.";
30
            }
32
            }
31
        }
33
        }
Line 32... Line 34...
32
       
34
       
33
        $this->envoyer($info);
35
        $this->envoyer($info,$this->type_mime);
34
    }
36
    }
35
	
37
    	
Line 36... Line 38...
36
	public function getExportObservation($start = null,$limit = null, $order_by = 'oo_date') {
38
	public function getExportObservation($start = null,$limit = null, $order_by = 'oo_date') {
37
						
39
						
38
		$requete_selection_observations = 'SELECT * FROM ods_observations '.
40
		$requete_selection_observations = 'SELECT * FROM ods_observations '.
Line 117... Line 119...
117
	}
119
	}
Line 118... Line 120...
118
	
120
	
Line 119... Line 121...
119
	public function getExportObservationPlat() {
121
	public function getExportObservationPlat() {
120
				
122
				
Line 121... Line 123...
121
		$donnees = $this->getExportObservation();
123
		$donnees = $this->getExportObservation();
122
		$donnees_formatees = $this->formaterPourExportCSV($donnees);	
124
		$donnees_formatees = $this->formaterPourExportObservationCSV($donnees);	
Line 123... Line 125...
123
			
125
			
Line 124... Line 126...
124
		return $donnees_formatees ;
126
		return $donnees_formatees ;
125
	}
127
	}
-
 
128
	
-
 
129
	public function getExportObservationJson() {
Line 126... Line 130...
126
	
130
		
127
	public function getExportObservationJson() {
131
		$donnees = $this->getExportObservation();
Line 128... Line 132...
128
		
132
		$donnees_formatees = $this->formaterPourExportObservationJson($donnees);
Line 129... Line 133...
129
		$donnees = $this->getExportObservation();
133
		
130
		$donnees_formatees = $this->formaterPourExportJson($donnees);
134
		$this->type_mime = 'application/json';
Line 131... Line 135...
131
		
135
		
Line 184... Line 188...
184
	}
188
	}
Line 185... Line 189...
185
	
189
	
Line 186... Line 190...
186
	public function getFichierExportObservationCsv() {
190
	public function getFichierExportObservationCsv() {
187
				
191
				
188
		$donnees = $this->getExportObservation();
192
		$donnees = $this->getExportObservation();
Line 189... Line 193...
189
		$donnees_formatees = $this->formaterPourExportCSV($donnees);		
193
		$donnees_formatees = $this->formaterPourExportObservationCSV($donnees);		
190
		$chaine_csv = $this->convertirTableauAssocVersCSV($donnees_formatees);
194
		$chaine_csv = $this->convertirTableauAssocVersCSV($donnees_formatees);
Line 191... Line 195...
191
			
195
			
Line 192... Line 196...
192
		$this->envoyerFichier($chaine_csv);
196
		$this->envoyerFichier($chaine_csv);
193
	}
197
	}
194
	
198
	
Line 258... Line 262...
258
		}
262
		}
Line 259... Line 263...
259
		
263
		
260
		return $resultats_formates;
264
		return $resultats_formates;
Line -... Line 265...
-
 
265
	}
-
 
266
	
-
 
267
	public function getExportStationJson() {
-
 
268
    	
-
 
269
    	$donnees = $this->getExportStation();
-
 
270
    	$donnees_formatees = $this->formaterPourExportStationJson($donnees);
-
 
271
    	
-
 
272
    	$this->type_mime = 'application/json';
-
 
273
    	
-
 
274
    	return $donnees_formatees;
-
 
275
    }
-
 
276
    
-
 
277
    public function getExportStation() {
-
 
278
    	
-
 
279
    	$requete_selection_stations = 'SELECT * FROM ods_stations '.
-
 
280
    								  ' LEFT JOIN ods_individus '.
-
 
281
    								  ' ON ods_individus.oi_ce_station = ods_stations.os_id_station '.
-
 
282
    								  ' ORDER BY ods_stations.os_id_station, ods_individus.oi_ce_espece ';
-
 
283
    								  
-
 
284
 		$res_selection_stations = $this->executerRequete($requete_selection_stations);
-
 
285
 		
-
 
286
 		return $res_selection_stations;
-
 
287
    }
-
 
288
    
-
 
289
    public function formaterPourExportStationJson($tableau_stations_infos) {
-
 
290
    	
-
 
291
    	$gestionnaire_especes = new OdsEspece($this->config);
-
 
292
		$gestionnaire_communes = new OdsCommune($this->config);
-
 
293
		$gestionnaire_utilisateurs = new OdsUtilisateur($this->config);		
-
 
294
				
-
 
295
		$especes = $gestionnaire_especes->getToutesEspeces();
-
 
296
		
-
 
297
		$resultats_formates = array();
-
 
298
		
-
 
299
		foreach($tableau_stations_infos as &$stations_infos) {
-
 
300
			
-
 
301
			if($stations_infos['os_ce_commune'] == "NULL") {
-
 
302
				$stations_infos['os_ce_commune'] = '';
-
 
303
			}
-
 
304
			
-
 
305
			$resultats_formates[$stations_infos['os_id_station']] = array(
-
 
306
				'station' => $stations_infos['os_nom'],
-
 
307
				'code_commune' => $stations_infos['os_ce_commune'],
-
 
308
				'nom_commune' => '',
-
 
309
				'latitude' => $stations_infos['os_latitude'],
-
 
310
				'longitude' => $stations_infos['os_longitude'],
-
 
311
				'altitude' => $stations_infos['os_altitude'],
-
 
312
				'id_participant' => $stations_infos['os_ce_participant'],
-
 
313
				'pseudo_participant' => '',
-
 
314
				'mail_participant' => ''
-
 
315
			);
-
 
316
			
-
 
317
			$infos_espece = $especes[$stations_infos['oi_ce_espece']];
-
 
318
			if($infos_espece['type'] != "") {
-
 
319
				$infos_espece['type'] = $this->obtenirValeurTripleParId($infos_espece['type']);
-
 
320
			}
-
 
321
			
-
 
322
			$resultats_formates[$stations_infos['os_id_station']]['especes'][] = $infos_espece;
-
 
323
			
-
 
324
			if(is_numeric($stations_infos['os_ce_commune'])) {
-
 
325
				$codes_insee_communes[] = $stations_infos['os_ce_commune'];
-
 
326
			}
-
 
327
		}
-
 
328
		
-
 
329
		$correspondance_codes_insee_noms = $gestionnaire_communes->obtenirTableauNomsCommunesParTableauCodesInsee($codes_insee_communes);
-
 
330
		$correspondance_id_utilisateur = $gestionnaire_utilisateurs->getListeUtilisateurAvecInfosComplementairesFormateeId();
-
 
331
		
-
 
332
		foreach($resultats_formates as &$resultat) {
-
 
333
			
-
 
334
			if(isset($correspondance_codes_insee_noms[$resultat['code_commune']]) && trim($correspondance_codes_insee_noms[$resultat['code_commune']]) != '') {								
-
 
335
				$resultat['nom_commune'] = $correspondance_codes_insee_noms[$resultat['code_commune']];
-
 
336
			}
-
 
337
			
-
 
338
			$resultat['pseudo_participant'] = $correspondance_id_utilisateur[$resultat['id_participant']]['name'];
-
 
339
			$resultat['mail_participant'] = $correspondance_id_utilisateur[$resultat['id_participant']]['mail'];
-
 
340
			
-
 
341
			//TODO: selection champ infos complémentaires à transmettre
-
 
342
		}
-
 
343
		
-
 
344
		return $resultats_formates;
261
	}
345
    }
Line 262... Line 346...
262
	
346
	
263
	public function convertirTableauAssocVersCSV($tableau) {
347
	public function convertirTableauAssocVersCSV($tableau) {
264
		
348