further work on marketing
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Mon, 10 Jan 2005 14:19:20 +0000 (14:19 +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-260

htdocs/marketing/promo.php
htdocs/marketing/recap.php [moved from htdocs/marketing/envoidirect.php with 65% similarity]
htdocs/marketing/search.php [moved from htdocs/marketing/utilisateurs_marketing.php with 98% similarity]
templates/marketing/index.tpl
templates/marketing/promo.tpl
templates/marketing/recap.tpl [moved from templates/marketing/envoidirect.tpl with 80% similarity]
templates/marketing/search.tpl [moved from templates/marketing/utilisateurs_form.tpl with 98% similarity]
upgrade/0.9.4/20_register.sql

index 1019543..9c50cc1 100644 (file)
@@ -25,18 +25,15 @@ new_admin_page('marketing/promo.tpl');
 
 $promo = (integer) (isset($_REQUEST["promo"]) ? $_REQUEST["promo"] : $_SESSION["promo"]);
 $page->assign('promo', $promo);
-$page->assign('promob10', $promo-10);
-$page->assign('promob1', $promo-1);
-$page->assign('promoa1', $promo+1);
-$page->assign('promoa10', $promo+10);
 
-$sql = "SELECT  u.nom, u.prenom, last_known_email, u.matricule, u.matricule_ax, MAX(e.date_envoi) AS dern_rel, c.email
-          FROM  auth_user_md5  AS u
-     LEFT JOIN  envoidirect    AS e ON (u.matricule = e.matricule)
-     LEFT JOIN  en_cours       AS c ON (u.matricule = c.matricule)
+$sql = "SELECT  u.user_id, u.nom, u.prenom, u.last_known_email, u.matricule_ax,
+                IF(MAX(m.last)>p.relance, MAX(m.last), p.relance) AS dern_rel, p.email
+          FROM  auth_user_md5      AS u
+     LEFT JOIN  register_pending   AS p ON p.uid = u.user_id
+     LEFT JOIN  register_marketing AS m ON m.uid = u.user_id
          WHERE  u.promo = {?} AND u.deces = 0 AND u.perms='pending'
-      GROUP BY  u.matricule
-      ORDER BY  nom,prenom";
+      GROUP BY  u.user_id
+      ORDER BY  nom, prenom";
 $page->assign('nonins', $globals->xdb->iterator($sql, $promo));
 
 $page->run();
similarity index 65%
rename from htdocs/marketing/envoidirect.php
rename to htdocs/marketing/recap.php
index 112b88e..4ece501 100644 (file)
  ***************************************************************************/
 
 require_once("xorg.inc.php");
-new_admin_page('marketing/envoidirect.tpl');
-
-// effacement des inscrits il y a plus de 8 jours
-$globals->xdb->execute("DELETE FROM envoidirect WHERE DATE_ADD(date_succes, INTERVAL 8 DAY) < CURRENT_DATE AND date_succes <> '0000-00-00'");
-
-$sql = "SELECT  e.date_succes,e.date_envoi,a.promo,a.nom,a.prenom,e.email,b.nom as sender
-          FROM  envoidirect   AS e
-    INNER JOIN  auth_user_md5 AS a ON e.matricule = a.matricule
-    INNER JOIN  auth_user_md5 AS b ON e.sender    = b.user_id
-         WHERE  a.date_ins != 0
-      ORDER BY  e.date_envoi DESC";
+new_admin_page('marketing/recap.tpl');
 
+$sql = "SELECT  s.success, u.promo, u.nom, u.prenom, a.alias as forlife, b.nom as sender
+          FROM  register_mstats AS s
+    INNER JOIN  auth_user_md5   AS u ON s.uid    = u.user_id
+    INNER JOIN  aliases         AS a ON (s.uid   = a.id AND a.type='a_vie')
+    INNER JOIN  auth_user_md5   AS b ON s.sender = b.user_id
+         WHERE  s.success > ".date('Ymd000000', strtotime('1 month ago'))."
+      ORDER BY  s.success DESC";
 $page->assign('recents', $globals->xdb->iterator($sql));
 
-$sql = "SELECT  DISTINCT e.date_envoi, a.promo, a.nom, a.prenom, e.email, b.nom as sender
-          FROM  envoidirect   AS e
-    INNER JOIN  auth_user_md5 AS a ON e.matricule = a.matricule
-    INNER JOIN  auth_user_md5 AS b ON e.sender    = b.user_id
-         WHERE  a.date_ins = 0
-      ORDER BY  e.date_envoi DESC";
+$sql = "SELECT  m.uid, MAX(m.last) AS last, COUNT(m.email) AS nb, u.promo, u.nom, u.prenom,  b.nom as sender
+          FROM  register_marketing AS m
+    INNER JOIN  auth_user_md5      AS u ON m.uid    = u.user_id
+    INNER JOIN  auth_user_md5      AS b ON m.sender = b.user_id
+         WHERE  m.nb > 0
+      GROUP BY  m.uid
+      ORDER BY  u.promo, u.nom";
 $page->assign('notsub', $globals->xdb->iterator($sql));
 
 $page->run();
similarity index 98%
rename from htdocs/marketing/utilisateurs_marketing.php
rename to htdocs/marketing/search.php
index f0923b7..b5d4db9 100644 (file)
@@ -34,7 +34,7 @@ switch (Env::get('submit')) {
        $res = $globals->xdb->query('SELECT * FROM auth_user_md5 WHERE matricule={?}', Env::getInt('xmat'));
        $row = $res->fetchOneAssoc();
 
-        new_admin_page('marketing/utilisateurs_form.tpl');
+        new_admin_page('marketing/search.tpl');
 
         $page->assign('row', $myrow);
 
index e4cd7a3..18674b8 100644 (file)
@@ -31,9 +31,9 @@
   <tr class="impair">
     <td>
       <span class="item">Premier contact : </span>
-      <a href="utilisateurs_marketing.php">Chercher un non inscrit</a> &nbsp;&nbsp;|&nbsp;&nbsp;
+      <a href="search.php">Chercher un non inscrit</a> &nbsp;&nbsp;|&nbsp;&nbsp;
       <a href="promo.php">Marketing promo</a> &nbsp;&nbsp;|&nbsp;&nbsp;
-      <a href="envoidirect.php">Sollicitations faites</a>
+      <a href="recap.php">Sollicitations faites</a>
     </td>
   </tr>
   <tr class="pair">
index 05fbc45..cc9c2a0 100644 (file)
 <table style="margin-left: auto; margin-right: auto">
   <tr>
     <td>
-      <form action="{$smarty.server.PHP_SELF}" method="post">
+      <form action="?" method="get">
         <div>
-          <input type="hidden" name="promo" value="{$promob10}" />
+          <input type="hidden" name="promo" value="{$promo-10}" />
           <input type="submit" value="&lt;&lt;" />
         </div>
       </form>
     </td>
     <td>
-      <form action="{$smarty.server.PHP_SELF}" method="post">
+      <form action="?" method="get">
         <div>
-          <input type="hidden" name="promo" value="{$promob1}" />
+          <input type="hidden" name="promo" value="{$promo-1}" />
           <input type="submit" value="&lt;" />
         </div>
       </form>
     </td>
     <td>
-      <form action="{$smarty.server.PHP_SELF}" method="post">
+      <form action="?" method="get">
         <div>
           Promotion : <input type="text" name="promo" value="{$promo}" size="4" maxlength="4" />
           <input type="submit" value="GO" />
       </form>
     </td>
     <td>
-      <form action="{$smarty.server.PHP_SELF}" method="post">
+      <form action="?" method="get">
         <div>
-          <input type="hidden" name="promo" value="{$promoa1}" />
+          <input type="hidden" name="promo" value="{$promo+1}" />
           <input type="submit" value="&gt;" />
         </div>
       </form>
     </td>
     <td>
-      <form action="{$smarty.server.PHP_SELF}" method="post">
+      <form action="?" method="get">
         <div>
-          <input type="hidden" name="promo" value="{$promoa10}" />
+          <input type="hidden" name="promo" value="{$promo+10}" />
           <input type="submit" value="&gt;&gt;" />
         </div>
       </form> 
     <tr>
       <th>Nom</th>
       <th>Dernière adresse connue</th>
-      <th>Date dernière relance<br />(si moins d'un an)</th>
+      <th>Statut</th>
+      <th>AX</th>
       <th>&nbsp;</th>
     </tr>
     {iterate from=$nonins item=it}
     <tr class="{cycle values="pair,impair"}">
       <td>{$it.nom} {$it.prenom}</td>
-      <td class="center">{if $it.last_known_email}{mailto address=$it.last_known_email}{/if}</td>
+      <td>{if $it.last_known_email}{mailto address=$it.last_known_email}{/if}</td>
       <td class="center">
-        {if $it.dern_rel}
-        {$it.dern_rel}
+        {if $it.dern_rel && $it.dern_rel != '0000-00-00'}
+        Relance le: {$it.dern_rel}
         {elseif $it.email}
-        Ins en cours depuis {$it.email}
+        En cours : {$it.email}
         {else}
-        Jamais ou + d'1 an
+        -
         {/if}
       </td>
       <td class="center">
-        <a href="http://www.polytechniciens.com/index.php?page=AX_FICHE_ANCIEN&amp;anc_id={$it.matricule_ax}">Fiche AX</a>/
-        <a href="utilisateurs_marketing.php?xmat={$it.matricule}">Marketing</a>
+        <a href="http://www.polytechniciens.com/index.php?page=AX_FICHE_ANCIEN&amp;anc_id={$it.matricule_ax}">{*
+          *}<img src="{rel}/images/ax.png" alt='AX' title="fiche AX" /></a>
+      </td>
+      <td>
+        <a href="utilisateurs_marketing.php?xmat={$it.user_id}">Marketing</a>
       </td>
     </tr>
     {/iterate}
similarity index 80%
rename from templates/marketing/envoidirect.tpl
rename to templates/marketing/recap.tpl
index b0e961f..9e33da2 100644 (file)
 
 <table class="bicol" summary="liste des sollicités inscrits">
   <tr>
-    <th>Date</th>
+    <th>Date Ins.</th>
     <th>Par</th>
     <th>Nom</th>
     <th>inscription</th>
   </tr>
   {iterate from=$recents item=it}
   <tr class="{cycle values="pair,impair"}">
-    <td>{$it.date_envoi|date_format}</td>
-    <td>{$it.sender|lower|truncate:8:""}</td>
+    <td>{$it.success|date_format}</td>
+    <td>{$it.sender|lower}</td>
     <td>
-      <a href="mailto:{$it.email}" title="{$it.email}">{$it.nom} {$it.prenom}</a>
-      (x<a href="promo.php?promo={$it.promo}">{$it.promo}</a>)
+      <a href="{rel}/fiche.php?user={$it.forlife}" class="popup2">{$it.prenom} {$it.nom}</a>
+      (<a href="promo.php?promo={$it.promo}">{$it.promo}</a>)
     </td>
     <td>{$it.date_succes|date_format}</td>
   </tr>
 
 <table class="bicol" summary="liste des sollicités non inscrits">
   <tr>
-    <th>Date</th>
+    <th>Dernier envoi</th>
     <th>Par</th>
     <th>Nom</th>
+    <th>Nb mails testés</th>
   </tr>
-  {iterate from=$notsub item=it}
+  {iterate from=$notsub item=x}
   <tr class="{cycle values="pair,impair"}">
-    <td>{$it.date_envoi|date_format}</td>
-    <td>{$it.sender|lower|truncate:8:""}</td>
+    <td class="center">
+      {if $x.last != '0000-00-00'}{$x.last|date_format:"%d %b %y"}{else}-{/if}
+    </td>
+    <td>{$x.sender|lower}</td>
+    <td>
+      {$x.promo} {$x.nom} {$x.prenom}
+    </td>
     <td>
-      <a href="mailto:{$it.email}" title="{$it.email}">{$it.nom} {$it.prenom}</a>
-      (x<a href="promo.php?promo={$it.promo}">{$it.promo}</a>)
+      {$x.nb}
     </td>
   </tr>
   {/iterate}
similarity index 98%
rename from templates/marketing/utilisateurs_form.tpl
rename to templates/marketing/search.tpl
index 57ca0de..7d38a99 100644 (file)
@@ -20,9 +20,7 @@
 
 
 
-<h1>
-  Envoyer un mail de pr&eacute;-inscription
-</h1>
+<h1>Envoyer un mail de pr&eacute;-inscription</h1>
 
 <p>
 Le nom, pr&eacute;nom et promotion sont pris dans la table d'identification.  Le login sera automatiquement
index 87fc357..6b33c79 100644 (file)
@@ -29,7 +29,8 @@ create table register_marketing (
     last        date         not null default '0000-00-00',
     nb          tinyint      not null default 0,
     type        set('user', 'staff') not null default 'user',
-    INDEX (uid),
+    hash        char(32)     not null,
+    PRIMARY KEY (uid, email),
     INDEX (date),
     INDEX (last),
     INDEX (nb)
@@ -41,4 +42,30 @@ create table register_mstats (
     success     date         not null default '0000-00-00',
     PRIMARY KEY (uid)
 );
-    
+
+
+--
+-- envoidirect -> register_mstats
+--
+
+insert into register_mstats (uid, sender, success)
+     select u.user_id, e.sender, u.date_ins
+       from envoidirect   as e
+ inner join auth_user_md5 as u using(matricule)
+      where u.date_ins != 0;
+
+insert into register_marketing (uid, sender, email, date, last, nb, type, hash)
+     select u.user_id, m.expe, m.email, 0, 0, FIND_IN_SET('envoye', m.flags), IF(FIND_IN_SET('mail_perso', m.flags), 'user', 'staff'), ''
+       from marketing     as m
+ inner join auth_user_md5 as u on u.matricule = m.dest
+      where date_ins = 0 and deces = 0
+      group by user_id, m.email;
+
+replace into register_marketing (uid, sender, email, date, last, nb, type, hash)
+     select u.user_id, e.sender, e.email, date_envoi, date_envoi, 1, 'staff', e.uid
+       from envoidirect   as e
+ inner join auth_user_md5 as u using(matricule)
+      where date_ins = 0 and deces = 0;
+
+drop table envoidirect;
+drop table marketing;