Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AdminUI - Convert "Administer Payment Processors" to SearchKit #24759

Merged
merged 2 commits into from
Oct 18, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
AdminUI - Convert "Administer Payment Processors" to SearchKit form
  • Loading branch information
colemanw committed Oct 18, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 497f3bd7ac284c1a3b26e0a918d5116e52fd499e
9 changes: 8 additions & 1 deletion CRM/Admin/Form/PaymentProcessor.php
Original file line number Diff line number Diff line change
@@ -106,6 +106,9 @@ public function setDeleteMessage() {
* @throws \CRM_Core_Exception
*/
public function preProcess() {
CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0);
$this->set('BAOName', 'CRM_Financial_BAO_PaymentProcessor');

parent::preProcess();

$this->setPaymentProcessorTypeID();
@@ -507,7 +510,11 @@ protected function setPaymentProcessorTypeID(): void {
$this->set('pp', $this->_paymentProcessorType);
}
else {
$this->_paymentProcessorType = CRM_Utils_Request::retrieve('pp', 'String', $this, TRUE, NULL);
$paymentProcessorTypes = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_PaymentProcessor', 'payment_processor_type_id', array(
'labelColumn' => 'name',
'flip' => 1,
));
$this->_paymentProcessorType = CRM_Utils_Request::retrieve('pp', 'String', $this, FALSE, $paymentProcessorTypes['PayPal']);
}
}

38 changes: 16 additions & 22 deletions CRM/Admin/Page/PaymentProcessor.php
Original file line number Diff line number Diff line change
@@ -47,30 +47,30 @@ public function getBAOName() {
*/
public function &links() {
if (!(self::$_links)) {
self::$_links = array(
CRM_Core_Action::UPDATE => array(
self::$_links = [
CRM_Core_Action::UPDATE => [
'name' => ts('Edit'),
'url' => 'civicrm/admin/paymentProcessor',
'url' => 'civicrm/admin/paymentProcessor/edit',
'qs' => 'action=update&id=%%id%%&reset=1',
'title' => ts('Edit Payment Processor'),
),
CRM_Core_Action::DISABLE => array(
],
CRM_Core_Action::DISABLE => [
'name' => ts('Disable'),
'ref' => 'crm-enable-disable',
'title' => ts('Disable Payment Processor'),
),
CRM_Core_Action::ENABLE => array(
],
CRM_Core_Action::ENABLE => [
'name' => ts('Enable'),
'ref' => 'crm-enable-disable',
'title' => ts('Enable Payment Processor'),
),
CRM_Core_Action::DELETE => array(
],
CRM_Core_Action::DELETE => [
'name' => ts('Delete'),
'url' => 'civicrm/admin/paymentProcessor',
'url' => 'civicrm/admin/paymentProcessor/edit',
'qs' => 'action=delete&id=%%id%%',
'title' => ts('Delete Payment Processor'),
),
);
],
];
}
return self::$_links;
}
@@ -85,20 +85,14 @@ public function &links() {
public function run() {
// set title and breadcrumb
CRM_Utils_System::setTitle(ts('Settings - Payment Processor'));
//CRM-15546
$paymentProcessorTypes = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_PaymentProcessor', 'payment_processor_type_id', array(
'labelColumn' => 'name',
'flip' => 1,
));
$this->assign('defaultPaymentProcessorType', $paymentProcessorTypes['PayPal']);
$breadCrumb = array(
array(
$breadCrumb = [
[
'title' => ts('Administration'),
'url' => CRM_Utils_System::url('civicrm/admin',
'reset=1'
),
),
);
],
];
CRM_Utils_System::appendBreadCrumb($breadCrumb);
return parent::run();
}
4 changes: 4 additions & 0 deletions CRM/Core/xml/Menu/Admin.xml
Original file line number Diff line number Diff line change
@@ -455,6 +455,10 @@
<weight>30</weight>
<access_arguments>administer payment processors</access_arguments>
</item>
<item>
<path>civicrm/admin/paymentProcessor/edit</path>
<page_callback>CRM_Admin_Form_PaymentProcessor</page_callback>
</item>
<item>
<path>civicrm/admin/setting/mapping</path>
<title>Mapping and Geocoding</title>
13 changes: 12 additions & 1 deletion CRM/Financial/DAO/PaymentProcessor.php
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Financial/PaymentProcessor.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:1046252e760c45a6fddafcf26931ace2)
* (GenCodeChecksum:2f84f05644f9b359fd9c70e8ebe3363a)
*/

/**
@@ -31,6 +31,17 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
*/
public static $_log = FALSE;

/**
* Paths for accessing this entity in the UI.
*
* @var string[]
*/
protected static $_paths = [
'add' => 'civicrm/admin/paymentProcessor/edit?action=add&reset=1',
'update' => 'civicrm/admin/paymentProcessor/edit?action=update&id=[id]&reset=1',
'delete' => 'civicrm/admin/paymentProcessor/edit?action=delete&id=[id]&reset=1',
];

/**
* Payment Processor ID
*
1 change: 0 additions & 1 deletion Civi/Api4/PaymentProcessor.php
Original file line number Diff line number Diff line change
@@ -15,7 +15,6 @@
*
* @see https://docs.civicrm.org/sysadmin/en/latest/setup/payment-processors/
*
* @searchable none
* @since 5.23
* @package Civi\Api4
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div af-fieldset="">
<div class="af-markup">
<div class="help">
{{:: ts('You can configure one or more Payment Processors for your CiviCRM installation. You must then assign an active Payment Processor to each Online Contribution Page and each paid Event.') }}
<a href="https://docs.civicrm.org/user/en/latest/contributions/payment-processors/" target="_blank" class="crm-doc-link no-popup">{{:: ts('Learn more...') }}</a>
</div>
</div>
<crm-search-display-table search-name="Administer_Payment_Processors" display-name="Administer_Payment_Processors_Table"></crm-search-display-table>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "search",
"title": "Administer Payment Processors",
"icon": "fa-list-alt",
"server_route": "civicrm/admin/paymentProcessor",
"permission": "administer payment processors"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
<?php
use CRM_CivicrmAdminUi_ExtensionUtil as E;

return [
[
'name' => 'SavedSearch_Administer_Payment_Processors',
'entity' => 'SavedSearch',
'cleanup' => 'always',
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
'name' => 'Administer_Payment_Processors',
'label' => E::ts('Administer Payment Processors'),
'api_entity' => 'PaymentProcessor',
'api_params' => [
'version' => 4,
'select' => [
'id',
'name',
'title',
'description',
'payment_processor_type_id:label',
'is_active',
'is_default',
'PaymentProcessor_EntityFinancialAccount_FinancialAccount_01.name',
],
'orderBy' => [],
'where' => [
[
'is_test',
'=',
FALSE,
],
[
'domain_id:name',
'=',
'current_domain',
],
],
'groupBy' => [],
'join' => [
[
'FinancialAccount AS PaymentProcessor_EntityFinancialAccount_FinancialAccount_01',
'LEFT',
'EntityFinancialAccount',
[
'id',
'=',
'PaymentProcessor_EntityFinancialAccount_FinancialAccount_01.entity_id',
],
[
'PaymentProcessor_EntityFinancialAccount_FinancialAccount_01.entity_table',
'=',
"'civicrm_payment_processor'",
],
],
],
'having' => [],
],
'expires_date' => NULL,
'description' => NULL,
],
],
],
[
'name' => 'SavedSearch_Administer_Payment_Processors_SearchDisplay_Administer_Payment_Processors_Table',
'entity' => 'SearchDisplay',
'cleanup' => 'always',
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
'name' => 'Administer_Payment_Processors_Table',
'label' => E::ts('Administer Payment Processors'),
'saved_search_id.name' => 'Administer_Payment_Processors',
'type' => 'table',
'settings' => [
'actions' => FALSE,
'limit' => 50,
'classes' => [
'table',
'table-striped',
],
'pager' => [],
'placeholder' => 5,
'sort' => [],
'columns' => [
[
'type' => 'field',
'key' => 'id',
'dataType' => 'Integer',
'label' => E::ts('ID'),
'sortable' => TRUE,
],
[
'type' => 'field',
'key' => 'name',
'dataType' => 'String',
'label' => E::ts('Name'),
'sortable' => TRUE,
],
[
'type' => 'field',
'key' => 'title',
'dataType' => 'String',
'label' => E::ts('Title'),
'sortable' => TRUE,
'editable' => TRUE,
],
[
'type' => 'field',
'key' => 'description',
'dataType' => 'String',
'label' => E::ts('Description'),
'sortable' => TRUE,
'editable' => TRUE,
],
[
'type' => 'field',
'key' => 'payment_processor_type_id:label',
'dataType' => 'Integer',
'label' => E::ts('Type'),
'sortable' => TRUE,
],
[
'type' => 'field',
'key' => 'PaymentProcessor_EntityFinancialAccount_FinancialAccount_01.name',
'dataType' => 'String',
'label' => E::ts('Financial Account'),
'sortable' => TRUE,
],
[
'type' => 'field',
'key' => 'is_active',
'dataType' => 'Boolean',
'label' => E::ts('Enabled'),
'sortable' => TRUE,
'editable' => TRUE,
],
[
'type' => 'field',
'key' => 'is_default',
'dataType' => 'Boolean',
'label' => E::ts('Default'),
'sortable' => TRUE,
'rewrite' => ' ',
'icons' => [
[
'icon' => 'fa-check-square-o',
'side' => 'left',
'if' => [
'is_default',
'=',
TRUE,
],
],
],
],
[
'size' => 'btn-xs',
'links' => [
[
'entity' => 'PaymentProcessor',
'action' => 'update',
'join' => '',
'target' => 'crm-popup',
'icon' => 'fa-pencil',
'text' => E::ts('Edit'),
'style' => 'default',
'path' => '',
'condition' => [],
],
[
'entity' => 'PaymentProcessor',
'action' => 'delete',
'join' => '',
'target' => 'crm-popup',
'icon' => 'fa-trash',
'text' => E::ts('Delete'),
'style' => 'danger',
'path' => '',
'condition' => [],
],
],
'type' => 'buttons',
'alignment' => 'text-right',
],
],
'addButton' => [
'path' => 'civicrm/admin/paymentProcessor/edit?action=add&reset=1',
'text' => E::ts('Add Payment Processor'),
'icon' => 'fa-plus',
],
'cssRules' => [
[
'disabled',
'is_active',
'=',
FALSE,
],
],
],
'acl_bypass' => FALSE,
],
],
],
];
4 changes: 2 additions & 2 deletions templates/CRM/Admin/Page/PaymentProcessor.tpl
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@

{if $action ne 1 and $action ne 2}
<div class="action-link">
{crmButton q="action=add&reset=1&pp=$defaultPaymentProcessorType" id="newPaymentProcessor" icon="plus-circle"}{ts}Add Payment Processor{/ts}{/crmButton}
{crmButton p='civicrm/admin/paymentProcessor/edit' q="action=add&reset=1" id="newPaymentProcessor" icon="plus-circle"}{ts}Add Payment Processor{/ts}{/crmButton}
</div>
{/if}
</div>
@@ -62,7 +62,7 @@
{ts}There are no Payment Processors entered.{/ts}
</div>
<div class="action-link">
{crmButton p='civicrm/admin/paymentProcessor' q="action=add&reset=1&pp=$defaultPaymentProcessorType" id="newPaymentProcessor" icon="plus-circle"}{ts}Add Payment Processor{/ts}{/crmButton}
{crmButton p='civicrm/admin/paymentProcessor/edit' q="action=add&reset=1" id="newPaymentProcessor" icon="plus-circle"}{ts}Add Payment Processor{/ts}{/crmButton}
</div>
{/if}
</div>
5 changes: 5 additions & 0 deletions xml/schema/Financial/PaymentProcessor.xml
Original file line number Diff line number Diff line change
@@ -6,6 +6,11 @@
<name>civicrm_payment_processor</name>
<add>1.8</add>
<component>CiviContribute</component>
<paths>
<add>civicrm/admin/paymentProcessor/edit?action=add&amp;reset=1</add>
<update>civicrm/admin/paymentProcessor/edit?action=update&amp;id=[id]&amp;reset=1</update>
<delete>civicrm/admin/paymentProcessor/edit?action=delete&amp;id=[id]&amp;reset=1</delete>
</paths>
<field>
<name>id</name>
<title>Payment Processor ID</title>