From 7841468156fef5f3e5ca7e5697fbca4d3de972d5 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Thu, 11 Feb 2016 10:15:58 +0000 Subject: [PATCH] CRM-18021 Add in report viewing option for ab tests --- CRM/Mailing/Info.php | 9 +++++++++ ang/crmMailing/services.js | 25 +++++++++++++------------ ang/crmMailingAB/EditCtrl/report.html | 6 ++++++ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/CRM/Mailing/Info.php b/CRM/Mailing/Info.php index 6702e27544..a4dd73c6d0 100644 --- a/CRM/Mailing/Info.php +++ b/CRM/Mailing/Info.php @@ -72,6 +72,14 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info { return array(); } + $reportIds = array(); + $reportTypes = array('detail', 'opened', 'bounce', 'clicks'); + foreach ($reportTypes as $report) { + $result = civicrm_api3('ReportInstance', 'get', array( + 'sequential' => 1, + 'report_id' => 'mailing/' . $report)); + $reportIds[$report] = $result['values'][0]['id']; + } $result = array(); $result['crmMailing'] = array( 'ext' => 'civicrm', @@ -174,6 +182,7 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info { )), 'visibility' => CRM_Utils_Array::makeNonAssociative(CRM_Core_SelectValues::groupVisibility()), 'workflowEnabled' => CRM_Mailing_Info::workflowEnabled(), + 'reportIds' => $reportIds, ), )) ->addPermissions(array( diff --git a/ang/crmMailing/services.js b/ang/crmMailing/services.js index c76da9238f..4201357182 100644 --- a/ang/crmMailing/services.js +++ b/ang/crmMailing/services.js @@ -453,15 +453,15 @@ angular.module('crmMailing').factory('crmMailingStats', function (crmApi, crmLegacy) { var statTypes = [ - // {name: 'Recipients', title: ts('Intended Recipients'), searchFilter: '', eventsFilter: '&event=queue'}, - {name: 'Delivered', title: ts('Successful Deliveries'), searchFilter: '&mailing_delivery_status=Y', eventsFilter: '&event=delivered'}, - {name: 'Opened', title: ts('Tracked Opens'), searchFilter: '&mailing_open_status=Y', eventsFilter: '&event=opened'}, - {name: 'Unique Clicks', title: ts('Click-throughs'), searchFilter: '&mailing_click_status=Y', eventsFilter: '&event=click&distinct=1'}, - // {name: 'Forward', title: ts('Forwards'), searchFilter: '&mailing_forward=1', eventsFilter: '&event=forward'}, - // {name: 'Replies', title: ts('Replies'), searchFilter: '&mailing_reply_status=Y', eventsFilter: '&event=reply'}, - {name: 'Bounces', title: ts('Bounces'), searchFilter: '&mailing_delivery_status=N', eventsFilter: '&event=bounce'}, - {name: 'Unsubscribers', title: ts('Unsubscribes'), searchFilter: '&mailing_unsubscribe=1', eventsFilter: '&event=unsubscribe'} - // {name: 'OptOuts', title: ts('Opt-Outs'), searchFilter: '&mailing_optout=1', eventsFilter: '&event=optout'} + // {name: 'Recipients', title: ts('Intended Recipients'), searchFilter: '', eventsFilter: '&event=queue', reportType: 'detail', reportFilter: ''}, + {name: 'Delivered', title: ts('Successful Deliveries'), searchFilter: '&mailing_delivery_status=Y', eventsFilter: '&event=delivered', reportType: 'detail', reportFilter: '&delivery_status_value=successful'}, + {name: 'Opened', title: ts('Tracked Opens'), searchFilter: '&mailing_open_status=Y', eventsFilter: '&event=opened', reportType: 'opened', reportFilter: ''}, + {name: 'Unique Clicks', title: ts('Click-throughs'), searchFilter: '&mailing_click_status=Y', eventsFilter: '&event=click&distinct=1', reportType: 'clicks', reportFilter: ''}, + // {name: 'Forward', title: ts('Forwards'), searchFilter: '&mailing_forward=1', eventsFilter: '&event=forward', reportType: 'detail', reportFilter: '&is_forwarded_value=1'}, + // {name: 'Replies', title: ts('Replies'), searchFilter: '&mailing_reply_status=Y', eventsFilter: '&event=reply', reportType: 'detail', reportFilter: '&is_replied_value=1'}, + {name: 'Bounces', title: ts('Bounces'), searchFilter: '&mailing_delivery_status=N', eventsFilter: '&event=bounce', reportType: 'bounce', reportFilter: ''}, + {name: 'Unsubscribers', title: ts('Unsubscribes'), searchFilter: '&mailing_unsubscribe=1', eventsFilter: '&event=unsubscribe', reportType: 'detail', reportFilter: '&is_unsubscribed_value=1'}, + // {name: 'OptOuts', title: ts('Opt-Outs'), searchFilter: '&mailing_optout=1', eventsFilter: '&event=optout', reportType: 'detail', reportFilter: ''} ]; return { @@ -505,12 +505,13 @@ var retParams = returnPath ? '&context=angPage&angPage=' + returnPath : ''; return crmLegacy.url('civicrm/mailing/report/event', 'reset=1&mid=' + mailing.id + statType.eventsFilter + retParams); - case 'search': return crmLegacy.url('civicrm/contact/search/advanced', 'force=1&mailing_id=' + mailing.id + statType.searchFilter); - - // TODO: case 'report': + case 'report': + var reportIds = CRM.crmMailing.reportIds; + return crmLegacy.url('civicrm/report/instance/' + reportIds[statType.reportType], + 'reset=1&mailing_id_value=' + mailing.id + statType.reportFilter); default: return null; } diff --git a/ang/crmMailingAB/EditCtrl/report.html b/ang/crmMailingAB/EditCtrl/report.html index 4c4b8291ae..73d7988b8a 100644 --- a/ang/crmMailingAB/EditCtrl/report.html +++ b/ang/crmMailingAB/EditCtrl/report.html @@ -79,6 +79,12 @@ ng-href="{{statUrl(am.mailing, statType, 'events')}}" title="{{ts('Browse events of type \'%1\'', {1: statType.title})}}" >{{stats[am.name][statType.name] || ts('n/a')}} + -- 2.25.1