From: Pierre Habouzit (MadCoder Date: Mon, 10 Jan 2005 11:35:56 +0000 (+0000) Subject: ins_convifmees -> last_week, and refactor relance a little X-Git-Tag: xorg/old~492 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=8e6330cafc1f4c8c1ea0c223fc796c959b8de4aa;p=platal.git ins_convifmees -> last_week, and refactor relance a little git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-259 --- diff --git a/htdocs/marketing/index.php b/htdocs/marketing/index.php index c5701fb..6f94a09 100644 --- a/htdocs/marketing/index.php +++ b/htdocs/marketing/index.php @@ -41,14 +41,17 @@ $res = $globals->xdb->query( $stats = $res->fetchOneAssoc(); $page->assign('stats', $stats); -$res = $globals->xdb->query("SELECT count(*) FROM auth_user_md5 WHERE date_ins > ".date("Ymd", strtotime ("last Monday"))."*1000000"); +$res = $globals->xdb->query("SELECT count(*) FROM auth_user_md5 WHERE date_ins > ".date('Ymd000000', strtotime('1 week ago'))); $page->assign('nbInsSem', $res->fetchOneCell()); -$res = $globals->xdb->query("SELECT count(*) FROM en_cours WHERE loginbis != 'INSCRIT'"); +$res = $globals->xdb->query("SELECT count(*) FROM register_pending WHERE hash != 'INSCRIT'"); $page->assign('nbInsEnCours', $res->fetchOneCell()); -$res = $globals->xdb->query("SELECT count(*) FROM envoidirect as e left join auth_user_md5 as a ON e.matricule = a.matricule WHERE a.nom is null"); -$page->assign('nbInsEnvDir', $res->fetchOneCell()); +$res = $globals->xdb->query("SELECT count(*) FROM register_marketing"); +$page->assign('nbInsMarket', $res->fetchOneCell()); + +$res = $globals->xdb->query("SELECT count(*) FROM register_mstats WHERE TO_DAYS(NOW()) - TO_DAYS(success) <= 7"); +$page->assign('nbInsMarkOK', $res->fetchOneCell()); $page->run(); ?> diff --git a/htdocs/marketing/relance.php b/htdocs/marketing/relance.php index 6880bf2..c6345ed 100644 --- a/htdocs/marketing/relance.php +++ b/htdocs/marketing/relance.php @@ -22,55 +22,49 @@ require_once("xorg.inc.php"); new_admin_page('marketing/relance.tpl'); - /* une relance a été demandée - on envoit les mails correspondants */ -if (isset($_POST["relancer"]) && isset($_POST["relancer"]) != "") { +if (Post::has('relancer')) { require_once("xorg.mailer.inc.php"); - - $res = $globals->xdb->query("SELECT COUNT(*) FROM auth_user_md5"); + $res = $globals->xdb->query("SELECT COUNT(*) FROM auth_user_md5 WHERE deces=0"); $nbdix = $res->fetchOneCell(); $res = $globals->xdb->iterRow( - "SELECT e.date,e.promo,e.nom,e.prenom,e.matricule,e.email,e.username - FROM en_cours AS e - INNER JOIN auth_user_md5 AS a ON (e.matricule=a.matricule AND a.perms = 'pending')"); + "SELECT r.date, u.promo, u.nom, u.prenom, r.user_id, r.email, r.bestalias + FROM register_pending AS r + INNER JOIN auth_user_md5 AS u ON u.user_id = e.uid"); $sent = Array(); - while (list($ldate, $lpromo, $lnom, $lprenom, $lmatricule, $lemail, $lusername) = $res->next()) { - if (Post::get($lmatricule) == "1") { - $lins_id = rand_url_id(12); - $nveau_pass = rand_pass(); - $lpass = md5($nveau_pass); - $fdate = substr($ldate, 8, 2)."/".substr($ldate, 5, 2)."/".substr($ldate, 0, 4); + while (list($ldate, $lpromo, $lnom, $lprenom, $uid, $lemail, $lusername) = $res->next()) { + if (Post::get($uid) == "1") { + $hash = rand_url_id(12); + $pass = rand_pass(); + $pass_md5 = md5($nveau_pass); + $fdate = substr($ldate, 8, 2)."/".substr($ldate, 5, 2)."/".substr($ldate, 0, 4); $mymail = new XOrgMailer('marketing.relance.tpl'); - $mymail->assign('nbdix',$nbdix); - $mymail->assign('fdate',$fdate); - $mymail->assign('lusername',$lusername); - $mymail->assign('nveau_pass',$nveau_pass); - $mymail->assign('baseurl',$globals->baseurl); - $mymail->assign('lins_id',$lins_id); - - $mymail->assign('lemail',$lemail); - $mymail->assign('subj',$lusername."@polytechnique.org"); - - $globals->xdb->execute("UPDATE en_cours SET ins_id={?}, password={?}, relance=NOW(), WHERE matricule = {?}", $lins_id, $lpass, $lmatricule); - // envoi du mail à l'utilisateur + $mymail->assign('nbdix', $nbdix); + $mymail->assign('fdate', $fdate); + $mymail->assign('lusername', $lusername); + $mymail->assign('nveau_pass', $pass); + $mymail->assign('baseurl', $globals->baseurl); + $mymail->assign('lins_id', $hash); + $mymail->assign('lemail', $lemail); + $mymail->assign('subj', $lusername."@polytechnique.org"); + $globals->xdb->execute("UPDATE register_pending SET hash={?}, password={?}, relance=NOW() WHERE uid={?}", + $lins_id, $lpass, $uid); $mymail->send(); $sent[] = "$lprenom $lnom ($lpromo) a été relancé !"; } } $page->assign_by_ref('sent', $sent); - -/* pas d'action particulière => on affiche la liste des relançables... */ } -$sql = "SELECT e.date,e.relance,e.promo,e.nom,e.prenom,e.matricule - FROM en_cours AS e - INNER JOIN auth_user_md5 AS a ON (e.matricule=a.matricule AND a.perms = 'pending') +$sql = "SELECT r.date, r.relance, r.uid, u.promo, u.nom, u.prenom + FROM register_pending AS r + INNER JOIN auth_user_md5 AS u ON r. uid = u.user_id ORDER BY date DESC"; $page->assign('relance', $globals->xdb->iterator($sql)); diff --git a/htdocs/marketing/ins_confirmees.php b/htdocs/marketing/this_week.php similarity index 78% rename from htdocs/marketing/ins_confirmees.php rename to htdocs/marketing/this_week.php index b05ed57..88d199f 100644 --- a/htdocs/marketing/ins_confirmees.php +++ b/htdocs/marketing/this_week.php @@ -20,15 +20,15 @@ ***************************************************************************/ require_once("xorg.inc.php"); -new_admin_page('marketing/ins_confirmees.tpl'); +new_admin_page('marketing/this_week.tpl'); -if (!isset($_GET["sort"]) || $_GET["sort"] != "promo") $_GET["sort"] = "date_ins"; +$sort = Get::get('sort') == 'promo' ? 'promo' : 'date_ins'; -$sql = "SELECT a.alias AS forlife,u.date_ins,u.promo,u.nom,u.prenom - FROM auth_user_md5 AS u - INNER JOIN aliases AS a ON (u.user_id = a.id AND a.type='a_vie') - WHERE u.date_ins > ".date("Ymd", strtotime ("last Monday"))."*1000000 - ORDER BY u.{$_GET['sort']} DESC"; +$sql = "SELECT a.alias AS forlife, u.date_ins, u.promo, u.nom, u.prenom + FROM auth_user_md5 AS u + INNER JOIN aliases AS a ON (u.user_id = a.id AND a.type='a_vie') + WHERE u.date_ins > ".date("Ymd000000", strtotime ('1 week ago'))." + ORDER BY u.$sort DESC"; $page->assign('ins', $globals->xdb->iterator($sql)); $page->run(); diff --git a/templates/marketing/index.tpl b/templates/marketing/index.tpl index c2c1a91..e4cd7a3 100644 --- a/templates/marketing/index.tpl +++ b/templates/marketing/index.tpl @@ -38,14 +38,6 @@ - Relances : - Inscriptions confirmées -   |   - Relance des ½-inscrits - - - - Emails : Utiliser les adresses données par les inscrits @@ -74,9 +66,10 @@ Soit un pourcentage d'inscrites de : {$stats.inse_rate} %

-Nombre d'inscrits depuis le début de la semaine : {$nbInsSem}
-Nombre d'inscriptions en cours (2ème phase non terminée) : {$nbInsEnCours}
-Nombre d'envois marketing effectués n'ayant pas abouti : {$nbInsEnvDir} +Nombre d'inscrits depuis le début de la semaine : {$nbInsSem}
+Nombre d'inscriptions en cours (2ème phase non terminée) : {$nbInsEnCours}
+Nombre d'envois marketing effectués n'ayant pas abouti : {$nbInsMarket}
+Nombre d'envois marketing ayant abouti cette semaine : {$nbInsMarkOK}

{* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/marketing/relance.tpl b/templates/marketing/relance.tpl index 80a001e..338e239 100644 --- a/templates/marketing/relance.tpl +++ b/templates/marketing/relance.tpl @@ -19,9 +19,7 @@ ***************************************************************************} -

- Relance -

+

Relance

{foreach from=$sent item=l}

{$l}

@@ -45,7 +43,7 @@ {if $it.relance eq "0000-00-00"}Jamais{else}{$it.relance}{/if} - + {/iterate} diff --git a/templates/marketing/ins_confirmees.tpl b/templates/marketing/this_week.tpl similarity index 87% rename from templates/marketing/ins_confirmees.tpl rename to templates/marketing/this_week.tpl index 0699845..29cc957 100644 --- a/templates/marketing/ins_confirmees.tpl +++ b/templates/marketing/this_week.tpl @@ -19,8 +19,18 @@ ***************************************************************************} +

Inscrits des 7 derniers jours

- +

+{$ins->total()} Polytechniciens se sont inscrits ces 7 derniers jours ! +

+ +
+ [par date] + [par promo] +
+ +
@@ -40,14 +50,10 @@ {/iterate}
Inscription Promo
-
[par date] [par promo]
-

-{$ins->total()} Polytechniciens se sont inscrits depuis le début de la semaine ! -

{* vim:set et sw=2 sts=2 sws=2: *}