ins_convifmees -> last_week, and refactor relance a little
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Mon, 10 Jan 2005 11:35:56 +0000 (11:35 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:27:21 +0000 (23:27 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-259

htdocs/marketing/index.php
htdocs/marketing/relance.php
htdocs/marketing/this_week.php [moved from htdocs/marketing/ins_confirmees.php with 78% similarity]
templates/marketing/index.tpl
templates/marketing/relance.tpl
templates/marketing/this_week.tpl [moved from templates/marketing/ins_confirmees.tpl with 87% similarity]

index c5701fb..6f94a09 100644 (file)
@@ -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();
 ?>
index 6880bf2..c6345ed 100644 (file)
 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));
 
similarity index 78%
rename from htdocs/marketing/ins_confirmees.php
rename to htdocs/marketing/this_week.php
index b05ed57..88d199f 100644 (file)
  ***************************************************************************/
 
 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();
index c2c1a91..e4cd7a3 100644 (file)
   </tr>
   <tr class="pair">
     <td>
-      <span class="item">Relances : </span>
-      <a href="ins_confirmees.php">Inscriptions confirmées</a>
-      &nbsp;&nbsp;|&nbsp;&nbsp;
-      <a href="relance.php">Relance des ½-inscrits</a>
-    </td>
-  </tr>
-  <tr class="impair">
-    <td>
       <span class="item">Emails : </span>
       <a href="volontaire.php">Utiliser les adresses données par les inscrits</a>
     </td>
@@ -74,9 +66,10 @@ Soit un pourcentage d'inscrites de : {$stats.inse_rate} % <br />
 </p>
 
 <p>
-Nombre d'inscrits depuis le début de la semaine : {$nbInsSem} <br />
-Nombre d'inscriptions en cours (2ème phase non terminée) : {$nbInsEnCours} <br />
-Nombre d'envois marketing effectués n'ayant pas abouti : {$nbInsEnvDir}
+Nombre d'<a href="this_week.php">inscrits depuis le début de la semaine</a> : {$nbInsSem}<br />
+Nombre d'<a href="relance.php">inscriptions en cours</a> (2ème phase non terminée) : {$nbInsEnCours} <br />
+Nombre d'envois marketing effectués n'ayant pas abouti : {$nbInsMarket}<br />
+Nombre d'envois marketing ayant abouti cette semaine : {$nbInsMarkOK}
 </p>
 
 {* vim:set et sw=2 sts=2 sws=2: *}
index 80a001e..338e239 100644 (file)
@@ -19,9 +19,7 @@
  ***************************************************************************}
 
 
-<h1>
-  Relance
-</h1>
+<h1>Relance</h1>
 
 {foreach from=$sent item=l}
 <p>{$l}</p>
@@ -45,7 +43,7 @@
         {if $it.relance eq "0000-00-00"}Jamais{else}{$it.relance}{/if}
       </td>
       <td class="center">
-        <input type="checkbox" name="{$it.matricule}" value="1" />
+        <input type="checkbox" name="{$it.uid}" value="1" />
       </td>
     </tr>
     {/iterate}
similarity index 87%
rename from templates/marketing/ins_confirmees.tpl
rename to templates/marketing/this_week.tpl
index 0699845..29cc957 100644 (file)
  ***************************************************************************}
 
 
+<h1>Inscrits des 7 derniers jours</h1>
 
-<table class="bicol" summary="liste des nouveaux inscrits">
+<p>
+{$ins->total()} Polytechniciens se sont inscrits ces 7 derniers jours !
+</p>
+
+<div class="right">
+  [<a href="{$smarty.server.PHP_SELF}?sort=date_ins">par date</a>]
+  [<a href="{$smarty.server.PHP_SELF}?sort=promo">par promo</a>]
+</div>
+
+<table class="tinybicol">
   <tr>
     <th>Inscription</th>
     <th>Promo</th>
 {/iterate}
 </table>
 
-<br />
 <div class="right">
   [<a href="{$smarty.server.PHP_SELF}?sort=date_ins">par date</a>]
   [<a href="{$smarty.server.PHP_SELF}?sort=promo">par promo</a>]
 </div>
-<p>
-{$ins->total()} Polytechniciens se sont inscrits depuis le début de la semaine !
-</p>
 
 
 {* vim:set et sw=2 sts=2 sws=2: *}