CRM-16189, added batch name as filter
authorPradeep Nayak <pradpnayak@gmail.com>
Wed, 3 Aug 2016 00:49:11 +0000 (06:19 +0530)
committerEdsel <edsel.lopez@jmaconsulting.biz>
Thu, 9 Feb 2017 14:02:14 +0000 (19:32 +0530)
----------------------------------------
* CRM-16189: Improve support for Accrual Method bookkeeping
  https://issues.civicrm.org/jira/browse/CRM-16189

CRM/Report/Form/Contribute/DeferredRevenue.php

index e5e6dc65abf7267c4d49455f3dfce8986c7f7918..4fd4163b36f2485b2277b9029f65f9a6758eb84a 100644 (file)
@@ -163,6 +163,18 @@ class CRM_Report_Form_Contribute_DeferredRevenue extends CRM_Report_Form {
       'civicrm_participant' => array(
         'dao' => 'CRM_Event_DAO_Participant',
       ),
+      'civicrm_batch' => array(
+        'dao' => 'CRM_Batch_DAO_EntityBatch',
+        'grouping' => 'contri-fields',
+        'filters' => array(
+          'batch_id' => array(
+            'title' => ts('Batch Title'),
+            'operatorType' => CRM_Report_Form::OP_MULTISELECT,
+            'options' => CRM_Batch_BAO_Batch::getBatches(),
+            'type' => CRM_Utils_Type::T_INT,
+          ),
+        ),
+      ),
       'civicrm_contribution' => array(
         'dao' => 'CRM_Contribute_DAO_Contribution',
         'fields' => array(
@@ -278,6 +290,13 @@ LEFT JOIN civicrm_participant {$this->_aliases['civicrm_participant']}
   END
 LEFT JOIN civicrm_event {$this->_aliases['civicrm_event']} ON {$this->_aliases['civicrm_participant']}.event_id = {$this->_aliases['civicrm_event']}.id
 ";
+
+if (!empty($this->_params['batch_id_value'])) {
+      $this->_from .= "
+        LEFT JOIN civicrm_entity_batch {$this->_aliases['civicrm_batch']}
+          ON {$this->_aliases['civicrm_batch']}.entity_id = {$this->_aliases['civicrm_financial_trxn_1']}.id AND
+            {$this->_aliases['civicrm_batch']}.entity_table = 'civicrm_financial_trxn'\n";
+    }
   }
 
   public function postProcess() {