(dev/core#4106) Add filter on pledge payment in contribution report templates
authoryashodha <yashodha@cividesk.com>
Mon, 20 Feb 2023 09:51:54 +0000 (15:21 +0530)
committeryashodha <yashodha@cividesk.com>
Mon, 20 Feb 2023 09:51:54 +0000 (15:21 +0530)
CRM/Report/Form/Contribute/Detail.php
CRM/Report/Form/Contribute/Summary.php

index 70965b4bd5e43df9ba400bfb248d271e51a90503..5ca489a3926b16d845efc71223fd11c7292a85d2 100644 (file)
@@ -255,6 +255,14 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form {
           ],
           'grouping' => 'contri-fields',
         ],
+        'civicrm_pledge_payment' => [
+          'dao' => 'CRM_Pledge_DAO_PledgePayment',
+          'filters' => [
+            'contribution_id' => [
+              'title' => ts('Contribution is a pledge payment'),
+            ],
+          ],
+        ],
         'civicrm_contribution_soft' => [
           'dao' => 'CRM_Contribute_DAO_ContributionSoft',
           'fields' => [
@@ -986,6 +994,13 @@ WHERE  civicrm_contribution_contribution_id={$row['civicrm_contribution_contribu
     $this->joinAddressFromContact();
     $this->joinEmailFromContact();
 
+    //for pledge payment
+    if ($this->isTableSelected('civicrm_pledge_payment')) {
+      $this->_from .= "
+        LEFT JOIN civicrm_pledge_payment {$this->_aliases['civicrm_pledge_payment']} ON {$this->_aliases['civicrm_contribution']}.id = {$this->_aliases['civicrm_pledge_payment']}.contribution_id
+      ";
+    }
+
     // include contribution note
     if (!empty($this->_params['fields']['contribution_note']) ||
       !empty($this->_params['note_value'])
index cb7a89af498b5a43237f793c9e8605c19dfa751e..a9c0877878da71265145c505c475767cf010b46c 100644 (file)
@@ -284,6 +284,14 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
           'batch_id' => ['title' => ts('Batch Title')],
         ],
       ],
+      'civicrm_pledge_payment' => [
+        'dao' => 'CRM_Pledge_DAO_PledgePayment',
+        'filters' => [
+          'contribution_id' => [
+            'title' => ts('Contribution is a pledge payment'),
+          ],
+        ],
+      ],
       'civicrm_contribution_soft' => [
         'dao' => 'CRM_Contribute_DAO_ContributionSoft',
         'fields' => [
@@ -527,6 +535,13 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
     $this->joinPhoneFromContact();
     $this->joinEmailFromContact();
 
+    //for pledge payment
+    if ($this->isTableSelected('civicrm_pledge_payment')) {
+      $this->_from .= "
+        LEFT JOIN civicrm_pledge_payment {$this->_aliases['civicrm_pledge_payment']} ON {$this->_aliases['civicrm_contribution']}.id = {$this->_aliases['civicrm_pledge_payment']}.contribution_id
+      ";
+    }
+
     //for contribution batches
     if ($this->isTableSelected('civicrm_batch')) {
       $this->_from .= "