Subversion Repositories Sites.tela-botanica.org

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 david 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
 
15
    echo 'Message Standard         : ' . $db->getMessage() . "\n";
16
    echo 'Message DBMS/Utilisateur : ' . $db->getUserInfo() . "\n";
17
    echo 'Message DBMS/D&eacute;boguage   : ' . $db->getDebugInfo() . "\n";
18
    exit;
19
}
20
 
21
$GraphData = array() ;
22
$requete = "select min(IS_DATE) as min,max(IS_DATE) as max from ins_STATS" ;
23
$resultat = $db->query($requete) ;
24
if (DB::isError ($resultat)) {
25
    die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
26
}
27
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
28
$date_fin = $ligne->max ;
29
$currentDate = $ligne->min ;
30
$i = 0 ;
31
 
32
// requête pour les trois premières semaines
33
$query2 = "select IS_ACTION from ins_STATS where IS_DATE>=\"$currentDate\"
34
						and IS_DATE < DATE_ADD(\"$currentDate\", INTERVAL 21 DAY)" ;
35
 
36
$result2 = $db->query($query2) ;
37
if (DB::isError ($result2)) {
38
    die ("Echec de la requete : $query2<br />".$result2->getMessage()) ;
39
}
40
$NBR = 0 ;
41
while ($row2 = $result2->fetchRow(DB_FETCHMODE_OBJECT)) {
42
	if ($row2->IS_ACTION=="add") $NBR++ ;
43
	if ($row2->IS_ACTION=="del") $NBR-- ;
44
}
45
$GraphData[$i] = $NBR + $GraphData[$i-1];
46
$i++ ;
47
$query3 = "select DATE_ADD(\"$currentDate\", INTERVAL 21 DAY) as new_date" ;
48
$result3 = $db->query ($query3) ;
49
$row3 = $result3->fetchRow(DB_FETCHMODE_OBJECT) ;
50
$currentDate = $row3->new_date ;
51
 
52
 
53
    //Requete pour les autres semaines
54
while  ($currentDate <= $date_fin) {
55
	$query2 = "select IS_ACTION from ins_STATS where IS_DATE>=\"$currentDate\"
56
					and IS_DATE < DATE_ADD(\"$currentDate\", INTERVAL 7 DAY)" ;
57
 
58
	$result2 = $db->query($query2) ;
59
	$NBR = 0 ;
60
	while ($row2 = $result2->fetchRow(DB_FETCHMODE_OBJECT)) {
61
		if ($row2->IS_ACTION=="add") $NBR++ ;
62
		if ($row2->IS_ACTION=="del") $NBR-- ;
63
	}
64
	$GraphData[$i] = $NBR + $GraphData[$i-1];
65
	$i++ ;
66
    $query4 = "select DATE_ADD(\"$currentDate\", INTERVAL 7 DAY) as new_date" ;
67
    $result4 = $db->query ($query4) ;
68
	$row3 = $result4->fetchRow(DB_FETCHMODE_OBJECT);
69
	$currentDate = $row3->new_date ;
70
}
71
 
72
$datay = array_values($GraphData) ;
73
 
74
$graph = new Graph(500,400,"auto");
75
$graph->img->SetMargin(30,30,30,40);
76
$graph->SetMarginColor("white");
77
$graph->SetScale("int");
78
$graph->SetShadow();
79
 
80
 
81
$graph->title->Set("Evolution du nombre d'inscrits au Réseau");
82
$graph->title->SetFont(FF_FONT1,FS_BOLD);
83
 
84
$graph->xaxis->title->Set("Semaines depuis le 1er avril 2002");
85
$p1 = new LinePlot($datay);
86
$p1->SetColor("brown") ;
87
 
88
$graph->Add($p1);
89
 
90
$graph->Stroke();
91
?>