Removed defunct order_by override from Member/Detail; added campaign functionality...
authorChris Doten <cdoten@ndi.org>
Sat, 4 May 2013 23:16:47 +0000 (23:16 +0000)
committerChris Doten <cdoten@ndi.org>
Sat, 4 May 2013 23:16:47 +0000 (23:16 +0000)
CRM/Report/Form/Event/ParticipantListing.php
CRM/Report/Form/Member/Detail.php

index bd97ebc42e5ab05db782b469391071743d218e52..c54ab20249c911d1b89dacd9d111a1238b614ae1 100644 (file)
@@ -42,7 +42,17 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event {
     'Participant'); 
   public $_drilldownReport = array('event/income' => 'Link to Detail Report');
 
-  function __construct() {
+  function __construct() {  
+         
+       // Check if CiviCampaign is a) enabled and b) has active campaigns
+       $config = CRM_Core_Config::singleton();
+    $campaignEnabled = in_array("CiviCampaign", $config->enableComponents);
+    if ($campaignEnabled) {
+      $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE);
+      $this->activeCampaigns = $getCampaigns['campaigns'];
+      asort($this->activeCampaigns);
+    }
+    
     $this->_columns = array(
       'civicrm_contact' =>
       array(
@@ -69,17 +79,21 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event {
           ),
         ),
         'grouping' => 'contact-fields',
-        'filters' =>
+        'order_bys' =>
         array(
           'sort_name' =>
-          array('title' => ts('Participant Name'),
-            'operator' => 'like',
+          array('title' => ts('Last Name, First Name'), 
+                       'default' => '1', 
+                       'default_weight' => '0', 
+                       'default_order' => 'ASC',
           ),
         ),
-        'order_bys' =>
+        'filters' =>
         array(
           'sort_name' =>
-          array('title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC'),
+          array('title' => ts('Participant Name'),
+            'operator' => 'like',
+          ),
         ),
       ),
       'civicrm_email' =>
@@ -235,9 +249,25 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event {
         ),
       ),
     );
+    
+    // If we have active campaigns add those elements to both the fields and filters
+    if ($campaignEnabled && !empty($this->activeCampaigns)) {
+      $this->_columns['civicrm_participant']['fields']['campaign_id'] = array(
+        'title' => ts('Campaign'),
+        'default' => 'false',
+      );
+      $this->_columns['civicrm_participant']['filters']['campaign_id'] = array('title' => ts('Campaign'),
+        'operatorType' => CRM_Report_Form::OP_MULTISELECT,
+        'options' => $this->activeCampaigns,
+      );
+      $this->_columns['civicrm_participant']['order_bys']['campaign_id'] = array('title' => ts('Campaign'));
+
+    }
+    
     $this->_currencyColumn = 'civicrm_participant_fee_currency';
     parent::__construct();
   }
+  
 
   function preProcess() {
     parent::preProcess();
@@ -498,6 +528,14 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event {
         }
       }
 
+      // Convert campaign_id to campaign title
+      if (array_key_exists('civicrm_participant_campaign_id', $row)) {
+        if ($value = $row['civicrm_participant_campaign_id']) {
+          $rows[$rowNum]['civicrm_participant_campaign_id'] = $this->activeCampaigns[$value];
+          $entryFound = TRUE;
+        }
+      }
+
       // skip looking further in rows, if first row itself doesn't
       // have the column we need
       if (!$entryFound) {
index e1c7a55365c96e265eb17e23beec2d1f444f2d71..b9181c269ee5f29532926c2e3aae0d65dfb6f13a 100644 (file)
@@ -433,11 +433,6 @@ class CRM_Report_Form_Member_Detail extends CRM_Report_Form {
     $this->_groupBy = " GROUP BY {$this->_aliases['civicrm_contact']}.id, {$this->_aliases['civicrm_membership']}.membership_type_id";
   }
 
-// This function overrides the default Form.php orderBy and breaks dynamic order
-// function orderBy() {
-//    $this->_orderBy = " ORDER BY {$this->_aliases['civicrm_contact']}.sort_name, {$this->_aliases['civicrm_contact']}.id, {$this->_aliases['civicrm_membership']}.membership_type_id";
-//  }
-
   function postProcess() {
 
     $this->beginPostProcess();