CRM-17993 -- Participant Listing Report: total paid doubled when multiple fee options...
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Wed, 10 Feb 2016 09:58:37 +0000 (15:28 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Wed, 10 Feb 2016 09:58:37 +0000 (15:28 +0530)
CRM/Report/Form/Event/ParticipantListing.php

index b26974d4642bfb6b17a9a356aaef061b2800fcf9..c296bd3e8ae464a858adf127556843c96c2bf904 100644 (file)
@@ -37,7 +37,6 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event {
   protected $_summary = NULL;
 
   protected $_contribField = FALSE;
-  protected $_lineitemField = FALSE;
   protected $_groupFilter = TRUE;
   protected $_tagFilter = TRUE;
   protected $_balance = FALSE;
@@ -452,9 +451,6 @@ ORDER BY  cv.label
       $this->_columnHeaders['blankColumnBegin']['title'] = '_ _ _ _';
     }
     foreach ($this->_columns as $tableName => $table) {
-      if ($tableName == 'civicrm_line_item') {
-        $this->_lineitemField = TRUE;
-      }
       if (array_key_exists('fields', $table)) {
         foreach ($table['fields'] as $fieldName => $field) {
           if (!empty($field['required']) ||
@@ -465,6 +461,9 @@ ORDER BY  cv.label
             }
             if ($fieldName == 'total_paid' || $fieldName == 'balance') {
               $this->_balance = TRUE;
+              if (!empty($this->_params['price_field_value_id_value'])) {
+                $field['dbAlias'] = str_replace('SUM(ft.total_amount)', 'ft.total_amount', $field['dbAlias']);
+              }
             }
             $alias = "{$tableName}_{$fieldName}";
             $select[] = "{$field['dbAlias']} as $alias";
@@ -527,7 +526,7 @@ ORDER BY  cv.label
                     ON (pp.contribution_id  = {$this->_aliases['civicrm_contribution']}.id)
       ";
     }
-    if ($this->_lineitemField) {
+    if (!empty($this->_params['price_field_value_id_value'])) {
       $this->_from .= "
             LEFT JOIN civicrm_line_item line_item_civireport
                   ON line_item_civireport.entity_table = 'civicrm_participant' AND