From 39bad6a687225ff74dd323d4724a09a104108df7 Mon Sep 17 00:00:00 2001 From: Allen Shaw Date: Tue, 15 Aug 2017 14:26:05 -0500 Subject: [PATCH] Fix CRM-21058: Add support for events to Personal Campaign Page Report. --- CRM/Report/Form/Contribute/PCP.php | 32 ++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/CRM/Report/Form/Contribute/PCP.php b/CRM/Report/Form/Contribute/PCP.php index bc3506824e..629ea99ba2 100644 --- a/CRM/Report/Form/Contribute/PCP.php +++ b/CRM/Report/Form/Contribute/PCP.php @@ -73,10 +73,12 @@ class CRM_Report_Form_Contribute_PCP extends CRM_Report_Form { ), 'civicrm_contribution_page' => array( 'dao' => 'CRM_Contribute_DAO_ContributionPage', + 'alias' => 'cp', 'fields' => array( 'page_title' => array( - 'title' => ts('Contribution Page Title'), + 'title' => ts('Page Title'), 'name' => 'title', + 'dbAlias' => 'coalesce(cp_civireport.title, e_civireport.title)', 'default' => TRUE, ), ), @@ -89,6 +91,17 @@ class CRM_Report_Form_Contribute_PCP extends CRM_Report_Form { ), 'grouping' => 'pcp-fields', ), + 'civicrm_event' => array( + 'alias' => 'e', + 'filters' => array( + 'event_title' => array( + 'title' => ts('Event Title'), + 'name' => 'title', + 'type' => CRM_Utils_Type::T_STRING, + ), + ), + 'grouping' => 'pcp-fields', + ), 'civicrm_pcp' => array( 'dao' => 'CRM_PCP_DAO_PCP', 'fields' => array( @@ -96,6 +109,10 @@ class CRM_Report_Form_Contribute_PCP extends CRM_Report_Form { 'title' => ts('Personal Campaign Title'), 'default' => TRUE, ), + 'page_type' => array( + 'title' => ts('Page Type'), + 'default' => FALSE, + ), 'goal_amount' => array( 'title' => ts('Goal Amount'), 'type' => CRM_Utils_Type::T_MONEY, @@ -207,7 +224,13 @@ LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact']} LEFT JOIN civicrm_contribution_page {$this->_aliases['civicrm_contribution_page']} ON {$this->_aliases['civicrm_pcp']}.page_id = - {$this->_aliases['civicrm_contribution_page']}.id"; + {$this->_aliases['civicrm_contribution_page']}.id + AND {$this->_aliases['civicrm_pcp']}.page_type = 'contribute' + +LEFT JOIN civicrm_event {$this->_aliases['civicrm_event']} + ON {$this->_aliases['civicrm_pcp']}.page_id = + {$this->_aliases['civicrm_event']}.id + AND {$this->_aliases['civicrm_pcp']}.page_type = 'event'"; // for credit card type $this->addFinancialTrxnFromClause(); @@ -381,6 +404,11 @@ LEFT JOIN civicrm_contribution_page {$this->_aliases['civicrm_contribution_page' $entryFound = TRUE; } + if (!empty($row['civicrm_pcp_page_type'])) { + $rows[$rowNum]['civicrm_pcp_page_type'] = ucfirst($rows[$rowNum]['civicrm_pcp_page_type']); + $entryFound = TRUE; + } + if (!$entryFound) { break; } -- 2.25.1