Retrieving & Stroing from DB stage 2
authoraditya-nambiar <aditya.nambiar007@gmail.com>
Sun, 27 Jul 2014 12:11:57 +0000 (17:41 +0530)
committeraditya-nambiar <aditya.nambiar007@gmail.com>
Sun, 27 Jul 2014 12:11:57 +0000 (17:41 +0530)
js/angular-crmMailingAB.js
partials/abtesting/from_name.html
partials/abtesting/main.html
partials/abtesting/subject_lines.html
partials/abtesting/two_emails.html

index a7078cb70188570ddc9feb9f52d0a3454c7a921c..a26f6d59e0cc84971fac5a594464c6bd82e2689e 100644 (file)
@@ -40,7 +40,7 @@
             }
             else {
               //created_id has been set to my id. Does not save without created_id. Needs to made generic based on the user
-              return {visibility: "Public Pages", url_tracking:"1", forward_replies:"0", created_id: "202", auto_responder:"0", open_tracking:"1",just_created:"1"
+              return { just_created:"1"
               };
             }
           }
     $scope.eMailing = CRM.crmMailing.emailAdd;
     $scope.tmpList = CRM.crmMailing.mesTemplate;
     $scope.headerfooter = CRM.crmMailing.headerfooterList;
+    if($scope.currentABTest.declare_winning_time != null){
+      $scope.ans= $scope.currentABTest.declare_winning_time.split(" ");
+      $scope.currentABTest.date=$scope.ans[0];
+      $scope.currentABTest.time=$scope.ans[1];
 
+    }
 
       if($scope.currentABTest.just_created != 1){
         console.log("Prithvi");
@@ -90,6 +95,7 @@
       }
       else{
         console.log("Prithvila");
+        console.log($scope.currentABTest);
         $scope.mailA = {};
         $scope.mailB = {};
       }
         $scope.tab_val = 0;
       }
     };
+
+    $scope.winner_criteria="";
     $scope.compose_clicked = function () {
       if ($scope.max_tab >= 1) {
         $scope.tab_val = 1;
       $scope.apply();
     };
 
-    $scope.scheddate = {};
-    $scope.scheddate.date = "6";
-    $scope.scheddate.time = "";
+
     $scope.incGroup = [];
     $scope.excGroup = [];
 
     $scope.create_abtest = function(){
       var result;
+      $scope.currentABTest.testing_criteria_id=$scope.template.val;
+
       if($scope.abId =="" )
       result= crmApi('MailingAB','create',{testing_criteria_id: $scope.template.val});
       else{
       });
     };
 
+    $scope.update_abtest = function(){
+
+      $scope.currentABTest.declare_winning_time= $scope.currentABTest.date + " " + $scope.currentABTest.time ;
+
+      result= crmApi('MailingAB','create',{id:$scope.abId,
+                      testing_criteria_id: $scope.template.val,
+                      mailing_id_a:$scope.currentABTest.mailing_id_a,
+                      mailing_id_b:$scope.currentABTest.mailing_id_b,
+                      winner_criteria_id : $scope.currentABTest.winner_criteria_id,
+                      group_percentage: $scope.currentABTest.group_percentage,
+                      declare_winning_time: $scope.currentABTest.declare_winning_time
+                      } );
+
+    };
+
+
+
+
+    $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{
+          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;
+            }
+          }
+        }
+      }
+      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{
+          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.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="";
       }
-      else{
-        for(var a in $scope.tmpList){
+      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="";
+        }
+        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;
+            if($scope.tmpList[a].id==$scope.mailA.msg_template_id){
+              $scope.mailA.body_html=$scope.tmpList[a].msg_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="";
+        }
+        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;
+            }
+          }
+        }
+
+
       }
     };
 
 
         $(element).on("click", function () {
           if(scope.tab_val==0){
-
             scope.create_abtest();
           }
+          else if(scope.tab_val == 2){
+            scope.update_abtest();
+            if(scope.currentABTest.winner_criteria_id==1){
+              scope.winner_criteria="Open";
+            }
+            else if(scope.currentABTest.winner_criteria_id==2){
+              scope.winner_criteria=" Total Unique Clicks";
+            }
+            else if(scope.currentABTest.winner_criteria_id==3){
+                scope.winner_criteria="Total Clicks on a particular link";
+              }
+          }
+
           scope.tab_val = scope.tab_val + 1;
 
           scope.max_tab = Math.max(scope.tab_val, scope.max_tab);
     return{
       restrict: 'AE',
       link: function (scope, element, attrs) {
+        if(typeof scope.currentABTest.group_percentage != undefined){
+          console.log("Yay");
+          $(element).slider({value:scope.currentABTest.group_percentage});
+        }
         $(element).slider({min: 1});
         $(element).slider({
           slide: function (event, ui) {
-            scope.slide_value = ui.value;
+            scope.currentABTest.group_percentage = ui.value;
             scope.$apply();
           }
         });
     };
   });
 
+  crmMailingAB.directive('chsdate',function(){
+    return {
+      restrict: 'AE',
+      link: function(scope,element,attrs){
+        $(element).datepicker({
+          dateFormat: "yy-mm-dd",
+          onSelect: function(date) {
+            $(".ui-datepicker a").removeAttr("href");
+            scope.scheddate.date=date.toString();
+            scope.$apply();
+            console.log(scope.scheddate.date);
+          }
+        });
+      }
+    };
+  });
+
   crmMailingAB.directive('prevbutton', function () {
     return {
       restrict: 'AE',
index e5782058a764024b4f6eea23104491ba7b33651a..db46d4fbb081dbc692e1c08a8b1f08fde370f31c 100644 (file)
@@ -41,7 +41,7 @@
     <tr>
         <td class="label">Use Template</td>
         <td>
-            <select ng-change="tmp(tst)" ng-model="tst" ng-options= "mstemp.id as mstemp.msg_title for mstemp in tmpList">
+            <select ng-change="tmp(mailA.msg_template_id,3)" ng-model="mailA.msg_template_id" ng-options= "mstemp.id as mstemp.msg_title for mstemp in tmpList">
                 <option value="">-none-</option>
             </select>
         </td>
index 54bb7c2bd75edfa6f48d5315bd9d93c1541d2527..2a7b9346ccfdf90e01dec17f9888b4d52eb2da53 100644 (file)
         {{incGroup}}<br>{{excGroup}}
 
         <h3>Select the size of your test group</h3><br>
-        &nbsp Percentage Selected - {{slide_value}}%
+        &nbsp Percentage Selected - {{currentABTest.group_percentage}}%
 
-        <div sliderbar id="trial" style="margin: 10px;"></div>
+        <div sliderbar id="trial" style="margin: 10px;" ></div>
 
         <h3>How will the winner be decided</h3><br>
-        &nbsp <input type="radio" ng-model="winner_criteria" value="Open" name="cri" required> Open <br/><br>
-        &nbsp <input type="radio" ng-model="winner_criteria" value="Total Unique Clicks" name="cri" checked="checked">
+        &nbsp <input type="radio" ng-model="currentABTest.winner_criteria_id" value=1 name="cri" required> Open <br/><br>
+        &nbsp <input type="radio" ng-model="currentABTest.winner_criteria_id" value=2 name="cri" checked="checked">
         Total Unique Clicks <br/><br>
-        &nbsp <input type="radio" ng-model="winner_criteria" value="Total Clicks on a particular link" name="cri"> Total
+        &nbsp <input type="radio" ng-model="currentABTest.winner_criteria_id" value=3 name="cri"> Total
         Clicks on a particular link <br/><br>
         <!-- Remove automated
                        <h3>Do you want the A/B test to be automated </h3>
 
                        </tpmax>
        -->
-        <h3>Declare the winner in how much time?</h3><br>
-        &nbsp <input type="text" style="height: 20px; width: 15px;" ng-model="days" numbar=7 name="d"> Days
-        &nbsp <input type="text" style="height: 20px; width: 15px;" ng-model="hours" numbar=23 name="h"> Hours
-        &nbsp <input type="text" style="height: 20px; width: 15px;" ng-model="minutes" numbar=59 name="m"> Minutes
-        <div
-          ng-show="((days == null || days ==0 ) && (hours==null|| hours == 0 ) && (minutes==null || minutes ==0 )|| days>99 || minutes>59 || hours >23) "
-          style="color: red;">&nbsp Please a Valid Time
+        <h3>Declare the winner by when?</h3><br>
+        <table>
+          <tbody>
+
+        <tr >
+          <td class="label">Date</td>
+          <td>
+            <input type="text" chsdate ng-model="currentABTest.date" >
+          </td>
+          <td class="label" >Time</td>
+          <td>
+            <input type="text" placeholder="hh:mm:ss" ng-model="currentABTest.time">
+          </td>
+        </tr>
+
+        </tbody>
+        </table>
+
+        <div id="help" >
+          Enter the time in the 12:32:45 format where 12 is the hour, 32 the minutes and 45 the seconds.
         </div>
         <br>
         <br>
         </tr>
         <tr>
           <td>Size of Test Group</td>
-          <td>{{slide_value}}</td>
+          <td>{{currentABTest.group_percentage}}</td>
         </tr>
         <tr>
           <td>Winner Criteria</td>
           <td>{{winner_criteria}}</td>
         </tr>
-
+<!--
         <tr ng-show="automated=='Yes'">
           <td>Minum Confidence Level</td>
           <td>{{conf}}%</td>
           <td>If Level not Achieved</td>
           <td>{{ifnot}}</td>
         </tr>
+-->
         <tr>
-          <td>Declare Winner in</td>
-          <td>{{days}} Days {{hours}} Hours {{minutes}} Minutes</td>
+          <td>Declare Winner By</td>
+          <td>{{currentABTest.date}} Date &nbsp {{currentABTest.time}} Time</td>
         </tr>
       </table>
 
index 63646f3d7a1de4d2884493eb0fe4c730a72aa2d6..3cd92152df663f6ef698fc9518e763bcbd26689e 100644 (file)
@@ -43,7 +43,7 @@
   <tr>
     <td class="label">Use Template</td>
     <td>
-      <select ng-change="tmp(tst)" ng-model="tst" ng-options= "mstemp.id as mstemp.msg_title for mstemp in tmpList">
+      <select ng-change="tmp(mailA.msg_template_id,3)" ng-model="mailA.msg_template_id" ng-options= "mstemp.id as mstemp.msg_title for mstemp in tmpList">
         <option value="">-none-</option>
       </select>
     </td>
index e0f8e5c1cf1574128d084ea54cb15e580b666995..163fb6a189792869c9a7ac306f087663330b3330 100644 (file)
@@ -47,7 +47,7 @@
           <tr>
             <td class="label">Use Template</td>
             <td>
-              <select ng-change="tmp(tst)" ng-model="tst" ng-options= "mstemp.id as mstemp.msg_title for mstemp in tmpList">
+              <select ng-change="tmp(mailA.msg_template_id,1)" ng-model="mailA.msg_template_id" ng-options= "mstemp.id as mstemp.msg_title for mstemp in tmpList">
                 <option value="">-none-</option>
               </select>
             </td>
           <tr>
             <td class="label">Use Template</td>
             <td>
-              <select ng-change="tmp(tst)" ng-model="tst" ng-options= "mstemp.id as mstemp.msg_title for mstemp in tmpList">
+              <select ng-change="tmp(mailB.msg_template_id,2)" ng-model="mailB.msg_template_id" ng-options= "mstemp.id as mstemp.msg_title for mstemp in tmpList">
                 <option value="">-none-</option>
               </select>
             </td>