fleches plus petites pour #484
[platal.git] / modules / payment.php
index 2cd1c2d..ff5c432 100644 (file)
@@ -77,8 +77,9 @@ class PaymentModule extends PLModule
     {
         return array(
             'payment'               => $this->make_hook('payment', AUTH_MDP),
-            'payment/cyber_return'  => $this->make_hook('cyber_return',  AUTH_PUB),
-            'payment/paypal_return' => $this->make_hook('paypal_return',  AUTH_PUB),
+            'payment/cyber_return'  => $this->make_hook('cyber_return',  AUTH_PUBLIC),
+            'payment/paypal_return' => $this->make_hook('paypal_return',  AUTH_PUBLIC),
+            'admin/payments'        => $this->make_hook('admin', AUTH_MDP, 'admin'),
         );
     }
 
@@ -87,21 +88,21 @@ class PaymentModule extends PLModule
         global $globals;
 
         require_once 'profil.func.inc.php' ;
-        require_once 'money.inc.php' ;
+        require_once dirname(__FILE__).'/payment/money.inc.php' ;
 
         $page->changeTpl('payment/index.tpl');
         $page->assign('xorg_title','Polytechnique.org - Télépaiements');
 
         // initialisation
-        $op   = Env::get('op', 'select');
-        $meth = new PayMethod(Env::getInt('methode', -1));
+        $op   = Env::v('op', 'select');
+        $meth = new PayMethod(Env::i('methode', -1));
         $pay  = new Payment($ref);
 
         if($pay->flags->hasflag('old')){
             $page->trig("La transaction selectionnée est périmée.");
             $pay = new Payment();
         }
-        $val = Env::get('montant') != 0 ? Env::get('montant') : $pay->montant_def;
+        $val = Env::v('montant') != 0 ? Env::v('montant') : $pay->montant_def;
 
         if (($e = $pay->check($val)) !== true) {
             $page->trig($e);
@@ -115,7 +116,7 @@ class PaymentModule extends PLModule
                                               FROM  paiement.transactions
                                              WHERE  uid = {?} AND ref = {?}
                                           ORDER BY  timestamp DESC",
-                                            Session::getInt('uid', -1), $ref);
+                                            S::v('uid', -1), $ref);
 
             if ($res->total()) $page->assign('transactions', $res);
         }
@@ -314,6 +315,23 @@ class PaymentModule extends PLModule
         $page->assign('texte', $conf_text);
         $page->assign('erreur', $erreur);
     }
+    function handler_admin(&$page, $action = 'list', $id = null) {
+        $page->assign('xorg_title','Polytechnique.org - Administration - Paiements');
+        $page->assign('title', 'Gestion des télépaiements');
+        $table_editor = new PLTableEditor('admin/payments','paiement.paiements','id');
+        $table_editor->add_join_table('paiement.transactions','ref',true);
+        $table_editor->add_sort_field('flags');
+        $table_editor->add_sort_field('id', true, true);
+        $table_editor->on_delete("UPDATE paiement.paiements SET flags = 'old' WHERE id = {?}", "Le paiement a été archivé");
+        $table_editor->describe('text','intitulé',true);
+        $table_editor->describe('url','site web',false);
+        $table_editor->describe('montant_def','montant par défaut',false);
+        $table_editor->describe('montant_min','montant minimum',false);
+        $table_editor->describe('montant_max','montant maximum',false);
+        $table_editor->describe('mail','email contact',true);
+        $table_editor->describe('confirmation','message confirmation',false);
+        $table_editor->apply($page, $action, $id);
+    }  
 }
 
 ?>