<?php
/***************************************************************************
- * Copyright (C) 2003-2004 Polytechnique.org *
+ * Copyright (C) 2003-2006 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
var $rules = "Laisser la validation à un trésorier";
// }}}
// {{{ constructor
-
- function PayReq($_uid, $_intitule, $_site, $_montant, $_msg, $_montantmin=0, $_montantmax=999, $_asso_id = 0, $_evt = 0, $_stamp=0)
+
+ function PayReq($_uid, $_intitule, $_site, $_montant, $_msg,
+ $_montantmin=0, $_montantmax=999, $_asso_id = 0,
+ $_evt = 0, $_stamp=0)
{
- global $globals;
$this->Validate($_uid, false, 'paiements', $_stamp);
-
+
$this->titre = $_intitule;
$this->site = $_site;
$this->msg_reponse = $_msg;
$this->montant_max = $_montantmax;
if ($_asso_id) {
- $res = $globals->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 = $globals->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();
}
}
// }}}
- // {{{ function formu()
+ // {{{ function same_event()
+ function same_event($evt, $asso_id)
+ {
+ $wevt = 's:3:"evt";s:'.strlen($evt+"").':"'.$evt.'"';
+ $wassoid = 's:7:"asso_id";s:'.strlen($asso_id + "").':"'.$asso_id.'"';
+ $where = "%".$wassoid."%".$wevt."%";
+ return $where;
+ }
+ // }}}
+ // {{{ function submit()
+ // supprime les demandes de paiments pour le meme evenement
+ function submit()
+ {
+ if ($this->evt)
+ {
+ XDB::execute('DELETE FROM requests WHERE type={?} AND data LIKE {?}', 'paiements', PayReq::same_event($this->evt, $this->asso_id));
+ }
+ Validate::submit();
+ }
+ // }}}
+ // {{{ function formu()
function formu()
{ return 'include/form.valid.paiements.tpl'; }
function commit()
{
global $globals;
- $res = $globals->xdb->query("SELECT MAX(id) FROM paiement.paiements");
+ $res = XDB::query("SELECT MAX(id) FROM paiement.paiements");
$id = $res->fetchOneCell()+1;
- $ret = $globals->xdb->execute("INSERT INTO paiement.paiements VALUES
+ $ret = XDB::execute("INSERT INTO paiement.paiements VALUES
( {?}, {?}, {?}, '',
{?}, {?}, {?},
{?}, {?}, {?} )
$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 = $globals->xdb->execute("UPDATE groupex.evenements SET paiement_id = {?} WHERE asso_id = {?} AND eid = {?}", $id, $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);
return $ret;
}