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

(dev/core/40) Show List of Contributions On Recurring Contribution View #11920

Merged
Show file tree
Hide file tree
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
30 changes: 29 additions & 1 deletion CRM/Contribute/Page/ContributionRecur.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class CRM_Contribute_Page_ContributionRecur extends CRM_Core_Page {
static $_links = NULL;
public $_permission = NULL;
public $_contactId = NULL;
public $_id = NULL;
public $_action = NULL;

/**
* View details of a recurring contribution.
Expand All @@ -57,7 +59,9 @@ public function view() {
CRM_Core_Error::statusBounce('Recurring contribution not found (ID: ' . $this->_id);
}

$contributionRecur['payment_processor'] = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessorName($contributionRecur['payment_processor_id']);
$contributionRecur['payment_processor'] = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessorName(
CRM_Utils_Array::value('payment_processor_id', $contributionRecur)
);
$idFields = array('contribution_status_id', 'campaign_id', 'financial_type_id');
foreach ($idFields as $idField) {
if (!empty($contributionRecur[$idField])) {
Expand Down Expand Up @@ -97,6 +101,30 @@ public function preProcess() {
$this->_permission = CRM_Core_Permission::VIEW;
$this->assign('permission', 'view');
}

$this->loadRelatedContributions();
}

/**
* Loads contributions associated to the current recurring contribution being
* viewed.
*/
private function loadRelatedContributions() {
$controller = new CRM_Core_Controller_Simple(
'CRM_Contribute_Form_Search',
ts('Contributions'),
$this->_action,
FALSE, FALSE, TRUE
);
$controller->setEmbedded(TRUE);
$controller->reset();
$controller->set('cid', $this->_contactId);
$controller->set('recur', $this->_id);
$controller->set('force', 1);
$controller->set('context', 'contribution');
$controller->set('limit', 50);
$controller->process();
$controller->run();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this automatically create a pager if there are more than 50 contributions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattwire ,

It does create pager controls, that was the idea behind using this controller to show the list of related contributions. I've updated screenshot to show the pager controls working.

}

/**
Expand Down
11 changes: 11 additions & 0 deletions templates/CRM/Contribute/Page/ContributionRecur.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@
<div class="crm-submit-buttons"><a class="button cancel crm-form-submit" href="{crmURL p='civicrm/contact/view' q='action=browse&selectedChild=contribute'}">{ts}Done{/ts}</a></div>
</div>
{/if}

{if $rows}
{include file="CRM/Contribute/Page/ContributionTotals.tpl" mode="view"}
<div class='clear'></div>
{include file="CRM/Contribute/Form/Selector.tpl"}
{else}
<div class="messages status no-popup">
<div class="icon inform-icon"></div>
{ts}No contributions have been recorded for this recurring contribution.{/ts}
</div>
{/if}
{/if}
{if $recurRows}
{strip}
Expand Down