Fix CRM-21058: Add support for events to Personal Campaign Page Report.
authorAllen Shaw <allen@JoineryHQ.com>
Tue, 15 Aug 2017 19:26:05 +0000 (14:26 -0500)
committerAllen Shaw <allen@JoineryHQ.com>
Tue, 15 Aug 2017 19:26:05 +0000 (14:26 -0500)
CRM/Report/Form/Contribute/PCP.php

index bc3506824efabb78740439e4dcaa271b074a96a8..629ea99ba2db08a949e80dc955bead51d2978588 100644 (file)
@@ -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;
       }