Double storing fixed
authoraditya-nambiar <aditya.nambiar007@gmail.com>
Sun, 17 Aug 2014 11:50:27 +0000 (17:20 +0530)
committeraditya-nambiar <aditya.nambiar007@gmail.com>
Sun, 17 Aug 2014 11:50:27 +0000 (17:20 +0530)
CRM/Mailing/Info.php
js/angular-crmMailingAB.js
partials/abtesting/tab1.html
partials/abtesting/tab4.html

index 188869b985983b4627465ed16ee968639ae24abb..548e8cdaac845411aa53f0f83e57343f0897a681 100644 (file)
@@ -72,7 +72,7 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info {
     $emailAdd = civicrm_api3('Email', 'get', array());
     $mesTemplate = civicrm_api3('MessageTemplate', 'get', array(
       'sequential' => 1,
-      'return' => array("msg_html", "id", "msg_title"),
+      'return' => array("msg_html", "id", "msg_title","msg_subject"),
       'id' => array('>' => 58),
     ));
     $mailTokens = civicrm_api3('Mailing', 'get_token', array( 'usage' => 'Mailing'));
index 824cbe98c820eb4d6f2f68a4604590e91e40a329..2d5455ecadcc2ee292021e1c9ee3eda85ced28d0 100755 (executable)
     $scope.sparestuff ={};
     $scope.sparestuff.emailadd = "";
     $scope.sparestuff.winnercriteria = "";
+    $scope.sparestuff.isnew = false;
     mltokens = CRM.crmMailing.mailTokens;
     if ($scope.currentABTest.declare_winning_time != null) {
       $scope.ans = $scope.currentABTest.declare_winning_time.split(" ");
 
     if ($scope.currentABTest.just_created != 1) {
       $scope.abId = $scope.currentABTest.id;
+      $scope.sparestuff.isnew = false;
       var abmailA = crmApi('Mailing', 'getsingle', {id: $scope.currentABTest.mailing_id_a});
       var abmailB = crmApi('Mailing', 'getsingle', {id: $scope.currentABTest.mailing_id_b});
       var abmailC = crmApi('Mailing', 'getsingle', {id: $scope.currentABTest.mailing_id_c});
       });
     }
     else {
+      $scope.sparestuff.isnew = true;
       $scope.mailA = {};
       $scope.mailB = {};
       $scope.mailC = {};
       $scope.currentABTest.testing_criteria_id = $scope.sparestuff.template.val;
 
       if ($scope.abId == "") {
+        console.log("bb");
         result = crmApi('MailingAB', 'create', {name: $scope.currentABTest.name, testing_criteria_id: $scope.sparestuff.template.val});
       }
       else {
+        console.log("aa");
         if (typeof $scope.currentABTest.mailing_id_a == 'undefined') {
           result = crmApi('MailingAB', 'create', {id: $scope.abId, testing_criteria_id: $scope.sparestuff.template.val});
         }
       }
 
     }
+
     $scope.update_abtest = function () {
       $scope.currentABTest.declare_winning_time = $scope.currentABTest.date + " " + $scope.currentABTest.time;
       result = crmApi('MailingAB', 'create', {
         $scope.mailA.msg_template_id = tst;
         if ($scope.mailA.msg_template_id == null) {
           $scope.mailA.body_html = "";
+          $scope.mailA.subject="";
         }
         else {
           for (var a in $scope.tmpList) {
             if ($scope.tmpList[a].id == $scope.mailA.msg_template_id) {
               $scope.mailA.body_html = $scope.tmpList[a].msg_html;
+              $scope.mailA.subject=$scope.tmpList[a].msg_subject;
             }
           }
         }
           $scope.mailB.msg_template_id = tst;
           if ($scope.mailB.msg_template_id == null) {
             $scope.mailB.body_html = "";
+            $scope.mailB.subject="";
           }
           else {
             for (var a in $scope.tmpList) {
               if ($scope.tmpList[a].id == $scope.mailB.msg_template_id) {
                 $scope.mailB.body_html = $scope.tmpList[a].msg_html;
+                $scope.mailB.subject=$scope.tmpList[a].msg_subject;
+
               }
             }
           }
           $scope.mailA.msg_template_id = tst;
           if ($scope.mailA.msg_template_id == null) {
             $scope.mailA.body_html = "";
+            $scope.mailA.subject="";
           }
           else {
             for (var a in $scope.tmpList) {
               if ($scope.tmpList[a].id == $scope.mailA.msg_template_id) {
                 $scope.mailA.body_html = $scope.tmpList[a].msg_html;
+                $scope.mailA.subject=$scope.tmpList[a].msg_subject;
               }
             }
           }
           $scope.mailB.msg_template_id = tst;
           if ($scope.mailB.msg_template_id == null) {
             $scope.mailB.body_html = "";
+            $scope.mailB.subject="";
+
           }
           else {
             for (var a in $scope.tmpList) {
               if ($scope.tmpList[a].id == $scope.mailB.msg_template_id) {
                 $scope.mailB.body_html = $scope.tmpList[a].msg_html;
+                $scope.mailB.subject=$scope.tmpList[a].msg_subject;
+
               }
             }
           }
       }
     }
 
+    /*$scope.tmp = function (tst){
+      $scope.currentMailing.msg_template_id=tst;
+      console.log($scope.currentMailing.msg_template_id+ "sasas");
+      if($scope.currentMailing.msg_template_id == null){
+        $scope.currentMailing.body_html="";
+        $scope.currentMailing.subject="";
+      }
+      else{
+        for(var a in $scope.tmpList){
+
+          if($scope.tmpList[a].id==$scope.currentMailing.msg_template_id){
+            $scope.currentMailing.body_html=$scope.tmpList[a].msg_html;
+            console.log($scope.tmpList[a].msg_subject);
+            $scope.currentMailing.subject=$scope.tmpList[a].msg_subject;
+            console.log($scope.currentMailing.subject);
+          }
+        }
+      }
+    };*/
+
     $scope.$watch('preview', function () {
       console.log("dsfdfsfds");
       if ($scope.preview == true) {
         var myarr = new Array(1, 2, 3)
 
         // disable remaining tabs
+        if(scope.sparestuff.isnew == true)
         tabselector.tabs({disabled: myarr});
 
         $(element).on("click", function () {
           if (scope.tab_val == 0) {
+            console.log("att");
             scope.create_abtest();
+
+            console.log("tt");
           }
           else {
             if (scope.tab_val == 2) {
index 75770b5ec7770556f10940e0ea2767404fda5f3b..185ae60162c570c4b379c9b982ff81ddfcff37fe 100755 (executable)
@@ -17,7 +17,7 @@
 
     <div class="crm-submit-buttons">
     <span class="crm-button">
-      <input type="submit" ng-click="tab1Form.$setPristine(); create_abtest();" ng-disabled="tab1Form.$invalid" value="Next" nexttab="{{tab_val}}"/>
+      <input type="submit" ng-click="tab1Form.$setPristine(); " ng-disabled="tab1Form.$invalid" value="Next" nexttab="{{tab_val}}"/>
     </span>
     <span class="crm-button">
       <input type="submit" ng-click="tab1Form.$setPristine(); goto('mailing/abtesting');" value="Cancel"/>
index 0402d98bfe9ab6dcfdf745f5bad005a4e269ac53..caada6782eb95cb251acc2526eefa22fe5ee268b 100755 (executable)
     <h3>When to Start</h3><br>
 
     <div>
-      <input type="radio" name="Start" ng-model="start" value="now"> Now &nbsp
+      <input type="radio" name="Start" ng-model="start" value="now" ng-checked="true"> Now &nbsp
       <input type="radio" name="Start" ng-model="start" value="later"> Later
       <div ng-show="start=='later'">
-      &nbsp &nbsp <input type="text" class="dateplugin"  ng-model="send_date" datepick>
+      &nbsp &nbsp <input type="text" class="dateplugin"  ng-model="send_date" datepick >
       &nbsp &nbsp Time :<input type="text" placeholder="hh:mm" ng-model="currentABTest.latertime"  checktimeentry >
       </div>
     </div>