X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fpayment.php;h=39f819321ea095dd13025b8ce7e58b29d37bfcb8;hb=cafb410fea6f257f45da08631c6cdb5c35f86b17;hp=8804a4fc7432bd27ea90a2631557a5e03e8179f3;hpb=e848335b6da4f080c2c51e75122945ddc8d00e1f;p=platal.git diff --git a/modules/payment.php b/modules/payment.php index 8804a4f..39f8193 100644 --- a/modules/payment.php +++ b/modules/payment.php @@ -296,7 +296,7 @@ class PaymentModule extends PLModule //} /* on extrait les informations sur l'utilisateur */ - $user = User::get(Env::v('vads_cust_id')); + $user = User::get(Env::i('vads_cust_id')); if (!$user) { cb_erreur("uid invalide"); } @@ -310,15 +310,17 @@ class PaymentModule extends PLModule $res = XDB::query("SELECT mail, text, confirmation FROM payments WHERE id={?}", $ref); - if (!list($conf_mail, $conf_title, $conf_text) = $res->fetchOneRow()) { + if ($res->numRows() != 1) { cb_erreur("référence de commande inconnue"); } + list($conf_mail, $conf_title, $conf_text) = $res->fetchOneRow(); /* on extrait le montant */ if (Env::v('vads_currency') != "978") { cb_erreur("monnaie autre que l'euro"); } - $montant = sprintf("%.02f", ((float)Env::v('vads_amount'))/100) . " EUR"; + $amount = ((float)Env::i('vads_amount')) / 100; + $montant = sprintf("%.02f EUR", $amount); /* on extrait le code de retour */ if (Env::v('vads_result') != "00") { @@ -332,18 +334,19 @@ class PaymentModule extends PLModule echo "Paiement stored.\n"; // We check if it is an Xnet payment and then update the related ML. - $res = XDB::query('SELECT eid + $res = XDB::query('SELECT eid, asso_id FROM group_events WHERE paiement_id = {?}', $ref); - if ($eid = $res->fetchOneCell()) { + if ($res->numRows() == 1) { + list($eid, $asso_id) = $res->fetchOneRow(); require_once dirname(__FILE__) . '/xnetevents/xnetevents.inc.php'; - $evt = get_event_detail($eid); - subscribe_lists_event($user->id(), $evt, 1, $montant, true); + $evt = get_event_detail($eid, false, $asso_id); + subscribe_lists_event($user->id(), $evt, 1, $amount, true); } /* on genere le mail de confirmation */ $conf_text = str_replace( - array('', '', '', '', '', '', 'comment>'), + array('', '', '', '', '', '', ''), array($user->firstName(), $user->lastName(), $user->promo(), $montant, $user->isFemale() ? 'Chère' : 'Cher', $user->isFemale() ? 'Chère' : 'Cher', Env::v('comment')), $conf_text); @@ -480,7 +483,7 @@ class PaymentModule extends PLModule } $res = XDB::query("SELECT 1 FROM group_events AS e - INNER JOIN group_event_participants AS ep ON (ep.eid = e.eid AND uid = {?}) + INNER JOIN group_event_participants AS ep ON (ep.eid = e.eid AND e.uid = {?}) WHERE e.paiement_id = {?} AND e.asso_id = {?}", S::i('uid'), $pid, $globals->asso('id')); if ($res->numRows() == 0) {