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

civicrm#31342 Refactor for the renew link conditions #31364

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 11 additions & 1 deletion CRM/Member/Page/UserDashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,21 @@ public function listMemberships() {

/**
* Helper function to build appropriate Member links
*
* @array &members
* bool isActiveMembers
*/
public function buildMemberLinks(&$members) {
public function buildMemberLinks(&$members, $isActiveMembers) {
if (!empty($members)) {
$statuses = ($isActiveMembers) ? ['Current','New','Cancelled','Deceased','Pending'] : ['Expired'];
foreach ($members as $id => &$member) {

// Is this recurring membership?
if (empty($member['contribution_recur_id'])) {
// Build Renewal Link if appropriate
if (($isActiveMembers && !in_array($member['status'], $statuses)) || (!$isActiveMembers && !empty($member['renewPageId']) && in_array($member['status'], $statuses))) {
$member['renewMembershipLink'] = CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id={$member['renewPageId']}&mid={$member['id']}", TRUE, NULL, FALSE, TRUE);
}
continue;
}

Expand Down
9 changes: 4 additions & 5 deletions templates/CRM/Member/Page/UserDashboard.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
<td class="crm-active-membership-start_date">{$activeMember.start_date|crmDate}</td>
<td class="crm-active-membership-end_date">{$activeMember.end_date|crmDate}</td>
<td class="crm-active-membership-status">{$activeMember.status}</td>
{if ($activeMember.status !== 'Current' AND $activeMember.status !== 'Cancelled') OR !empty($activeMember.cancelSubscriptionUrl) OR !empty($activeMember.updateSubscriptionBillingUrl) OR !empty($activeMember.updateSubscriptionURL)}
{if !empty($activeMember.renewMembershipLink) OR !empty($activeMember.cancelSubscriptionUrl) OR !empty($activeMember.updateSubscriptionBillingUrl) OR !empty($activeMember.updateSubscriptionURL)}
<td class="crm-active-membership-renew">
{if $activeMember.status !== 'Current' AND $activeMember.status !== 'Cancelled'}<a href="{crmURL p='civicrm/contribute/transact' q="id=`$activeMember.renewPageId`&mid=`$activeMember.id`&reset=1"}" class="button"><span class="nowrap">{ts}Renew Now{/ts}</span></a>{/if}
{if !empty($activeMember.renewMembershipLink}<a href="{$activeMember.renewMembershipLink}" class="button"><span class="nowrap">{ts}Renew Now{/ts}</span></a>{/if}
{if !empty($activeMember.cancelSubscriptionUrl)}<a href="{$activeMember.cancelSubscriptionUrl}" class="button"><span class="nowrap">{ts}Cancel Subscription{/ts}</span></a>{/if}
{if !empty($activeMember.updateSubscriptionBillingUrl)}<a href="{$activeMember.updateSubscriptionBillingUrl}" class="button"><span class="nowrap">{ts}Update Billing Information{/ts}</span></a>{/if}
{if !empty($activeMember.updateSubscriptionUrl)}<a href="{$activeMember.updateSubscriptionUrl}" class="button"><span class="nowrap">{ts}Chnage Subscription Amount{/ts}</span></a>{/if}
Expand Down Expand Up @@ -67,15 +67,14 @@
<td class="crm-inactive-membership-start_date">{$inActiveMember.start_date|crmDate}</td>
<td class="crm-inactive-membership-end_date">{$inActiveMember.end_date|crmDate}</td>
<td class="crm-inactive-membership-status">{$inActiveMember.status}</td>
{if $inActiveMember.status == 'Expired' OR !empty($activeMember.cancelSubscriptionUrl) OR !empty($activeMember.updateSubscriptionBillingUrl) OR !empty($activeMember.updateSubscriptionURL)}
{if !empty($inActiveMember.renewMembershipLink) OR !empty($inActiveMember.cancelSubscriptionUrl) OR !empty($inActiveMember.updateSubscriptionBillingUrl) OR !empty($inActiveMember.updateSubscriptionURL)}
<td class="crm-active-membership-renew">
{if $inActiveMember.status == 'Expired'}<a href="{crmURL p='civicrm/contribute/transact' q="id=`$inActiveMember.renewPageId`&mid=`$inActiveMember.id`&reset=1"}" class="button"><span class="nowrap">{ts}Renew Now{/ts}</span></a>{/if}
{if !empty($inActiveMember.renewMembershipLink)}<a href="{$inActiveMember.renewMembershipLink}" class="button"><span class="nowrap">{ts}Renew Now{/ts}</span></a>{/if}
{if !empty($inActiveMember.cancelSubscriptionUrl)}<a href="{$inActiveMember.cancelSubscriptionUrl}" class="button"><span class="nowrap">{ts}Cancel Subscription{/ts}</span></a>{/if}
{if !empty($inActiveMember.updateSubscriptionBillingUrl)}<a href="{$inActiveMember.updateSubscriptionBillingUrl}" class="button"><span class="nowrap">{ts}Update Billing Information{/ts}</span></a>{/if}
{if !empty($inActiveMember.updateSubscriptionUrl)}<a href="{$inActiveMember.updateSubscriptionUrl}" class="button"><span class="nowrap">{ts}Chnage Subscription Amount{/ts}</span></a>{/if}
</td>
{/if}
<td class="crm-inactive-membership-renew">{if $inActiveMember.renewPageId}<a href="{crmURL p='civicrm/contribute/transact' q="id=`$inActiveMember.renewPageId`&mid=`$inActiveMember.id`&reset=1"}">[ {ts}Renew Now{/ts} ]</a>{/if}</td>
</tr>
{/foreach}
</table>
Expand Down