dev/core/issues/277, Fixed count to include only live recurring contribution
authorPradeep Nayak <pradpnayak@gmail.com>
Tue, 24 Jul 2018 13:02:35 +0000 (14:02 +0100)
committerPradeep Nayak <pradpnayak@gmail.com>
Tue, 24 Jul 2018 13:02:35 +0000 (14:02 +0100)
CRM/Contribute/Page/Tab.php
templates/CRM/Contribute/Page/Tab.tpl

index b5c20a9e0c57449eff850f1ec1d539143d154db0..5431bc8dafce4039e04edf173fad6427f027c618 100644 (file)
@@ -166,13 +166,14 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page {
    * Get all the recurring contribution information and assign to the template
    */
   private function addRecurringContributionsBlock() {
-    $activeContributions = $this->getActiveRecurringContributions();
-    $inactiveRecurringContributions = $this->getInactiveRecurringContributions();
+    list($activeContributions, $activeContributionsCount) = $this->getActiveRecurringContributions();
+    list($inactiveRecurringContributions, $inactiveContributionsCount) = $this->getInactiveRecurringContributions();
 
     if (!empty($activeContributions) || !empty($inactiveRecurringContributions)) {
       // assign vars to templates
       $this->assign('action', $this->_action);
       $this->assign('activeRecurRows', $activeContributions);
+      $this->assign('activeContributionsCount', $activeContributionsCount);
       $this->assign('inactiveRecurRows', $inactiveRecurringContributions);
       $this->assign('recur', TRUE);
     }
@@ -228,11 +229,16 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page {
    * @return mixed
    */
   private function buildRecurringContributionsArray($recurContributions) {
+    $liveRecurringContributionCount = 0;
     foreach ($recurContributions as $recurId => $recurDetail) {
       $action = array_sum(array_keys($this->recurLinks($recurId)));
       // no action allowed if it's not active
       $recurContributions[$recurId]['is_active'] = (!CRM_Contribute_BAO_Contribution::isContributionStatusNegative($recurDetail['contribution_status_id']));
 
+      if (empty($recurDetail['is_test'])) {
+        $liveRecurringContributionCount++;
+      }
+
       // Get the name of the payment processor
       if (!empty($recurDetail['payment_processor_id'])) {
         $recurContributions[$recurId]['payment_processor'] = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessorName($recurDetail['payment_processor_id']);
@@ -265,7 +271,7 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page {
       }
     }
 
-    return $recurContributions;
+    return [$recurContributions, $liveRecurringContributionCount];
   }
 
   /**
index f38a200afd4c1717f8a0570effee271cde79f1e7..f4617bfd899bdfe0f31be5ed4cfa3dbd8d862a14 100644 (file)
@@ -51,7 +51,7 @@
           </li>
           <li id="tab_recurring" class="crm-tab-button ui-corner-all ui-tabs-tab ui-corner-top ui-state-default ui-tab">
             <a href="#recurring-subtab" title="{ts}Recurring Contributions{/ts}">
-              {ts}Recurring Contributions{/ts} <em>{$activeRecurRows|@count}</em>
+              {ts}Recurring Contributions{/ts} <em>{$activeContributionsCount}</em>
             </a>
           </li>
         </ul>