255 |
jpm |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
include ("../../../../api/jpgraph_1.12.2/jpgraph.php") ;
|
|
|
4 |
include ("../../../../api/jpgraph_1.12.2/jpgraph_line.php") ;
|
|
|
5 |
include ("../../../../api/jpgraph_1.12.2/jpgraph_bar.php");
|
|
|
6 |
include ("../../../../papyrus/configuration/pap_config.inc.php") ;
|
|
|
7 |
|
|
|
8 |
include_once 'DB.php' ;
|
|
|
9 |
$db = DB::connect (PAP_DSN) ;
|
|
|
10 |
if (DB::isError($db)) {
|
|
|
11 |
echo 'Message Standard : ' . $db->getMessage() . "\n";
|
|
|
12 |
echo 'Message DBMS/Utilisateur : ' . $db->getUserInfo() . "\n";
|
|
|
13 |
echo 'Message DBMS/Déboguage : ' . $db->getDebugInfo() . "\n";
|
|
|
14 |
exit;
|
|
|
15 |
}
|
|
|
16 |
|
257 |
jpm |
17 |
$tab_mois = array('Jan', 'Fev', 'Mar', 'Avr', 'Mai', 'Juin', 'Juil', 'Août', 'Sep', 'Oct', 'Nov', 'Dec');
|
255 |
jpm |
18 |
$tab_donnees_add = array() ;
|
|
|
19 |
$tab_donnees_del = array() ;
|
257 |
jpm |
20 |
if (isset($_GET['annee'])) {
|
|
|
21 |
$tps_debut = mktime(0, 0, 0, 1, 1, $_GET['annee']);
|
|
|
22 |
$tps_fin = mktime(23, 59, 59, 12, 31, $_GET['annee']);
|
|
|
23 |
$annee = $_GET['annee'];
|
|
|
24 |
} else {
|
|
|
25 |
$tps_debut = mktime(0, 0, 0, 1, 1);
|
|
|
26 |
$tps_fin = time();// jour courrant
|
|
|
27 |
$annee = date('Y', $tps_fin);
|
|
|
28 |
}
|
255 |
jpm |
29 |
$tps_courrant = $tps_debut;
|
|
|
30 |
$i = 0;
|
|
|
31 |
//Requete par mois
|
|
|
32 |
while ($tps_courrant <= $tps_fin) {
|
|
|
33 |
$tps_semaine_suivante = $tps_courrant + (7 * 24 * 60 * 60);
|
257 |
jpm |
34 |
$tps_mois_suivant = mktime(0, 0, 0,$i+2, 1, $annee);
|
255 |
jpm |
35 |
//echo date('Y-m-d H:i:s', $tps_courrant).' - '.date('Y-m-d H:i:s', $tps_mois_suivant);
|
|
|
36 |
$requete = 'SELECT IS_ACTION '.
|
|
|
37 |
'FROM ins_STATS '.
|
|
|
38 |
'WHERE IS_DATE >= "'.date('Y-m-d H:i:s', $tps_courrant).'" '.
|
|
|
39 |
'AND IS_DATE < "'.date('Y-m-d H:i:s', $tps_mois_suivant).'" ';
|
|
|
40 |
$resultat = $db->query($requete) ;
|
|
|
41 |
$tab_donnees_add[$i] = 0 ;
|
|
|
42 |
$tab_donnees_del[$i] = 0 ;
|
|
|
43 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
|
|
|
44 |
if ($ligne->IS_ACTION == 'add') $tab_donnees_add[$i]++ ;
|
|
|
45 |
if ($ligne->IS_ACTION == 'del') $tab_donnees_del[$i]++ ;
|
|
|
46 |
}
|
|
|
47 |
//echo ' - '.$tab_donnees[$i-1].'<br/>';
|
|
|
48 |
$tps_courrant = $tps_mois_suivant;
|
|
|
49 |
$i++;
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
// Création du graphique
|
257 |
jpm |
53 |
$graph = new Graph(500, 400, 'auto');
|
|
|
54 |
$graph->img->SetMargin(30, 30, 30, 40);
|
|
|
55 |
$graph->SetMarginColor('white');
|
255 |
jpm |
56 |
$graph->SetScale('textint');
|
|
|
57 |
$graph->xaxis->SetTickLabels($tab_mois);
|
|
|
58 |
$graph->SetShadow();
|
257 |
jpm |
59 |
$graph->title->Set('Évolution des inscriptions au Réseau');
|
255 |
jpm |
60 |
$graph->title->SetFont(FF_FONT1,FS_BOLD);
|
257 |
jpm |
61 |
$graph->xaxis->title->Set("Mois depuis le 1er janvier $annee");
|
255 |
jpm |
62 |
$graph->legend->SetLayout(LEGEND_HOR);
|
|
|
63 |
$graph->legend->Pos(0.5, 0.05, 'left', 'top');
|
|
|
64 |
|
|
|
65 |
// Création des barres
|
|
|
66 |
$BarPlotAdd = new BarPlot($tab_donnees_add);
|
257 |
jpm |
67 |
$BarPlotAdd->SetFillColor('orange');
|
255 |
jpm |
68 |
$BarPlotAdd->value->Show();
|
257 |
jpm |
69 |
$BarPlotAdd->value->SetFormat('%s');
|
255 |
jpm |
70 |
$BarPlotAdd->SetLegend ('Inscription');
|
|
|
71 |
|
|
|
72 |
$BarPlotDel = new BarPlot($tab_donnees_del);
|
257 |
jpm |
73 |
$BarPlotDel->SetFillColor('green');
|
255 |
jpm |
74 |
$BarPlotDel->value->Show();
|
257 |
jpm |
75 |
$BarPlotDel->value->SetFormat('%s');
|
255 |
jpm |
76 |
$BarPlotDel->SetLegend ('Désinscription');
|
|
|
77 |
|
|
|
78 |
// Nous assemblons les barres
|
|
|
79 |
//$ab1plot = new AccBarPlot (array($BarPlotAdd ,$BarPlotDel));
|
|
|
80 |
$gbplot = new GroupBarPlot(array($BarPlotAdd, $BarPlotDel));
|
|
|
81 |
|
|
|
82 |
$graph->Add($gbplot);
|
|
|
83 |
$graph->Stroke();
|
|
|
84 |
?>
|