Subversion Repositories Sites.obs-saisons.fr

Rev

Rev 264 | Rev 271 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 264 Rev 270
Line 34... Line 34...
34
        }
34
        }
Line 35... Line 35...
35
 
35
 
36
	$this->envoyer($info,$this->type_mime);
36
		$this->envoyer($info,$this->type_mime);
Line -... Line 37...
-
 
37
    }
-
 
38
    
-
 
39
    public function getExportStationJson() {
-
 
40
    
-
 
41
    	$donnees = $this->getExportStation();
-
 
42
    	$donnees_formatees = $this->formaterListeStationPourExportJson($donnees);
-
 
43
    
-
 
44
    	$this->type_mime = 'application/json';
-
 
45
    
-
 
46
    	return $donnees_formatees;
-
 
47
    }
-
 
48
    
-
 
49
    public function getExportStation($start = null,$limit = null, $order_by = 'oo_date') {
-
 
50
    
-
 
51
    	$requete_selection_stations = 'SELECT * FROM ods_stations ';    
-
 
52
    	$res_selection_stations = $this->executerRequete($requete_selection_stations);
-
 
53
    
-
 
54
    	return $res_selection_stations;
-
 
55
    }
-
 
56
    
-
 
57
    public function formaterListeStationPourExportJson($tableau_stations_infos) {
-
 
58
    
-
 
59
    	$gestionnaire_especes = new OdsEspece($this->config);
-
 
60
    	$gestionnaire_communes = new OdsCommune($this->config);
-
 
61
    	$gestionnaire_utilisateurs = new OdsUtilisateur($this->config);
-
 
62
    
-
 
63
    	$especes = $gestionnaire_especes->getToutesEspeces();
-
 
64
    	$evenements = $this->obtenirValeursListeParAbreviation(self::ABBR_LISTE_EVENEMENTS);
-
 
65
    	$milieux = $this->obtenirValeursListeParAbreviation(self::ABBR_LISTE_MILIEUX);
-
 
66
    	$utilisateurs = $gestionnaire_utilisateurs->getListeUtilisateurAvecInfosComplementairesFormateeId();
-
 
67
    	$communes = $gestionnaire_communes->obtenirCommunesLieesAStationIndexeesCodeInsee();
-
 
68
  
-
 
69
    	$resultats_formates = array();
-
 
70
    	$stats = array('total' => count($tableau_stations_infos));
-
 
71
    	
-
 
72
    	foreach($tableau_stations_infos as $stations_infos) {    		
-
 
73
    		$commune = isset($communes[$stations_infos['os_ce_commune']]['oc_nom']) ? $communes[$stations_infos['os_ce_commune']]['oc_nom'] : '';
-
 
74
    		
-
 
75
    		$id_station = $stations_infos['os_id_station'];
-
 
76
    		$resultats_formates[$id_station]['nom'] = $stations_infos['os_nom'];
-
 
77
    		$resultats_formates[$id_station]['code_commune'] = is_numeric($stations_infos['os_ce_commune']) ? substr($stations_infos['os_ce_commune'], 0, 2) : '';
-
 
78
    		$resultats_formates[$id_station]['nom_commune'] = $commune;
-
 
79
    		$resultats_formates[$id_station]['latitude'] = $stations_infos['os_latitude'];
-
 
80
    		$resultats_formates[$id_station]['longitude'] = $stations_infos['os_longitude'];
-
 
81
    		$resultats_formates[$id_station]['altitude'] = $stations_infos['os_altitude'];
-
 
82
    		$resultats_formates[$id_station]['type_participant'] = 'Particulier';
-
 
83
    		
-
 
84
    		if(isset($utilisateurs[$stations_infos['os_ce_participant']])) {
-
 
85
    			$participant = $utilisateurs[$stations_infos['os_ce_participant']];
-
 
86
    			$resultats_formates[$id_station]['participant']['id'] = $participant['uid'];
-
 
87
    			$resultats_formates[$id_station]['participant']['nom'] = $participant['name'];
-
 
88
    			$resultats_formates[$id_station]['type_participant'] = isset($participant['profile_type']) ? $participant['profile_type'] : 'Particulier';
-
 
89
    		} else {
-
 
90
    			$resultats_formates[$id_station]['participant']['id'] = null;
-
 
91
    			$resultats_formates[$id_station]['participant']['nom'] = 'Anonyme';
-
 
92
    			$resultats_formates[$id_station]['type_participant'] = 'Particulier';
-
 
93
    		}
-
 
94
    		if(isset($stats[$resultats_formates[$id_station]['type_participant']])) {
-
 
95
    			$stats[$resultats_formates[$id_station]['type_participant']]++;
-
 
96
    		} else {
-
 
97
    			$stats[$resultats_formates[$id_station]['type_participant']] = 1;
-
 
98
    		}
-
 
99
    	}
-
 
100
    	$resultat = array('stats' => $stats, 'stations' => $resultats_formates);
-
 
101
    	
-
 
102
    	return $resultat;
37
    }
103
    }
Line 38... Line 104...
38
	
104
	
39
	public function getExportObservation($start = null,$limit = null, $order_by = 'oo_date') {
105
	public function getExportObservation($start = null,$limit = null, $order_by = 'oo_date') {
40
						
106
						
Line 139... Line 205...
139
	}
205
	}
Line 140... Line 206...
140
	
206
	
Line 141... Line 207...
141
	public function getExportObservationPlat() {
207
	public function getExportObservationPlat() {
142
				
208
				
Line 143... Line 209...
143
		$donnees = $this->getExportObservation();
209
		$donnees = $this->getExportObservation();
144
		$donnees_formatees = $this->formaterPourExportCSV($donnees);	
210
		$donnees_formatees = $this->formaterListeObservationPourExportCSV($donnees);	
Line 145... Line 211...
145
			
211
			
Line 146... Line 212...
146
		return $donnees_formatees ;
212
		return $donnees_formatees ;
147
	}
213
	}
Line 148... Line 214...
148
	
214
	
Line 149... Line 215...
149
	public function getExportObservationJson() {
215
	public function getExportObservationJson() {
150
		
216
		
Line 151... Line 217...
151
		$donnees = $this->getExportObservation();
217
		$donnees = $this->getExportObservation();
Line 152... Line 218...
152
		$donnees_formatees = $this->formaterPourExportJson($donnees);
218
		$donnees_formatees = $this->formaterListeObservationPourExportJson($donnees);
153
 
219
 
Line 154... Line 220...
154
		$this->type_mime = 'application/json';
220
		$this->type_mime = 'application/json';
Line 209... Line 275...
209
	}
275
	}
Line 210... Line 276...
210
	
276
	
Line 211... Line 277...
211
	public function getFichierExportObservationCsv() {
277
	public function getFichierExportObservationCsv() {
212
				
278
				
213
		$donnees = $this->getExportObservation();
279
		$donnees = $this->getExportObservation();
Line 214... Line 280...
214
		$donnees_formatees = $this->formaterPourExportCSV($donnees);		
280
		$donnees_formatees = $this->formaterListeObservationPourExportCSV($donnees);		
215
		$chaine_csv = $this->convertirTableauAssocVersCSV($donnees_formatees);
281
		$chaine_csv = $this->convertirTableauAssocVersCSV($donnees_formatees);
Line 216... Line 282...
216
			
282
			
Line 217... Line 283...
217
		$this->envoyerFichier($chaine_csv);
283
		$this->envoyerFichier($chaine_csv);
218
	}
284
	}
219
	
285