Subversion Repositories Sites.tela-botanica.org

Rev

Go to most recent revision | Details | 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") ;
7
include_once 'DB.php' ;
8
$month=array(
9
"Jan","Feb","Mar","Apr","Maj","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
10
 
11
$db = DB::connect (PAP_DSN) ;
12
 
13
if (DB::isError($db)) {
14
    echo 'Message Standard         : ' . $db->getMessage() . "\n";
15
    echo 'Message DBMS/Utilisateur : ' . $db->getUserInfo() . "\n";
16
    echo 'Message DBMS/D&eacute;boguage   : ' . $db->getDebugInfo() . "\n";
17
    exit;
18
}
19
 
20
$GraphData = array() ;
21
$currentDate = date('Y').'-01-01';// 1er janvier de l'année courrante
22
$date_fin = date('Y-m-d');// jour courrant
23
//Requete pour les autres semaines
24
while  ($currentDate <= $date_fin) {
25
	$query2 = "select IS_ACTION from ins_STATS where IS_DATE>=\"$currentDate\"
26
					and IS_DATE < DATE_ADD(\"$currentDate\", INTERVAL 7 DAY)" ;
27
 
28
	$result2 = $db->query($query2) ;
29
	$NBR = 0 ;
30
	while ($row2 = $result2->fetchRow(DB_FETCHMODE_OBJECT)) {
31
		if ($row2->IS_ACTION=="add") $NBR++ ;
32
		if ($row2->IS_ACTION=="del") $NBR-- ;
33
	}
34
	$GraphData[$i] = $NBR + $GraphData[$i-1];
35
	$i++ ;
36
    $query4 = "select DATE_ADD(\"$currentDate\", INTERVAL 7 DAY) as new_date" ;
37
    $result4 = $db->query ($query4) ;
38
	$row3 = $result4->fetchRow(DB_FETCHMODE_OBJECT);
39
	$currentDate = $row3->new_date ;
40
}
41
 
42
$datay = array_values($GraphData) ;
43
 
44
$graph = new Graph(500,400,"auto");
45
$graph->img->SetMargin(30,30,30,40);
46
$graph->SetMarginColor("white");
47
$graph->SetScale("int");
48
$graph->SetShadow();
49
 
50
 
51
$graph->title->Set("Évolution du nombre d'inscrits au Réseau");
52
$graph->title->SetFont(FF_FONT1,FS_BOLD);
53
 
54
$graph->xaxis->title->Set("Semaines depuis le 1er janvier ".date('Y'));
55
$p1 = new LinePlot($datay);
56
$p1->SetColor("brown") ;
57
 
58
$graph->Add($p1);
59
 
60
$graph->Stroke();
61
?>