From 41f6e155792f6a387dd2c8ef26b75dff8f45a199 Mon Sep 17 00:00:00 2001 From: aditya-nambiar Date: Sun, 27 Jul 2014 17:41:57 +0530 Subject: [PATCH] Retrieving & Stroing from DB stage 2 --- js/angular-crmMailingAB.js | 138 +++++++++++++++++++++++--- partials/abtesting/from_name.html | 2 +- partials/abtesting/main.html | 46 ++++++--- partials/abtesting/subject_lines.html | 2 +- partials/abtesting/two_emails.html | 4 +- 5 files changed, 157 insertions(+), 35 deletions(-) diff --git a/js/angular-crmMailingAB.js b/js/angular-crmMailingAB.js index a7078cb701..a26f6d59e0 100644 --- a/js/angular-crmMailingAB.js +++ b/js/angular-crmMailingAB.js @@ -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" }; } } @@ -65,7 +65,12 @@ $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 = {}; } @@ -104,6 +110,8 @@ $scope.tab_val = 0; } }; + + $scope.winner_criteria=""; $scope.compose_clicked = function () { if ($scope.max_tab >= 1) { $scope.tab_val = 1; @@ -221,14 +229,14 @@ $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{ @@ -250,21 +258,88 @@ }); }; + $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; + } + } + } + + } }; @@ -286,9 +361,21 @@ $(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); @@ -450,10 +537,14 @@ 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(); } }); @@ -671,6 +762,23 @@ }; }); + 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', diff --git a/partials/abtesting/from_name.html b/partials/abtesting/from_name.html index e5782058a7..db46d4fbb0 100644 --- a/partials/abtesting/from_name.html +++ b/partials/abtesting/from_name.html @@ -41,7 +41,7 @@ Use Template - diff --git a/partials/abtesting/main.html b/partials/abtesting/main.html index 54bb7c2bd7..2a7b9346cc 100644 --- a/partials/abtesting/main.html +++ b/partials/abtesting/main.html @@ -57,15 +57,15 @@ {{incGroup}}
{{excGroup}}

Select the size of your test group


-   Percentage Selected - {{slide_value}}% +   Percentage Selected - {{currentABTest.group_percentage}}% -
+

How will the winner be decided


-   Open

-   +   Open

+   Total Unique Clicks

-   Total +   Total Clicks on a particular link

-

Declare the winner in how much time?


-   Days -   Hours -   Minutes -
  Please a Valid Time +

Declare the winner by when?


+ + + + + + + + + + + +
Date + + Time + +
+ +
+ Enter the time in the 12:32:45 format where 12 is the hour, 32 the minutes and 45 the seconds.


@@ -125,13 +138,13 @@ Size of Test Group - {{slide_value}} + {{currentABTest.group_percentage}} Winner Criteria {{winner_criteria}} - + - Declare Winner in - {{days}} Days {{hours}} Hours {{minutes}} Minutes + Declare Winner By + {{currentABTest.date}} Date   {{currentABTest.time}} Time diff --git a/partials/abtesting/subject_lines.html b/partials/abtesting/subject_lines.html index 63646f3d7a..3cd92152df 100644 --- a/partials/abtesting/subject_lines.html +++ b/partials/abtesting/subject_lines.html @@ -43,7 +43,7 @@ Use Template - diff --git a/partials/abtesting/two_emails.html b/partials/abtesting/two_emails.html index e0f8e5c1cf..163fb6a189 100644 --- a/partials/abtesting/two_emails.html +++ b/partials/abtesting/two_emails.html @@ -47,7 +47,7 @@ Use Template - @@ -266,7 +266,7 @@ Use Template - -- 2.25.1