254 |
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") ;
|
255 |
jpm |
7 |
|
254 |
jpm |
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 = array(0);
|
257 |
jpm |
19 |
if (isset($_GET['annee'])) {
|
|
|
20 |
$tps_debut = mktime(0,0,0,1,1, $_GET['annee']);
|
|
|
21 |
$tps_fin = mktime(23,59,59,12,31, $_GET['annee']);
|
|
|
22 |
$annee = $_GET['annee'];
|
|
|
23 |
} else {
|
|
|
24 |
$tps_debut = mktime(0,0,0,1,1);
|
|
|
25 |
$tps_fin = time();// jour courrant
|
|
|
26 |
$annee = date('Y', $tps_fin);
|
|
|
27 |
}
|
255 |
jpm |
28 |
$tps_courrant = $tps_debut;
|
|
|
29 |
$i = 1;
|
|
|
30 |
//Requete par mois
|
|
|
31 |
while ($tps_courrant <= $tps_fin) {
|
|
|
32 |
$tps_semaine_suivante = $tps_courrant + (7 * 24 * 60 * 60);
|
257 |
jpm |
33 |
$tps_mois_suivant = mktime(0,0,0,$i+1,1,$annee);
|
255 |
jpm |
34 |
//echo date('Y-m-d H:i:s', $tps_courrant).' - '.date('Y-m-d H:i:s', $tps_mois_suivant);
|
|
|
35 |
$requete = 'SELECT IS_ACTION '.
|
|
|
36 |
'FROM ins_STATS '.
|
|
|
37 |
'WHERE IS_DATE >= "'.date('Y-m-d H:i:s', $tps_courrant).'" '.
|
|
|
38 |
'AND IS_DATE < "'.date('Y-m-d H:i:s', $tps_mois_suivant).'" ';
|
|
|
39 |
$resultat = $db->query($requete) ;
|
|
|
40 |
$nbre = 0 ;
|
|
|
41 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
|
|
|
42 |
if ($ligne->IS_ACTION == 'add') $nbre++ ;
|
|
|
43 |
if ($ligne->IS_ACTION == 'del') $nbre-- ;
|
254 |
jpm |
44 |
}
|
255 |
jpm |
45 |
$tab_donnees[$i] = $nbre + $tab_donnees[$i-1];
|
|
|
46 |
//echo ' - '.$tab_donnees[$i-1].'<br/>';
|
|
|
47 |
$tps_courrant = $tps_mois_suivant;
|
|
|
48 |
$i++;
|
254 |
jpm |
49 |
}
|
255 |
jpm |
50 |
//echo '<pre>'.print_r($tab_donnees, true).'</pre>';
|
254 |
jpm |
51 |
|
257 |
jpm |
52 |
$graph = new Graph(500, 440, 'auto');
|
|
|
53 |
$graph->img->SetMargin(50, 50, 30, 50);
|
|
|
54 |
$graph->SetMarginColor('white');
|
255 |
jpm |
55 |
$graph->SetScale('textint');
|
|
|
56 |
$graph->xaxis->SetTickLabels($tab_mois);
|
254 |
jpm |
57 |
$graph->SetShadow();
|
257 |
jpm |
58 |
$graph->title->Set('Évolution des inscriptions au Réseau');
|
254 |
jpm |
59 |
$graph->title->SetFont(FF_FONT1,FS_BOLD);
|
257 |
jpm |
60 |
$graph->xaxis->title->Set("Mois depuis le 1er janvier $annee");
|
254 |
jpm |
61 |
|
255 |
jpm |
62 |
$LinePlot = new LinePlot($tab_donnees);
|
|
|
63 |
$LinePlot->value->Show();
|
257 |
jpm |
64 |
$LinePlot->value->SetFormat('%s');
|
|
|
65 |
$LinePlot->SetColor('brown') ;
|
254 |
jpm |
66 |
|
255 |
jpm |
67 |
$graph->Add($LinePlot);
|
254 |
jpm |
68 |
$graph->Stroke();
|
255 |
jpm |
69 |
?>
|