Moving to GitHub.
[platal.git] / bin / cron / registrations.php
CommitLineData
ee68ddc1 1#!/usr/bin/php5 -q
0337d704 2<?php
5ecaa68e 3
525bec1a 4require 'connect.db.inc.php';
0337d704 5
5ecaa68e 6$message = '';
0337d704 7
0f3b6657 8$res = XDB::iterRow("SELECT DATE(a.registration_date), a.hruid, GROUP_CONCAT(DISTINCT r.redirect SEPARATOR ', ')
82d70770
SJ
9 FROM accounts AS a
10 INNER JOIN account_profiles 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 email_source_account AS s ON (a.uid = s.uid)
13 LEFT JOIN email_redirect_account AS r ON (a.uid = r.uid)
525bec1a 14 WHERE a.registration_date > {?}
336820ba 15 GROUP BY a.hruid
525bec1a
SJ
16 ORDER BY pd.promo",
17 date("Ymd000000", strtotime('last Monday')));
18if ($count = $res->total()) {
bf56938b 19 $message .= "$count INSCRIPTIONS CONFIRMÉES CETTE SEMAINE :\n";
82d70770
SJ
20 while (list($date, $hruid, $email, $redirect) = $res->next()) {
21 $message .= "$date, $hruid, $email, $redirect\n";
0337d704 22 }
23}
24
bf56938b 25$res = XDB::iterRow("SELECT r.date, a.hruid, r.email
525bec1a
SJ
26 FROM register_pending AS r
27 INNER JOIN accounts AS a ON (a.uid = r.uid)
bf56938b
SJ
28 INNER JOIN account_profiles AS ap ON (ap.uid = a.uid AND FIND_IN_SET('owner', ap.perms))
29 INNER JOIN profile_display AS pd ON (ap.pid = pd.pid)
525bec1a 30 WHERE r.hash != 'INSCRIT'
bf56938b
SJ
31 GROUP BY a.hruid
32 ORDER BY pd.promo");
525bec1a
SJ
33if ($count = $res->total()) {
34 $message .= "\n$count INSCRIPTIONS NON CONFIRMÉES :\n";
bf56938b
SJ
35 while (list($date, $hruid, $email) = $res->next()) {
36 $message .= "$date, $hruid, $email\n";
0337d704 37 }
38}
39
525bec1a
SJ
40$res = XDB::query('SELECT COUNT(DISTINCT uid), COUNT(*)
41 FROM register_marketing');
0337d704 42list($a, $b) = $res->fetchOneRow();
bf56938b 43$message .= "\nINSCRIPTIONS SOLLICITÉES :\n";
525bec1a 44$message .= " $a utilisateurs\n $b adresses email\n";
0337d704 45
525bec1a 46$message .= "\n\n";
0337d704 47
1e33266a 48$mailer = new PlMailer();
525bec1a 49$mailer->setSubject('Rapport des inscriptions de la semaine');
40bc7e89 50$mailer->setFrom($globals->register->notif);
51$mailer->addTo($globals->register->notif);
525bec1a 52$mailer->setTxtBody($message);
0337d704 53$mailer->send();
5ecaa68e 54
448c8cdc 55// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
0337d704 56?>