From 6cc7ad024e366b8292ec68b4c395c5c8758e78fa Mon Sep 17 00:00:00 2001 From: Daniel Subiabre Date: Tue, 16 Jan 2024 12:09:16 +0100 Subject: [PATCH 1/2] Allow to filter backer invests by subscription based payment methods --- .../Controller/Dashboard/ProjectDashboardController.php | 6 ++++++ src/Goteo/Model/Invest.php | 8 ++++++++ translations/ca/dashboard.yml | 1 + translations/en/dashboard.yml | 1 + translations/es/dashboard.yml | 1 + 5 files changed, 17 insertions(+) diff --git a/src/Goteo/Controller/Dashboard/ProjectDashboardController.php b/src/Goteo/Controller/Dashboard/ProjectDashboardController.php index 990cc7cbce..448a5f379c 100644 --- a/src/Goteo/Controller/Dashboard/ProjectDashboardController.php +++ b/src/Goteo/Controller/Dashboard/ProjectDashboardController.php @@ -900,10 +900,16 @@ public static function getInvestFilters(Project $project, $filter = []): array foreach($project->getIndividualRewards() as $reward) { $filters['reward'][$reward->id] = $reward->getTitle(); } + if($project->getCall()) { $filters['others']['drop'] = Text::Get('dashboard-project-filter-by-drop'); $filters['others']['nondrop'] = Text::Get('dashboard-project-filter-by-nondrop'); } + + if ($project->isPermanent()) { + $filters['others']['from_subscription'] = Text::get('dashboard-project-filter-by-subscription'); + } + $status = [ Invest::STATUS_CHARGED, Invest::STATUS_PAID, diff --git a/src/Goteo/Model/Invest.php b/src/Goteo/Model/Invest.php index 92666314eb..dc6651cb38 100644 --- a/src/Goteo/Model/Invest.php +++ b/src/Goteo/Model/Invest.php @@ -19,6 +19,7 @@ use Goteo\Library\Text; use Goteo\Model\Invest\InvestLocation; use Goteo\Model\Project\Reward; +use Goteo\Payment\Method\StripeSubscriptionPaymentMethod; use Goteo\Payment\Payment; use Goteo\Repository\InvestOriginRepository; @@ -492,6 +493,13 @@ public static function getSQLFilter($filters = []) { $sqlFilter[] = "invest.resign = 0"; $sqlFilter[] = "invest.campaign = 0"; break; + case 'from_subscription': + $values[':subscription_methods'] = implode(',', [ + StripeSubscriptionPaymentMethod::PAYMENT_METHOD_ID + ]); + + $sqlFilter[] = "invest.method IN (:subscription_methods)"; + break; } } diff --git a/translations/ca/dashboard.yml b/translations/ca/dashboard.yml index 592f68ad50..b5c5e2b3af 100644 --- a/translations/ca/dashboard.yml +++ b/translations/ca/dashboard.yml @@ -242,6 +242,7 @@ dashboard-project-filter-by-drop: 'Veure només les aportacions de matchfunding' dashboard-project-filter-by-nondrop: 'Amaga les aportacions de matchfunding' dashboard-project-filter-by-pending: 'Veure només les pendents' dashboard-project-filter-by-fulfilled: 'Veure només les completades' +dashboard-project-filter-by-subscription: 'Veure només les aportacions des de suscripcions' dashboard-project-no-invests: 'No hi ha aportacions per a aquest criteri de cerca' dashboard-new-message-to-donors: 'Nou missatge als cofinançadors' dashboard-message-donors-reward: 'Cofinançadors amb la recompensa %s' diff --git a/translations/en/dashboard.yml b/translations/en/dashboard.yml index 43d50d5737..01b0ea75a9 100644 --- a/translations/en/dashboard.yml +++ b/translations/en/dashboard.yml @@ -241,6 +241,7 @@ dashboard-project-filter-by-drop: 'Show only matchfunding donations' dashboard-project-filter-by-nondrop: 'Hide matchfunding donations' dashboard-project-filter-by-pending: 'Show only pending' dashboard-project-filter-by-fulfilled: 'Show only completed' +dashboard-project-filter-by-subscription: 'Show only donations from subscriptions' dashboard-project-no-invests: 'No entries for the current search criteria' dashboard-new-message-to-donors: 'New message to donors' dashboard-message-donors-reward: 'Donors with the reward %s' diff --git a/translations/es/dashboard.yml b/translations/es/dashboard.yml index e433de0543..9fd4736a5f 100644 --- a/translations/es/dashboard.yml +++ b/translations/es/dashboard.yml @@ -243,6 +243,7 @@ dashboard-project-filter-by-drop: 'Ver sólo aportes de matchfunding' dashboard-project-filter-by-nondrop: 'Esconder aportes de matchfunding' dashboard-project-filter-by-pending: 'Ver sólo las pendientes' dashboard-project-filter-by-fulfilled: 'Ver sólo las completadas' +dashboard-project-filter-by-subscription: 'Ver sólo aportes desde subscripciones' dashboard-project-no-invests: 'No hay aportes para este criterio de búsqueda' dashboard-new-message-to-donors: 'Nuevo mensaje a cofinanciadores' dashboard-message-donors-reward: 'Los cofinanciadores con la recompensa %s' From 7088d4d11033e218036b3526f8192c3572bd3dcd Mon Sep 17 00:00:00 2001 From: Daniel Subiabre Date: Thu, 18 Jan 2024 17:48:51 +0100 Subject: [PATCH 2/2] Remove 'subscription_methods' filter --- .../Controller/Dashboard/ProjectDashboardController.php | 7 +++++++ src/Goteo/Model/Invest.php | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Goteo/Controller/Dashboard/ProjectDashboardController.php b/src/Goteo/Controller/Dashboard/ProjectDashboardController.php index 448a5f379c..46b7aa479f 100644 --- a/src/Goteo/Controller/Dashboard/ProjectDashboardController.php +++ b/src/Goteo/Controller/Dashboard/ProjectDashboardController.php @@ -49,6 +49,7 @@ use Goteo\Model\Project\Support; use Goteo\Model\Stories; use Goteo\Model\User; +use Goteo\Payment\Method\StripeSubscriptionPaymentMethod; use Goteo\Util\Form\Type\SubmitType; use Goteo\Util\Form\Type\TextareaType; use Goteo\Util\Form\Type\TextType; @@ -925,6 +926,12 @@ public static function getInvestFilters(Project $project, $filter = []): array } if(array_key_exists($filter['others'], $filters['others'])) { $filter_by['types'] = $filter['others']; + + if($filter['others']['from_subscription']) { + $filter_by['methods'] = [ + StripeSubscriptionPaymentMethod::PAYMENT_METHOD_ID + ]; + } } if($filter['query']) { $filter_by['name'] = $filter['query']; diff --git a/src/Goteo/Model/Invest.php b/src/Goteo/Model/Invest.php index dc6651cb38..8bc5f29e32 100644 --- a/src/Goteo/Model/Invest.php +++ b/src/Goteo/Model/Invest.php @@ -493,13 +493,6 @@ public static function getSQLFilter($filters = []) { $sqlFilter[] = "invest.resign = 0"; $sqlFilter[] = "invest.campaign = 0"; break; - case 'from_subscription': - $values[':subscription_methods'] = implode(',', [ - StripeSubscriptionPaymentMethod::PAYMENT_METHOD_ID - ]); - - $sqlFilter[] = "invest.method IN (:subscription_methods)"; - break; } }