1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
(function(angular, $, _) {
angular.module('crmMailingAB').controller('CrmMailingABReportCtrl', function($scope, crmApi, crmMailingStats) {
var ts = $scope.ts = CRM.ts(null);
var CrmMailingABReportCnt = 1, activeMailings = null;
$scope.getActiveMailings = function() {
if ($scope.abtest.$CrmMailingABReportCnt != CrmMailingABReportCnt) {
$scope.abtest.$CrmMailingABReportCnt = ++CrmMailingABReportCnt;
activeMailings = [
{
name: 'a',
title: ts('Mailing A'),
mailing: $scope.abtest.mailings.a,
attachments: $scope.abtest.attachments.a
},
{
name: 'b',
title: ts('Mailing B'),
mailing: $scope.abtest.mailings.b,
attachments: $scope.abtest.attachments.b
}
];
if ($scope.abtest.ab.status == 'Final') {
activeMailings.push({
name: 'c',
title: ts('Final'),
mailing: $scope.abtest.mailings.c,
attachments: $scope.abtest.attachments.c
});
}
}
return activeMailings;
};
crmMailingStats.getStats({
a: $scope.abtest.ab.mailing_id_a,
b: $scope.abtest.ab.mailing_id_b,
c: $scope.abtest.ab.mailing_id_c
}).then(function(stats) {
$scope.stats = stats;
});
$scope.rateStats = {
'Unique Clicks': 'clickthrough_rate',
'Delivered': 'delivered_rate',
'Opened': 'opened_rate',
};
$scope.statTypes = crmMailingStats.getStatTypes();
$scope.statUrl = function statUrl(mailing, statType, view) {
return crmMailingStats.getUrl(mailing, statType, view, 'abtest/' + $scope.abtest.ab.id);
};
$scope.checkPerm = CRM.checkPerm;
});
})(angular, CRM.$, CRM._);
|