Subversion Repositories Sites.tela-botanica.org

Rev

Blame | Last modification | View Log | RSS feed

<?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() ;
$requete = "select min(IS_DATE) as min,max(IS_DATE) as max from ins_STATS" ;
$resultat = $db->query($requete) ;
if (DB::isError ($resultat)) {
    die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
}
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
$date_fin = $ligne->max ;
$currentDate = $ligne->min ;
$i = 0 ;

// requête pour les trois premières semaines
$query2 = "select IS_ACTION from ins_STATS where IS_DATE>=\"$currentDate\"
                                                and IS_DATE < DATE_ADD(\"$currentDate\", INTERVAL 21 DAY)" ;

$result2 = $db->query($query2) ;
if (DB::isError ($result2)) {
    die ("Echec de la requete : $query2<br />".$result2->getMessage()) ;
}
$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++ ;
$query3 = "select DATE_ADD(\"$currentDate\", INTERVAL 21 DAY) as new_date" ;
$result3 = $db->query ($query3) ;
$row3 = $result3->fetchRow(DB_FETCHMODE_OBJECT) ;
$currentDate = $row3->new_date ;


    //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("Evolution du nombre d'inscrits au Réseau"); 
$graph->title->SetFont(FF_FONT1,FS_BOLD); 

$graph->xaxis->title->Set("Semaines depuis le 1er avril 2002");
$p1 = new LinePlot($datay); 
$p1->SetColor("brown") ;

$graph->Add($p1); 

$graph->Stroke(); 
?>