Subversion Repositories Sites.tela-botanica.org

Compare Revisions

Ignore whitespace Rev 253 → Rev 254

/trunk/sites/reseau/fr/images/graph_inscrit_annee.php
New file
0,0 → 1,61
<?php
 
include ("../../../../api/jpgraph_1.12.2/jpgraph.php") ;
include ("../../../../api/jpgraph_1.12.2/jpgraph_line.php") ;
include ("../../../../api/jpgraph_1.12.2/jpgraph_bar.php");
include ("../../../../papyrus/configuration/pap_config.inc.php") ;
include_once 'DB.php' ;
$month=array(
"Jan","Feb","Mar","Apr","Maj","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
 
$db = DB::connect (PAP_DSN) ;
 
if (DB::isError($db)) {
echo 'Message Standard : ' . $db->getMessage() . "\n";
echo 'Message DBMS/Utilisateur : ' . $db->getUserInfo() . "\n";
echo 'Message DBMS/D&eacute;boguage : ' . $db->getDebugInfo() . "\n";
exit;
}
 
$GraphData = array() ;
$currentDate = date('Y').'-01-01';// 1er janvier de l'année courrante
$date_fin = date('Y-m-d');// jour courrant
//Requete pour les autres semaines
while ($currentDate <= $date_fin) {
$query2 = "select IS_ACTION from ins_STATS where IS_DATE>=\"$currentDate\"
and IS_DATE < DATE_ADD(\"$currentDate\", INTERVAL 7 DAY)" ;
 
$result2 = $db->query($query2) ;
$NBR = 0 ;
while ($row2 = $result2->fetchRow(DB_FETCHMODE_OBJECT)) {
if ($row2->IS_ACTION=="add") $NBR++ ;
if ($row2->IS_ACTION=="del") $NBR-- ;
}
$GraphData[$i] = $NBR + $GraphData[$i-1];
$i++ ;
$query4 = "select DATE_ADD(\"$currentDate\", INTERVAL 7 DAY) as new_date" ;
$result4 = $db->query ($query4) ;
$row3 = $result4->fetchRow(DB_FETCHMODE_OBJECT);
$currentDate = $row3->new_date ;
}
 
$datay = array_values($GraphData) ;
 
$graph = new Graph(500,400,"auto");
$graph->img->SetMargin(30,30,30,40);
$graph->SetMarginColor("white");
$graph->SetScale("int");
$graph->SetShadow();
 
 
$graph->title->Set("Évolution du nombre d'inscrits au Réseau");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
 
$graph->xaxis->title->Set("Semaines depuis le 1er janvier ".date('Y'));
$p1 = new LinePlot($datay);
$p1->SetColor("brown") ;
 
$graph->Add($p1);
 
$graph->Stroke();
?>