Subversion Repositories Applications.annuaire

Rev

Rev 94 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
61 aurelien 1
<?php
2
/**
3
* PHP Version 5
4
*
5
* @category  PHP
6
* @package   annuaire
7
* @author    aurelien <aurelien@tela-botanica.org>
8
* @copyright 2010 Tela-Botanica
9
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
10
* @version   SVN: <svn_id>
11
* @link      /doc/annuaire/
12
*/
13
 
14
class StatistiquesControleur extends Controleur {
15
 
16
	private $statistiques = null;
17
 
18
	private $champ_pays = '12';
19
	private $onto_pays = '1074';
20
 
21
	private $champ_rapport_activite_bota = '102';
22
	private $onto_rapport_activite_bota = '30797';
23
 
24
	private $champ_experience_bota = '4';
25
	private $onto_experience_bota = '30785';
26
 
27
	public function StatistiquesControleur() {
28
		$this->statistiques = Composant::fabrique('statistiques', array());
29
	}
30
 
31
	public function obtenirGraphiques($id_annuaire) {
32
 
33
		$graph = array();
34
 
35
		//$this->obtenirStatistiquesParPays($id_annuaire);
36
		$graph['pays'] =  $this->obtenirStatistiquesParCritere($id_annuaire, $this->champ_pays, $this->onto_pays);
37
		$graph['activite_bota'] = $this->obtenirStatistiquesParCritere($id_annuaire, $this->champ_rapport_activite_bota, $this->onto_rapport_activite_bota, 'Répartition des inscrits selon leur activité');
38
		$graph['experience_bota'] =  $this->obtenirStatistiquesParCritere($id_annuaire, $this->champ_experience_bota, $this->onto_experience_bota, 'Répartition des inscrits selon leur expérience botanique');
39
 
40
		$image = $this->statistiques->combinerGraphiques($graph);
41
 
88 aurelien 42
		// Envoi d'une image png
61 aurelien 43
		header("Content-type: image/png");
44
		imagepng ($image);
45
 
46
		return $graph ;
47
	}
48
 
49
	public function obtenirStatistiquesParPays($id_annuaire, $titre = 'Répartition des inscrits par pays') {
50
 
51
	    $controleur = new AnnuaireControleur();
52
 
53
	    $modele_meta = new MetadonneeModele();
54
	   	$modele_onto = new OntologieModele();
55
	    $valeurs = $modele_meta->obtenirNombreValeurMetadonnee($this->champ_experience_bota);
56
	   	$legendes = $modele_onto->chargerListeOntologie($this->onto_experience_bota);
57
 
58
		$valeurs_a_stat_code = array();
59
		$valeurs_a_stat_legende = array();
60
 
61
		foreach($valeurs as $valeur) {
62
			$valeurs_a_stat_code[$valeur['amv_valeur']] = $valeur['nb'];
63
		}
64
 
65
	    foreach($legendes as $legende) {
66
	    	$legende_nom = $legende['amo_nom'];
67
	    	$legende_code = $legende['amo_id_ontologie'];
68
 
69
	    	if(isset($valeurs_a_stat_code[$legende_code])) {
70
				$valeurs_a_stat_legende[$legende_nom] = $valeurs_a_stat_code[$legende_code];
71
	    	}
72
	    }
73
 
74
		return $this->statistiques->genererGraphique(Statistiques::GRAPH_CAMEMBERT,$valeurs_a_stat_legende);
75
 
76
	}
77
 
78
	public function obtenirStatistiquesParCritere($id_annuaire, $id_champ, $id_onto, $titre = '') {
79
 
80
	    $controleur = new AnnuaireControleur();
81
 
82
	    $modele_meta = new MetadonneeModele();
83
	   	$modele_onto = new OntologieModele();
84
	    $valeurs = $modele_meta->obtenirNombreValeurMetadonnee($id_champ);
85
	   	$legendes = $modele_onto->chargerListeOntologie($id_onto);
86
 
87
		$valeurs_a_stat_code = array();
88
		$valeurs_a_stat_legende = array();
89
 
90
		foreach($valeurs as $valeur) {
91
			$valeurs_a_stat_code[$valeur['amv_valeur']] = $valeur['nb'];
92
		}
93
 
94
	    foreach($legendes as $legende) {
95
	    	$legende_nom = $legende['amo_nom'];
96
	    	$legende_code = $legende['amo_id_ontologie'];
97
 
98
	    	if(isset($valeurs_a_stat_code[$legende_code])) {
99
				$valeurs_a_stat_legende[$legende_nom] = $valeurs_a_stat_code[$legende_code];
100
	    	}
101
	    }
102
 
103
		return $this->statistiques->genererGraphique(Statistiques::GRAPH_CAMEMBERT,$valeurs_a_stat_legende, $titre);
104
 
105
	}
106
 
107
	public function obtenirStatistiquesParAnnees($id_annuaire) {
108
 
109
	    $controleur = new AnnuaireControleur();
110
 
111
	    $modele_stats = new StatistiquesModele();
112
	    $valeurs = $modele_stats->obtenirNombreInscriptionsParDate($id_annuaire);
113
	   	$legendes = $modele_onto->chargerListeOntologie('1074');
114
 
115
 
116
		$valeurs_a_stat_code = array();
117
		$valeurs_a_stat_legende = array();
118
 
119
		foreach($valeurs as $valeur) {
120
			$valeurs_a_stat_code[$valeur['amv_valeur']] = $valeur['nb'];
121
		}
122
 
123
	    foreach($legendes as $legende) {
124
	    	$legende_nom = $legende['amo_nom'];
125
	    	$legende_code = $legende['amo_id_ontologie'];
126
 
127
	    	if(isset($valeurs_a_stat_code[$legende_code])) {
128
				$valeurs_a_stat_legende[$legende_nom] = $valeurs_a_stat_code[$legende_code];
129
	    	}
130
	    }
131
 
132
		return $this->statistiques->genererGraphique(Statistiques::GRAPH_CAMEMBERT,$valeurs_a_stat_legende);
133
 
134
	}
135
 
136
}
137
?>