}
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");
}
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',
{{incGroup}}<br>{{excGroup}}
<h3>Select the size of your test group</h3><br>
-   Percentage Selected - {{slide_value}}%
+   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>
-   <input type="radio" ng-model="winner_criteria" value="Open" name="cri" required> Open <br/><br>
-   <input type="radio" ng-model="winner_criteria" value="Total Unique Clicks" name="cri" checked="checked">
+   <input type="radio" ng-model="currentABTest.winner_criteria_id" value=1 name="cri" required> Open <br/><br>
+   <input type="radio" ng-model="currentABTest.winner_criteria_id" value=2 name="cri" checked="checked">
Total Unique Clicks <br/><br>
-   <input type="radio" ng-model="winner_criteria" value="Total Clicks on a particular link" name="cri"> Total
+   <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>
-   <input type="text" style="height: 20px; width: 15px;" ng-model="days" numbar=7 name="d"> Days
-   <input type="text" style="height: 20px; width: 15px;" ng-model="hours" numbar=23 name="h"> Hours
-   <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;">  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   {{currentABTest.time}} Time</td>
</tr>
</table>