2 /***************************************************************************
3 * Copyright (C) 2003-2004 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 require_once("xorg.inc.php");
24 new_skinned_page('index.tpl', AUTH_COOKIE
);
26 //nombre de jours sur le graph
27 $JOURS=Env
::getInt('jours', 364);
28 define('DUREEJOUR',24*3600);
30 //recupere le nombre d'inscriptions par jour sur la plage concernée
31 $res = $globals->xdb
->iterRow(
32 "SELECT IF( date_ins>DATE_SUB(NOW(),INTERVAL $JOURS DAY),
33 TO_DAYS(date_ins)-TO_DAYS(NOW()),
34 ".(-($JOURS+
1)).") AS jour,
37 WHERE perms IN ('admin','user')
40 //genere des donnees compatibles avec GNUPLOT
43 // la première ligne contient le total des inscrits avant la date de départ (J - $JOURS)
44 list(,$init_nb) = $res->next();
47 list($numjour, $nb) = $res->next();
49 for ($i=-$JOURS;$i<=0;$i++
) {
51 if(!list($numjour, $nb) = $res->next()) {
56 if ($numjour==$i) $total+
=$nb;
57 $inscrits .= date('d/m/y',$i*DUREEJOUR+
time())." ".$total."\n";
60 //Genere le graphique à la volée avec GNUPLOT
61 header( "Content-type: image/png");
63 $delt = ($total - $init_nb)/10;
64 $ymin = round($init_nb - $delt,0);
65 $ymax = round($total +
$delt,0);
70 set term png small color
73 set timefmt
"%d/%m/%y"
78 set title
"Nombre d'inscrits"
80 plot
"-" using
1:2 title
'inscrits' with lines
;