From 69fffc4bfc98948ba2357c3d0b1599e90190965a Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sun, 14 Feb 2010 14:45:10 +0100 Subject: [PATCH] Move paiement db in x4dat (tables payment*). Signed-off-by: Florent Bruneau --- include/validations/paiements.inc.php | 4 ++-- modules/payment.php | 30 ++++++++++++------------- templates/payment/index.tpl | 4 ++-- upgrade/account/07_payment.sql | 41 +++++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 19 deletions(-) create mode 100644 upgrade/account/07_payment.sql diff --git a/include/validations/paiements.inc.php b/include/validations/paiements.inc.php index 0942529..6c13c31 100644 --- a/include/validations/paiements.inc.php +++ b/include/validations/paiements.inc.php @@ -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 ( {?}, {?}, {?}, '', {?}, {?}, {?}, {?}, {?}, {?} ) diff --git a/modules/payment.php b/modules/payment.php index 250988a..d15281d 100644 --- a/modules/payment.php +++ b/modules/payment.php @@ -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); diff --git a/templates/payment/index.tpl b/templates/payment/index.tpl index a8c3a8d..be1474c 100644 --- a/templates/payment/index.tpl +++ b/templates/payment/index.tpl @@ -129,7 +129,7 @@ function payment_submit(form) Méthode @@ -158,7 +158,7 @@ function payment_submit(form) {iterate from=$transactions item=t} {$t.timestamp|date_format} - {$t.montant|replace:'EUR':'€'} + {$t.amount|replace:'EUR':'€'} {/iterate} diff --git a/upgrade/account/07_payment.sql b/upgrade/account/07_payment.sql new file mode 100644 index 0000000..52acbb0 --- /dev/null +++ b/upgrade/account/07_payment.sql @@ -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: -- 2.1.4