Subversion Repositories Applications.annuaire

Compare Revisions

No changes between revisions

Ignore whitespace Rev 435 → Rev 442

/trunk/jrest/services/StatistiquesAnnuaire.php
15,41 → 15,40
class StatistiquesAnnuaire extends JRestService {
 
public function getElement($uid){
 
if (!isset($uid[0])) {
if (!isset($uid[0])) {
$id_annuaire = $uid[0];
} else {
} else {
$id_annuaire = Config::get('annuaire_defaut');
}
}
 
if (isset($uid[1])) {
$type_stat = $uid[1];
} else {
$type_stat = '';
}
$controleur = new StatistiqueControleur();
switch($type_stat) {
case 'annee' :
$annee = isset($uid[2]) ? $uid[2] : null;
$graph = $controleur->obtenirStatistiquesPourAnnee($id_annuaire, $annee);
break;
case 'annees' :
$graph = $controleur->obtenirStatistiquesParAnnees($id_annuaire);
break;
case 'continents' :
$graph = $controleur->obtenirStatistiquesInscritsParContinents($id_annuaire);
break;
case 'europe' :
$graph = $controleur->obtenirStatistiquesInscritsEurope($id_annuaire);
break;
case 'modification' :
$graph = $controleur->obtenirStatistiquesModificationsProfil($id_annuaire);
break;
default:
$graph = $controleur->obtenirStatistiquesParCritere($id_annuaire,$type_stat, '');
}
} else {
$type_stat = '';
}
 
$controleur = new StatistiqueControleur();
 
switch($type_stat) {
case 'annee' :
$annee = isset($uid[2]) ? $uid[2] : null;
$graph = $controleur->obtenirStatistiquesPourAnnee($id_annuaire, $annee);
break;
case 'annees' :
$graph = $controleur->obtenirStatistiquesParAnnees($id_annuaire);
break;
case 'continents' :
$graph = $controleur->obtenirStatistiquesInscritsParContinents($id_annuaire);
break;
case 'europe' :
$graph = $controleur->obtenirStatistiquesInscritsEurope($id_annuaire);
break;
case 'modification' :
$graph = $controleur->obtenirStatistiquesModificationsProfil($id_annuaire);
break;
default:
$graph = $controleur->obtenirStatistiquesParCritere($id_annuaire,$type_stat, '');
}
// Envoi d'une image png
header("Content-type: image/png charset=utf-8\n\n");
/trunk/configurations/config.defaut.ini
147,4 → 147,9
url_services_applications_inscription = ""
url_services_applications_resume = ""
; url des application qui possèdent une fonction de gestion de l'appli
url_services_applications_gestion = "";
url_services_applications_gestion = "";
 
; +-----------------------------------------------------------------------------------------------------+
; Chemins
; Chemin vers la bibliothèque jpgraph
chemin_jpgraph = "/home/telabotap/www/commun/jpgraph/2.1.4/"
/trunk/squelettes/css/annuaire_complexe.css
480,10 → 480,6
margin-top: -5px;
}
 
.resultat_recherche .profil_avatar {
margin-right: 0px;
}
 
.resultat_recherche .element_resultat {
height: 85px;
margin: 10px !important;
492,7 → 488,8
}
 
.resultat_recherche .profil_avatar {
width: 110px;
width: 80px;
margin-right: 0;
}
 
.resultat_recherche .selection_destinataire {
/trunk/controleurs/StatistiqueControleur.php
18,150 → 18,139
private $champ_pays = '12';
private $champ_rapport_activite_bota = '102';
private $champ_experience_bota = '4';
 
private $tab_mois = array('Jan','Fev','Mar','Avr','Mai','Juin','Juil','Aout','Sep','Oct','Nov','Dec');
public function StatistiqueControleur() {
$this->__construct();
$this->statistiques = Composant::fabrique('statistiques', array());
}
public function obtenirStatistiquesInscritsParContinents($id_annuaire) {
$cartographe = new CartoControleur();
$annuaire_controleur = new AnnuaireControleur();
$continents = array('Afrique (%1.2f%%)' => 'pays_afrique',
'Amerique du nord (%1.2f%%)' => 'pays_nord_amerique',
'Asie (%1.2f%%)' => 'pays_asie',
'Europe (%1.2f%%)' => 'pays_europe',
'Oceanie (%1.2f%%)' => 'pays_oceanie',
'Amerique du sud (%1.2f%%)' => 'pays_sud_amerique',
'Moyen Orient (%1.2f%%)' => 'pays_moyen_orient');
$continents = array(
'Afrique (%1.2f%%)' => 'pays_afrique',
'Amerique du nord (%1.2f%%)' => 'pays_nord_amerique',
'Asie (%1.2f%%)' => 'pays_asie',
'Europe (%1.2f%%)' => 'pays_europe',
'Oceanie (%1.2f%%)' => 'pays_oceanie',
'Amerique du sud (%1.2f%%)' => 'pays_sud_amerique',
'Moyen Orient (%1.2f%%)' => 'pays_moyen_orient');
// pour chacun des continents, on fait la somme des membres de sa zone
foreach($continents as $id_continent => $continent) {
$zones_continent_ids = $cartographe->chargerInformationsPaysDuContinentsCsv($continent);
$zones_continent_ids = array_map(array($this,'miniQuote'), array_keys($zones_continent_ids));
$nb_inscrits[$id_continent] = array_sum($annuaire_controleur->chargerNombreAnnuaireListeInscritsParPays($id_annuaire, $zones_continent_ids));
}
$graph = $this->statistiques->genererGraphique(Statistiques::GRAPH_CAMEMBERT,$nb_inscrits,'', array(650, 500));
return $this->dessinerGraph($graph);
// pour chacun des continents, on fait la somme des membres de sa zone
foreach($continents as $id_continent => $continent) {
$zones_continent_ids = $cartographe->chargerInformationsPaysDuContinentsCsv($continent);
$zones_continent_ids = array_map(array($this,'miniQuote'), array_keys($zones_continent_ids));
$nb_inscrits[$id_continent] = array_sum($annuaire_controleur->chargerNombreAnnuaireListeInscritsParPays($id_annuaire, $zones_continent_ids));
}
 
$graph = $this->statistiques->genererGraphique(Statistiques::GRAPH_CAMEMBERT,$nb_inscrits,'', array(650, 500));
 
return $this->dessinerGraph($graph);
}
public function obtenirStatistiquesInscritsEurope($id_annuaire) {
$cartographe = new CartoControleur();
$annuaire_controleur = new AnnuaireControleur();
$cartographe = new CartoControleur();
$ids_zones_europe = $cartographe->chargerInformationsPaysDuContinentsCsv('pays_europe');
$codes_zones_europe = array_map(array($this,'miniQuote'), array_keys($ids_zones_europe));
$codes_zones_europe = array_map(array($this, 'miniQuote'), array_keys($ids_zones_europe));
 
$titre_zone = $this->convertirPourLegende($zone[2]);
$nb_inscrits_par_code = $annuaire_controleur->chargerNombreAnnuaireListeInscritsParPays($id_annuaire, $codes_zones_europe);
$nb_inscrits_par_code = $annuaire_controleur->chargerNombreAnnuaireListeInscritsParPays($id_annuaire, $codes_zones_europe);
$nb_inscrits_par_legende = array();
$inscrits_france = $nb_inscrits_par_code['fr'];
unset($nb_inscrits_par_code['fr']);
$somme_autres_pays = 0;
foreach($nb_inscrits_par_code as $code_pays => $inscrits_pays) {
$label_pays = $this->convertirPourLegende($ids_zones_europe[$code_pays][2].' (%1.2f%%)');
$nb_inscrits_par_legende[$label_pays] = $inscrits_pays;
$somme_autres_pays += $inscrits_pays;
}
$tableau_france_autres = array('France (%1.2f%%)' => $inscrits_france, 'Autres (%1.2f%%)' => $somme_autres_pays);
$graph_france = $this->statistiques->genererGraphique(Statistiques::GRAPH_CAMEMBERT,$tableau_france_autres,'', array(320, 200));
$graph_autres = $this->statistiques->genererGraphique(Statistiques::GRAPH_CAMEMBERT,$nb_inscrits_par_legende,'', array(900, 700));
$graph = $this->statistiques->combinerGraphiques($graph_france, $graph_autres, array(920, 1200));
$nb_inscrits_par_legende = array();
 
$inscrits_france = $nb_inscrits_par_code['fr'];
 
unset($nb_inscrits_par_code['fr']);
$somme_autres_pays = 0;
 
foreach ($nb_inscrits_par_code as $code_pays => $inscrits_pays) {
$label_pays = $this->convertirPourLegende($ids_zones_europe[$code_pays][2].' (%1.2f%%)');
$nb_inscrits_par_legende[$label_pays] = $inscrits_pays;
$somme_autres_pays += $inscrits_pays;
}
 
$tableau_france_autres = array('France (%1.2f%%)' => $inscrits_france, 'Autres (%1.2f%%)' => $somme_autres_pays);
 
$graph_france = $this->statistiques->genererGraphique(Statistiques::GRAPH_CAMEMBERT, $tableau_france_autres, '', array(320, 200));
$graph_autres = $this->statistiques->genererGraphique(Statistiques::GRAPH_CAMEMBERT, $nb_inscrits_par_legende, '', array(930, 900));
$graph = $this->statistiques->combinerGraphiques($graph_france, $graph_autres, array(940, 1110));
return $this->dessinerGraph($graph);
}
 
public function obtenirStatistiquesParPays($id_annuaire) {
$controleur = new AnnuaireControleur();
 
$controleur = new AnnuaireControleur();
//$controleur = new AnnuaireControleur();
$modele_meta = new MetadonneeModele();
$modele_onto = new OntologieModele();
$id_champ = 12;
$valeurs = $modele_meta->obtenirNombreValeurMetadonnee($id_champ);
$id_onto = $modele_meta->obtenirOntologieLieeAChampParId($id_champ);
$legendes = $modele_onto->chargerListeOntologie($id_onto);
//$controleur = new AnnuaireControleur();
$modele_meta = new MetadonneeModele();
$modele_onto = new OntologieModele();
$id_champ = 12;
$valeurs = $modele_meta->obtenirNombreValeurMetadonnee($id_champ);
$id_onto = $modele_meta->obtenirOntologieLieeAChampParId($id_champ);
$legendes = $modele_onto->chargerListeOntologie($id_onto);
 
$valeurs_a_stat_code = array();
$valeurs_a_stat_legende = array();
 
foreach($valeurs as $valeur) {
foreach ($valeurs as $valeur) {
$valeurs_a_stat_code[$valeur['amv_valeur']] = $valeur['nb'];
}
 
foreach($legendes as $legende) {
$legende_nom = $legende['amo_nom'];
$legende_code = $legende['amo_id_ontologie'];
foreach ($legendes as $legende) {
$legende_nom = $legende['amo_nom'];
$legende_code = $legende['amo_id_ontologie'];
 
if(isset($valeurs_a_stat_code[$legende_code])) {
if (isset($valeurs_a_stat_code[$legende_code])) {
$valeurs_a_stat_legende[$legende_nom] = $valeurs_a_stat_code[$legende_code];
}
}
}
}
 
$graph = $this->statistiques->genererGraphique(Statistiques::GRAPH_CAMEMBERT,$valeurs_a_stat_legende);
return $this->dessinerGraph($graph);
 
return $this->dessinerGraph($graph);
}
 
public function obtenirStatistiquesParCritere($id_annuaire, $code_champ, $titre = '') {
$modele_meta = new MetadonneeModele();
$modele_onto = new OntologieModele();
$id_champ = $modele_meta->renvoyerIdChampMetadonneeParAbreviation($id_annuaire, $code_champ);
$valeurs = $modele_meta->obtenirNombreValeurMetadonnee($id_champ);
$id_onto = $modele_meta->obtenirOntologieLieeAChampParId($id_champ);
$legendes = $modele_onto->chargerListeOntologie($id_onto);
 
$modele_meta = new MetadonneeModele();
$modele_onto = new OntologieModele();
$id_champ = $modele_meta->renvoyerIdChampMetadonneeParAbreviation($id_annuaire, $code_champ);
$valeurs = $modele_meta->obtenirNombreValeurMetadonnee($id_champ);
$id_onto = $modele_meta->obtenirOntologieLieeAChampParId($id_champ);
$legendes = $modele_onto->chargerListeOntologie($id_onto);
$valeurs_a_stat_code = array();
$valeurs_a_stat_legende = array();
 
$titre = $this->convertirPourLegende($titre);
 
foreach($valeurs as $valeur) {
foreach ($valeurs as $valeur) {
$valeurs_a_stat_code[$valeur['amv_valeur']] = $valeur['nb'];
}
foreach($legendes as $legende) {
$legende_nom = $this->convertirPourLegende($legende['amo_nom']);
$legende_code = $legende['amo_id_ontologie'];
if(isset($valeurs_a_stat_code[$legende_code])) {
 
foreach ($legendes as $legende) {
$legende_nom = $this->convertirPourLegende($legende['amo_nom']);
$legende_code = $legende['amo_id_ontologie'];
 
if (isset($valeurs_a_stat_code[$legende_code])) {
$valeurs_a_stat_legende[$legende_nom] = $valeurs_a_stat_code[$legende_code];
} else {
}
}
}
}
 
$graph = $this->statistiques->genererGraphique(Statistiques::GRAPH_CAMEMBERT,$valeurs_a_stat_legende, $titre, array(650, 400));
return $this->dessinerGraph($graph);
}
 
public function obtenirStatistiquesPourAnnee($id_annuaire, $annee = null) {
$annee = ($annee == null) ? date("Y") : $annee;
$annuaire_modele = new AnnuaireModele();
$valeurs_a_stat_code = array();
$valeurs_a_stat_legende = array();
$tab_mois = array("Jan","Fev","Mar","Avr","Mai","Juin","Juil","Aout","Sep","Oct","Nov","Dec");
$annee_debut = $annee;
$mois = 1;
170,7 → 159,7
$tps_courant = $tps_debut;
$annee_courante = date("Y");
if($annee_fin == $annee_courante) {
if ($annee_fin == $annee_courante) {
$tps_fin = time();// jour courant
} else {
$tps_fin = mktime(0,0,0,1,1,$annee+1);
178,9 → 167,8
//Requete par mois
$i = 1;
while ($tps_courant <= $tps_fin) {
if (($mois)/12 > 1) {
while ($tps_courant <= $tps_fin) {
if ($mois/12 > 1) {
$mois = 1;
$annee = $annee+1;
}
187,7 → 175,7
$tps_mois_suivant = mktime(0,0,0,$mois+1,1,$annee);
$nb_inscrits_dans_intervalle = $annuaire_modele->obtenirNombreInscriptionsDansIntervalleDate($id_annuaire, $tps_debut, $tps_courant);
$valeurs_a_stat_legende[$tab_mois[$mois-1].' '.$annee] = $nb_inscrits_dans_intervalle;
$valeurs_a_stat_legende[$this->tab_mois[$mois-1].' '.$annee] = $nb_inscrits_dans_intervalle;
$tps_courant = $tps_mois_suivant;
$mois++;
201,21 → 189,18
}
 
public function obtenirStatistiquesParAnnees($id_annuaire, $annee_fin = '') {
$annuaire_modele = new AnnuaireModele();
 
$annuaire_modele = new AnnuaireModele();
 
$valeurs_a_stat_code = array();
$valeurs_a_stat_legende = array();
$tab_mois = array("Jan","Fev","Mar","Avr","Mai","Juin","Juil","Aout","Sep","Oct","Nov","Dec");
 
$annee_debut = 2002;
$mois = 4;
$annee = 2002;
$tps_debut = mktime(0,0,0,$mois,1,$annee);
$tps_courant = $tps_debut;
if($annee_fin != '') {
 
if ($annee_fin != '') {
$tps_fin = mktime(0,0,0,1,1,$annee_fin);
} else {
$tps_fin = time();// jour courant
223,19 → 208,18
 
//Requete par mois
$i = 1;
while ($tps_courant <= $tps_fin) {
while ($tps_courant <= $tps_fin) {
if (($mois)/12 > 1) {
$mois = 1;
$annee = $annee+1;
}
 
$tps_mois_suivant = mktime(0,0,0,$mois+1,1,$annee);
 
$nb_inscrits_dans_intervalle = $annuaire_modele->obtenirNombreInscriptionsDansIntervalleDate($id_annuaire, $tps_debut, $tps_courant);
$valeurs_a_stat_legende[$tab_mois[$mois-1].' '.$annee] = $nb_inscrits_dans_intervalle;
 
$valeurs_a_stat_legende[$this->tab_mois[$mois-1].' '.$annee] = $nb_inscrits_dans_intervalle;
 
$tps_courant = $tps_mois_suivant;
$mois++;
$i++;
242,35 → 226,31
}
 
$nom_axeX = 'Mois depuis le 1er avril 2002';
 
$graph = $this->statistiques->genererGraphique(Statistiques::GRAPH_COURBE,$valeurs_a_stat_legende, '', array(500,490), $nom_axeX, '');
return $this->dessinerGraph($graph);
 
return $this->dessinerGraph($graph);
}
public function obtenirStatistiquesModificationsProfil($id_annuaire, $annee_fin = '') {
$modele = new StatistiqueModele();
 
$modele = new StatistiqueModele();
 
$valeurs_a_stat_code = array();
$valeurs_a_stat_legende = array();
$tab_mois = array("Jan","Fev","Mar","Avr","Mai","Juin","Juil","Aout","Sep","Oct","Nov","Dec");
 
$annee_debut = 2010;
$mois = 1;
$annee = 2010;
$tps_debut = mktime(0,0,0,$mois,1,$annee);
$tps_courant = $tps_debut;
 
if($annee_fin != '') {
$tps_fin = mktime(0,0,0,1,1,$annee_fin);
} else {
$today = date_parse(date('Y-m-d H:i:s'));
 
$annee_fin_today = $today['year'];
$mois_fin_today = $today['month'];
 
if($annee_debut == $annee_fin_today) {
$tps_fin = mktime(0,0,0,$mois_fin_today+1,1,$annee_fin_today);
} else {
277,22 → 257,21
$tps_fin = time();// jour courant
}
}
 
//Requete par mois
$i = 1;
while ($tps_courant <= $tps_fin) {
while ($tps_courant <= $tps_fin) {
if (($mois)/12 > 1) {
$mois = 1;
$annee = $annee+1;
}
 
$tps_mois_suivant = mktime(0,0,0,$mois+1,1,$annee);
 
$nb_modif_dans_intervalle = $modele->obtenirEvenementsDansIntervalle($id_annuaire,'modification', $tps_debut, $tps_courant);
$valeurs_a_stat_legende[$tab_mois[$mois-1].' '.$annee] = $nb_modif_dans_intervalle;
 
$valeurs_a_stat_legende[$this->tab_mois[$mois-1].' '.$annee] = $nb_modif_dans_intervalle;
 
$tps_courant = $tps_mois_suivant;
$mois++;
$i++;
299,14 → 278,12
}
 
$nom_axeX = 'Mois depuis le 1er juillet 2010';
 
$graph = $this->statistiques->genererGraphique(Statistiques::GRAPH_COURBE,$valeurs_a_stat_legende, '', array(500,490), $nom_axeX, '');
return $this->dessinerGraph($graph);
 
return $this->dessinerGraph($graph);
}
public function ajouterEvenementStatistique($id_annuaire, $id_utilisateur, $type) {
$this->chargerModele('StatistiqueModele');
$this->StatistiqueModele->ajouterEvenementStatistique($id_annuaire, $id_utilisateur, $type);
313,7 → 290,6
}
public function obtenirDerniersEvenementsStatistique($id_annuaire, $type) {
$this->chargerModele('StatistiqueModele');
return $this->StatistiqueModele->obtenirDerniersEvenementsStatistique($id_annuaire, $type);
323,9 → 299,8
return $this->statistiques->dessinerGraph($graph);
}
private function convertirPourLegende($texte) {
 
if(trim($texte) == '') {
private function convertirPourLegende($texte) {
if (trim($texte) == '') {
$texte = '' ;
}
 
359,7 → 334,7
'C', 'Y', 'N',
),$texte);
return $texte;
return $texte;
}
private function miniQuote($chaine) {
/trunk/composants/statistiques/Statistiques.php
15,25 → 15,25
 
const GRAPH_CAMEMBERT = 'pie';
const GRAPH_COURBE = 'courbe';
private $chemin_lib_graph = '';
public function __construct() {
$this->chemin_lib_graph = Config::get('chemin_jpgraph');
}
 
public function genererGraphique($type_graphique, $valeurs, $titre = '', $taille = array(800, 800), $nom_axe_x = '', $nom_axe_y = '') {
 
// Inclusion de la librairie JpGraph
include_once("lib/jpgraph.php");
include_once $this->chemin_lib_graph.'jpgraph.php';
$graph = null;
 
switch($type_graphique) {
case Statistiques::GRAPH_CAMEMBERT:
$graph = $this->genererGraphiqueCamembert($valeurs, $titre, $taille);
break;
 
break;
case Statistiques::GRAPH_COURBE:
$graph = $this->genererGraphiqueCourbe($valeurs, $titre, $taille, $nom_axe_x, $nom_axe_y);
break;
 
break;
default:
$graph = $this->genererGraphiqueCourbe($valeurs);
break;
}
 
return $graph;
40,36 → 40,28
}
 
public function genererGraphiqueCamembert($valeurs, $titre, $taille) {
 
include_once("lib/jpgraph_pie.php");
$graph = new PieGraph($taille[0],$taille[1]);
include_once $this->chemin_lib_graph.'jpgraph_pie.php';
$legendes = array_keys($valeurs);
$valeurs = array_values($valeurs);
 
//die('<pre>'.print_r($valeurs, true).'</pre>');
$oPie = new PiePlot($valeurs);
$oPie->SetLegends($legendes);
 
// Ajouter le titre du graphique
$graph->title->Set($titre);
 
// position du graphique (légèrement à droite)
$oPie->SetCenter(0.35);
 
$oPie->SetValueType(PIE_VALUE_PER);
 
// Format des valeurs de type "entier"
$oPie->value->SetFormat('%1.2f%%');
 
$graph = new PieGraph($taille[0],$taille[1]);
// Ajouter le titre du graphique
$graph->title->Set($titre);
$graph->Add($oPie);
return $graph;
}
 
public function genererGraphiqueCourbe($valeurs, $titre, $taille, $nom_axe_x, $nom_axe_y) {
 
include_once("lib/jpgraph_line.php");
 
include_once $this->chemin_lib_graph.'jpgraph_line.php';
// Création du conteneur
$graph = new Graph($taille[0],$taille[1],"auto");
 
130,8 → 122,8
}
 
public function combinerGraphiques($graph1, $graph2, $taille) {
include_once $this->chemin_lib_graph.'jpgraph_mgraph.php';
 
include_once('lib/jpgraph_mgraph.php');
$mgraph = new MGraph($taille[0],$taille[1],"auto");
$xpos1=300;$ypos1=3;
$xpos2=3;$ypos2=200;
150,6 → 142,5
public function dessinerGraph($graph) {
return $graph->Stroke(_IMG_HANDLER);
}
 
}
?>
?>
/trunk/.
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.2-autel:r438-441