Subversion Repositories Applications.annuaire

Rev

Rev 429 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 429 Rev 442
1
<?php
1
<?php
2
/**
2
/**
3
* PHP Version 5
3
* PHP Version 5
4
*
4
*
5
* @category  PHP
5
* @category  PHP
6
* @package   annuaire
6
* @package   annuaire
7
* @author    aurelien <aurelien@tela-botanica.org>
7
* @author    aurelien <aurelien@tela-botanica.org>
8
* @copyright 2010 Tela-Botanica
8
* @copyright 2010 Tela-Botanica
9
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
9
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
10
* @version   SVN: <svn_id>
10
* @version   SVN: <svn_id>
11
* @link      /doc/annuaire/
11
* @link      /doc/annuaire/
12
*/
12
*/
13
 
13
 
14
class StatistiqueControleur extends AppControleur {
14
class StatistiqueControleur extends AppControleur {
15
 
15
 
16
	private $statistiques = null;
16
	private $statistiques = null;
17
 
17
 
18
	private $champ_pays = '12';
18
	private $champ_pays = '12';
19
	private $champ_rapport_activite_bota = '102';
19
	private $champ_rapport_activite_bota = '102';
20
	private $champ_experience_bota = '4';
20
	private $champ_experience_bota = '4';
-
 
21
	private $tab_mois = array('Jan','Fev','Mar','Avr','Mai','Juin','Juil','Aout','Sep','Oct','Nov','Dec');
21
 
22
	
22
	public function StatistiqueControleur() {
23
	public function StatistiqueControleur() {
23
		
-
 
24
		$this->__construct();
24
		$this->__construct();
25
		$this->statistiques = Composant::fabrique('statistiques', array());
25
		$this->statistiques = Composant::fabrique('statistiques', array());
26
	}
26
	}
27
	
27
	
28
	public function obtenirStatistiquesInscritsParContinents($id_annuaire) {
28
	public function obtenirStatistiquesInscritsParContinents($id_annuaire) {
29
		
-
 
30
		$cartographe = new CartoControleur();
29
		$cartographe = new CartoControleur();
31
		$annuaire_controleur = new AnnuaireControleur();
30
		$annuaire_controleur = new AnnuaireControleur();
-
 
31
		
32
		
32
		$continents = array(
33
		$continents = array('Afrique (%1.2f%%)' => 'pays_afrique',
33
			'Afrique (%1.2f%%)' => 'pays_afrique',
34
		 							'Amerique du nord (%1.2f%%)' => 'pays_nord_amerique', 
34
			'Amerique du nord (%1.2f%%)' => 'pays_nord_amerique', 
35
		 							'Asie (%1.2f%%)' => 'pays_asie', 
35
			'Asie (%1.2f%%)' => 'pays_asie', 
36
		 							'Europe (%1.2f%%)' => 'pays_europe', 
36
			'Europe (%1.2f%%)' => 'pays_europe', 
37
		 							'Oceanie (%1.2f%%)' => 'pays_oceanie', 
37
			'Oceanie (%1.2f%%)' => 'pays_oceanie', 
38
		 							'Amerique du sud (%1.2f%%)' => 'pays_sud_amerique', 
38
			'Amerique du sud (%1.2f%%)' => 'pays_sud_amerique', 
39
		 							'Moyen Orient (%1.2f%%)' => 'pays_moyen_orient');
39
			'Moyen Orient (%1.2f%%)' => 'pays_moyen_orient');
40
				
40
				
41
	    // pour chacun des continents, on fait la somme des membres de sa zone
41
		// pour chacun des continents, on fait la somme des membres de sa zone
42
    	foreach($continents as $id_continent => $continent) {
42
		foreach($continents as $id_continent => $continent) {
43
    		$zones_continent_ids = $cartographe->chargerInformationsPaysDuContinentsCsv($continent);
43
			$zones_continent_ids = $cartographe->chargerInformationsPaysDuContinentsCsv($continent);
44
    		$zones_continent_ids = array_map(array($this,'miniQuote'), array_keys($zones_continent_ids));    		
44
			$zones_continent_ids = array_map(array($this,'miniQuote'), array_keys($zones_continent_ids));    		
45
    		$nb_inscrits[$id_continent] = array_sum($annuaire_controleur->chargerNombreAnnuaireListeInscritsParPays($id_annuaire, $zones_continent_ids));
45
			$nb_inscrits[$id_continent] = array_sum($annuaire_controleur->chargerNombreAnnuaireListeInscritsParPays($id_annuaire, $zones_continent_ids));
46
    	}
46
		}
47
    	    	
47
 
48
    	$graph = $this->statistiques->genererGraphique(Statistiques::GRAPH_CAMEMBERT,$nb_inscrits,'', array(650, 500));
48
		$graph = $this->statistiques->genererGraphique(Statistiques::GRAPH_CAMEMBERT,$nb_inscrits,'', array(650, 500));
49
    	
49
 
50
    	return $this->dessinerGraph($graph);
50
		return $this->dessinerGraph($graph);
51
	}
51
	}
52
	
52
	
53
	public function obtenirStatistiquesInscritsEurope($id_annuaire) {
53
	public function obtenirStatistiquesInscritsEurope($id_annuaire) {
54
		
-
 
55
		$cartographe = new CartoControleur();
54
		$cartographe = new CartoControleur();
56
		$annuaire_controleur = new AnnuaireControleur();
55
		$annuaire_controleur = new AnnuaireControleur();
57
		$cartographe = new CartoControleur();
56
		$cartographe = new CartoControleur();
58
		
57
		
59
		$ids_zones_europe = $cartographe->chargerInformationsPaysDuContinentsCsv('pays_europe');
58
		$ids_zones_europe = $cartographe->chargerInformationsPaysDuContinentsCsv('pays_europe');
60
				
59
		
61
		$codes_zones_europe = array_map(array($this,'miniQuote'), array_keys($ids_zones_europe));    
60
		$codes_zones_europe = array_map(array($this, 'miniQuote'), array_keys($ids_zones_europe));    
62
 
61
 
63
		$titre_zone = $this->convertirPourLegende($zone[2]);
62
		$titre_zone = $this->convertirPourLegende($zone[2]);
64
    	$nb_inscrits_par_code = $annuaire_controleur->chargerNombreAnnuaireListeInscritsParPays($id_annuaire, $codes_zones_europe);
63
		$nb_inscrits_par_code = $annuaire_controleur->chargerNombreAnnuaireListeInscritsParPays($id_annuaire, $codes_zones_europe);
65
		
64
		
66
    	$nb_inscrits_par_legende = array();
65
		$nb_inscrits_par_legende = array();
67
    	
66
 
68
    	$inscrits_france = $nb_inscrits_par_code['fr'];
67
		$inscrits_france = $nb_inscrits_par_code['fr'];
69
    	
68
 
70
    	unset($nb_inscrits_par_code['fr']);
69
		unset($nb_inscrits_par_code['fr']);
71
    	$somme_autres_pays = 0;
70
		$somme_autres_pays = 0;
72
    	
-
 
73
    	foreach($nb_inscrits_par_code as $code_pays => $inscrits_pays) {
71
 
74
    		
72
		foreach ($nb_inscrits_par_code as $code_pays => $inscrits_pays) {
75
    		$label_pays = $this->convertirPourLegende($ids_zones_europe[$code_pays][2].' (%1.2f%%)');
73
			$label_pays = $this->convertirPourLegende($ids_zones_europe[$code_pays][2].' (%1.2f%%)');
76
    		$nb_inscrits_par_legende[$label_pays] = $inscrits_pays;
74
			$nb_inscrits_par_legende[$label_pays] = $inscrits_pays;
77
    		$somme_autres_pays += $inscrits_pays;
75
			$somme_autres_pays += $inscrits_pays;
78
    	}
76
		}
79
    	    	
77
 
80
    	$tableau_france_autres = array('France (%1.2f%%)' => $inscrits_france, 'Autres (%1.2f%%)' => $somme_autres_pays);
78
		$tableau_france_autres = array('France (%1.2f%%)' => $inscrits_france, 'Autres (%1.2f%%)' => $somme_autres_pays);
81
    	
79
 
82
    	$graph_france = $this->statistiques->genererGraphique(Statistiques::GRAPH_CAMEMBERT,$tableau_france_autres,'', array(320, 200));
80
		$graph_france = $this->statistiques->genererGraphique(Statistiques::GRAPH_CAMEMBERT, $tableau_france_autres, '', array(320, 200));
83
		$graph_autres = $this->statistiques->genererGraphique(Statistiques::GRAPH_CAMEMBERT,$nb_inscrits_par_legende,'', array(900, 700));
81
		$graph_autres = $this->statistiques->genererGraphique(Statistiques::GRAPH_CAMEMBERT, $nb_inscrits_par_legende, '', array(930, 900));
84
		$graph = $this->statistiques->combinerGraphiques($graph_france, $graph_autres, array(920, 1200));
82
		$graph = $this->statistiques->combinerGraphiques($graph_france, $graph_autres, array(940, 1110));
85
		
83
		
86
		return $this->dessinerGraph($graph);
84
		return $this->dessinerGraph($graph);
87
	}
85
	}
88
 
86
 
89
	public function obtenirStatistiquesParPays($id_annuaire) {
87
	public function obtenirStatistiquesParPays($id_annuaire) {
-
 
88
		$controleur = new AnnuaireControleur();
90
 
-
 
91
	    $controleur = new AnnuaireControleur();
-
 
92
	   	
89
 
93
	   	//$controleur = new AnnuaireControleur();
90
		//$controleur = new AnnuaireControleur();
94
	    $modele_meta = new MetadonneeModele();
91
		$modele_meta = new MetadonneeModele();
95
	   	$modele_onto = new OntologieModele();
92
		$modele_onto = new OntologieModele();
96
	   	$id_champ = 12;
93
		$id_champ = 12;
97
	    $valeurs = $modele_meta->obtenirNombreValeurMetadonnee($id_champ);
94
		$valeurs = $modele_meta->obtenirNombreValeurMetadonnee($id_champ);
98
	    $id_onto = $modele_meta->obtenirOntologieLieeAChampParId($id_champ);
95
		$id_onto = $modele_meta->obtenirOntologieLieeAChampParId($id_champ);
99
	   	$legendes = $modele_onto->chargerListeOntologie($id_onto);
96
		$legendes = $modele_onto->chargerListeOntologie($id_onto);
100
 
97
 
101
		$valeurs_a_stat_code = array();
98
		$valeurs_a_stat_code = array();
102
		$valeurs_a_stat_legende = array();
99
		$valeurs_a_stat_legende = array();
103
 
100
 
104
		foreach($valeurs as $valeur) {
101
		foreach ($valeurs as $valeur) {
105
			$valeurs_a_stat_code[$valeur['amv_valeur']] = $valeur['nb'];
102
			$valeurs_a_stat_code[$valeur['amv_valeur']] = $valeur['nb'];
106
		}
103
		}
107
 
104
 
108
	    foreach($legendes as $legende) {
105
		foreach ($legendes as $legende) {
109
	    	$legende_nom = $legende['amo_nom'];
106
			$legende_nom = $legende['amo_nom'];
110
	    	$legende_code = $legende['amo_id_ontologie'];
107
			$legende_code = $legende['amo_id_ontologie'];
111
 
108
 
112
	    	if(isset($valeurs_a_stat_code[$legende_code])) {
109
			if (isset($valeurs_a_stat_code[$legende_code])) {
113
				$valeurs_a_stat_legende[$legende_nom] = $valeurs_a_stat_code[$legende_code];
110
				$valeurs_a_stat_legende[$legende_nom] = $valeurs_a_stat_code[$legende_code];
114
	    	}
111
			}
115
	    }
112
		}
116
 
-
 
117
		$graph = $this->statistiques->genererGraphique(Statistiques::GRAPH_CAMEMBERT,$valeurs_a_stat_legende);
113
 
118
	    return $this->dessinerGraph($graph);
114
		$graph = $this->statistiques->genererGraphique(Statistiques::GRAPH_CAMEMBERT,$valeurs_a_stat_legende);
119
 
115
		return $this->dessinerGraph($graph);
120
	}
116
	}
121
 
117
 
122
	public function obtenirStatistiquesParCritere($id_annuaire, $code_champ, $titre = '') {
118
	public function obtenirStatistiquesParCritere($id_annuaire, $code_champ, $titre = '') {
-
 
119
		$modele_meta = new MetadonneeModele();
-
 
120
		$modele_onto = new OntologieModele();
-
 
121
		$id_champ = $modele_meta->renvoyerIdChampMetadonneeParAbreviation($id_annuaire, $code_champ);
-
 
122
		$valeurs = $modele_meta->obtenirNombreValeurMetadonnee($id_champ);
-
 
123
		$id_onto = $modele_meta->obtenirOntologieLieeAChampParId($id_champ);
-
 
124
		$legendes = $modele_onto->chargerListeOntologie($id_onto);
123
 
-
 
124
	    $modele_meta = new MetadonneeModele();
-
 
125
	   	$modele_onto = new OntologieModele();
-
 
126
	   	$id_champ = $modele_meta->renvoyerIdChampMetadonneeParAbreviation($id_annuaire, $code_champ);
-
 
127
	    $valeurs = $modele_meta->obtenirNombreValeurMetadonnee($id_champ);
-
 
128
	    $id_onto = $modele_meta->obtenirOntologieLieeAChampParId($id_champ);
-
 
129
	   	$legendes = $modele_onto->chargerListeOntologie($id_onto);
-
 
130
	   	
125
 
131
		$valeurs_a_stat_code = array();
126
		$valeurs_a_stat_code = array();
132
		$valeurs_a_stat_legende = array();
127
		$valeurs_a_stat_legende = array();
133
				
128
 
134
		$titre = $this->convertirPourLegende($titre);
129
		$titre = $this->convertirPourLegende($titre);
135
 
130
 
136
		foreach($valeurs as $valeur) {
131
		foreach ($valeurs as $valeur) {
137
			$valeurs_a_stat_code[$valeur['amv_valeur']] = $valeur['nb'];
132
			$valeurs_a_stat_code[$valeur['amv_valeur']] = $valeur['nb'];
138
		}
133
		}
139
		
134
 
140
	    foreach($legendes as $legende) {
135
		foreach ($legendes as $legende) {
141
	    	$legende_nom = $this->convertirPourLegende($legende['amo_nom']);
136
			$legende_nom = $this->convertirPourLegende($legende['amo_nom']);
142
	    	$legende_code = $legende['amo_id_ontologie'];
137
			$legende_code = $legende['amo_id_ontologie'];
143
	    	
138
 
144
	    	if(isset($valeurs_a_stat_code[$legende_code])) {
-
 
145
				$valeurs_a_stat_legende[$legende_nom] = $valeurs_a_stat_code[$legende_code];
-
 
146
	    	} else {
139
			if (isset($valeurs_a_stat_code[$legende_code])) {
147
	    		
140
				$valeurs_a_stat_legende[$legende_nom] = $valeurs_a_stat_code[$legende_code];
148
	    	}
141
			}
149
	    }
142
		}
150
	    
143
 
151
		$graph = $this->statistiques->genererGraphique(Statistiques::GRAPH_CAMEMBERT,$valeurs_a_stat_legende, $titre, array(650, 400));
-
 
152
		return $this->dessinerGraph($graph);
144
		$graph = $this->statistiques->genererGraphique(Statistiques::GRAPH_CAMEMBERT,$valeurs_a_stat_legende, $titre, array(650, 400));
153
		
145
		return $this->dessinerGraph($graph);
154
	}
146
	}
155
 
147
 
156
	public function obtenirStatistiquesPourAnnee($id_annuaire, $annee = null) {
148
	public function obtenirStatistiquesPourAnnee($id_annuaire, $annee = null) {
157
		
-
 
158
		$annee = ($annee == null) ? date("Y") : $annee; 
149
		$annee = ($annee == null) ? date("Y") : $annee; 
159
		$annuaire_modele = new AnnuaireModele();
150
		$annuaire_modele = new AnnuaireModele();
160
		
151
		
161
		$valeurs_a_stat_code = array();
152
		$valeurs_a_stat_code = array();
162
		$valeurs_a_stat_legende = array();
153
		$valeurs_a_stat_legende = array();
163
		 
-
 
164
		$tab_mois = array("Jan","Fev","Mar","Avr","Mai","Juin","Juil","Aout","Sep","Oct","Nov","Dec");
-
 
165
		
154
		
166
		$annee_debut = $annee;
155
		$annee_debut = $annee;
167
		$mois = 1;
156
		$mois = 1;
168
		$annee = $annee;
157
		$annee = $annee;
169
		$tps_debut = mktime(0,0,0,1,1,$annee);
158
		$tps_debut = mktime(0,0,0,1,1,$annee);
170
		$tps_courant = $tps_debut;
159
		$tps_courant = $tps_debut;
171
		
160
		
172
		$annee_courante = date("Y");
161
		$annee_courante = date("Y");
173
		if($annee_fin == $annee_courante) {
162
		if ($annee_fin == $annee_courante) {
174
			$tps_fin = time();// jour courant
163
			$tps_fin = time();// jour courant
175
		} else {
164
		} else {
176
			$tps_fin = mktime(0,0,0,1,1,$annee+1);			
165
			$tps_fin = mktime(0,0,0,1,1,$annee+1);			
177
		}
166
		}
178
		
167
		
179
		//Requete par mois
168
		//Requete par mois
180
		$i = 1;
169
		$i = 1;
181
		while  ($tps_courant <= $tps_fin) {
170
		while ($tps_courant <= $tps_fin) {
182
				
-
 
183
			if (($mois)/12 > 1) {
171
			if ($mois/12 > 1) {
184
				$mois = 1;
172
				$mois = 1;
185
				$annee = $annee+1;
173
				$annee = $annee+1;
186
			}
174
			}
187
				
175
				
188
			$tps_mois_suivant = mktime(0,0,0,$mois+1,1,$annee);
176
			$tps_mois_suivant = mktime(0,0,0,$mois+1,1,$annee);
189
			$nb_inscrits_dans_intervalle = $annuaire_modele->obtenirNombreInscriptionsDansIntervalleDate($id_annuaire, $tps_debut, $tps_courant);	
177
			$nb_inscrits_dans_intervalle = $annuaire_modele->obtenirNombreInscriptionsDansIntervalleDate($id_annuaire, $tps_debut, $tps_courant);	
190
			$valeurs_a_stat_legende[$tab_mois[$mois-1].' '.$annee] = $nb_inscrits_dans_intervalle;
178
			$valeurs_a_stat_legende[$this->tab_mois[$mois-1].' '.$annee] = $nb_inscrits_dans_intervalle;
191
				
179
				
192
			$tps_courant = $tps_mois_suivant;
180
			$tps_courant = $tps_mois_suivant;
193
			$mois++;
181
			$mois++;
194
			$i++;
182
			$i++;
195
		}
183
		}
196
		
184
		
197
		$nom_axeX = 'Mois depuis le 1er janvier '.$annee;
185
		$nom_axeX = 'Mois depuis le 1er janvier '.$annee;
198
		
186
		
199
		$graph = $this->statistiques->genererGraphique(Statistiques::GRAPH_COURBE,$valeurs_a_stat_legende, '', array(500,490), $nom_axeX, '');
187
		$graph = $this->statistiques->genererGraphique(Statistiques::GRAPH_COURBE,$valeurs_a_stat_legende, '', array(500,490), $nom_axeX, '');
200
		return $this->dessinerGraph($graph);
188
		return $this->dessinerGraph($graph);
201
	}
189
	}
202
 
190
 
203
	public function obtenirStatistiquesParAnnees($id_annuaire, $annee_fin = '') {
191
	public function obtenirStatistiquesParAnnees($id_annuaire, $annee_fin = '') {
204
 
-
 
205
	    $annuaire_modele = new AnnuaireModele();
192
		$annuaire_modele = new AnnuaireModele();
206
 
193
 
207
		$valeurs_a_stat_code = array();
194
		$valeurs_a_stat_code = array();
208
		$valeurs_a_stat_legende = array();
195
		$valeurs_a_stat_legende = array();
209
			        
196
 
210
		$tab_mois = array("Jan","Fev","Mar","Avr","Mai","Juin","Juil","Aout","Sep","Oct","Nov","Dec");
-
 
211
		
-
 
212
		$annee_debut = 2002;
197
		$annee_debut = 2002;
213
		$mois = 4;
198
		$mois = 4;
214
		$annee = 2002;
199
		$annee = 2002;
215
		$tps_debut = mktime(0,0,0,$mois,1,$annee);
200
		$tps_debut = mktime(0,0,0,$mois,1,$annee);
216
		$tps_courant = $tps_debut;
201
		$tps_courant = $tps_debut;
217
		
202
 
218
		if($annee_fin != '') {
203
		if ($annee_fin != '') {
219
			$tps_fin = mktime(0,0,0,1,1,$annee_fin);
204
			$tps_fin = mktime(0,0,0,1,1,$annee_fin);
220
		} else {
205
		} else {
221
			$tps_fin = time();// jour courant
206
			$tps_fin = time();// jour courant
222
		}
207
		}
223
 
208
 
224
		//Requete par mois
209
		//Requete par mois
225
		$i = 1;
210
		$i = 1;
226
		while  ($tps_courant <= $tps_fin) {
211
		while ($tps_courant <= $tps_fin) {
227
			
-
 
228
			if (($mois)/12 > 1) {
212
			if (($mois)/12 > 1) {
229
				$mois = 1;
213
				$mois = 1;
230
				$annee = $annee+1;
214
				$annee = $annee+1;
231
			}
215
			}
232
			
216
 
233
			$tps_mois_suivant = mktime(0,0,0,$mois+1,1,$annee);
217
			$tps_mois_suivant = mktime(0,0,0,$mois+1,1,$annee);
234
			
218
 
235
			$nb_inscrits_dans_intervalle = $annuaire_modele->obtenirNombreInscriptionsDansIntervalleDate($id_annuaire, $tps_debut, $tps_courant);
219
			$nb_inscrits_dans_intervalle = $annuaire_modele->obtenirNombreInscriptionsDansIntervalleDate($id_annuaire, $tps_debut, $tps_courant);
236
			
220
 
237
			$valeurs_a_stat_legende[$tab_mois[$mois-1].' '.$annee] = $nb_inscrits_dans_intervalle;
221
			$valeurs_a_stat_legende[$this->tab_mois[$mois-1].' '.$annee] = $nb_inscrits_dans_intervalle;
238
			
222
 
239
			$tps_courant = $tps_mois_suivant;
223
			$tps_courant = $tps_mois_suivant;
240
			$mois++;
224
			$mois++;
241
			$i++;
225
			$i++;
242
		}
226
		}
243
 
227
 
244
		$nom_axeX = 'Mois depuis le 1er avril 2002'; 
228
		$nom_axeX = 'Mois depuis le 1er avril 2002'; 
245
		
-
 
246
		$graph = $this->statistiques->genererGraphique(Statistiques::GRAPH_COURBE,$valeurs_a_stat_legende, '', array(500,490), $nom_axeX, '');
-
 
247
	    return $this->dessinerGraph($graph);
-
 
-
 
229
 
-
 
230
		$graph = $this->statistiques->genererGraphique(Statistiques::GRAPH_COURBE,$valeurs_a_stat_legende, '', array(500,490), $nom_axeX, '');
248
 
231
		return $this->dessinerGraph($graph);
249
	}
232
	}
250
	
233
	
251
	public function obtenirStatistiquesModificationsProfil($id_annuaire, $annee_fin = '') {
234
	public function obtenirStatistiquesModificationsProfil($id_annuaire, $annee_fin = '') {
252
 
-
 
253
	    $modele = new StatistiqueModele();
235
		$modele = new StatistiqueModele();
254
 
236
 
255
		$valeurs_a_stat_code = array();
237
		$valeurs_a_stat_code = array();
256
		$valeurs_a_stat_legende = array();
238
		$valeurs_a_stat_legende = array();
257
			        
239
 
258
		$tab_mois = array("Jan","Fev","Mar","Avr","Mai","Juin","Juil","Aout","Sep","Oct","Nov","Dec");
-
 
259
		
-
 
260
		$annee_debut = 2010;
240
		$annee_debut = 2010;
261
		$mois = 1;
241
		$mois = 1;
262
		$annee = 2010;
242
		$annee = 2010;
263
		$tps_debut = mktime(0,0,0,$mois,1,$annee);
243
		$tps_debut = mktime(0,0,0,$mois,1,$annee);
264
		$tps_courant = $tps_debut;
244
		$tps_courant = $tps_debut;
265
		
245
 
266
		if($annee_fin != '') {
246
		if($annee_fin != '') {
267
			$tps_fin = mktime(0,0,0,1,1,$annee_fin);
247
			$tps_fin = mktime(0,0,0,1,1,$annee_fin);
268
		} else {
248
		} else {
269
			$today = date_parse(date('Y-m-d H:i:s'));
249
			$today = date_parse(date('Y-m-d H:i:s'));
270
			
250
 
271
			$annee_fin_today = $today['year'];
251
			$annee_fin_today = $today['year'];
272
			$mois_fin_today = $today['month'];
252
			$mois_fin_today = $today['month'];
273
						
253
 
274
			if($annee_debut == $annee_fin_today) {
254
			if($annee_debut == $annee_fin_today) {
275
				$tps_fin = mktime(0,0,0,$mois_fin_today+1,1,$annee_fin_today);
255
				$tps_fin = mktime(0,0,0,$mois_fin_today+1,1,$annee_fin_today);
276
			} else {
256
			} else {
277
				$tps_fin = time();// jour courant
257
				$tps_fin = time();// jour courant
278
			}
258
			}
279
		}
259
		}
280
		
260
 
281
		//Requete par mois
261
		//Requete par mois
282
		$i = 1;
262
		$i = 1;
283
		while  ($tps_courant <= $tps_fin) {
263
		while ($tps_courant <= $tps_fin) {
284
			
-
 
285
			if (($mois)/12 > 1) {
264
			if (($mois)/12 > 1) {
286
				$mois = 1;
265
				$mois = 1;
287
				$annee = $annee+1;
266
				$annee = $annee+1;
288
			}
267
			}
289
			
268
 
290
			$tps_mois_suivant = mktime(0,0,0,$mois+1,1,$annee);
269
			$tps_mois_suivant = mktime(0,0,0,$mois+1,1,$annee);
291
			
270
 
292
			$nb_modif_dans_intervalle = $modele->obtenirEvenementsDansIntervalle($id_annuaire,'modification', $tps_debut, $tps_courant);
271
			$nb_modif_dans_intervalle = $modele->obtenirEvenementsDansIntervalle($id_annuaire,'modification', $tps_debut, $tps_courant);
293
			
272
 
294
			$valeurs_a_stat_legende[$tab_mois[$mois-1].' '.$annee] = $nb_modif_dans_intervalle;
273
			$valeurs_a_stat_legende[$this->tab_mois[$mois-1].' '.$annee] = $nb_modif_dans_intervalle;
295
			
274
 
296
			$tps_courant = $tps_mois_suivant;
275
			$tps_courant = $tps_mois_suivant;
297
			$mois++;
276
			$mois++;
298
			$i++;
277
			$i++;
299
		}
278
		}
300
 
279
 
301
		$nom_axeX = 'Mois depuis le 1er juillet 2010'; 
280
		$nom_axeX = 'Mois depuis le 1er juillet 2010'; 
302
		
-
 
303
		$graph = $this->statistiques->genererGraphique(Statistiques::GRAPH_COURBE,$valeurs_a_stat_legende, '', array(500,490), $nom_axeX, '');
-
 
304
	    return $this->dessinerGraph($graph);
-
 
-
 
281
 
-
 
282
		$graph = $this->statistiques->genererGraphique(Statistiques::GRAPH_COURBE,$valeurs_a_stat_legende, '', array(500,490), $nom_axeX, '');
305
 
283
		return $this->dessinerGraph($graph);
306
	}
284
	}
307
	
285
	
308
	public function ajouterEvenementStatistique($id_annuaire, $id_utilisateur, $type) {
286
	public function ajouterEvenementStatistique($id_annuaire, $id_utilisateur, $type) {
309
		
-
 
310
		$this->chargerModele('StatistiqueModele');	
287
		$this->chargerModele('StatistiqueModele');	
311
		$this->StatistiqueModele->ajouterEvenementStatistique($id_annuaire, $id_utilisateur, $type);
288
		$this->StatistiqueModele->ajouterEvenementStatistique($id_annuaire, $id_utilisateur, $type);
312
		
289
		
313
	}
290
	}
314
	
291
	
315
	public function obtenirDerniersEvenementsStatistique($id_annuaire, $type) {
292
	public function obtenirDerniersEvenementsStatistique($id_annuaire, $type) {
316
		
-
 
317
		$this->chargerModele('StatistiqueModele');	
293
		$this->chargerModele('StatistiqueModele');	
318
		return $this->StatistiqueModele->obtenirDerniersEvenementsStatistique($id_annuaire, $type);
294
		return $this->StatistiqueModele->obtenirDerniersEvenementsStatistique($id_annuaire, $type);
319
		
295
		
320
	}
296
	}
321
	
297
	
322
	private function dessinerGraph($graph) {
298
	private function dessinerGraph($graph) {
323
		return $this->statistiques->dessinerGraph($graph);
299
		return $this->statistiques->dessinerGraph($graph);
324
	}
300
	}
325
	
301
	
326
	private function convertirPourLegende($texte) {	
-
 
327
 
302
	private function convertirPourLegende($texte) {
328
		if(trim($texte) == '') {
303
		if (trim($texte) == '') {
329
			$texte = '' ;
304
			$texte = '' ;
330
		}
305
		}
331
 
306
 
332
		$texte = str_replace(
307
		$texte = str_replace(
333
			array(
308
			array(
334
				'à', 'â', 'ä', 'á', 'ã', 'å',
309
				'à', 'â', 'ä', 'á', 'ã', 'å',
335
				'î', 'ï', 'ì', 'í', 
310
				'î', 'ï', 'ì', 'í', 
336
				'ô', 'ö', 'ò', 'ó', 'õ', 'ø', 
311
				'ô', 'ö', 'ò', 'ó', 'õ', 'ø', 
337
				'ù', 'û', 'ü', 'ú', 
312
				'ù', 'û', 'ü', 'ú', 
338
				'é', 'è', 'ê', 'ë', 
313
				'é', 'è', 'ê', 'ë', 
339
				'ç', 'ÿ', 'ñ',
314
				'ç', 'ÿ', 'ñ',
340
				'À', 'Â', 'Ä', 'Á', 'Ã', 'Å',
315
				'À', 'Â', 'Ä', 'Á', 'Ã', 'Å',
341
				'Î', 'Ï', 'Ì', 'Í', 
316
				'Î', 'Ï', 'Ì', 'Í', 
342
				'Ô', 'Ö', 'Ò', 'Ó', 'Õ', 'Ø', 
317
				'Ô', 'Ö', 'Ò', 'Ó', 'Õ', 'Ø', 
343
				'Ù', 'Û', 'Ü', 'Ú', 
318
				'Ù', 'Û', 'Ü', 'Ú', 
344
				'É', 'È', 'Ê', 'Ë', 
319
				'É', 'È', 'Ê', 'Ë', 
345
				'Ç', 'Ÿ', 'Ñ',
320
				'Ç', 'Ÿ', 'Ñ',
346
			),
321
			),
347
			array(
322
			array(
348
				'a', 'a', 'a', 'a', 'a', 'a', 
323
				'a', 'a', 'a', 'a', 'a', 'a', 
349
				'i', 'i', 'i', 'i', 
324
				'i', 'i', 'i', 'i', 
350
				'o', 'o', 'o', 'o', 'o', 'o', 
325
				'o', 'o', 'o', 'o', 'o', 'o', 
351
				'u', 'u', 'u', 'u', 
326
				'u', 'u', 'u', 'u', 
352
				'e', 'e', 'e', 'e', 
327
				'e', 'e', 'e', 'e', 
353
				'c', 'y', 'n', 
328
				'c', 'y', 'n', 
354
				'A', 'A', 'A', 'A', 'A', 'A', 
329
				'A', 'A', 'A', 'A', 'A', 'A', 
355
				'I', 'I', 'I', 'I', 
330
				'I', 'I', 'I', 'I', 
356
				'O', 'O', 'O', 'O', 'O', 'O', 
331
				'O', 'O', 'O', 'O', 'O', 'O', 
357
				'U', 'U', 'U', 'U', 
332
				'U', 'U', 'U', 'U', 
358
				'E', 'E', 'E', 'E', 
333
				'E', 'E', 'E', 'E', 
359
				'C', 'Y', 'N', 
334
				'C', 'Y', 'N', 
360
			),$texte);
335
			),$texte);
361
		
336
		
362
		return $texte;	
337
		return $texte;
363
	}
338
	}
364
	
339
	
365
	private function miniQuote($chaine) {
340
	private function miniQuote($chaine) {
366
		return "'".$chaine."'";
341
		return "'".$chaine."'";
367
	}
342
	}
368
}
343
}
369
?>
344
?>