3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2019
35 * Main page for viewing Recurring Contributions.
37 class CRM_Contribute_Page_ContributionRecur
extends CRM_Core_Page
{
39 public static $_links = NULL;
40 public $_permission = NULL;
41 public $_contactId = NULL;
43 public $_action = NULL;
46 * View details of a recurring contribution.
48 public function view() {
49 if (empty($this->_id
)) {
50 CRM_Core_Error
::statusBounce('Recurring contribution not found');
54 $contributionRecur = civicrm_api3('ContributionRecur', 'getsingle', [
58 catch (Exception
$e) {
59 CRM_Core_Error
::statusBounce('Recurring contribution not found (ID: ' . $this->_id
);
62 $contributionRecur['payment_processor'] = CRM_Financial_BAO_PaymentProcessor
::getPaymentProcessorName(
63 CRM_Utils_Array
::value('payment_processor_id', $contributionRecur)
65 $idFields = ['contribution_status_id', 'campaign_id', 'financial_type_id'];
66 foreach ($idFields as $idField) {
67 if (!empty($contributionRecur[$idField])) {
68 $contributionRecur[substr($idField, 0, -3)] = CRM_Core_PseudoConstant
::getLabel('CRM_Contribute_BAO_ContributionRecur', $idField, $contributionRecur[$idField]);
72 // Add linked membership
73 $membership = civicrm_api3('Membership', 'get', [
74 'contribution_recur_id' => $contributionRecur['id'],
76 if (!empty($membership['count'])) {
77 $membershipDetails = reset($membership['values']);
78 $contributionRecur['membership_id'] = $membershipDetails['id'];
79 $contributionRecur['membership_name'] = $membershipDetails['membership_name'];
82 $groupTree = CRM_Core_BAO_CustomGroup
::getTree('ContributionRecur', NULL, $contributionRecur['id']);
83 CRM_Core_BAO_CustomGroup
::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $contributionRecur['id']);
85 $this->assign('recur', $contributionRecur);
87 $displayName = CRM_Contact_BAO_Contact
::displayName($contributionRecur['contact_id']);
88 $this->assign('displayName', $displayName);
90 // Check if this is default domain contact CRM-10482
91 if (CRM_Contact_BAO_Contact
::checkDomainContact($contributionRecur['contact_id'])) {
92 $displayName .= ' (' . ts('default organization') . ')';
95 // omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container
96 CRM_Utils_System
::setTitle(ts('View Recurring Contribution from') . ' ' . $displayName);
99 public function preProcess() {
100 $this->_action
= CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE, 'view');
101 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
102 $this->_contactId
= CRM_Utils_Request
::retrieve('cid', 'Positive', $this, TRUE);
103 $this->assign('contactId', $this->_contactId
);
105 // check logged in url permission
106 CRM_Contact_Page_View
::checkUserPermission($this);
108 $this->assign('action', $this->_action
);
110 if ($this->_permission
== CRM_Core_Permission
::EDIT
&& !CRM_Core_Permission
::check('edit contributions')) {
111 // demote to view since user does not have edit contrib rights
112 $this->_permission
= CRM_Core_Permission
::VIEW
;
113 $this->assign('permission', 'view');
118 * the main function that is called when the page loads,
119 * it decides the which action has to be taken for the page.
123 public function run() {
126 if ($this->_action
& CRM_Core_Action
::VIEW
) {
130 return parent
::run();