* View details of a recurring contribution.
*/
public function view() {
- $recur = new CRM_Contribute_DAO_ContributionRecur();
- $recur->id = $this->_id;
- if ($recur->find(TRUE)) {
- $values = array();
- CRM_Core_DAO::storeValues($recur, $values);
- // if there is a payment processor ID, get the name of the payment processor
- if (!empty($values['payment_processor_id'])) {
- $values['payment_processor'] = CRM_Core_DAO::getFieldValue(
- 'CRM_Financial_DAO_PaymentProcessor',
- $values['payment_processor_id'],
- 'name'
- );
- }
- $idFields = array('contribution_status_id', 'campaign_id');
- if (CRM_Contribute_BAO_ContributionRecur::supportsFinancialTypeChange($values['id'])) {
- $idFields[] = 'financial_type_id';
- }
- foreach ($idFields as $idField) {
- if (!empty($values[$idField])) {
- $values[substr($idField, 0, -3)] = CRM_Core_PseudoConstant::getLabel('CRM_Contribute_BAO_ContributionRecur', $idField, $values[$idField]);
- }
- }
+ if (empty($this->_id)) {
+ CRM_Core_Error::statusBounce('Recurring contribution not found');
+ }
- // Add linked membership
- $membership = civicrm_api3('Membership', 'get', array(
- 'contribution_recur_id' => $recur->id,
+ try {
+ $contributionRecur = civicrm_api3('ContributionRecur', 'getsingle', array(
+ 'id' => $this->_id,
));
- if (!empty($membership['count'])) {
- $membershipDetails = reset($membership['values']);
- $values['membership_id'] = $membershipDetails['id'];
- $values['membership_name'] = $membershipDetails['membership_name'];
+ }
+ catch (Exception $e) {
+ CRM_Core_Error::statusBounce('Recurring contribution not found (ID: ' . $this->_id);
+ }
+
+ $contributionRecur['payment_processor'] = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessorName($contributionRecur['payment_processor_id']);
+ $idFields = array('contribution_status_id', 'campaign_id', 'financial_type_id');
+ foreach ($idFields as $idField) {
+ if (!empty($contributionRecur[$idField])) {
+ $contributionRecur[substr($idField, 0, -3)] = CRM_Core_PseudoConstant::getLabel('CRM_Contribute_BAO_ContributionRecur', $idField, $contributionRecur[$idField]);
}
+ }
- $this->assign('recur', $values);
+ // Add linked membership
+ $membership = civicrm_api3('Membership', 'get', array(
+ 'contribution_recur_id' => $contributionRecur['id'],
+ ));
+ if (!empty($membership['count'])) {
+ $membershipDetails = reset($membership['values']);
+ $contributionRecur['membership_id'] = $membershipDetails['id'];
+ $contributionRecur['membership_name'] = $membershipDetails['membership_name'];
}
+
+ $this->assign('recur', $contributionRecur);
}
public function preProcess() {
- $context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'view');
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);