6,7 → 6,8 |
* |
* Cas d'utilisation : |
* /CelStatistique/TypeDeGraph : retourne le graphique demandé |
* /CelStatistique/TypeDeGraph/1 : retourne le graphique demandé sur le serveur 1 (voir http://code.google.com/intl/fr/apis/chart/docs/making_charts.html#enhancements) |
* Paramêtres : |
* serveur=[0-9] : retourne le graphique demandé sur le serveur numéro 0 à 9 (voir http://code.google.com/intl/fr/apis/chart/docs/making_charts.html#enhancements ) |
* |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt> |
27,7 → 28,6 |
$graph_demande = array_shift($param); |
$methode = 'get'.$graph_demande; |
if (method_exists($this, $methode)) { |
$serveur = isset($param[1]) ? array_shift($param).'.' : ''; |
$graph = $this->$methode($param); |
} else { |
$this->messages[] = "Ce type de graphique '$graph_demande' n'est pas disponible."; |
37,6 → 37,7 |
} |
|
if (!is_null($graph)) { |
$serveur = (isset($_GET['serveur']) && preg_match('/^[0-9]$/', $_GET['serveur'])) ? $_GET['serveur'].'.' : ''; |
$url = "http://{$serveur}chart.apis.google.com/chart"; |
$contexte = stream_context_create( |
array('http' => array( |
52,7 → 53,6 |
|
private function getEvolImgLieesParMois($param) { |
// Récupération des données |
|
$requete = "SELECT DATE_FORMAT(ci_meta_date_ajout, '%Y%m') AS periode, COUNT(ci_id_image) AS nbre ". |
"FROM cel_obs_images LEFT JOIN cel_images ON (coi_ce_image = ci_id_image) ". |
"WHERE ci_meta_date_ajout != '0000-00-00 00:00:00' ". |
120,7 → 120,6 |
|
private function getEvolImgParMois($param) { |
// Récupération des données |
|
$requete = "SELECT DATE_FORMAT(ci_meta_date_ajout, '%Y%m') AS periode, COUNT(ci_id_image) AS nbre ". |
"FROM cel_images ". |
"WHERE ci_meta_date_ajout != '0000-00-00 00:00:00' ". |
510,9 → 509,12 |
} |
|
private function getNbreObsAvecIndicationGeo($param) { |
$utilisateur = isset($_GET['utilisateur']) ? ' AND identifiant = '.$this->bdd->quote($_GET['utilisateur']) : ''; |
|
// Récupération des données |
$total = $this->executerRequeteNombre('cel_inventory', 'id'); |
$obs['commune'] = $this->executerRequeteNombre('cel_inventory', 'id', "location != '000null' AND location != '' AND location IS NOT NULL"); |
$total = $this->executerRequeteNombre('cel_inventory', 'id', $utilisateur); |
$where_commune = "location != '000null' AND location != '' AND location IS NOT NULL"; |
$obs['commune'] = $this->executerRequeteNombre('cel_inventory', 'id', $where_commune); |
$obs['commune identifiée'] = $this->executerRequeteNombre('cel_inventory', 'id', "id_location != '000null' AND id_location != '' AND id_location IS NOT NULL"); |
$obs['lieu-dit'] = $this->executerRequeteNombre('cel_inventory', 'id', "lieudit != '000null' AND lieudit != '' AND lieudit IS NOT NULL"); |
$obs['station'] = $this->executerRequeteNombre('cel_inventory', 'id', "station != '000null' AND station != '' AND station IS NOT NULL"); |
754,9 → 756,26 |
} |
|
private function getNuagePointsObsParHeureEtJourSemaine($param) { |
$utilisateur = isset($_GET['utilisateur']) ? $this->bdd->quote($_GET['utilisateur']) : false; |
|
// Récupération des données de la base |
$observations = $this->executerRequeteEvol('cel_inventory', 'id', '%w-%H', null, 'date_creation'); |
|
$requete = 'SELECT identifiant, DATE_FORMAT(date_creation, "%w-%H") AS periode, (ROUND(LOG10(COUNT(id))) + 1) AS nbre '. |
'FROM cel_inventory '. |
'WHERE date_creation != "0000-00-00 00:00:00" '. |
' AND identifiant '.($utilisateur ? "= $utilisateur " : 'LIKE "%@%" '). |
'GROUP BY periode, identifiant '; |
$infos = $this->executerRequete($requete); |
|
// Traitement résulat requête |
$observations = array(); |
foreach ($infos as $info) { |
if (isset($observations[$info['periode']])) { |
$observations[$info['periode']] += $info['nbre']; |
} else { |
$observations[$info['periode']] = $info['nbre']; |
} |
} |
|
// Postraitement des données |
// Jour de la semaine |
$donnees['joursSemaine'] = array(); |
885,9 → 904,12 |
} |
|
private function executerRequeteEvol($table, $champ, $format_date = '%Y%m', $where = null, $champ_date = 'date_creation', $order_by = null, $limit = null) { |
$utilisateur = isset($_GET['utilisateur']) ? $this->bdd->quote($_GET['utilisateur']) : false; |
|
$requete = "SELECT DATE_FORMAT($champ_date, '$format_date') AS periode, COUNT($champ) AS nbre ". |
"FROM $table ". |
"WHERE $champ_date != '0000-00-00 00:00:00' ". |
($utilisateur ? " AND identifiant = $utilisateur " : ''). |
((is_null($where)) ? '' : " AND $where "). |
'GROUP BY periode '. |
((is_null($order_by)) ? '' : "ORDER BY $order_by "); |