1 (function(angular
, $, _
) {
3 angular
.module('crmMailingAB').controller('CrmMailingABReportCtrl', function($scope
, crmApi
, crmMailingStats
) {
4 var ts
= $scope
.ts
= CRM
.ts(null);
6 var CrmMailingABReportCnt
= 1, activeMailings
= null;
7 $scope
.getActiveMailings = function() {
8 if ($scope
.abtest
.$CrmMailingABReportCnt
!= CrmMailingABReportCnt
) {
9 $scope
.abtest
.$CrmMailingABReportCnt
= ++CrmMailingABReportCnt
;
13 title
: ts('Mailing A'),
14 mailing
: $scope
.abtest
.mailings
.a
,
15 attachments
: $scope
.abtest
.attachments
.a
19 title
: ts('Mailing B'),
20 mailing
: $scope
.abtest
.mailings
.b
,
21 attachments
: $scope
.abtest
.attachments
.b
24 if ($scope
.abtest
.ab
.status
== 'Final') {
28 mailing
: $scope
.abtest
.mailings
.c
,
29 attachments
: $scope
.abtest
.attachments
.c
33 return activeMailings
;
36 crmMailingStats
.getStats({
37 a
: $scope
.abtest
.ab
.mailing_id_a
,
38 b
: $scope
.abtest
.ab
.mailing_id_b
,
39 c
: $scope
.abtest
.ab
.mailing_id_c
40 }).then(function(stats
) {
44 'Unique Clicks': 'clickthrough_rate',
45 'Delivered': 'delivered_rate',
46 'Opened': 'opened_rate',
48 $scope
.statTypes
= crmMailingStats
.getStatTypes();
49 $scope
.statUrl
= function statUrl(mailing
, statType
, view
) {
50 return crmMailingStats
.getUrl(mailing
, statType
, view
, 'abtest/' + $scope
.abtest
.ab
.id
);
53 $scope
.checkPerm
= CRM
.checkPerm
;
56 })(angular
, CRM
.$, CRM
._
);