X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fvalidations%2Fpaiements.inc.php;h=1b4fc8fec9259cf565c0c7f2209b6a0ba7200fff;hb=7a5d8476a10ef09b09b0128bb145b5407e6ed1e4;hp=a7c4fbd899f96f711a1747ab27325a77de870452;hpb=82af3fc3b6e003b0cbbcf4faf4ed4f0ea5c07570;p=platal.git diff --git a/include/validations/paiements.inc.php b/include/validations/paiements.inc.php index a7c4fbd..1b4fc8f 100644 --- a/include/validations/paiements.inc.php +++ b/include/validations/paiements.inc.php @@ -1,6 +1,6 @@ montant = $_montant; $this->montant_min = $_montantmin; $this->montant_max = $_montantmax; + $this->public = $_public; if ($_asso_id) { $res = XDB::query("SELECT nom FROM groups WHERE id = {?}", $_asso_id); @@ -67,6 +69,11 @@ Si le télépaiement n'est pas lié à un groupe ou supérieur à 51 euros, lais $res = XDB::query("SELECT intitule FROM group_events WHERE asso_id = {?} AND eid = {?}", $_asso_id, $_evt); $this->evt_intitule = $res->fetchOneCell(); } + // for future use, when anims can choose there bankaccounts + if ($this->rib_id) { + $res = XDB::query("SELECT owner FROM payment_bankaccounts WHERE id = {?}", $this->rib_id); + $this->rib_nom = $res->fetchOneCell(); + } } // }}} @@ -87,7 +94,7 @@ Si le télépaiement n'est pas lié à un groupe ou supérieur à 51 euros, lais public function accept() { // no text [AI JMIAJM IJA MIJ] - if (preg_match('/\[[-\'"A-Z ]+\]/', $this->msg_reponse)) { + if (preg_match('/\[[-\'"a-zA-Z ]+\]/', replace_accent($this->msg_reponse))) { $this->trigError("La demande de paiement n'est pas valide. Merci de compléter le texte avant de la soumettre"); return false; } @@ -133,10 +140,18 @@ Si le télépaiement n'est pas lié à un groupe ou supérieur à 51 euros, lais { $this->titre = Env::v('pay_titre'); $this->site = Env::v('pay_site'); - $this->montant = Env::i('pay_montant'); + $this->montant = Env::t('pay_montant'); $this->montant_min = Env::i('pay_montant_min'); $this->montant_max = Env::i('pay_montant_max'); $this->msg_reponse = Env::v('pay_msg_reponse'); + $this->public = (Env::v('pay_public') == 'yes'); + $this->rib_id = Env::v('pay_rib_id'); + if ($this->rib_id) { + $res = XDB::query("SELECT owner FROM payment_bankaccounts WHERE id = {?}", $this->rib_id); + $this->rib_nom = $res->fetchOneCell(); + } else { + $this->rib_nom = null; + } return true; } @@ -154,9 +169,9 @@ Si le télépaiement n'est pas lié à un groupe ou supérieur à 51 euros, lais protected function _mail_body($isok) { if ($isok) { - return " Le paiement que tu avais demandé pour {$this->titre} vient d'être créé.".($this->evt?" Il a bien été associé à la gestion de l'événement du groupe":""); + return " Le paiement demandé pour {$this->titre} vient d'être créé.".($this->evt?" Il a bien été associé à la gestion de l'événement du groupe":""); } else { - return " La demande que tu avais faite pour le paiement de {$this->intitule} a été refusée."; + return " La demande faite pour le paiement de {$this->intitule} a été refusée."; } } @@ -167,14 +182,11 @@ Si le télépaiement n'est pas lié à un groupe ou supérieur à 51 euros, lais { $res = XDB::query("SELECT MAX(id) FROM payments"); $id = $res->fetchOneCell()+1; - $ret = XDB::execute("INSERT INTO payments VALUES - ( {?}, {?}, {?}, '', - {?}, {?}, {?}, - {?}, {?}, {?} ) - ", - $id, $this->titre, $this->site, - $this->montant, $this->montant_min, $this->montant_max, - $this->user->bestEmail(), $this->msg_reponse, $this->asso_id); + $ret = XDB::execute('INSERT INTO payments (id, text, url, amount_def, amount_min, amount_max, mail, confirmation, asso_id, flags, rib_id) + VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', + $id, $this->titre, $this->site, $this->montant, $this->montant_min, + $this->montant_max, $this->user->bestEmail(), $this->msg_reponse, $this->asso_id, + ($this->public ? 'public' : ''), $this->rib_id); if ($this->asso_id && $this->evt) { XDB::execute("UPDATE group_events SET paiement_id = {?} @@ -188,25 +200,19 @@ Si le télépaiement n'est pas lié à un groupe ou supérieur à 51 euros, lais list($nom, $diminutif, $evt) = $res->fetchOneRow(); require_once dirname(__FILE__) . '/../../modules/xnetevents/xnetevents.inc.php'; $participants = get_event_participants(get_event_detail($this->evt, false, $this->asso_id), null); - foreach ($participants as &$u) { + foreach ($participants as $u) { if (!$u['notify_payment']) { continue; } $topay = $u['montant'] - $u['paid']; if ($topay > 0) { $mailer = new PlMailer('xnetevents/newpayment.mail.tpl'); + $mailer->addTo($u['user']); $mailer->assign('asso', $nom); $mailer->assign('diminutif', $diminutif); $mailer->assign('evt', $evt); - $mailer->assign('payment', $id); - $mailer->assign('prenom', $u['prenom']); - $mailer->assign('topay', $topay); - - if (strpos($u['email'], '@') === false) { - $mailer->assign('to', $u['email'] . '@' . $globals->mail->domain); - } else { - $mailer->assign('to', $u['email']); - } + $mailer->assign('eid', $this->evt); + $mailer->assign('prenom', $u['user']->firstName()); $mailer->send(); } } @@ -219,5 +225,5 @@ Si le télépaiement n'est pas lié à un groupe ou supérieur à 51 euros, lais // }}} -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: ?>