6,6 → 6,8 |
const ABBR_LISTE_EVENEMENTS = 'evenement'; |
const ABBR_LISTE_ESPECES = 'espece'; |
|
private $type_mime = 'text/html'; |
|
/** |
* Méthodes d'extractions d'informations |
*/ |
30,7 → 32,7 |
} |
} |
|
$this->envoyer($info); |
$this->envoyer($info,$this->type_mime); |
} |
|
public function getExportObservation($start = null,$limit = null, $order_by = 'oo_date') { |
119,7 → 121,7 |
public function getExportObservationPlat() { |
|
$donnees = $this->getExportObservation(); |
$donnees_formatees = $this->formaterPourExportCSV($donnees); |
$donnees_formatees = $this->formaterPourExportObservationCSV($donnees); |
|
return $donnees_formatees ; |
} |
127,12 → 129,14 |
public function getExportObservationJson() { |
|
$donnees = $this->getExportObservation(); |
$donnees_formatees = $this->formaterPourExportJson($donnees); |
$donnees_formatees = $this->formaterPourExportObservationJson($donnees); |
|
$this->type_mime = 'application/json'; |
|
return $donnees_formatees; |
} |
|
public function formaterPourExportJson($tableau_observations_infos) { |
public function formaterPourExportObservationJson($tableau_observations_infos) { |
|
$gestionnaire_especes = new OdsEspece($this->config); |
$gestionnaire_communes = new OdsCommune($this->config); |
186,13 → 190,13 |
public function getFichierExportObservationCsv() { |
|
$donnees = $this->getExportObservation(); |
$donnees_formatees = $this->formaterPourExportCSV($donnees); |
$donnees_formatees = $this->formaterPourExportObservationCSV($donnees); |
$chaine_csv = $this->convertirTableauAssocVersCSV($donnees_formatees); |
|
$this->envoyerFichier($chaine_csv); |
} |
|
public function formaterPourExportCSV($tableau_observations_infos) { |
public function formaterPourExportObservationCSV($tableau_observations_infos) { |
|
$gestionnaire_especes = new OdsEspece($this->config); |
$gestionnaire_communes = new OdsCommune($this->config); |
260,6 → 264,86 |
return $resultats_formates; |
} |
|
public function getExportStationJson() { |
|
$donnees = $this->getExportStation(); |
$donnees_formatees = $this->formaterPourExportStationJson($donnees); |
|
$this->type_mime = 'application/json'; |
|
return $donnees_formatees; |
} |
|
public function getExportStation() { |
|
$requete_selection_stations = 'SELECT * FROM ods_stations '. |
' LEFT JOIN ods_individus '. |
' ON ods_individus.oi_ce_station = ods_stations.os_id_station '. |
' ORDER BY ods_stations.os_id_station, ods_individus.oi_ce_espece '; |
|
$res_selection_stations = $this->executerRequete($requete_selection_stations); |
|
return $res_selection_stations; |
} |
|
public function formaterPourExportStationJson($tableau_stations_infos) { |
|
$gestionnaire_especes = new OdsEspece($this->config); |
$gestionnaire_communes = new OdsCommune($this->config); |
$gestionnaire_utilisateurs = new OdsUtilisateur($this->config); |
|
$especes = $gestionnaire_especes->getToutesEspeces(); |
|
$resultats_formates = array(); |
|
foreach($tableau_stations_infos as &$stations_infos) { |
|
if($stations_infos['os_ce_commune'] == "NULL") { |
$stations_infos['os_ce_commune'] = ''; |
} |
|
$resultats_formates[$stations_infos['os_id_station']] = array( |
'station' => $stations_infos['os_nom'], |
'code_commune' => $stations_infos['os_ce_commune'], |
'nom_commune' => '', |
'latitude' => $stations_infos['os_latitude'], |
'longitude' => $stations_infos['os_longitude'], |
'altitude' => $stations_infos['os_altitude'], |
'id_participant' => $stations_infos['os_ce_participant'], |
'pseudo_participant' => '', |
'mail_participant' => '' |
); |
|
$infos_espece = $especes[$stations_infos['oi_ce_espece']]; |
if($infos_espece['type'] != "") { |
$infos_espece['type'] = $this->obtenirValeurTripleParId($infos_espece['type']); |
} |
|
$resultats_formates[$stations_infos['os_id_station']]['especes'][] = $infos_espece; |
|
if(is_numeric($stations_infos['os_ce_commune'])) { |
$codes_insee_communes[] = $stations_infos['os_ce_commune']; |
} |
} |
|
$correspondance_codes_insee_noms = $gestionnaire_communes->obtenirTableauNomsCommunesParTableauCodesInsee($codes_insee_communes); |
$correspondance_id_utilisateur = $gestionnaire_utilisateurs->getListeUtilisateurAvecInfosComplementairesFormateeId(); |
|
foreach($resultats_formates as &$resultat) { |
|
if(isset($correspondance_codes_insee_noms[$resultat['code_commune']]) && trim($correspondance_codes_insee_noms[$resultat['code_commune']]) != '') { |
$resultat['nom_commune'] = $correspondance_codes_insee_noms[$resultat['code_commune']]; |
} |
|
$resultat['pseudo_participant'] = $correspondance_id_utilisateur[$resultat['id_participant']]['name']; |
$resultat['mail_participant'] = $correspondance_id_utilisateur[$resultat['id_participant']]['mail']; |
|
//TODO: selection champ infos complémentaires à transmettre |
} |
|
return $resultats_formates; |
} |
|
public function convertirTableauAssocVersCSV($tableau) { |
|
$csv = ''; |