From: Pierre Habouzit (MadCoder Date: Mon, 10 Jan 2005 14:19:20 +0000 (+0000) Subject: further work on marketing X-Git-Tag: xorg/old~491 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=4e89a46f2a4c5628567cbbe534289f08f4ab68c9;p=platal.git further work on marketing git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-260 --- diff --git a/htdocs/marketing/promo.php b/htdocs/marketing/promo.php index 1019543..9c50cc1 100644 --- a/htdocs/marketing/promo.php +++ b/htdocs/marketing/promo.php @@ -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(); diff --git a/htdocs/marketing/envoidirect.php b/htdocs/marketing/recap.php similarity index 65% rename from htdocs/marketing/envoidirect.php rename to htdocs/marketing/recap.php index 112b88e..4ece501 100644 --- a/htdocs/marketing/envoidirect.php +++ b/htdocs/marketing/recap.php @@ -20,26 +20,24 @@ ***************************************************************************/ 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(); diff --git a/htdocs/marketing/utilisateurs_marketing.php b/htdocs/marketing/search.php similarity index 98% rename from htdocs/marketing/utilisateurs_marketing.php rename to htdocs/marketing/search.php index f0923b7..b5d4db9 100644 --- a/htdocs/marketing/utilisateurs_marketing.php +++ b/htdocs/marketing/search.php @@ -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); diff --git a/templates/marketing/index.tpl b/templates/marketing/index.tpl index e4cd7a3..18674b8 100644 --- a/templates/marketing/index.tpl +++ b/templates/marketing/index.tpl @@ -31,9 +31,9 @@ Premier contact : - Chercher un non inscrit   |   + Chercher un non inscrit   |   Marketing promo   |   - Sollicitations faites + Sollicitations faites diff --git a/templates/marketing/promo.tpl b/templates/marketing/promo.tpl index 05fbc45..cc9c2a0 100644 --- a/templates/marketing/promo.tpl +++ b/templates/marketing/promo.tpl @@ -23,23 +23,23 @@ - + + {iterate from=$nonins item=it} - + + {/iterate} diff --git a/templates/marketing/envoidirect.tpl b/templates/marketing/recap.tpl similarity index 80% rename from templates/marketing/envoidirect.tpl rename to templates/marketing/recap.tpl index b0e961f..9e33da2 100644 --- a/templates/marketing/envoidirect.tpl +++ b/templates/marketing/recap.tpl @@ -26,18 +26,18 @@
-
+
- +
-
+
- +
-
+
Promotion : @@ -47,17 +47,17 @@
-
+
- +
-
+
- +
@@ -78,25 +78,29 @@
Nom Dernière adresse connueDate dernière relance
(si moins d'un an)
StatutAX  
{$it.nom} {$it.prenom}{if $it.last_known_email}{mailto address=$it.last_known_email}{/if}{if $it.last_known_email}{mailto address=$it.last_known_email}{/if} - {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} - Fiche AX/ - Marketing + {* + *}AX + + Marketing
- + {iterate from=$recents item=it} - - + + @@ -53,17 +53,22 @@
DateDate Ins. Par Nom inscription
{$it.date_envoi|date_format}{$it.sender|lower|truncate:8:""}{$it.success|date_format}{$it.sender|lower} - {$it.nom} {$it.prenom} - (x{$it.promo}) + {$it.prenom} {$it.nom} + ({$it.promo}) {$it.date_succes|date_format}
- + + - {iterate from=$notsub item=it} + {iterate from=$notsub item=x} - - + + + {/iterate} diff --git a/templates/marketing/utilisateurs_form.tpl b/templates/marketing/search.tpl similarity index 98% rename from templates/marketing/utilisateurs_form.tpl rename to templates/marketing/search.tpl index 57ca0de..7d38a99 100644 --- a/templates/marketing/utilisateurs_form.tpl +++ b/templates/marketing/search.tpl @@ -20,9 +20,7 @@ -

- Envoyer un mail de pré-inscription -

+

Envoyer un mail de pré-inscription

Le nom, prénom et promotion sont pris dans la table d'identification. Le login sera automatiquement diff --git a/upgrade/0.9.4/20_register.sql b/upgrade/0.9.4/20_register.sql index 87fc357..6b33c79 100644 --- a/upgrade/0.9.4/20_register.sql +++ b/upgrade/0.9.4/20_register.sql @@ -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;

DateDernier envoi Par NomNb mails testés
{$it.date_envoi|date_format}{$it.sender|lower|truncate:8:""} + {if $x.last != '0000-00-00'}{$x.last|date_format:"%d %b %y"}{else}-{/if} + {$x.sender|lower} + {$x.promo} {$x.nom} {$x.prenom} + - {$it.nom} {$it.prenom} - (x{$it.promo}) + {$x.nb}