Subversion Repositories eFlore/Applications.coel

Compare Revisions

Ignore whitespace Rev 1578 → Rev 1579

/trunk/jrest/services/CoelStatistique.php
71,6 → 71,7
$url = sprintf($this->url_serveur_graph_tpl, rand(0, 9).'.');
return $url;
}
private function construireUrlGraph($graph) {
$graph = $this->protegerGraphPourUrl($graph);
89,6 → 90,11
return $graph;
}
private function existerParametre($numero) {
$exister = (isset($this->parametres[$numero]) && $this->parametres[$numero] != '*') ? true : false;
return $exister;
}
private function getNombreDonnees() {
// Récupération des données
$types = array( array('Commentaires', 'commentaire', 'ccm'),
111,12 → 117,12
// Paramètres du graphique
$graph = array(
'cht' => 'bhs',
'chs' => '250x180',
'chco' => '4D89F9',
'chs' => '290x210',
'chco' => '264327|5D7E2D|84A435|B5CD75|DFF1B3',// Source : Broccoli par DandL : http://www.colourlovers.com/palette/1371426/Broccoli
'chd' => "t:$valeurs",
'chds' => '0,'.max($donnees),
'chxt' => 'y',
'chxl' => "0 :|$etiquettes|",
'chxl' => "0:|$etiquettes|",
'chm' => 'N ** ,000000,0,-1,10',
'chtt' => 'Nombre de données');
return $graph;
143,20 → 149,21
}
 
private function getMesDonnees() {
$personne_id = (isset($this->parametres[0]) ? $this->parametres[0] : null);
// Récupération des données
$types = array( 'Commentaires' => '107',
'Publications' => '118, 119',
'Personnes' => '113, 114',
'Collections' => '101, 102, 103, 104, 105, 106',
'Structures' => '120, 121, 122, 123');
$types = array( 'Commentaires' => array('107', 'ccm'),
'Publications' => array('118, 119', 'cpu,cpuap'),
'Personnes' => array('113, 114', 'cp,cpar'),
'Collections' => array('101, 102, 103, 104, 106', 'cc,ccac,ccap,ccapu,ccb'),
'Structures' => array('120, 121, 122, 123', 'cs,csap,csc,csv'));
$etats = array(1 => 'Ajouts',
2 => 'Modifications',
3 => 'Suppressions');
$donnees = array();
foreach ($types as $type => $table_identifiants) {
foreach ($types as $type => $tables_parametres) {
$tables_infos['identifiants'] = $tables_parametres[0];
$tables_infos['abreviations'] = $tables_parametres[1];
foreach ($etats as $etat_id => $etat_type) {
$donnees[$etat_type][$type] = $this->executerRequeteNombreDansHistorique($table_identifiants, $etat_id, $personne_id);
$donnees[$etat_type][$type] = $this->executerRequeteNombreDansHistorique($tables_infos, $etat_id);
}
}
180,33 → 187,50
$etiquettes = implode('|', array_keys($types));
$legende = implode('|', $etats);
$etiquettes_x = "0|$moitier|$maximum";
$titre = $this->existerParametre(0) ? 'Ma participation' : 'Participation';
$titre .= $this->existerParametre(1) ? ' au projet' : ' tous projets confondus';
// Paramètres du graphique
$graph = array(
'cht' => 'bhs',
'chs' => '320x180',
'cht' => 'bhg',
'chs' => '290x210',
'chbh' => 'a,2,4',
'chco' => '66B032,FABC02,FE2712',
'chdl' => $legende,
'chdlp' => 'b',
'chdlp' => 'r',
'chd' => "t:$valeurs",
'chds' => "0,$maximum",
'chxt' => 'y,x',
'chxl' => "0:|$etiquettes|1:|$etiquettes_x",
'chm' => 'N,000000,0,-1,10,1|N,000000,1,-1,10,1|N,000000,2,-1,10,1',
'chtt' => 'Ma participation tous projets confondus');
'chtt' => $titre);
return $graph;
}
private function executerRequeteNombreDansHistorique($table_identifiants, $etat, $personne_id = null) {
$personne_id = $this->bdd->quote($personne_id);
private function executerRequeteNombreDansHistorique($tables_infos, $etat) {
// Récupération des paramêtres
$personne_id = (isset($this->parametres[0]) && $this->parametres[0] != '*') ? $this->bdd->quote($this->parametres[0]) : null;
$projet_id = (isset($this->parametres[1]) && $this->parametres[1] != '*') ? $this->bdd->quote($this->parametres[1]) : null;
// Construction du Xpath si nécessaire
if (isset($projet_id)) {
$squelette = '//row[1]/%s_ce_projet';
$abreviations = explode(',', $tables_infos['abreviations']);
$xpath = array();
foreach ($abreviations as $abr) {
$xpath[] = sprintf($squelette, $abr);
}
$xpath = implode(' | ', $xpath);
}
// Récupération des données
$requete = "SELECT COUNT(cmhl_date_modification) AS nbre ".
"FROM coel_meta_historique_ligne ".
"WHERE cmhl_ce_table IN ($table_identifiants) ".
"WHERE cmhl_ce_table IN ({$tables_infos['identifiants']}) ".
" AND cmhl_ce_etat = $etat ".
(isset($personne_id) ? " AND cmhl_ce_modifier_par = $personne_id " : '');
(isset($personne_id) ? " AND cmhl_ce_modifier_par = $personne_id " : '').
(isset($projet_id) ? " AND ExtractValue(cmhl_enregistrement, '$xpath') = $projet_id " : '');
try {
$nbre = $this->bdd->query($requete)->fetchColumn();
if ($nbre === false) {
255,12 → 279,12
// Paramètres du graphique
$graph = array(
'cht' => 'bhs',
'chs' => '250x170',
'chco' => '4D89F9',
'chs' => '290x210',
'chco' => '264327|5D7E2D|84A435|B5CD75|DFF1B3',
'chd' => "t:$valeurs",
'chds' => '0,'.(max($donnees)+5),
'chxt' => 'y',
'chxl' => "0 :|$etiquettes|",
'chxl' => "0:|$etiquettes|",
'chm' => 'N *,000000,0,-1,10',
'chtt' => 'Type de dépôt|des collections',
'chts' => '000000,12');
325,7 → 349,7
// Paramètres du graphique
$graph = array(
'cht' => 'p3',
'chs' => '350x200',
'chs' => '400x225',
'chco' => 'EDC951|DEB0DB|DEC9B0|B0DEB3|B0C4DE|B0B0DE|927CBA',
'chd' => "t:$valeurs",
'chds' => '0,'.max($donnees),
774,12 → 798,13
foreach ($infos as $info) {
// Récupération du type d'herbier
$type_id = ($info['ccb_ce_truk_type'] != '') ? $info['ccb_ce_truk_type'] : 0;
 
// Augmentation du nombre de collection par période
if (! isset($donnees[$types[$type_id]['nom']])) {
$donnees[$types[$type_id]['nom']] = 1;
$type_nom = $types[$type_id]['nom'];
// Augmentation du nombre de collection par période
if (! isset($donnees[$type_nom])) {
$donnees[$type_nom] = 1;
} else {
$donnees[$types[$type_id]['nom']]++;
$donnees[$type_nom]++;
}
}
786,7 → 811,12
$donnees_tmp = $donnees;
$donnees = array();
foreach ($donnees_tmp as $cle => $valeur) {
$donnees[$cle.' ('.$valeur.')'] = $valeur;
if ($remplacement = preg_replace('/^([^(]+) \([^\)]+\)/', '$1', $cle)) {
$cle = $remplacement;
}
$legende = $cle.' ('.$valeur.')';
$donnees[$legende] = $valeur;
}
asort($donnees);
796,12 → 826,12
// Paramètres du graphique
$graph = array(
'cht' => 'p3',
'chs' => '300x350',
'chs' => '400x225',
'chco' => 'EDC951|DEB0DB|DEC9B0|B0DEB3|B0C4DE|B0B0DE|927CBA',
'chd' => "t:$valeurs",
'chds' => '0,'.max($donnees),
'chdl' => $legende,
'chdlp' => 'bv',
'chdlp' => 'r',
'chtt' => "Nombre d'herbier par type",
'chts' => '000000,11.5',
'chts' => '000000,12');