From baff85dd52c5d8336254abb59f2a9a943f0c76c3 Mon Sep 17 00:00:00 2001 From: yashodha Date: Thu, 29 Aug 2013 11:01:07 +0530 Subject: [PATCH] patched CRM-13291 --- CRM/Report/Form/Mailing/Summary.php | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/CRM/Report/Form/Mailing/Summary.php b/CRM/Report/Form/Mailing/Summary.php index cd334b0357..c5fdc8f437 100644 --- a/CRM/Report/Form/Mailing/Summary.php +++ b/CRM/Report/Form/Mailing/Summary.php @@ -51,6 +51,8 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form { 'bar_3dChart' => 'Bar Chart', ); + public $campaignEnabled = False; + function __construct() { $this->_columns = array(); @@ -228,7 +230,23 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form { ), ), ); - + $config = CRM_Core_Config::singleton(); + $this->campaignEnabled = in_array("CiviCampaign", $config->enableComponents); + if ($this->campaignEnabled) { + $this->_columns['civicrm_campaign'] = array( + 'dao' => 'CRM_Campaign_DAO_Campaign', + 'fields' => array( + 'title' => array( + 'title' => ts('Campaign Name'), + ), + ), + 'filters' => array( + 'title' => array( + 'type' => CRM_Utils_Type::T_STRING, + ), + ), + ); + } parent::__construct(); } @@ -325,6 +343,13 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form { ON {$this->_aliases['civicrm_mailing_event_trackable_url_open']}.event_queue_id = {$this->_aliases['civicrm_mailing_event_queue']}.id LEFT JOIN civicrm_mailing_event_unsubscribe {$this->_aliases['civicrm_mailing_event_unsubscribe']} ON {$this->_aliases['civicrm_mailing_event_unsubscribe']}.event_queue_id = {$this->_aliases['civicrm_mailing_event_queue']}.id"; + + if ($this->campaignEnabled) { + $this->_from .= " + LEFT JOIN civicrm_campaign {$this->_aliases['civicrm_campaign']} + ON {$this->_aliases['civicrm_campaign']}.id = {$this->_aliases['civicrm_mailing']}.campaign_id"; + } + // need group by and order by //print_r($this->_from); @@ -344,7 +369,7 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form { $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); - $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); + $clause = $this->dateClause($this->_aliases[$tableName] . '.' . $field['name'], $relative, $from, $to, $field['type']); } else { $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); -- 2.25.1