fixed saving of mailing a/b
authoraditya-nambiar <aditya.nambiar007@gmail.com>
Sun, 17 Aug 2014 10:43:08 +0000 (16:13 +0530)
committeraditya-nambiar <aditya.nambiar007@gmail.com>
Sun, 17 Aug 2014 10:43:08 +0000 (16:13 +0530)
CRM/Mailing/Event/BAO/Delivered.php
api/v3/MailingAB.php
js/angular-crmMailingAB.js

index 7c424102ab694337a0cf549a5a83d42682528f0b..f1af54d82253878cdd68f8782b3222dcf61fa06a 100755 (executable)
@@ -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();
index af06b8a512b9a9734140d8703c8a8861a561a3c4..847233ec3a4da57674ebc6c1a82af693a09e25a2 100755 (executable)
@@ -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();
index b1f59f9a27e04151380487485e35ebf03a8dd152..824cbe98c820eb4d6f2f68a4604590e91e40a329 100755 (executable)
       $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
       });
       });
 
       $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});
 
     }
     $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,
     $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 = "";
         }
       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 = "";
           }
         }
         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 = "";
           }
           }
 
           $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 = "";
           }
             my: 'left',
             at: 'top',
             of: $(".crmABTestingAllTabs")
-
-
           },
 
           close: function () {
     }, true);
 
     $scope.call = function(){
-      console.log($scope.emailadd);
       $scope.$apply();
       var result = crmApi('Mailing','send_test',{
         mailing_id : $scope.currentABTest.mailing_id_a,
         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',
           buttons: {
             'Send': function () {
               $scope.call();
-
               $scope.sendtest = false;
               $('#sendtest').dialog("close");
 
         });
       }
     });
-
   });
 
   crmMailingAB.directive('nexttab', function () {