0337d704 |
1 | <?php |
2 | /*************************************************************************** |
3 | * Copyright (C) 2003-2004 Polytechnique.org * |
4 | * http://opensource.polytechnique.org/ * |
5 | * * |
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. * |
10 | * * |
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. * |
15 | * * |
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 * |
18 | * Foundation, Inc., * |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
20 | ***************************************************************************/ |
21 | |
22 | require_once("xorg.inc.php"); |
23 | |
24 | new_skinned_page('index.tpl', AUTH_COOKIE); |
25 | $promo = Env::getInt('promo', Session::getInt('promo')); |
26 | |
27 | // date de départ |
28 | $depart = 1920; |
29 | |
30 | //recupere le nombre d'inscriptions par jour sur la plage concernée |
31 | $res = $globals->xdb->iterRow( |
32 | "SELECT promo, SUM(perms IN ('admin', 'user')) / COUNT(*) * 100 |
33 | FROM auth_user_md5 |
34 | WHERE promo >= $depart AND deces = 0 |
35 | GROUP BY promo"); |
36 | |
37 | //genere des donnees compatibles avec GNUPLOT |
38 | $inscrits=''; |
39 | |
40 | // la première ligne contient le total des inscrits avant la date de départ |
41 | list($annee, $nb) = $res->next(); |
42 | |
43 | for ($i=$depart;$i<=date("Y");$i++) { |
44 | if ($annee<$i) { |
45 | if(!list($annee, $nb) = $res->next()) { |
46 | $annee = 0; |
47 | $nb = 0; |
48 | } |
49 | } |
50 | if ($nb > 0 || $i < date("Y")) |
51 | $inscrits .= $i." ".$nb."\n"; |
52 | } |
53 | |
54 | //Genere le graphique à la volée avec GNUPLOT |
55 | header( "Content-type: image/png"); |
56 | |
57 | $ymin = 0; |
58 | $ymax = 100; |
59 | |
60 | $fin = $i+10; |
61 | |
62 | $gnuplot = <<<EOF2 |
63 | gnuplot <<EOF |
64 | |
65 | set term png small color |
66 | set size 640/480 |
67 | set timefmt "%d/%m/%y" |
68 | |
69 | set xr [$depart:$fin] |
70 | set yr [$ymin:$ymax] |
71 | |
72 | set title "Nombre d'inscrits par promotion depuis $depart." |
73 | |
74 | plot "-" using 1:2 title 'inscrits' with boxes; |
75 | {$inscrits} |
76 | EOF |
77 | EOF2; |
78 | |
79 | passthru($gnuplot); |
80 | ?> |