'forward',
'reply',
'opened',
+ 'opened_unique',
'optout',
) as $key) {
$url = 'mailing/detail';
break;
case 'opened':
+ $url = "mailing/opened";
+ $searchFilter .= "&mailing_open_status=Y";
+ $reportFilter .= "&distinct=0"; // do not use group by clause in report, because same report used for total and unique open
+ break;
+
+ case 'opened_unique':
$url = "mailing/opened";
$searchFilter .= "&mailing_open_status=Y";
break;
}
public function groupBy() {
- $groupBys = empty($this->_params['charts']) ? array("civicrm_mailing_event_queue.email_id") : array("{$this->_aliases['civicrm_mailing']}.id");
-
- if (!empty($this->_params['unique_opens_value'])) {
- $groupBys[] = "civicrm_mailing_event_queue.id";
+ $groupBys = array();
+ // Do not use group by clause if distinct = 0 mentioned in url params. flag is used in mailing report screen, default value is TRUE
+ // this report is used to show total opened and unique opened
+ if (CRM_Utils_Request::retrieve('distinct', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, TRUE)) {
+ $groupBys = empty($this->_params['charts']) ? array("civicrm_mailing_event_queue.email_id") : array("{$this->_aliases['civicrm_mailing']}.id");
+ if (!empty($this->_params['unique_opens_value'])) {
+ $groupBys[] = "civicrm_mailing_event_queue.id";
+ }
+ }
+ if (!empty($groupBys)) {
+ $this->_select = CRM_Contact_BAO_Query::appendAnyValueToSelect($this->_selectClauses, $groupBys);
+ $this->_groupBy = "GROUP BY " . implode(', ', $groupBys);
}
- $this->_select = CRM_Contact_BAO_Query::appendAnyValueToSelect($this->_selectClauses, $groupBys);
- $this->_groupBy = "GROUP BY " . implode(', ', $groupBys);
}
public function postProcess() {
{if $report.mailing.open_tracking}
<tr><td class="label"><a href="{$report.event_totals.links.opened}&distinct=1">{ts}Unique Opens{/ts}</a></td>
<td>{$report.event_totals.opened} ({$report.event_totals.opened_rate|string_format:"%0.2f"}%)</td>
- <td>{$report.event_totals.actionlinks.opened}</td></tr>
+ <td>{$report.event_totals.actionlinks.opened_unique}</td></tr>
<tr><td class="label"><a href="{$report.event_totals.links.opened}">{ts}Total Opens{/ts}</a></td>
<td>{$report.event_totals.total_opened}</td>
<td>{$report.event_totals.actionlinks.opened}</td></tr>