From ad3f31dc083555531004e4c246710e51cfe54577 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Sun, 19 May 2024 09:53:48 +0200 Subject: [PATCH] Changes for Galette 1.1 support Contributions amount are now stored core side --- .../Controllers/PaypalController.php | 9 +-------- lib/GalettePaypal/Paypal.php | 8 ++++---- templates/default/paypal_form.html.twig | 18 +++++++----------- templates/default/paypal_preferences.html.twig | 5 ++--- 4 files changed, 14 insertions(+), 26 deletions(-) diff --git a/lib/GalettePaypal/Controllers/PaypalController.php b/lib/GalettePaypal/Controllers/PaypalController.php index 3e3fb3e..d86ca98 100644 --- a/lib/GalettePaypal/Controllers/PaypalController.php +++ b/lib/GalettePaypal/Controllers/PaypalController.php @@ -90,14 +90,7 @@ public function form(Request $request, Response $response): Response ); } - if (!$paypal->areAmountsLoaded()) { - $this->flash->addMessageNow( - 'warning', - _T("Predefined amounts cannot be loaded, that is not a critical error.", "paypal") - ); - } - - // display page + // display page $this->view->render( $response, $this->getTemplate('paypal_form'), diff --git a/lib/GalettePaypal/Paypal.php b/lib/GalettePaypal/Paypal.php index b97b55f..ead7440 100644 --- a/lib/GalettePaypal/Paypal.php +++ b/lib/GalettePaypal/Paypal.php @@ -33,7 +33,6 @@ * * @author Johan Cwiklinski */ - class Paypal { public const TABLE = 'types_cotisation_prices'; @@ -98,7 +97,7 @@ public function load(): void } } $this->loaded = true; - $this->loadAmounts(); + $this->loadContributionsTypes(); } catch (\Exception $e) { Analog::log( '[' . get_class($this) . '] Cannot load paypal preferences |' . @@ -116,7 +115,7 @@ public function load(): void * * @return void */ - private function loadAmounts(): void + private function loadContributionsTypes(): void { $ct = new ContributionsTypes($this->zdb); $this->prices = $ct->getCompleteList(); @@ -142,7 +141,6 @@ private function loadAmounts(): void foreach ($results as $paypal) { if ($paypal['id_type_cotis'] == $k) { $_found = true; - $this->prices[$k]['amount'] = (double)$paypal['amount']; break; } } @@ -162,6 +160,8 @@ private function loadAmounts(): void } if (count($queries) > 0) { $this->newEntries($queries); + $this->loadContributionsTypes(); + return; } //amounts should be loaded here $this->amounts_loaded = true; diff --git a/templates/default/paypal_form.html.twig b/templates/default/paypal_form.html.twig index f6758cb..c04d18d 100644 --- a/templates/default/paypal_form.html.twig +++ b/templates/default/paypal_form.html.twig @@ -35,24 +35,20 @@
- {% if paypal.areAmountsLoaded() %} - {% if amounts|length > 0 %} + {% if amounts|length > 0 %} - {% for k, amount in amounts %} + {% for k, amount in amounts %} {% if loop.index0 != 0 %}
{% endif %} - {% endfor %} - {% else %} + {% endfor %} + {% else %} - {% endif %} - {% else %} - {{ _T("No predefined amounts have been configured yet.", "paypal") }} {% endif %}
@@ -96,7 +92,7 @@ {% endblock %} {% block javascripts %} - {% if paypal.isLoaded() and paypal.getId() is not null and paypal.areAmountsLoaded() %} + {% if paypal.isLoaded() and paypal.getId() is not null %}