| Line 33... |
Line 33... |
| 33 |
// TODO : supprimer le TRIM quand les obs seront reliées correctements aux localisations (sur le code INSEE par exemple)
|
33 |
// TODO : supprimer le TRIM quand les obs seront reliées correctements aux localisations (sur le code INSEE par exemple)
|
| 34 |
class CelWidgetMapPoint extends Cel {
|
34 |
class CelWidgetMapPoint extends Cel {
|
| 35 |
const MARQUEUR_GROUPE = 'GROUPE';
|
35 |
const MARQUEUR_GROUPE = 'GROUPE';
|
| 36 |
const MARQUEUR_COMMUNE = 'COMMUNE';
|
36 |
const MARQUEUR_COMMUNE = 'COMMUNE';
|
| 37 |
const MARQUEUR_STATION = 'STATION';
|
37 |
const MARQUEUR_STATION = 'STATION';
|
| 38 |
private $standard = "AND donnees_standard = 1";
|
38 |
private $standard = "1";
|
| - |
|
39 |
private $table_export = "cel_export";
|
| Line 39... |
Line 40... |
| 39 |
|
40 |
|
| 40 |
/**
|
41 |
/**
|
| 41 |
* Méthode appelée avec une requête de type GET.
|
42 |
* Méthode appelée avec une requête de type GET.
|
| 42 |
*/
|
43 |
*/
|
| Line 46... |
Line 47... |
| 46 |
$this->parametres = array();
|
47 |
$this->parametres = array();
|
| 47 |
}
|
48 |
}
|
| 48 |
extract($this->parametres);
|
49 |
extract($this->parametres);
|
| 49 |
//Chronometre::chrono("Avant groupage");
|
50 |
//Chronometre::chrono("Avant groupage");
|
| 50 |
if (isset($this->parametres['standard']) && $this->parametres['standard'] == 0) {
|
51 |
if (isset($this->parametres['standard']) && $this->parametres['standard'] == 0) {
|
| 51 |
$this->standard = "";
|
52 |
$this->standard = "0";
|
| - |
|
53 |
$this->table_export = "cel_export_total";
|
| - |
|
54 |
|
| 52 |
}
|
55 |
}
|
| Line 53... |
Line 56... |
| 53 |
|
56 |
|
| 54 |
$action = array_shift($ressources);
|
57 |
$action = array_shift($ressources);
|
| 55 |
if (isset($action)) {
|
58 |
if (isset($action)) {
|
| Line 105... |
Line 108... |
| 105 |
|
108 |
|
| Line 106... |
Line 109... |
| 106 |
public function getTout($params) {
|
109 |
public function getTout($params) {
|
| 107 |
|
110 |
|
| 108 |
$emplacements = null;
|
- |
|
| - |
|
111 |
$emplacements = null;
|
| 109 |
$concatenation_id = "CONCAT(IFNULL(latitude,''),IFNULL(longitude,''), IFNULL(wgs84_latitude,''),IFNULL(wgs84_longitude,'')) ";
|
112 |
$concatenation_id = "CONCAT(IFNULL(latitude,''),IFNULL(longitude,''), IFNULL(wgs84_latitude,''),IFNULL(wgs84_longitude,'')) ";
|
| 110 |
|
113 |
$transmission = ( $this->standard = 0) ? "transmission = '1' AND " : "";
|
| 111 |
$requete = 'SELECT ce_zone_geo, zone_geo, station, '.
|
114 |
$requete = 'SELECT ce_zone_geo, zone_geo, station, '.
|
| 112 |
"mots_cles_texte, ".
|
115 |
"mots_cles_texte, ".
|
| 113 |
"latitude, ".
|
116 |
"latitude, ".
|
| 114 |
"wgs84_latitude, ".
|
117 |
"wgs84_latitude, ".
|
| 115 |
"longitude, ".
|
118 |
"longitude, ".
|
| 116 |
"wgs84_longitude, ".
|
119 |
"wgs84_longitude, ".
|
| 117 |
$concatenation_id." as id_coord ".
|
120 |
$concatenation_id." as id_coord ".
|
| 118 |
'FROM cel_export_total AS co '.
|
121 |
'FROM '.$this->table_export.' AS co '.
|
| 119 |
' LEFT JOIN cel_zones_geo AS zg '.
|
122 |
' LEFT JOIN cel_zones_geo AS zg '.
|
| 120 |
' ON (zg.nom = co.zone_geo AND zg.id_zone_geo = co.ce_zone_geo) '.
|
- |
|
| 121 |
"WHERE transmission = '1' ".
|
123 |
' ON (zg.nom = co.zone_geo AND zg.id_zone_geo = co.ce_zone_geo) '.
|
| 122 |
$this->standard.
|
124 |
"WHERE ".$transmission.
|
| 123 |
" AND (".
|
125 |
" (".
|
| 124 |
$this->construireWhereRectangleStationOR()." OR ".
|
126 |
$this->construireWhereRectangleStationOR()." OR ".
|
| 125 |
$this->construireWhereRectangleCommuneOR().") ".
|
127 |
$this->construireWhereRectangleCommuneOR().") ".
|
| 126 |
$this->construireWhereDept().
|
128 |
$this->construireWhereDept().
|
| Line 153... |
Line 155... |
| 153 |
}
|
155 |
}
|
| Line 154... |
Line 156... |
| 154 |
|
156 |
|
| Line 155... |
Line 157... |
| 155 |
private $nb_obs = 0;
|
157 |
private $nb_obs = 0;
|
| - |
|
158 |
|
| 156 |
|
159 |
private function compterObservations($params) {
|
| 157 |
private function compterObservations($params) {
|
160 |
$transmission = ( $this->standard = 0) ? "transmission = '1' AND " : "";
|
| 158 |
$requete = 'SELECT COUNT(*) as nb '.
|
161 |
$requete = 'SELECT COUNT(*) as nb '.
|
| 159 |
'FROM cel_export_total AS co '.
|
162 |
'FROM '.$this->table_export.' AS co '.
|
| 160 |
' LEFT JOIN cel_zones_geo AS zg '.
|
163 |
' LEFT JOIN cel_zones_geo AS zg '.
|
| 161 |
' ON (zg.nom = co.zone_geo AND zg.id_zone_geo = co.ce_zone_geo) '.
|
- |
|
| 162 |
"WHERE transmission = '1' ".
|
164 |
' ON (zg.nom = co.zone_geo AND zg.id_zone_geo = co.ce_zone_geo) '.
|
| 163 |
$this->standard.
|
165 |
"WHERE ".$transmission.
|
| 164 |
" AND (".
|
166 |
" (".
|
| 165 |
$this->construireWhereRectangleStationOR()." OR ".
|
167 |
$this->construireWhereRectangleStationOR()." OR ".
|
| 166 |
$this->construireWhereRectangleCommuneOR().") ".
|
168 |
$this->construireWhereRectangleCommuneOR().") ".
|
| 167 |
$this->construireWhereDept().
|
169 |
$this->construireWhereDept().
|
| Line 342... |
Line 344... |
| 342 |
* Données pour l'affichage des obs d'une station
|
344 |
* Données pour l'affichage des obs d'une station
|
| 343 |
*/
|
345 |
*/
|
| 344 |
public function getObservations($params) {
|
346 |
public function getObservations($params) {
|
| 345 |
$resultats = array();
|
347 |
$resultats = array();
|
| 346 |
$total = 0;
|
348 |
$total = 0;
|
| - |
|
349 |
$transmission = ( $this->standard = 0) ? "transmission = '1' " : "";
|
| - |
|
350 |
|
| 347 |
if (isset($this->parametres['station']) && !$this->etreNull($this->parametres['station'])) {
|
351 |
if (isset($this->parametres['station']) && !$this->etreNull($this->parametres['station'])) {
|
| 348 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS id_observation, ce_utilisateur, courriel_utilisateur, pseudo_utilisateur as nom_utilisateur, "" as prenom_utilisateur, '.
|
352 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS id_observation, ce_utilisateur, courriel_utilisateur, pseudo_utilisateur as nom_utilisateur, "" as prenom_utilisateur, '.
|
| 349 |
' nom_sel, nom_ret, nom_sel_nn, nom_ret_nn, "" as nt, famille, '.
|
353 |
' nom_sel, nom_ret, nom_sel_nn, nom_ret_nn, "" as nt, famille, '.
|
| 350 |
' lieudit, zone_geo, date_observation, milieu, commentaire, '.
|
354 |
' lieudit, zone_geo, date_observation, milieu, commentaire, '.
|
| 351 |
' utm_secteur, utm_x, utm_y, code, date_transmission, nom_referentiel '.
|
355 |
' utm_secteur, utm_x, utm_y, code, date_transmission, nom_referentiel '.
|
| 352 |
'FROM cel_export_total AS co '.
|
356 |
'FROM '.$this->table_export.' AS co '.
|
| 353 |
' LEFT JOIN cel_zones_geo AS zg '.
|
357 |
' LEFT JOIN cel_zones_geo AS zg '.
|
| 354 |
" ON (zg.nom = co.zone_geo AND zg.id_zone_geo = co.ce_zone_geo) ".
|
358 |
" ON (zg.nom = co.zone_geo AND zg.id_zone_geo = co.ce_zone_geo) ".
|
| 355 |
"WHERE transmission = '1' ".
|
359 |
"WHERE ".$transmission.
|
| 356 |
$this->standard.
|
- |
|
| 357 |
(($this->communeEstDemandee()) ? $this->construireWhereCommuneSansCoordonneesAvecSensibles() : $this->construireWhereCoordonneesSansSensibles()).
|
360 |
(($this->communeEstDemandee()) ? $this->construireWhereCommuneSansCoordonneesAvecSensibles() : $this->construireWhereCoordonneesSansSensibles()).
|
| 358 |
$this->construireWhereDept().
|
361 |
$this->construireWhereDept().
|
| 359 |
$this->construireWherePays().
|
362 |
$this->construireWherePays().
|
| 360 |
$this->construireWhereUtilisateur().
|
363 |
$this->construireWhereUtilisateur().
|
| 361 |
$this->construireWhereNumTaxonAvecSousTaxons().
|
364 |
$this->construireWhereNumTaxonAvecSousTaxons().
|
| Line 494... |
Line 497... |
| 494 |
/**
|
497 |
/**
|
| 495 |
* Liste des taxons présents sur la carte
|
498 |
* Liste des taxons présents sur la carte
|
| 496 |
*/
|
499 |
*/
|
| 497 |
public function getTaxons($params) {
|
500 |
public function getTaxons($params) {
|
| 498 |
$json = null;
|
501 |
$json = null;
|
| 499 |
|
- |
|
| - |
|
502 |
$transmission = ( $this->standard = 0) ? "transmission = '1' AND " : "";
|
| 500 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS DISTINCT nom_ret, nom_ret_nn, nt, famille '.
|
503 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS DISTINCT nom_ret, nom_ret_nn, nt, famille '.
|
| 501 |
'FROM cel_export_total AS co '.
|
504 |
'FROM '.$this->table_export.' AS co '.
|
| 502 |
' LEFT JOIN cel_zones_geo AS zg '.
|
505 |
' LEFT JOIN cel_zones_geo AS zg '.
|
| 503 |
' ON (zg.nom = co.zone_geo AND zg.id_zone_geo = co.ce_zone_geo) '.
|
506 |
' ON (zg.nom = co.zone_geo AND zg.id_zone_geo = co.ce_zone_geo) '.
|
| 504 |
"WHERE transmission = '1' ".
|
507 |
"WHERE ".$transmission.
|
| 505 |
$this->standard.
|
- |
|
| 506 |
" AND nom_ret != '' ".
|
508 |
" nom_ret != '' ".
|
| 507 |
$this->construireWhereDept().
|
509 |
$this->construireWhereDept().
|
| 508 |
$this->construireWhereCommune().
|
510 |
$this->construireWhereCommune().
|
| 509 |
$this->construireWherePays().
|
511 |
$this->construireWherePays().
|
| 510 |
$this->construireWhereUtilisateur().
|
512 |
$this->construireWhereUtilisateur().
|
| 511 |
$this->construireWhereNumTaxon().
|
513 |
$this->construireWhereNumTaxon().
|
| Line 645... |
Line 647... |
| 645 |
|
647 |
|
| 646 |
private function construireWhereReferentiel() {
|
648 |
private function construireWhereReferentiel() {
|
| 647 |
$sql = '';
|
649 |
$sql = '';
|
| 648 |
extract($this->parametres);
|
650 |
extract($this->parametres);
|
| 649 |
if (isset($referentiel) && !$this->etreNull($referentiel)) {
|
651 |
if (isset($referentiel) && !$this->etreNull($referentiel)) {
|
| 650 |
$referentiel = Cel::db()->proteger($referentiel.'%');
|
652 |
$referentiel = Cel::db()->proteger($referentiel);
|
| 651 |
$sql = ' AND co.nom_referentiel LIKE '.$referentiel.' ';
|
653 |
$sql = ' AND co.nom_referentiel = '.$referentiel.' ';
|
| 652 |
}
|
654 |
}
|
| 653 |
return $sql;
|
655 |
return $sql;
|
| Line 654... |
Line 656... |
| 654 |
}
|
656 |
}
|
| Line 756... |
Line 758... |
| 756 |
/**
|
758 |
/**
|
| 757 |
* Récupération des identifiant d'utilisateur et des ordres des observations correspondant à une date.
|
759 |
* Récupération des identifiant d'utilisateur et des ordres des observations correspondant à une date.
|
| 758 |
* Retour sous forme de tableau : array[identifiant] = array(ordre, ordre...);
|
760 |
* Retour sous forme de tableau : array[identifiant] = array(ordre, ordre...);
|
| 759 |
*/
|
761 |
*/
|
| 760 |
private function obtenirObsLieesImg($type, $param) {
|
762 |
private function obtenirObsLieesImg($type, $param) {
|
| - |
|
763 |
$transmission = ( $this->standard = 0) ? "transmission = '1' AND " : "";
|
| 761 |
// Construction de la requête
|
764 |
// Construction de la requête
|
| 762 |
$requete = 'SELECT DISTINCT co.id_obs, co.ce_utilisateur AS utilisateur '.
|
765 |
$requete = 'SELECT DISTINCT co.id_obs, co.ce_utilisateur AS utilisateur '.
|
| 763 |
'FROM cel_export_total AS co '.
|
766 |
'FROM '.$this->table_export.' AS co '.
|
| 764 |
' LEFT JOIN cel_zones_geo AS zg '.
|
767 |
' LEFT JOIN cel_zones_geo AS zg '.
|
| 765 |
' ON (zg.nom = co.zone_geo AND zg.id_zone_geo = co.ce_zone_geo) '.
|
768 |
' ON (zg.nom = co.zone_geo AND zg.id_zone_geo = co.ce_zone_geo) '.
|
| 766 |
"WHERE co.transmission = '1' and co.images != null".
|
769 |
"WHERE ".$transmission." co.images != null".
|
| 767 |
$this->standard.
|
- |
|
| 768 |
($type == 'date.creation' ? " AND co.date_creation LIKE $param " : '').
|
770 |
($type == 'date.creation' ? " AND co.date_creation LIKE $param " : '').
|
| 769 |
($type == 'commentaire.obs' ? " AND co.commentaire LIKE $param " : '').
|
771 |
($type == 'commentaire.obs' ? " AND co.commentaire LIKE $param " : '').
|
| 770 |
($type == 'commentaire.*' ? " AND co.commentaire LIKE $param " : '').
|
772 |
($type == 'commentaire.*' ? " AND co.commentaire LIKE $param " : '').
|
| 771 |
$this->construireWhereCoordonnees().
|
773 |
$this->construireWhereCoordonnees().
|
| 772 |
$this->construireWhereDept().
|
774 |
$this->construireWhereDept().
|
| Line 1141... |
Line 1143... |
| 1141 |
/**
|
1143 |
/**
|
| 1142 |
* Traitement de $tag pour construction du filtre dans la requête
|
1144 |
* Traitement de $tag pour construction du filtre dans la requête
|
| 1143 |
*/
|
1145 |
*/
|
| 1144 |
private function getSqlWhereObsAvecImagesTaguees($tag) {
|
1146 |
private function getSqlWhereObsAvecImagesTaguees($tag) {
|
| 1145 |
$sql = null;
|
1147 |
$sql = null;
|
| - |
|
1148 |
$transmission = ( $this->standard = 0) ? "co.transmission = '1' " : "";
|
| 1146 |
if (isset($tag) && !$this->etreNull($tag)) {
|
1149 |
if (isset($tag) && !$this->etreNull($tag)) {
|
| 1147 |
$tag_sql = $this->getSqlWhereMotsCles($tag);
|
1150 |
$tag_sql = $this->getSqlWhereMotsCles($tag);
|
| 1148 |
// Construction de la requête
|
1151 |
// Construction de la requête
|
| 1149 |
$requete = 'SELECT DISTINCT co.id_observation AS id_obs, co.ce_utilisateur AS utilisateur '.
|
1152 |
$requete = 'SELECT DISTINCT co.id_observation AS id_obs, co.ce_utilisateur AS utilisateur '.
|
| 1150 |
'FROM cel_images_export ci'.
|
1153 |
'FROM cel_images_export ci'.
|
| 1151 |
' INNER JOIN cel_export_total AS co '.
|
1154 |
' INNER JOIN '.$this->table_export.' AS co '.
|
| 1152 |
' ON (ci.ce_observation = co.id_observation) '.
|
1155 |
' ON (ci.ce_observation = co.id_observation) '.
|
| 1153 |
' LEFT JOIN cel_zones_geo AS zg '.
|
1156 |
' LEFT JOIN cel_zones_geo AS zg '.
|
| 1154 |
" ON (zg.nom = co.zone_geo AND zg.id_zone_geo = co.ce_zone_geo) ".
|
1157 |
" ON (zg.nom = co.zone_geo AND zg.id_zone_geo = co.ce_zone_geo) ".
|
| 1155 |
"WHERE co.transmission = '1' ".
|
- |
|
| 1156 |
$this->standard.
|
1158 |
"WHERE ".
|
| 1157 |
$this->construireWhereCoordonnees().
|
1159 |
$this->construireWhereCoordonnees().
|
| 1158 |
$this->construireWhereUtilisateur().
|
1160 |
$this->construireWhereUtilisateur().
|
| 1159 |
$this->construireWhereNumTaxon().
|
1161 |
$this->construireWhereNumTaxon().
|
| 1160 |
$this->construireWhereNomTaxon().
|
1162 |
$this->construireWhereNomTaxon().
|
| 1161 |
$this->construireWhereReferentiel().
|
1163 |
$this->construireWhereReferentiel().
|