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 |
|
|
|
17 |
$tab_mois = array("Jan","Fev","Mar","Avr","Mai","Juin","Juil","Août","Sep","Oct","Nov","Dec");
|
|
|
18 |
$tab_donnees_add = array() ;
|
|
|
19 |
$tab_donnees_del = array() ;
|
|
|
20 |
$tps_debut = mktime(0,0,0,1,1);
|
|
|
21 |
$tps_courrant = $tps_debut;
|
|
|
22 |
$tps_fin = time();// jour courrant
|
|
|
23 |
$i = 0;
|
|
|
24 |
//Requete par mois
|
|
|
25 |
while ($tps_courrant <= $tps_fin) {
|
|
|
26 |
$tps_semaine_suivante = $tps_courrant + (7 * 24 * 60 * 60);
|
|
|
27 |
$tps_mois_suivant = mktime(0,0,0,$i+2,1);
|
|
|
28 |
//echo date('Y-m-d H:i:s', $tps_courrant).' - '.date('Y-m-d H:i:s', $tps_mois_suivant);
|
|
|
29 |
$requete = 'SELECT IS_ACTION '.
|
|
|
30 |
'FROM ins_STATS '.
|
|
|
31 |
'WHERE IS_DATE >= "'.date('Y-m-d H:i:s', $tps_courrant).'" '.
|
|
|
32 |
'AND IS_DATE < "'.date('Y-m-d H:i:s', $tps_mois_suivant).'" ';
|
|
|
33 |
$resultat = $db->query($requete) ;
|
|
|
34 |
$tab_donnees_add[$i] = 0 ;
|
|
|
35 |
$tab_donnees_del[$i] = 0 ;
|
|
|
36 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
|
|
|
37 |
if ($ligne->IS_ACTION == 'add') $tab_donnees_add[$i]++ ;
|
|
|
38 |
if ($ligne->IS_ACTION == 'del') $tab_donnees_del[$i]++ ;
|
|
|
39 |
}
|
|
|
40 |
//echo ' - '.$tab_donnees[$i-1].'<br/>';
|
|
|
41 |
$tps_courrant = $tps_mois_suivant;
|
|
|
42 |
$i++;
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
// Création du graphique
|
|
|
46 |
$graph = new Graph(500,400,"auto");
|
|
|
47 |
$graph->img->SetMargin(30,30,30,40);
|
|
|
48 |
$graph->SetMarginColor("white");
|
|
|
49 |
$graph->SetScale('textint');
|
|
|
50 |
$graph->xaxis->SetTickLabels($tab_mois);
|
|
|
51 |
$graph->SetShadow();
|
|
|
52 |
$graph->title->Set("Évolution des inscriptions au Réseau");
|
|
|
53 |
$graph->title->SetFont(FF_FONT1,FS_BOLD);
|
|
|
54 |
$graph->xaxis->title->Set("Mois depuis le 1er janvier ".date('Y'));
|
|
|
55 |
$graph->legend->SetLayout(LEGEND_HOR);
|
|
|
56 |
$graph->legend->Pos(0.5, 0.05, 'left', 'top');
|
|
|
57 |
|
|
|
58 |
// Création des barres
|
|
|
59 |
$BarPlotAdd = new BarPlot($tab_donnees_add);
|
|
|
60 |
$BarPlotAdd->SetFillColor("orange");
|
|
|
61 |
$BarPlotAdd->value->Show();
|
|
|
62 |
$BarPlotAdd->value->SetFormat("%s");
|
|
|
63 |
$BarPlotAdd->SetLegend ('Inscription');
|
|
|
64 |
|
|
|
65 |
$BarPlotDel = new BarPlot($tab_donnees_del);
|
|
|
66 |
$BarPlotDel->SetFillColor("green");
|
|
|
67 |
$BarPlotDel->value->Show();
|
|
|
68 |
$BarPlotDel->value->SetFormat("%s");
|
|
|
69 |
$BarPlotDel->SetLegend ('Désinscription');
|
|
|
70 |
|
|
|
71 |
// Nous assemblons les barres
|
|
|
72 |
//$ab1plot = new AccBarPlot (array($BarPlotAdd ,$BarPlotDel));
|
|
|
73 |
$gbplot = new GroupBarPlot(array($BarPlotAdd, $BarPlotDel));
|
|
|
74 |
|
|
|
75 |
$graph->Add($gbplot);
|
|
|
76 |
$graph->Stroke();
|
|
|
77 |
?>
|