Subversion Repositories Sites.tela-botanica.org

Rev

Rev 254 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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&eacute;boguage   : ' . $db->getDebugInfo() . "\n";
14
    exit;
15
}
16
 
255 jpm 17
$tab_mois = array('', "Jan","Fev","Mar","Avr","Mai","Juin","Juil","Août","Sep","Oct","Nov","Dec");
18
$tab_donnees = array(0);
19
$tps_debut = mktime(0,0,0,1,1);
20
$tps_courrant = $tps_debut;
21
$tps_fin = time();// jour courrant
22
$i = 1;
23
//Requete par mois
24
while  ($tps_courrant <= $tps_fin) {
25
	$tps_semaine_suivante = $tps_courrant + (7 * 24 * 60 * 60);
26
	$tps_mois_suivant = mktime(0,0,0,$i+1,1);
27
	//echo date('Y-m-d H:i:s', $tps_courrant).' - '.date('Y-m-d H:i:s', $tps_mois_suivant);
28
	$requete = 	'SELECT IS_ACTION '.
29
				'FROM ins_STATS '.
30
				'WHERE IS_DATE >= "'.date('Y-m-d H:i:s', $tps_courrant).'" '.
31
				'AND IS_DATE < "'.date('Y-m-d H:i:s', $tps_mois_suivant).'" ';
32
	$resultat = $db->query($requete) ;
33
	$nbre = 0 ;
34
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
35
		if ($ligne->IS_ACTION == 'add') $nbre++ ;
36
		if ($ligne->IS_ACTION == 'del') $nbre-- ;
254 jpm 37
	}
255 jpm 38
	$tab_donnees[$i] = $nbre + $tab_donnees[$i-1];
39
	//echo ' - '.$tab_donnees[$i-1].'<br/>';
40
	$tps_courrant = $tps_mois_suivant;
41
	$i++;
254 jpm 42
}
255 jpm 43
//echo '<pre>'.print_r($tab_donnees, true).'</pre>';
254 jpm 44
 
255 jpm 45
$graph = new Graph(500,440,"auto");
46
$graph->img->SetMargin(50,50,30,50);
254 jpm 47
$graph->SetMarginColor("white");
255 jpm 48
$graph->SetScale('textint');
49
$graph->xaxis->SetTickLabels($tab_mois);
254 jpm 50
$graph->SetShadow();
255 jpm 51
$graph->title->Set("Évolution des inscriptions au Réseau");
254 jpm 52
$graph->title->SetFont(FF_FONT1,FS_BOLD);
255 jpm 53
$graph->xaxis->title->Set("Mois depuis le 1er janvier ".date('Y'));
254 jpm 54
 
255 jpm 55
$LinePlot = new LinePlot($tab_donnees);
56
$LinePlot->value->Show();
57
$LinePlot->value->SetFormat("%s");
58
$LinePlot->SetColor("brown") ;
254 jpm 59
 
255 jpm 60
$graph->Add($LinePlot);
254 jpm 61
$graph->Stroke();
255 jpm 62
?>