Skip to content

Commit

Permalink
Show 'Pay Now' on user dashboard for partially paid contributions
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaphoneJon committed May 26, 2021
1 parent a876dc4 commit fcd395a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
9 changes: 6 additions & 3 deletions CRM/Contribute/Page/UserDashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ public function listContribution() {
// This is required for tpl logic. We should move away from hard-code this to adding an array of actions to the row
// which the tpl can iterate through - this should allow us to cope with competing attempts to add new buttons
// and allow extensions to assign new ones through the pageRun hook
if ('Pending' === CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $row['contribution_status_id'])) {
$row['balance_amount'] = CRM_Contribute_BAO_Contribution::getContributionBalance($row['contribution_id']);
$contributionStatus = CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $row['contribution_status_id']);

if (in_array($contributionStatus, ['Pending', 'Partially paid'])) {
$row['buttons']['pay'] = [
'class' => 'button',
'label' => ts('Pay Now'),
Expand Down Expand Up @@ -98,7 +101,7 @@ public function listContribution() {
$values['recur_status'] = $recurStatus[$values['contribution_status_id']];
$recurRow[$values['id']] = $values;

$action = array_sum(array_keys(CRM_Contribute_Page_Tab::recurLinks((int) $recur->id, 'dashboard')));
$action = array_sum(array_keys(CRM_Contribute_Page_Tab::dashboardRecurLinks((int) $recur->id, (int) $recur->contact_id)));

$details = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($recur->id, 'recur');
$hideUpdate = $details->membership_id & $details->auto_renew;
Expand All @@ -107,7 +110,7 @@ public function listContribution() {
$action -= CRM_Core_Action::UPDATE;
}

$recurRow[$values['id']]['action'] = CRM_Core_Action::formLink(CRM_Contribute_Page_Tab::recurLinks((int) $recur->id, 'dashboard'),
$recurRow[$values['id']]['action'] = CRM_Core_Action::formLink(CRM_Contribute_Page_Tab::dashboardRecurLinks((int) $recur->id, (int) $this->_contactId),
$action, [
'cid' => $this->_contactId,
'crid' => $values['id'],
Expand Down
10 changes: 6 additions & 4 deletions templates/CRM/Contribute/Page/UserDashboard.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
<th>{ts}Financial Type{/ts}</th>
<th>{ts}Received date{/ts}</th>
<th>{ts}Receipt Sent{/ts}</th>
<th>{ts}Balance{/ts}</th>
<th>{ts}Status{/ts}</th>
{if $isIncludeInvoiceLinks}
<th></th>
{/if}
{foreach from=$row.buttons item=button}
<th></th>
{/foreach}
<th></th>
</tr>

{foreach from=$contribute_rows item=row}
Expand All @@ -39,6 +38,7 @@
<td>{$row.financial_type}</td>
<td>{$row.receive_date|truncate:10:''|crmDate}</td>
<td>{$row.receipt_date|truncate:10:''|crmDate}</td>
<td>{$row.balance_amount|crmMoney:$row.currency}</td>
<td>{$row.contribution_status}</td>
{if $isIncludeInvoiceLinks}
<td>
Expand All @@ -59,9 +59,11 @@
{/if}
</td>
{/if}
<td>
{foreach from=$row.buttons item=button}
<td><a class="{$button.class}" href="{$button.url}"><span class='nowrap'>{$button.label}</span></a></td>
<a class="{$button.class}" href="{$button.url}"><span class='nowrap'>{$button.label}</span></a>
{/foreach}
</td>
</tr>
{/foreach}
</table>
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/CRM/Contact/Page/View/UserDashBoardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ public function testDashboardContentContributionsWithInvoicingEnabled() {
$this->runUserDashboard();
$expectedStrings = [
'Your Contribution(s)',
'<table class="selector"><tr class="columnheader"><th>Total Amount</th><th>Financial Type</th><th>Received date</th><th>Receipt Sent</th><th>Status</th><th></th>',
'<td>Completed</td><td><a class="button no-popup nowrap"href="/index.php?q=civicrm/contribute/invoice&amp;reset=1&amp;id=1&amp;cid=' . $this->contactID . '"><i class="crm-i fa-print" aria-hidden="true"></i><span>Print Invoice</span></a></td></tr><tr id=\'rowid2\'',
'<table class="selector"><tr class="columnheader"><th>Total Amount</th><th>Financial Type</th><th>Received date</th><th>Receipt Sent</th><th>Balance</th><th>Status</th><th></th>',
'<td>Completed</td><td><a class="button no-popup nowrap"href="/index.php?q=civicrm/contribute/invoice&amp;reset=1&amp;id=1&amp;cid=' . $this->contactID . '"><i class="crm-i fa-print" aria-hidden="true"></i><span>Print Invoice</span></a></td><td></td></tr><tr id=\'rowid2\'',
'Pay Now',
];

Expand Down Expand Up @@ -149,7 +149,7 @@ public function testDashboardContentContributions() {
$this->runUserDashboard();
$expectedStrings = [
'Your Contribution(s)',
'<table class="selector"><tr class="columnheader"><th>Total Amount</th><th>Financial Type</th><th>Received date</th><th>Receipt Sent</th><th>Status</th>',
'<table class="selector"><tr class="columnheader"><th>Total Amount</th><th>Financial Type</th><th>Received date</th><th>Receipt Sent</th><th>Balance</th><th>Status</th>',
'<td>$ 100.00 </td><td>Donation</td>',
'<td>Completed</td>',
];
Expand Down

0 comments on commit fcd395a

Please sign in to comment.