Proof of concept:
[platal.git] / htdocs / marketing / index.php
1 <?php
2 /***************************************************************************
3 * Copyright (C) 2003-2006 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 new_admin_page('marketing/index.tpl');
24 $page->assign('xorg_title','Polytechnique.org - Marketing');
25
26 # Quelques statistiques
27
28 $res = $globals->xdb->query(
29 "SELECT COUNT(*) AS vivants,
30 COUNT(NULLIF(perms='admin' OR perms='user', 0)) AS inscrits,
31 100*COUNT(NULLIF(perms='admin' OR perms='user', 0))/COUNT(*) AS ins_rate,
32 COUNT(NULLIF(promo >= 1972, 0)) AS vivants72,
33 COUNT(NULLIF(promo >= 1972 AND (perms='admin' OR perms='user'), 0)) AS inscrits72,
34 100 * COUNT(NULLIF(promo >= 1972 AND (perms='admin' OR perms='user'), 0)) /
35 COUNT(NULLIF(promo >= 1972, 0)) AS ins72_rate,
36 COUNT(NULLIF(FIND_IN_SET('femme', flags), 0)) AS vivantes,
37 COUNT(NULLIF(FIND_IN_SET('femme', flags) AND (perms='admin' OR perms='user'), 0)) AS inscrites,
38 100 * COUNT(NULLIF(FIND_IN_SET('femme', flags) AND (perms='admin' OR perms='user'), 0)) /
39 COUNT(NULLIF(FIND_IN_SET('femme', flags), 0)) AS inse_rate
40 FROM auth_user_md5
41 WHERE deces = 0");
42 $stats = $res->fetchOneAssoc();
43 $page->assign('stats', $stats);
44
45 $res = $globals->xdb->query("SELECT count(*) FROM auth_user_md5 WHERE date_ins > ".date('Ymd000000', strtotime('1 week ago')));
46 $page->assign('nbInsSem', $res->fetchOneCell());
47
48 $res = $globals->xdb->query("SELECT count(*) FROM register_pending WHERE hash != 'INSCRIT'");
49 $page->assign('nbInsEnCours', $res->fetchOneCell());
50
51 $res = $globals->xdb->query("SELECT count(*) FROM register_marketing");
52 $page->assign('nbInsMarket', $res->fetchOneCell());
53
54 $res = $globals->xdb->query("SELECT count(*) FROM register_mstats WHERE TO_DAYS(NOW()) - TO_DAYS(success) <= 7");
55 $page->assign('nbInsMarkOK', $res->fetchOneCell());
56
57 $page->run();
58 ?>