Move paiement db in x4dat (tables payment*).
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 14 Feb 2010 13:45:10 +0000 (14:45 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 14 Feb 2010 13:45:10 +0000 (14:45 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
include/validations/paiements.inc.php
modules/payment.php
templates/payment/index.tpl
upgrade/account/07_payment.sql [new file with mode: 0644]

index 0942529..6c13c31 100644 (file)
@@ -165,9 +165,9 @@ Si le télépaiement n'est pas lié à un groupe ou supérieur à 51 euros, lais
 
     public function commit()
     {
-        $res = XDB::query("SELECT MAX(id) FROM #paiement#.paiements");
+        $res = XDB::query("SELECT MAX(id) FROM payments");
         $id = $res->fetchOneCell()+1;
-        $ret = XDB::execute("INSERT INTO #paiement#.paiements VALUES
+        $ret = XDB::execute("INSERT INTO payments VALUES
             ( {?}, {?}, {?}, '',
             {?}, {?}, {?},
             {?}, {?}, {?} )
index 250988a..d15281d 100644 (file)
@@ -112,7 +112,7 @@ class PaymentModule extends PLModule
                 return PL_NOT_FOUND;
             }
             $res = XDB::query("SELECT asso_id
-                                 FROM #paiement#.paiements
+                                 FROM payments
                                 WHERE asso_id = {?} AND id = {?}",
                               $globals->asso('id'), $ref);
             if (!$res->numRows()) {
@@ -141,8 +141,8 @@ class PaymentModule extends PLModule
             $pay->init($val, $meth);
             $pay->prepareform($pay);
         } else {
-            $res = XDB::iterator("SELECT  timestamp, montant
-                                    FROM  #paiement#.transactions
+            $res = XDB::iterator("SELECT  timestamp, amount
+                                    FROM  payment_transactions
                                    WHERE  uid = {?} AND ref = {?}
                                 ORDER BY  timestamp DESC",
                                  S::v('uid', -1), $ref);
@@ -193,7 +193,7 @@ class PaymentModule extends PLModule
 
         echo ($ref = $matches[1]);
         $res = XDB::query("SELECT  mail, text, confirmation
-                             FROM  #paiement#.paiements
+                             FROM  payments
                             WHERE  id={?}", $ref);
         if (!list($conf_mail, $conf_title, $conf_text) = $res->fetchOneRow()) {
             cb_erreur("référence de commande inconnue");
@@ -202,8 +202,8 @@ class PaymentModule extends PLModule
         /* on extrait le code de retour */
         if ($champ906 != "0000") {
             $res = XDB::query('SELECT  rcb.text, c.id, c.text
-                                 FROM  #paiement#.codeRCB AS rcb
-                            LEFT JOIN  #paiement#.codeC   AS c ON (rcb.codeC = c.id)
+                                 FROM  payment_codeRCB AS rcb
+                            LEFT JOIN  payment_codeC   AS c ON (rcb.codeC = c.id)
                                 WHERE  rcb.id = {?}', $champ906);
             if (list($rcb_text, $c_id, $c_text) = $res->fetchOneRow()) {
                 cb_erreur("erreur lors du paiement : $c_text ($c_id)");
@@ -213,7 +213,7 @@ class PaymentModule extends PLModule
         }
 
         /* on fait l'insertion en base de donnees */
-        XDB::execute("INSERT INTO  #paiement#.transactions (id, uid, ref, fullref, montant, cle, comment)
+        XDB::execute("INSERT INTO  payment_transactions (id, uid, ref, fullref, amount, pkey, comment)
                            VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?})",
                      $champ901, $user->id(), $ref, $champ200, $montant, $champ905, Env::v('comment'));
 
@@ -300,14 +300,14 @@ class PaymentModule extends PLModule
 
         $ref = $matches[1];
         $res = XDB::query("SELECT  mail, text, confirmation
-                             FROM  #paiement#.paiements
+                             FROM  payments
                             WHERE  id = {?}", $ref);
         if (!list($conf_mail,$conf_title,$conf_text) = $res->fetchOneRow()) {
             paypal_erreur("référence de commande inconnue");
         }
 
         /* on fait l'insertion en base de donnees */
-        XDB::execute("INSERT INTO  #paiement#.transactions (id, uid, ref, fullref, montant, cle, comment)
+        XDB::execute("INSERT INTO  payment_transactions (id, uid, ref, fullref, amount, pkey, comment)
                            VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?})",
                     $no_transaction, $user->id(), $ref, $fullref, $montant, $clef, Env::v('comment'));
 
@@ -442,16 +442,16 @@ class PaymentModule extends PLModule
     function handler_admin(&$page, $action = 'list', $id = null) {
         $page->setTitle('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 = new PLTableEditor('admin/payments','payments','id');
+        $table_editor->add_join_table('payment_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->on_delete("UPDATE payments 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('amount_def','montant par défaut',false);
+        $table_editor->describe('amount_min','montant minimum',false);
+        $table_editor->describe('amount_max','montant maximum',false);
         $table_editor->describe('mail','email contact',true);
         $table_editor->describe('confirmation','message confirmation',false);
         $table_editor->apply($page, $action, $id);
index a8c3a8d..be1474c 100644 (file)
@@ -129,7 +129,7 @@ function payment_submit(form)
       <td>Méthode</td>
       <td>
         <select name="methode">
-          {select_db_table table="#paiement#.methodes" valeur=$smarty.request.methode}
+          {select_db_table table="payment_methods" valeur=$smarty.request.methode}
         </select>
       </td>
     </tr>
@@ -158,7 +158,7 @@ function payment_submit(form)
 {iterate from=$transactions item=t}
   <tr class="{cycle values="pair,impair"}">
     <td>{$t.timestamp|date_format}</td>
-    <td>{$t.montant|replace:'EUR':'&euro;'}</td>
+    <td>{$t.amount|replace:'EUR':'&euro;'}</td>
   </tr>
 {/iterate}
 </table>
diff --git a/upgrade/account/07_payment.sql b/upgrade/account/07_payment.sql
new file mode 100644 (file)
index 0000000..52acbb0
--- /dev/null
@@ -0,0 +1,41 @@
+CREATE TABLE  payment_codeC
+        LIKE  paiement.codeC;
+ INSERT INTO  payment_codeC
+      SELECT  *
+        FROM  paiement.codeC;
+
+CREATE TABLE  payment_codeRCB
+        LIKE  paiement.codeRCB;
+ INSERT INTO  payment_codeRCB
+      SELECT  *
+        FROM  paiement.codeRCB;
+
+CREATE TABLE  payment_methods
+        LIKE  paiement.methodes;
+ INSERT INTO  payment_methods
+      SELECT  *
+        FROM  paiement.methodes;
+
+CREATE TABLE  payments
+        LIKE  paiement.paiements;
+ INSERT INTO  payments
+      SELECT  *
+        FROM  paiement.paiements;
+
+CREATE TABLE  payment_transactions
+        LIKE  paiement.transactions;
+ INSERT INTO  payment_transactions
+      SELECT  *
+        FROM  paiement.transactions;
+
+# Conform to naming convention
+  ALTER TABLE  payments
+CHANGE COLUMN  montant_def amount_def DECIMAL(10,2) NOT NULL DEFAULT 0.00,
+CHANGE COLUMN  montant_min amount_min DECIMAL(10,2) NOT NULL DEFAULT 0.00,
+CHANGE COLUMN  montant_max amount_max DECIMAL(10,2) NOT NULL DEFAULT 0.00;
+
+  ALTER TABLE  payment_transactions
+CHANGE COLUMN  montant amount VARCHAR(15) NOT NULL DEFAULT '0.00',
+CHANGE COLUMN  cle pkey VARCHAR(5) NOT NULL;
+
+# vim:set ft=mysql: