From dd87478584d93c1aadb909a65d4123fa1d8bb27e Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 8 Apr 2021 15:03:38 -0400 Subject: [PATCH] SearchKit - Make contribution tasks available as actions So far there is only one action (Send Receipt) available, and it only works for contributions with status=Completed. SearchKit doesn't yet respect that limitation and shows the action for every record. --- CRM/Contribute/Task.php | 7 ++++--- .../Action/SearchDisplay/GetSearchTasks.php | 20 +++++++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/CRM/Contribute/Task.php b/CRM/Contribute/Task.php index 01dad553a9..ffe0cab0c3 100644 --- a/CRM/Contribute/Task.php +++ b/CRM/Contribute/Task.php @@ -91,8 +91,9 @@ class CRM_Contribute_Task extends CRM_Core_Task { 'result' => FALSE, 'title_single_mode' => ts('Send Receipt'), 'name' => ts('Send Receipt'), - 'is_support_standalone' => TRUE, + 'url' => 'civicrm/contribute/task?reset=1&task=receipt', 'key' => 'receipt', + 'icon' => 'fa-envelope-o', 'filters' => ['contribution_status_id' => [CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed')]], 'is_single_mode' => TRUE, ], @@ -151,8 +152,8 @@ class CRM_Contribute_Task extends CRM_Core_Task { } } } - $tasks[$key]['url'] = 'civicrm/contribute/task'; - $tasks[$key]['qs'] = ['reset' => 1, 'id' => $row['contribution_id'], 'task' => $task['key']]; + $tasks[$key]['url'] = $task['url']; + $tasks[$key]['qs'] = ['id' => $row['contribution_id']]; $tasks[$key]['title'] = $task['title_single_mode'] ?? $task['title']; } return $tasks; diff --git a/ext/search/Civi/Api4/Action/SearchDisplay/GetSearchTasks.php b/ext/search/Civi/Api4/Action/SearchDisplay/GetSearchTasks.php index 4cd63717de..ff34da0f2d 100644 --- a/ext/search/Civi/Api4/Action/SearchDisplay/GetSearchTasks.php +++ b/ext/search/Civi/Api4/Action/SearchDisplay/GetSearchTasks.php @@ -41,7 +41,7 @@ class GetSearchTasks extends \Civi\Api4\Generic\AbstractAction { 'icon' => 'fa-file-excel-o', 'crmPopup' => [ 'path' => "'civicrm/export/standalone'", - 'query' => "{entity: '{$entity['name']}', id: ids.join(',')}", + 'query' => "{reset: 1, entity: '{$entity['name']}', id: ids.join(',')}", ], ]; } @@ -78,7 +78,23 @@ class GetSearchTasks extends \Civi\Api4\Generic\AbstractAction { 'icon' => $task['icon'] ?? 'fa-gear', 'crmPopup' => [ 'path' => "'{$task['url']}'", - 'query' => "{cids: ids.join(',')}", + 'query' => "{reset: 1, cids: ids.join(',')}", + ], + ]; + } + } + } + + if ($entity['name'] === 'Contribution') { + foreach (\CRM_Contribute_Task::tasks() as $id => $task) { + if (!empty($task['url'])) { + $tasks[] = [ + 'name' => 'contribution.' . $id, + 'title' => $task['title'], + 'icon' => $task['icon'] ?? 'fa-gear', + 'crmPopup' => [ + 'path' => "'{$task['url']}'", + 'query' => "{id: ids.join(',')}", ], ]; } -- 2.25.1