From 2e84f38d71dff3d89f5540923f1d33a1f296ad2c Mon Sep 17 00:00:00 2001 From: aditya-nambiar Date: Sun, 17 Aug 2014 16:13:08 +0530 Subject: [PATCH] fixed saving of mailing a/b --- CRM/Mailing/Event/BAO/Delivered.php | 2 +- api/v3/MailingAB.php | 6 +++--- js/angular-crmMailingAB.js | 26 +++++++------------------- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/CRM/Mailing/Event/BAO/Delivered.php b/CRM/Mailing/Event/BAO/Delivered.php index 7c424102ab..f1af54d822 100755 --- a/CRM/Mailing/Event/BAO/Delivered.php +++ b/CRM/Mailing/Event/BAO/Delivered.php @@ -153,7 +153,7 @@ class CRM_Mailing_Event_BAO_Delivered extends CRM_Mailing_Event_DAO_Delivered { * @static */ public static function &getRows($mailing_id, $job_id = NULL, - $is_distinct = FALSE, $offset = NULL, $rowCount = NULL, $sort = NULL, $is_test = FALSE + $is_distinct = FALSE, $offset = NULL, $rowCount = NULL, $sort = NULL, $is_test = 0 ) { $dao = new CRM_Core_Dao(); diff --git a/api/v3/MailingAB.php b/api/v3/MailingAB.php index af06b8a512..847233ec3a 100755 --- a/api/v3/MailingAB.php +++ b/api/v3/MailingAB.php @@ -138,12 +138,12 @@ function civicrm_api3_mailing_a_b_send_mail($params) { $params['scheduled_date'] = CRM_Utils_Date::processDate($params['scheduled_date'] . ' ' . $params['scheduled_date_time']); } - $mailingAB = civicrm_api3('MailingAB', 'get', array('id' => $params['id'])); $mailingAB = $mailingAB['values'][$params['id']]; - foreach (array('mailing_id_a', 'mailing_id_b') as $columnName) { - civicrm_api3('Mailing', 'create', $params + array('id' => $mailingAB[$columnName])); + foreach (array('mailing_id_a', 'mailing_id_b') as $columnName) { + $params['id'] = $mailingAB[$columnName]; + civicrm_api3('Mailing', 'create', $params); } return civicrm_api3_create_success(); diff --git a/js/angular-crmMailingAB.js b/js/angular-crmMailingAB.js index b1f59f9a27..824cbe98c8 100755 --- a/js/angular-crmMailingAB.js +++ b/js/angular-crmMailingAB.js @@ -425,11 +425,7 @@ $scope.tp1.include = $scope.incGroupids; $scope.tp1.exclude = $scope.excGroupids; - console.log($scope.tp1); - console.log($scope.currentABTest.id); - - console.log("--------"); - var result = crmApi('Mailing', 'a_b_recipients_update', { + var result = crmApi('MailingAB', 'recipients_update', { id: $scope.currentABTest.id, groups: $scope.tp1 }); @@ -453,7 +449,9 @@ }); $scope.startabtest = function(){ - console.log("yo"); + if (typeof $scope.sparestuff.date == 'undefined') { + $scope.sparestuff.date = 'now'; + } var result = crmApi('MailingAB', 'send_mail', {id: $scope.abId, scheduled_date : $scope.sparestuff.date , scheduled_date_time: $scope.currentABTest.latertime}); @@ -475,7 +473,8 @@ } $scope.update_abtest = function () { $scope.currentABTest.declare_winning_time = $scope.currentABTest.date + " " + $scope.currentABTest.time; - result = crmApi('MailingAB', 'create', {id: $scope.abId, + result = crmApi('MailingAB', 'create', { + id: $scope.abId, testing_criteria_id: $scope.sparestuff.template.val, mailing_id_a: $scope.currentABTest.mailing_id_a, mailing_id_b: $scope.currentABTest.mailing_id_b, @@ -490,7 +489,6 @@ $scope.tmp = function (tst, aorb) { if (aorb == 1) { $scope.mailA.msg_template_id = tst; - console.log($scope.mailA.msg_template_id + "sasas"); if ($scope.mailA.msg_template_id == null) { $scope.mailA.body_html = ""; } @@ -505,7 +503,6 @@ else { if (aorb == 2) { $scope.mailB.msg_template_id = tst; - console.log($scope.mailB.msg_template_id + "sasas"); if ($scope.mailB.msg_template_id == null) { $scope.mailB.body_html = ""; } @@ -519,7 +516,6 @@ } else { $scope.mailA.msg_template_id = tst; - console.log($scope.mailA.msg_template_id + "sasas"); if ($scope.mailA.msg_template_id == null) { $scope.mailA.body_html = ""; } @@ -532,7 +528,6 @@ } $scope.mailB.msg_template_id = tst; - console.log($scope.mailB.msg_template_id + "sasas"); if ($scope.mailB.msg_template_id == null) { $scope.mailB.body_html = ""; } @@ -561,8 +556,6 @@ my: 'left', at: 'top', of: $(".crmABTestingAllTabs") - - }, close: function () { @@ -578,7 +571,6 @@ }, true); $scope.call = function(){ - console.log($scope.emailadd); $scope.$apply(); var result = crmApi('Mailing','send_test',{ mailing_id : $scope.currentABTest.mailing_id_a, @@ -589,11 +581,9 @@ mailing_id : $scope.currentABTest.mailing_id_b, test_email : $scope.sparestuff.emailadd }) - console.log($scope.sparestuff.emailadd); - } - $scope.$watch('sendtest', function () { + $scope.$watch('sendtest', function () { if ($scope.sendtest == true) { $('#sendtest').dialog({ title: 'Send Test Mails', @@ -605,7 +595,6 @@ buttons: { 'Send': function () { $scope.call(); - $scope.sendtest = false; $('#sendtest').dialog("close"); @@ -619,7 +608,6 @@ }); } }); - }); crmMailingAB.directive('nexttab', function () { -- 2.25.1