Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 5.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 1999-2006 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This file is part of tela_botanica_v4. |
// | |
// | Foobar is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation; either version 2 of the License, or |
// | (at your option) any later version. |
// | |
// | Foobar is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with Foobar; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id$
/**
* tela_botanica_v4 - graph_niveau_bota.php
*
* Description :
*
*@package tela_botanica_v4
//Auteur original :
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 1999-2007
*@version $Revision$ $Date$
// +------------------------------------------------------------------------------------------------------+
*/
// +------------------------------------------------------------------------------------------------------+
// | ENTÊTE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
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' ;
// +------------------------------------------------------------------------------------------------------+
// | CORPS du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
$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éboguage : ' . $db->getDebugInfo() . "\n";
exit;
}
$tab_mois = array('Jan', 'Fev', 'Mar', 'Avr', 'Mai', 'Juin', 'Juil', 'Août', 'Sep', 'Oct', 'Nov', 'Dec');
$tab_legende_axe_x = array('');
$tab_legende = array();
$tab_donnees = array(0) ;
$annee_debut = 2002;
$mois = 4;
$annee = 2002;
$tps_debut = mktime(0,0,0,$mois,1,$annee);
$tps_courrant = $tps_debut;
$tps_fin = mktime(0, 0, 0, date('m'), 0);// dernier jour du mois précedent le mois courrant
//Requete par mois
$i = 0;
while ($tps_courrant <= $tps_fin) {
if (($mois)/12 > 1) {
$mois = 1;
$annee = $annee+1;
}
$tps_mois_suivant = mktime(0,0,0,$mois+1,1,$annee);
//echo date('Y-m-d H:i:s', $tps_courrant).' - '.date('Y-m-d H:i:s', $tps_mois_suivant);
$requete = 'SELECT ID_LABEL_NIV, COUNT( U_NIV ) AS nbre, LABEL_NIV '.
'FROM annuaire_tela, annuaire_LABEL_NIV '.
'WHERE U_DATE >= "'.date('Y-m-d H:i:s', $tps_courrant).'" '.
'AND U_NIV = ID_LABEL_NIV '.
'AND U_DATE < "'.date('Y-m-d H:i:s', $tps_mois_suivant).'" '.
'GROUP BY ID_LABEL_NIV ';
$resultat = $db->query($requete) ;
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
$tab_donnees[$ligne->ID_LABEL_NIV][$i] = $tab_donnees[$ligne->ID_LABEL_NIV][$i-1] + $ligne->nbre;
if (!isset($legende[$ligne->ID_LABEL_NIV])) {
$tab_legende[$ligne->ID_LABEL_NIV] = $ligne->LABEL_NIV;
}
}
//echo ' - '.$resultat->numRows().'<br/>';
$tab_legende_axe_x[$i] = $tab_mois[$mois-1].' '.$annee;
$tps_courrant = $tps_mois_suivant;
$mois++;
$i++;
}
//echo '<pre>'.print_r($tab_donnees, true).'</pre>';
$graph = new Graph(500, 490, 'auto');
$graph->img->SetMargin(50, 30, 50, 100);
$graph->SetMarginColor('white');
$graph->SetScale('textint');
$graph->xaxis->SetTickLabels($tab_legende_axe_x);
$graph->xaxis->SetLabelAngle(90);
$graph->xaxis->SetTextLabelInterval(4);
$graph->SetShadow();
$graph->title->Set("Évolution du niveau en botanique des inscrits au Réseau au ".date('d-m-Y', $tps_fin));
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->legend->SetLayout(LEGEND_VERT);
$graph->legend->Pos(0.15, 0.10, 'left', 'top');
$txt = new Text('Mois depuis le 1er avril 2002', 270, 460);
$graph->AddText($txt);
// Création des lignes
$p1 = new LinePlot($tab_donnees[1]); // Débutant
$p2 = new LinePlot($tab_donnees[2]); // Ayant une bonne pratique
$p3 = new LinePlot($tab_donnees[3]); // Confirmé
$p4 = new LinePlot($tab_donnees[4]); // Ne se prononce pas
// Attribution des couleurs
$p1->SetFillColor('red');
$p2->SetFillColor('blue');
$p3->SetFillColor('green');
$p4->SetFillColor('white');
// Attribution des textes pour la légende
$p1->SetLegend($tab_legende[1]);
$p2->SetLegend($tab_legende[2]);
$p3->SetLegend($tab_legende[3]);
$p4->SetLegend($tab_legende[4]);
// Nous ajoutons ensemble les lignes
$ap = new AccLinePlot(array($p4, $p3, $p2, $p1));
// Add the accumulated line plot to the graph
$graph->Add($ap);
$graph->Stroke();
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log$
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>