From: Matthew Wire Date: Fri, 14 Aug 2020 15:33:28 +0000 (+0100) Subject: Move add/submit membership buttons to PHP level on membership tab X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a3ca6fe36ec7e8c077497a6da2b71bbf88d24fe0;p=civicrm-core.git Move add/submit membership buttons to PHP level on membership tab --- diff --git a/CRM/Member/Page/Tab.php b/CRM/Member/Page/Tab.php index ec2300d0ba..ef4d4551d5 100644 --- a/CRM/Member/Page/Tab.php +++ b/CRM/Member/Page/Tab.php @@ -48,6 +48,23 @@ class CRM_Member_Page_Tab extends CRM_Core_Page { $permissions = [CRM_Core_Permission::VIEW]; if (CRM_Core_Permission::check('edit memberships')) { $permissions[] = CRM_Core_Permission::EDIT; + $linkButtons['add_membership'] = [ + 'title' => ts('Add Membership'), + 'url' => 'civicrm/contact/view/membership', + 'qs' => "reset=1&action=add&cid={$this->_contactId}&context=membership", + 'icon' => 'fa-plus-circle', + 'accessKey' => 'N', + ]; + if ($this->_accessContribution && CRM_Core_Config::isEnabledBackOfficeCreditCardPayments()) { + $linkButtons['creditcard_membership'] = [ + 'title' => ts('Submit Credit Card Membership'), + 'url' => 'civicrm/contact/view/membership', + 'qs' => "reset=1&action=add&cid={$this->_contactId}&context=membership&mode=live", + 'icon' => 'fa-credit-card', + 'accessKey' => 'C', + ]; + } + $this->assign('linkButtons', $linkButtons ?? []); } if (CRM_Core_Permission::check('delete in CiviMember')) { $permissions[] = CRM_Core_Permission::DELETE; @@ -317,10 +334,7 @@ class CRM_Member_Page_Tab extends CRM_Core_Page { $this->preProcess(); // check if we can process credit card membership - $newCredit = CRM_Core_Config::isEnabledBackOfficeCreditCardPayments(); - $this->assign('newCredit', $newCredit); - - if ($newCredit) { + if (CRM_Core_Config::isEnabledBackOfficeCreditCardPayments()) { $this->_isPaymentProcessor = TRUE; } else { diff --git a/templates/CRM/Member/Page/Tab.tpl b/templates/CRM/Member/Page/Tab.tpl index 249634931c..7e807c9482 100644 --- a/templates/CRM/Member/Page/Tab.tpl +++ b/templates/CRM/Member/Page/Tab.tpl @@ -15,31 +15,20 @@ {elseif $action eq 32768} {* renew *} {include file="CRM/Member/Form/MembershipRenewal.tpl"} {elseif $action eq 16} {* Browse memberships for a contact *} - {if $permission EQ 'edit'} - {capture assign=newURL}{crmURL p="civicrm/contact/view/membership" q="reset=1&action=add&cid=`$contactId`&context=membership"}{/capture}{/if} - {if $action ne 1 and $action ne 2 and $permission EQ 'edit'}
- {if $permission EQ 'edit'} - {capture assign="link"}class="action-item" href="{$newURL}"{/capture} - {ts 1=$link}Click Add Membership to record a new membership.{/ts} - {if $newCredit} - {capture assign=newCreditURL}{crmURL p="civicrm/contact/view/membership" q="reset=1&action=add&cid=`$contactId`&context=membership&mode=live"}{/capture} - {capture assign="link"}class="action-item" href="{$newCreditURL}"{/capture} - {ts 1=$link}Click Submit Credit Card Membership to process a Membership on behalf of the member using their credit card.{/ts} - {/if} + {if $linkButtons.add_membership} + {ts}Click Add Membership to record a new membership.{/ts} {else} - {ts 1=$displayName}Current and inactive memberships for %1 are listed below.{/ts} + {ts 1=$displayName}Current and inactive memberships for %1 are listed below.{/ts} + {/if} + {if $linkButtons.creditcard_membership} + {ts}Click Submit Credit Card Membership to process a Membership on behalf of the member using their credit card.{/ts} {/if}
{/if} {if NOT ($activeMembers or $inActiveMembers) and $action ne 2 and $action ne 1 and $action ne 8 and $action ne 4 and $action ne 32768}