diff options
author | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
commit | fc7369835258467bf97eb64f184b93691f9a9fd5 (patch) | |
tree | daabd60089d2dd76d9f5fb416b005fbe159c799d /www/crm/wp-content/plugins/civicrm/civicrm/ang/crmMailingAB/ReportCtrl.js |
first commit
Diffstat (limited to 'www/crm/wp-content/plugins/civicrm/civicrm/ang/crmMailingAB/ReportCtrl.js')
-rw-r--r-- | www/crm/wp-content/plugins/civicrm/civicrm/ang/crmMailingAB/ReportCtrl.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/www/crm/wp-content/plugins/civicrm/civicrm/ang/crmMailingAB/ReportCtrl.js b/www/crm/wp-content/plugins/civicrm/civicrm/ang/crmMailingAB/ReportCtrl.js new file mode 100644 index 00000000..8755945e --- /dev/null +++ b/www/crm/wp-content/plugins/civicrm/civicrm/ang/crmMailingAB/ReportCtrl.js @@ -0,0 +1,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._); |