s/a\.uid/$UID/ && s/p\.pid/$PID/
[platal.git] / bin / cron / rapports_inscription.php
CommitLineData
ee68ddc1 1#!/usr/bin/php5 -q
0337d704 2<?php
525bec1a
SJ
3require 'connect.db.inc.php';
4$message = '';
0337d704 5
6// ---------------------------------------
7
525bec1a
SJ
8$res = XDB::iterRow("SELECT al.alias, pd.promo, e.email //a.alias, u.promo, email
9 FROM accounts AS a
10 INNER JOIN account_profile AS ap ON (ap.uid = a.uid AND FIND_IN_SET('owner', ap.perms))
11 INNER JOIN profile_display AS pd ON (ap.pid = pd.pid)
12 LEFT JOIN aliases AS al ON (a.uid =a.uid AND al.type = 'a_vie')
13 LEFT JOIN emails AS e ON (a.uid = e.uid AND NOT FIND_IN_SET('filter', e.flags))
14 WHERE a.registration_date > {?}
15 GROUP BY al.alias
16 ORDER BY pd.promo",
17 date("Ymd000000", strtotime('last Monday')));
18if ($count = $res->total()) {
19 $message .= "$count INSCRIPTIONS CONFIRMÉES :\n";
20 while (list($forlife, $promo, $email) = $res->next()) {
21 $message .= "$promo, $forlife, $email\n";
0337d704 22 }
23}
24
25// ---------------------------------------
26
525bec1a
SJ
27$res = XDB::iterRow("SELECT a.hruid, r.email, r.date
28 FROM register_pending AS r
29 INNER JOIN accounts AS a ON (a.uid = r.uid)
30 WHERE r.hash != 'INSCRIT'
31 ORDER BY r.date");
32if ($count = $res->total()) {
33 $message .= "\n$count INSCRIPTIONS NON CONFIRMÉES :\n";
34 while (list($forlife, $email, $date) = $res->next()) {
35 $message .= "$date, $forlife,\n $email\n";
0337d704 36 }
37}
38
39// ---------------------------------------
40
525bec1a
SJ
41$res = XDB::query('SELECT COUNT(DISTINCT uid), COUNT(*)
42 FROM register_marketing');
0337d704 43list($a, $b) = $res->fetchOneRow();
525bec1a
SJ
44$message .= "\nINSCRIPTIONS SOLICITÉES :\n";
45$message .= " $a utilisateurs\n $b adresses email\n";
0337d704 46
47// ---------------------------------------
48
525bec1a 49$message .= "\n\n";
0337d704 50
1e33266a 51$mailer = new PlMailer();
525bec1a 52$mailer->setSubject('Rapport des inscriptions de la semaine');
40bc7e89 53$mailer->setFrom($globals->register->notif);
54$mailer->addTo($globals->register->notif);
525bec1a 55$mailer->setTxtBody($message);
0337d704 56$mailer->send();
a7de4ef7 57// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
0337d704 58?>