X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations%2Fpaiements.inc.php;h=094252970b15c8c5ded7f9ae255c4ae6e5653ec4;hb=b6ba1a0417b6fc73f3d1701146373b4bec0d1428;hp=7e7f96b2935ca0e11e4e1cb603ee7e636b5a4460;hpb=20934085ed6e05fc18aa83e3a91259e638128f53;p=platal.git diff --git a/include/validations/paiements.inc.php b/include/validations/paiements.inc.php index 7e7f96b..0942529 100644 --- a/include/validations/paiements.inc.php +++ b/include/validations/paiements.inc.php @@ -1,6 +1,6 @@ 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; if ($_asso_id) { - $res = XDB::query("SELECT nom FROM groupex.asso WHERE id = {?}", $_asso_id); + $res = XDB::query("SELECT nom FROM #groupex#.asso WHERE id = {?}", $_asso_id); $this->asso = $res->fetchOneCell(); } if ($_asso_id && $_evt) { - $res = XDB::query("SELECT intitule FROM groupex.evenements WHERE asso_id = {?} AND eid = {?}", $_asso_id, $_evt); + $res = XDB::query("SELECT intitule FROM #groupex#.evenements WHERE asso_id = {?} AND eid = {?}", $_asso_id, $_evt); $this->evt_intitule = $res->fetchOneCell(); } } @@ -77,7 +79,7 @@ class PayReq extends Validate $where = "%".$wassoid."%".$wevt."%"; return $where; } - + // }}} // {{{ function accept() @@ -86,19 +88,19 @@ class PayReq extends Validate { // no text [AI JMIAJM IJA MIJ] if (preg_match('/\[[-\'"A-Z ]+\]/', $this->msg_reponse)) { - $this->trig("La demande de paiement n'est pas valide. Merci de compléter le texte avant de la soumettre"); + $this->trigError("La demande de paiement n'est pas valide. Merci de compléter le texte avant de la soumettre"); return false; } if (!preg_match('//', $this->msg_reponse)) { - $this->trig("Le demande de paiement ne contient pas la balise obligatoire <montant>"); + $this->trigError("Le demande de paiement ne contient pas la balise obligatoire <montant>"); return false; } return true; } - // }}} - // {{{ function submit() - + // }}} + // {{{ function submit() + // supprime les demandes de paiments pour le meme evenement public function submit() { @@ -160,23 +162,55 @@ class PayReq extends Validate // }}} // {{{ function commit() - + public function commit() { - global $globals; - $res = XDB::query("SELECT MAX(id) FROM paiement.paiements"); + $res = XDB::query("SELECT MAX(id) FROM #paiement#.paiements"); $id = $res->fetchOneCell()+1; - $ret = XDB::execute("INSERT INTO paiement.paiements VALUES + $ret = XDB::execute("INSERT INTO #paiement#.paiements VALUES ( {?}, {?}, {?}, '', {?}, {?}, {?}, {?}, {?}, {?} ) ", $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); - + $this->user->bestEmail(), $this->msg_reponse, $this->asso_id); + 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(); + 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 = new PlMailer('xnetevents/newpayment.mail.tpl'); + $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->send(); + } + } + } return $ret; }