fix autocomplete for IE
[platal.git] / include / validations / paiements.inc.php
index 0a3a9e4..7e7f96b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
+ *  Copyright (C) 2003-2007 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -25,28 +25,29 @@ class PayReq extends Validate
 {
     // {{{ properties
     
-    var $titre;
-    var $site;
+    public $titre;
+    public $site;
 
-    var $montant;
-    var $montant_min;
-    var $montant_max;
+    public $montant;
+    public $montant_min;
+    public $montant_max;
 
-    var $msg_reponse;
-    var $asso_id;
-    var $asso;
-    var $evt;
-    var $evt_intitule;
+    public $msg_reponse;
+    public $asso_id;
+    public $asso;
+    public $evt;
+    public $evt_intitule;
 
-    var $rules = "Laisser la validation à un trésorier";
+    public $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)
+
+    public function __construct($_uid, $_intitule, $_site, $_montant, $_msg,
+                                $_montantmin=0, $_montantmax=999, $_asso_id = 0,
+                                $_evt = 0, $_stamp=0)
     {
-        global $globals;
-        $this->Validate($_uid, false, 'paiements', $_stamp);
-       
+        parent::__construct($_uid, false, 'paiements', $_stamp);
+
         $this->titre        = $_intitule;
         $this->site         = $_site;
         $this->msg_reponse  = $_msg;
@@ -67,56 +68,100 @@ class PayReq extends Validate
     }
 
     // }}}
-  // {{{ function same_event()
-    function same_event($evt, $asso_id)
+    // {{{ function same_event()
+
+    static public 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()
+  
+    // }}}
+    // {{{ function accept()
+
+    // check the message
+    public function accept()
+    {
+        // 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");
+            return false;
+        }
+        if (!preg_match('/<montant>/', $this->msg_reponse)) {
+            $this->trig("Le demande de paiement ne contient pas la balise obligatoire &lt;montant&gt;");
+            return false;
+        }
+        return true;
+    }
+
+    // }}}    
+    // {{{ function submit() 
+  
+    // supprime les demandes de paiments pour le meme evenement
+    public function submit()
     {
-        global $globals;
         if ($this->evt)
         {
             XDB::execute('DELETE FROM requests WHERE type={?} AND data LIKE {?}', 'paiements', PayReq::same_event($this->evt, $this->asso_id));
         }
-        Validate::submit();
+        parent::submit();
     }
     // }}}
       // {{{ function formu()
 
-    function formu()
-    { return 'include/form.valid.paiements.tpl'; }
+    public function formu()
+    {
+        return 'include/form.valid.paiements.tpl';
+    }
+
+    // }}}
+    // {{{ function editor()
+
+    public function editor()
+    {
+        return 'include/form.valid.edit-paiements.tpl';
+    }
+
+    // }}}
+    // {{{ function handle_editor()
+
+    protected function handle_editor()
+    {
+        $this->titre       = Env::v('pay_titre');
+        $this->site        = Env::v('pay_site');
+        $this->montant     = Env::i('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');
+        return true;
+    }
 
     // }}}
     // {{{ function _mail_subj
 
-    function _mail_subj()
+    protected function _mail_subj()
     {
-        return "[Polytechnique.org/Paiments] Demande de création de paiement {$this->titre}";
+        return "[Polytechnique.org/Paiments] Demande de création de paiement {$this->titre}";
     }
 
     // }}}
     // {{{ function _mail_body
 
-    function _mail_body($isok)
+    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 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":"");
         } else {
-            return "  La demande que tu avais faite pour le paiement de {$this->intitule} a été refusée.";
+            return "  La demande que tu avais faite pour le paiement de {$this->intitule} a été refusée.";
         }
     }
 
     // }}}
     // {{{ function commit()
     
-    function commit()
+    public function commit()
     {
         global $globals;
         $res = XDB::query("SELECT MAX(id) FROM paiement.paiements");
@@ -140,5 +185,5 @@ class PayReq extends Validate
 
 // }}}
 
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>