CRM-16189, added link on contribution edit form to record payment for pending pay...
[civicrm-core.git] / CRM / Contribute / Selector / Search.php
index 79155fd50b1bb0282c5f070548672bd29c59f2dd..efb4b786ced6b13e25c088c4e086af6c0c4c50e8 100644 (file)
@@ -82,7 +82,6 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
     'contribution_soft_credit_contact_id',
     'contribution_soft_credit_amount',
     'contribution_soft_credit_type',
-    'contribution_participant_id',
   );
 
   /**
@@ -185,7 +184,6 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
     // type of selector
     $this->_action = $action;
     $returnProperties = CRM_Contribute_BAO_Query::selectorReturnProperties();
-    $returnProperties['contribution_participant_id'] = 1;
     $this->_includeSoftCredits = CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($this->_queryParams);
     $this->_query = new CRM_Contact_BAO_Query(
       $this->_queryParams,
@@ -418,7 +416,9 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
         $contributionStatuses
       );
 
+      $isPayLater = FALSE;
       if ($result->is_pay_later && CRM_Utils_Array::value('contribution_status_name', $row) == 'Pending') {
+        $isPayLater = TRUE;
         $row['contribution_status'] .= ' (' . ts('Pay Later') . ')';
         $links[CRM_Core_Action::ADD] = array(
           'name' => ts('Pay with Credit Card'),
@@ -441,26 +441,26 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
         'id' => $result->contribution_id,
         'cid' => $result->contact_id,
         'cxt' => $this->_context,
-        'pid' => $result->contribution_participant_id,
+        'compId' => $result->contribution_id,
+        'comp' => 'contribution',
       );
-      if (!empty($row['contribution_participant_id'])) {
-        if ($row['contribution_status_name'] == 'Partially paid') {
-          $links[CRM_Core_Action::ADD] = array(
-            'name' => ts('Record Payment'),
-            'url' => 'civicrm/payment',
-            'qs' => 'reset=1&id=%%pid%%&cid=%%cid%%&action=add&component=event',
-            'title' => ts('Record Payment'),
-          );
-        }
 
-        if ($row['contribution_status_name'] == 'Pending refund') {
-          $links[CRM_Core_Action::ADD] = array(
-            'name' => ts('Record Refund'),
-            'url' => 'civicrm/payment',
-            'qs' => 'reset=1&id=%%pid%%&cid=%%cid%%&action=add&component=event',
-            'title' => ts('Record Refund'),
-          );
-        }
+      if ($row['contribution_status_name'] == 'Partially paid' || $isPayLater) {
+        $links[CRM_Core_Action::ADD] = array(
+          'name' => ts('Record Payment'),
+          'url' => 'civicrm/payment',
+          'qs' => 'reset=1&id=%%compId%%&cid=%%cid%%&action=add&component=%%comp%%',
+          'title' => ts('Record Payment'),
+        );
+      }
+
+      if ($row['contribution_status_name'] == 'Pending refund') {
+        $links[CRM_Core_Action::ADD] = array(
+          'name' => ts('Record Refund'),
+          'url' => 'civicrm/payment',
+          'qs' => 'reset=1&id=%%pid%%&cid=%%cid%%&action=add&component=event',
+          'title' => ts('Record Refund'),
+        );
       }
 
       $row['action'] = CRM_Core_Action::formLink(