subscribers of that event can be notified they can pay.
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
* Search:
- Shortcuts to open profiles or search in documentation -FRU
+ * XnetEvents:
+ - #702: Be notified of the availability of the payment -FRU
+
Bug/Wish:
* Auth:
[mails_ax]
from="Association des Anciens élèves de l'X" <info@amicale.polytechnique.org>
replyto=info@amicale.polytechnique.org
+
+[payment_ready]
+from="Gestion des paiements" <support@polytechnique.org>
$this->titre = $_intitule;
$this->site = $_site;
$this->msg_reponse = $_msg;
- $this->asso_id = $_asso_id;
- $this->evt = $_evt;
+ $this->asso_id = (string)$_asso_id;
+ $this->evt = (string)$_evt;
$this->montant = $_montant;
$this->montant_min = $_montantmin;
$this->montant_max = $_montantmax;
$id, $this->titre, $this->site,
$this->montant, $this->montant_min, $this->montant_max,
$this->bestalias."@".$globals->mail->domain, $this->msg_reponse, $this->asso_id);
- if ($this->asso_id && $this->evt)
- $ret = XDB::execute("UPDATE groupex.evenements SET paiement_id = {?} WHERE asso_id = {?} AND eid = {?}", $id, $this->asso_id, $this->evt);
-
+ if ($this->asso_id && $this->evt) {
+ XDB::execute("UPDATE groupex.evenements
+ SET paiement_id = {?}
+ WHERE asso_id = {?} AND eid = {?}",
+ $id, $this->asso_id, $this->evt);
+ $res = XDB::query("SELECT a.nom, a.diminutif, e.intitule
+ FROM groupex.asso AS a
+ INNER JOIN groupex.evenements AS e ON (a.id = e.asso_id)
+ WHERE e.eid = {?}",
+ $this->evt);
+ list($nom, $diminutif, $evt) = $res->fetchOneRow();
+ $mailer = new PlMailer('xnetevents/mail.new_payment.tpl');
+ $mailer->assign('asso', $nom);
+ $mailer->assign('diminutif', $diminutif);
+ $mailer->assign('evt', $evt);
+ $mailer->assign('payment', $id);
+ require_once dirname(__FILE__) . '/../../modules/xnetevents/xnetevents.inc.php';
+ $participants = get_event_participants(get_event_detail($this->evt, false, $this->asso_id), null, 'nom');
+ foreach ($participants as &$u) {
+ if (!$u['notify_payment']) {
+ continue;
+ }
+ $topay = $u['montant'] - $u['paid'];
+ if ($topay > 0) {
+ $mailer->assign('prenom', $u['prenom']);
+ $mailer->assign('topay', $topay);
+ $mailer->assign('to', $u['email']);
+ $mailer->send();
+ }
+ }
+ }
return $ret;
}
$page->kill('Cet événement est fermé aux non-membres du groupe');
}
+ global $globals;
+ $res = XDB::query("SELECT stamp FROM requests
+ WHERE type = 'paiements' AND data LIKE {?}",
+ PayReq::same_event($evt['eid'], $globals->asso('id')));
+ $page->assign('validation', $res->numRows());
$page->assign('event', $evt);
if (!Post::has('submit')) {
if ($nb >= 0) {
XDB::execute(
"REPLACE INTO groupex.evenements_participants
- VALUES ({?}, {?}, {?}, {?}, {?})",
- $eid, S::v('uid'), $j, $nb, $paid);
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?})",
+ $eid, S::v('uid'), $j, $nb, Env::has('notify_payment') ? 'notify_payment' : '', $paid);
$updated = $eid;
} else {
XDB::execute(
foreach ($nbs as $id => $nb) {
$nb = max(intval($nb), 0);
XDB::execute("REPLACE INTO groupex.evenements_participants
- VALUES ({?}, {?}, {?}, {?}, {?})",
- $evt['eid'], $member['uid'], $id, $nb, $paid);
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?})",
+ $evt['eid'], $member['uid'], $id, $nb, '', $paid);
}
$res = XDB::query("SELECT COUNT(uid) AS cnt, SUM(nb) AS nb
// {{{ function get_event_detail()
-function get_event_detail($eid, $item_id = false)
+function get_event_detail($eid, $item_id = false, $asso_id = null)
{
global $globals;
+ if (is_null($asso_id)) {
+ $asso_id = $globals->asso('id');
+ }
$res = XDB::query(
- "SELECT SUM(nb) AS nb_tot, COUNT(DISTINCT ep.uid) AS nb, e.*,
+ "SELECT SUM(nb) AS nb_tot, COUNT(DISTINCT ep.uid) AS nb, e.*,
IF(e.deadline_inscription, e.deadline_inscription >= LEFT(NOW(), 10),
1) AS inscr_open,
LEFT(10, e.debut) AS debut_day, LEFT(10, e.fin) AS fin_day,
ei.titre,
al.vid AS absent_list, pl.vid AS participant_list,
a.nom, a.prenom, a.promo, aa.alias
- FROM groupex.evenements AS e
+ FROM groupex.evenements AS e
INNER JOIN x4dat.auth_user_md5 AS a ON a.user_id = e.organisateur_uid
INNER JOIN x4dat.aliases AS aa ON (aa.type = 'a_vie' AND aa.id = a.user_id)
- INNER JOIN groupex.evenements_items AS ei ON (e.eid = ei.eid)
- LEFT JOIN groupex.evenements_participants AS ep ON(e.eid = ep.eid AND ei.item_id = ep.item_id)
+ INNER JOIN groupex.evenements_items AS ei ON (e.eid = ei.eid)
+ LEFT JOIN groupex.evenements_participants AS ep ON(e.eid = ep.eid AND ei.item_id = ep.item_id)
LEFT JOIN virtual AS al ON(al.type = 'evt' AND al.alias = CONCAT(short_name, {?}))
LEFT JOIN virtual AS pl ON(pl.type = 'evt' AND pl.alias = CONCAT(short_name, {?}))
- WHERE (e.eid = {?} OR e.short_name = {?}) AND ei.item_id = {?} AND e.asso_id = {?}
+ WHERE (e.eid = {?} OR e.short_name = {?}) AND ei.item_id = {?} AND e.asso_id = {?}
GROUP BY ei.item_id",
'-absents@'.$globals->xnet->evts_domain,
'-participants@'.$globals->xnet->evts_domain,
- $eid, $eid, $item_id ? $item_id : 1, $globals->asso('id'));
+ $eid, $eid, $item_id ? $item_id : 1, $asso_id);
$evt = $res->fetchOneAssoc();
- if (!$evt || ($evt['accept_nonmembre'] == 0 && !is_member() && !may_update())) {
+ if (!$evt || ($GLOBALS['IS_XNET_SITE'] && $evt['accept_nonmembre'] == 0 && !is_member() && !may_update())) {
return null;
}
}
$res = XDB::query(
- "SELECT titre, details, montant, ei.item_id, nb, ep.paid
+ "SELECT titre, details, montant, ei.item_id, nb, ep.paid, FIND_IN_SET('notify_payment', ep.flags) AS notify_payment
FROM groupex.evenements_items AS ei
LEFT JOIN groupex.evenements_participants AS ep
ON (ep.eid = ei.eid AND ep.item_id = ei.item_id AND uid = {?})
$evt['topay'] = 0;
$evt['paid'] = 0;
+ $evt['notify_payment'] = false;
foreach ($evt['moments'] as $m) {
$evt['topay'] += $m['nb'] * $m['montant'];
if ($m['montant']) {
$evt['money'] = true;
}
$evt['paid'] = $m['paid'];
+ $evt['notify_payment'] = $evt['notify_payment'] || $m['notify_payment'];
}
$req = XDB::query(
}
$eid = $evt['eid'];
- $money = $evt['money'] && may_update();
+ $money = $evt['money'] && (function_exists('may_update')) && may_update();
$pay_id = $evt['paiement_id'];
$query =
IF(m.origine != 'X',m.sexe,FIND_IN_SET('femme', u.flags)) AS femme,
m.perms='admin' AS admin,
(m.origine = 'X') AS x,
- ep.uid, SUM(ep.paid) AS paid, SUM(nb) AS nb
+ ep.uid, SUM(ep.paid) AS paid, SUM(nb) AS nb,
+ FIND_IN_SET('notify_payment', ep.flags) AS notify_payment
FROM groupex.evenements_participants AS ep
INNER JOIN groupex.evenements AS e ON (ep.eid = e.eid)
- LEFT JOIN groupex.membres AS m ON ( ep.uid = m.uid AND e.asso_id = m.asso_id)
+ LEFT JOIN groupex.membres AS m ON ( ep.uid = m.uid AND e.asso_id = m.asso_id)
LEFT JOIN auth_user_md5 AS u ON ( u.user_id = ep.uid )
LEFT JOIN aliases AS a ON ( a.id = ep.uid AND a.type='a_vie' )
WHERE ep.eid = {?} AND ep.nb > 0
while ($u = $res->next()) {
$u['adminpaid'] = $u['paid'];
$u['montant'] = 0;
- if ($money && $pay_id) {
+ if ($money && $pay_id) {
$res_ = XDB::query(
"SELECT montant
FROM {$globals->money->mpay_tprefix}transactions AS t
$p = strtr(substr($m, 0, strpos($m, "EUR")), ",", ".");
$u['paid'] += trim($p);
}
- }
+ }
$u['telepayment'] = $u['paid'] - $u['adminpaid'];
$res_ = XDB::iterator(
- "SELECT ep.nb, ep.item_id, ei.montant
- FROM groupex.evenements_participants AS ep
- INNER JOIN groupex.evenements_items AS ei ON (ei.eid = ep.eid AND ei.item_id = ep.item_id)
- WHERE ep.eid = {?} AND ep.uid = {?}",
+ "SELECT ep.nb, ep.item_id, ei.montant
+ FROM groupex.evenements_participants AS ep
+ INNER JOIN groupex.evenements_items AS ei ON (ei.eid = ep.eid AND ei.item_id = ep.item_id)
+ WHERE ep.eid = {?} AND ep.uid = {?}",
$eid, $u['uid']);
while ($i = $res_->next()) {
$u[$i['item_id']] = $i['nb'];
$u['montant'] += $i['montant']*$i['nb'];
}
- $tab[] = $u;
+ $tab[] = $u;
}
return $tab;
}
--- /dev/null
+{**************************************************************************}
+{* *}
+{* Copyright (C) 2003-2007 Polytechnique.org *}
+{* http://opensource.polytechnique.org/ *}
+{* *}
+{* This program is free software; you can redistribute it and/or modify *}
+{* it under the terms of the GNU General Public License as published by *}
+{* the Free Software Foundation; either version 2 of the License, or *}
+{* (at your option) any later version. *}
+{* *}
+{* This program is distributed in the hope that it will be useful, *}
+{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
+{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
+{* GNU General Public License for more details. *}
+{* *}
+{* You should have received a copy of the GNU General Public License *}
+{* along with this program; if not, write to the Free Software *}
+{* Foundation, Inc., *}
+{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
+{* *}
+{**************************************************************************}
+
+{config_load file="mails.conf" section="payment_ready"}
+{if $mail_part eq 'head'}
+{from full=#from#}
+{to addr=$to}
+{subject text="[`$asso`] Paiement activé"}
+{elseif $mail_part eq 'wiki'}
+Cher {$prenom},
+
+Nous t'écrivons pour t'informer que le télépaiement associé à l'événement '''{$evt}''' du groupe {$asso} vient d'être activé. Tu peux donc finaliser ton inscription.
+
+Pour ceci, va simplement sur [[http://www.polytechnique.net/{$diminutif}/payment/{$payment}?montant={$topay}|cette page]].
+
+Cordialement,\\
+L'Equipe de Polytechnique.org
+{/if}
+{* vim:set et sw=2 sts=2 sws=2: *}
<tr>
<td>
{if $event.topay}
- <span class="error">
+ <div class="error">
{if !$event.paid}
Tu dois payer {$event.topay|replace:'.':','} €.
{elseif $event.paid < $event.topay}
(tu as déjà payé {$event.paid|replace:'.':','} €)
{else}
Tu as déjà payé {$event.paid|replace:'.':','} € pour ton inscription.
- {/if}
+ {/if}
+ </div>
+ <div>
{if $event.paiement_id && $event.paid < $event.topay}
[<a href="{$platal->ns}payment/{$event.paiement_id}?montant={math equation="a-b" a=$event.topay b=$event.paid}">
Payer en ligne</a>]
+ {elseif $validation && $event.paid < $event.topay}
+ <br />Le télépaiement pour cet événement est en instance de validation :<br />
+ <input type="checkbox" name="notify_payment" {if $event.notify_payment}checked="checked"{/if} id="notify" />
+ <label for="notify">être prévenu lorsque le télépaiment pour cet événement sera disponible</label>
{/if}
- </span>
+ </div>
{else}
Rien à payer
{if $event.paid > 0}
--- /dev/null
+use groupex;
+alter table evenements_participants add column flags set('notify_payment') not null after nb;
+use x4dat;
+# vim:set syntax=mysql: