Commit | Line | Data |
---|---|---|
679996bb TO |
1 | (function(angular, $, _) { |
2 | ||
3 | angular.module('crmMailingAB').controller('CrmMailingABReportCtrl', function($scope, crmApi, crmMailingStats) { | |
4 | var ts = $scope.ts = CRM.ts(null); | |
5 | ||
6 | var CrmMailingABReportCnt = 1, activeMailings = null; | |
7 | $scope.getActiveMailings = function() { | |
8 | if ($scope.abtest.$CrmMailingABReportCnt != CrmMailingABReportCnt) { | |
9 | $scope.abtest.$CrmMailingABReportCnt = ++CrmMailingABReportCnt; | |
10 | activeMailings = [ | |
11 | { | |
12 | name: 'a', | |
13 | title: ts('Mailing A'), | |
14 | mailing: $scope.abtest.mailings.a, | |
15 | attachments: $scope.abtest.attachments.a | |
16 | }, | |
17 | { | |
18 | name: 'b', | |
19 | title: ts('Mailing B'), | |
20 | mailing: $scope.abtest.mailings.b, | |
21 | attachments: $scope.abtest.attachments.b | |
22 | } | |
23 | ]; | |
24 | if ($scope.abtest.ab.status == 'Final') { | |
25 | activeMailings.push({ | |
26 | name: 'c', | |
27 | title: ts('Final'), | |
28 | mailing: $scope.abtest.mailings.c, | |
29 | attachments: $scope.abtest.attachments.c | |
30 | }); | |
31 | } | |
32 | } | |
33 | return activeMailings; | |
34 | }; | |
35 | ||
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) { | |
41 | $scope.stats = stats; | |
42 | }); | |
796b4348 SL |
43 | $scope.rateStats = { |
44 | 'Unique Clicks': 'clickthrough_rate', | |
45 | 'Delivered': 'delivered_rate', | |
46 | 'Opened': 'opened_rate', | |
47 | }; | |
679996bb TO |
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); | |
51 | }; | |
52 | ||
53 | $scope.checkPerm = CRM.checkPerm; | |
54 | }); | |
55 | ||
56 | })(angular, CRM.$, CRM._); |