From 5fe9815570ac4f6b1581783b50672eac06aec58b Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 20 Apr 2021 23:54:33 +0200 Subject: [PATCH 1/6] Update paymentok.php --- htdocs/public/payment/paymentok.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 1942635001f..112abe9b149 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -394,7 +394,7 @@ if ($ispaymentok) { // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) { - $result = $object->validate($user); + $result = $object->status == -2 ? -1 : object->validate($user); // if membre is excluded (status == -2) the new validation is not possible if ($result < 0 || empty($object->datevalid)) { $error++; $errmsg = $object->error; @@ -412,7 +412,13 @@ if ($ispaymentok) { $datesubend = null; if ($datesubscription && $defaultdelay && $defaultdelayunit) { - $datesubend = dol_time_plus_duree(dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit), -1, 'd'); + $datesubend = dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit); + // the new end date of subscription must be in futur + while (dol_time_plus_duree($datesubend, -1, 'd') < $now) { + $datesubend = dol_time_plus_duree($datesubend, $defaultdelay, $defaultdelayunit); + $datesubscription = dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit); + } + $datesubend = dol_time_plus_duree($datesubend, -1, 'd'); } $paymentdate = $now; From be9986f47bebb0586bc137e1460d008525c5777b Mon Sep 17 00:00:00 2001 From: daraelmin Date: Wed, 21 Apr 2021 21:23:14 +0200 Subject: [PATCH 2/6] Missing $ --- htdocs/public/payment/paymentok.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 112abe9b149..6bbfd1e3b31 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -394,7 +394,7 @@ if ($ispaymentok) { // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) { - $result = $object->status == -2 ? -1 : object->validate($user); // if membre is excluded (status == -2) the new validation is not possible + $result = $object->status == -2 ? -1 : $object->validate($user); // if membre is excluded (status == -2) the new validation is not possible if ($result < 0 || empty($object->datevalid)) { $error++; $errmsg = $object->error; From 25e3beb3eeb5e10bd15a243986e27359e99301ef Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 27 Apr 2021 01:55:51 +0200 Subject: [PATCH 3/6] $object::STATUS_RESILIATE --- htdocs/public/payment/paymentok.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 6bbfd1e3b31..ecd74445311 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -394,7 +394,7 @@ if ($ispaymentok) { // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) { - $result = $object->status == -2 ? -1 : $object->validate($user); // if membre is excluded (status == -2) the new validation is not possible + $result = $object->status == $object::STATUS_RESILIATE ? -1 : $object->validate($user); // if membre is excluded (status == -2) the new validation is not possible if ($result < 0 || empty($object->datevalid)) { $error++; $errmsg = $object->error; From db92de2a22874047cd444410ab3fd4d373ed6700 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 27 Apr 2021 02:36:47 +0200 Subject: [PATCH 4/6] Draft and resiliated member could (re)validate --- htdocs/public/payment/paymentok.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index ecd74445311..37efcbadbd0 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -394,7 +394,7 @@ if ($ispaymentok) { // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) { - $result = $object->status == $object::STATUS_RESILIATE ? -1 : $object->validate($user); // if membre is excluded (status == -2) the new validation is not possible + $result = $object->status < $object::STATUS_DRAFT ? -1 : $object->validate($user); // if membre is excluded (status == -2) the new validation is not possible if ($result < 0 || empty($object->datevalid)) { $error++; $errmsg = $object->error; From e6d2bad6e051d59b0ef6c4eb6b49fe4d958d77b5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Apr 2021 19:46:26 +0200 Subject: [PATCH 5/6] Update paymentok.php --- htdocs/public/payment/paymentok.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 37efcbadbd0..7918a5b6f55 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -394,7 +394,7 @@ if ($ispaymentok) { // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) { - $result = $object->status < $object::STATUS_DRAFT ? -1 : $object->validate($user); // if membre is excluded (status == -2) the new validation is not possible + $result = ($object->status == $object::STATUS_EXCLUDED) ? -1 : $object->validate($user); // if membre is excluded (status == -2) the new validation is not possible if ($result < 0 || empty($object->datevalid)) { $error++; $errmsg = $object->error; From 5b74676e549f45d05a0e57e1f57d1e5240a0feb4 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 27 Apr 2021 20:14:03 +0200 Subject: [PATCH 6/6] fix infinite loop --- htdocs/public/payment/paymentok.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 7918a5b6f55..10c27baf044 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -414,7 +414,7 @@ if ($ispaymentok) { if ($datesubscription && $defaultdelay && $defaultdelayunit) { $datesubend = dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit); // the new end date of subscription must be in futur - while (dol_time_plus_duree($datesubend, -1, 'd') < $now) { + while ($datesubend < $now) { $datesubend = dol_time_plus_duree($datesubend, $defaultdelay, $defaultdelayunit); $datesubscription = dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit); }