983052fe |
1 | /** |
2 | * Created by aditya on 6/12/14. |
3 | */ |
4 | |
5 | |
5c691259 |
6 | (function (angular, $, _) { |
7 | |
fd843187 |
8 | var partialUrl = function (relPath) { |
9 | return CRM.resourceUrls['civicrm'] + '/partials/abtesting/' + relPath; |
10 | }; |
11 | |
12 | var crmMailingAB = angular.module('crmMailingAB', ['ngRoute', 'ui.utils']); |
493b91cf |
13 | var mltokens = []; |
fd843187 |
14 | crmMailingAB.run(function ($rootScope, $templateCache) { |
15 | $rootScope.$on('$viewContentLoaded', function () { |
16 | $templateCache.removeAll(); |
17 | }); |
18 | }); |
19 | |
20 | crmMailingAB.config([ |
21 | '$routeProvider', |
22 | function ($routeProvider) { |
23 | $routeProvider.when('/mailing/abtesting', { |
24 | templateUrl: partialUrl('list.html'), |
25 | controller: 'ListingCtrl', |
26 | resolve: { |
27 | mailingList: function ($route, crmApi) { |
28 | return crmApi('Mailing', 'get', {}); |
29 | } |
30 | } |
31 | }); |
32 | $routeProvider.when('/mailing/abtesting/:id', { |
33 | templateUrl: partialUrl('main.html'), |
34 | controller: 'TabsDemoCtrl', |
35 | resolve: { |
493b91cf |
36 | selectedABTest: function($route, crmApi) { |
37 | if ( $route.current.params.id !== 'new') { |
38 | |
39 | return crmApi('MailingAB', 'getsingle', {id: $route.current.params.id}); |
40 | } |
41 | else { |
5cd34d46 |
42 | console.log("created"); |
493b91cf |
43 | //created_id has been set to my id. Does not save without created_id. Needs to made generic based on the user |
41f6e155 |
44 | return { just_created:"1" |
493b91cf |
45 | }; |
46 | } |
fd843187 |
47 | } |
48 | } |
49 | }); |
50 | } |
51 | ]); |
f2719425 |
52 | |
983052fe |
53 | //----------------------------------------- |
fd843187 |
54 | // Add a new record by name. |
55 | // Ex: <crmAddName crm-options="['Alpha','Beta','Gamma']" crm-var="newItem" crm-on-add="callMyCreateFunction(newItem)" /> |
56 | crmMailingAB.controller('ListingCtrl', function ($scope, crmApi) { |
fbbff1a0 |
57 | $scope.abmailList = CRM.crmMailing.mailingabNames; |
58 | console.log($scope.abmailList); |
59 | |
fd843187 |
60 | |
61 | }) |
493b91cf |
62 | crmMailingAB.controller('TabsDemoCtrl', function ($scope, crmApi,selectedABTest) { |
63 | $scope.abId=""; |
3cbae671 |
64 | $scope.whatnext=2; |
493b91cf |
65 | $scope.currentABTest=selectedABTest |
fd843187 |
66 | $scope.groups = CRM.crmMailing.groupNames; |
67 | $scope.mailList = CRM.crmMailing.civiMails; |
493b91cf |
68 | $scope.eMailing = CRM.crmMailing.emailAdd; |
69 | $scope.tmpList = CRM.crmMailing.mesTemplate; |
70 | $scope.headerfooter = CRM.crmMailing.headerfooterList; |
41f6e155 |
71 | if($scope.currentABTest.declare_winning_time != null){ |
72 | $scope.ans= $scope.currentABTest.declare_winning_time.split(" "); |
73 | $scope.currentABTest.date=$scope.ans[0]; |
74 | $scope.currentABTest.time=$scope.ans[1]; |
493b91cf |
75 | |
41f6e155 |
76 | } |
493b91cf |
77 | |
78 | if($scope.currentABTest.just_created != 1){ |
79 | console.log("Prithvi"); |
80 | console.log($scope.currentABTest); |
81 | console.log($scope.currentABTest.mailing_id_a); |
82 | |
83 | $scope.abId = $scope.currentABTest.id; |
3cbae671 |
84 | var abmailA = crmApi('Mailing','getsingle',{id:$scope.currentABTest.mailing_id_a}); |
85 | var abmailB= crmApi('Mailing','getsingle',{id:$scope.currentABTest.mailing_id_b}); |
86 | abmailA.success(function (data) { |
87 | if (data.is_error == 0) { |
88 | $scope.mailA = data; |
89 | |
90 | }; |
91 | }); |
92 | abmailB.success(function(data) { |
93 | if (data.is_error == 0) { |
94 | $scope.mailB = data; |
95 | |
96 | }; |
97 | }); |
493b91cf |
98 | } |
99 | else{ |
100 | console.log("Prithvila"); |
41f6e155 |
101 | console.log($scope.currentABTest); |
493b91cf |
102 | $scope.mailA = {}; |
103 | $scope.mailB = {}; |
104 | } |
105 | |
fbbff1a0 |
106 | $scope.templates = |
107 | [ |
108 | { name: 'Subject Lines', url: partialUrl('subject_lines.html'),val: 1}, |
109 | { name: 'From Name', url: partialUrl('from_name.html'),val:2}, |
110 | {name: 'Two different Emails', url: partialUrl('two_emails.html'),val:3} |
111 | ]; |
5cd34d46 |
112 | if($scope.currentABTest.just_created != 1){ |
113 | |
fbbff1a0 |
114 | console.log("adit "+$scope.currentABTest.testing_criteria_id); |
115 | |
116 | $scope.template=$scope.templates[$scope.currentABTest.testing_criteria_id-1]; |
117 | console.log($scope.template.val); |
5cd34d46 |
118 | } |
119 | else{ |
120 | console.log("adi"); |
121 | $scope.template = $scope.templates[0]; |
fbbff1a0 |
122 | } |
493b91cf |
123 | |
124 | mltokens = CRM.crmMailing.mailTokens; |
fd843187 |
125 | |
126 | $scope.tab_val = 0; |
127 | $scope.max_tab = 0; |
128 | $scope.campaign_clicked = function () { |
129 | if ($scope.max_tab >= 0) { |
130 | $scope.tab_val = 0; |
131 | } |
132 | }; |
41f6e155 |
133 | |
134 | $scope.winner_criteria=""; |
fd843187 |
135 | $scope.compose_clicked = function () { |
136 | if ($scope.max_tab >= 1) { |
137 | $scope.tab_val = 1; |
138 | } |
139 | }; |
140 | $scope.rec_clicked = function () { |
141 | if ($scope.max_tab >= 2) { |
142 | $scope.tab_val = 2; |
143 | } |
144 | }; |
145 | $scope.preview_clicked = function () { |
146 | if ($scope.max_tab >= 3) { |
147 | $scope.tab_val = 3; |
148 | } |
149 | }; |
fd843187 |
150 | |
151 | $scope.slide_value = 0; |
152 | |
153 | $scope.setifyes = function (val) { |
154 | if (val == 1) { |
155 | $scope.ifyes = true; |
156 | } |
157 | else { |
158 | $scope.ifyes = false; |
159 | } |
160 | }; |
161 | |
493b91cf |
162 | $scope.reply = function(){ |
163 | if($scope.trackreplies==0){ |
164 | $scope.trackreplies=1; |
165 | } |
166 | else{ |
167 | $scope.trackreplies=0; |
168 | $scope.currentMailing.forward_replies=0; |
169 | $scope.currentMailing.auto_responder=0; |
170 | } |
171 | } |
172 | |
173 | $scope.isAuto= function(au){ |
174 | return au.component_type == "Reply"; |
175 | }; |
176 | |
177 | $scope.trackr= function(trackreplies){ |
178 | if(trackreplies=="1"){ |
179 | return true; |
180 | } |
181 | else |
182 | return false; |
183 | } |
184 | |
185 | |
186 | |
187 | $scope.isHeader= function(hf){ |
188 | return hf.component_type == "Header"; |
189 | }; |
190 | //filter so we only get footers from mailing component |
191 | $scope.isFooter= function(f){ |
192 | return f.component_type == "Footer"; |
193 | }; |
194 | |
fd843187 |
195 | $scope.send_date = "01/01/2000"; |
196 | |
197 | $scope.dt = ""; |
198 | |
fd843187 |
199 | |
493b91cf |
200 | $scope.savea = function (dat) { |
fd843187 |
201 | |
202 | var result = crmApi('Mailing', 'create', dat, true); |
493b91cf |
203 | console.log(result); |
204 | result.success(function(data) { |
205 | if (data.is_error == 0) { |
206 | $scope.mailA.id = data.id; |
207 | console.log("Mail a Id "+ $scope.mailA.id); |
208 | } |
209 | }); |
210 | }; |
211 | |
212 | $scope.append_mails = function(){ |
213 | crmApi('MailingAB','create',{id:$scope.abId,mailing_id_a:$scope.mailA.id,mailing_id_b:$scope.mailB.id}); |
214 | }; |
215 | |
216 | $scope.saveb = function (dat) { |
217 | var flag =0; |
218 | var result = crmApi('Mailing', 'create', dat, true); |
219 | console.log(result); |
220 | result.success(function(data) { |
221 | if (data.is_error == 0) { |
222 | $scope.mailB.id = data.id; |
223 | console.log("Mail b Id "+ $scope.mailB.id); |
224 | $scope.append_mails(); |
225 | |
226 | |
227 | } |
228 | }); |
229 | |
fd843187 |
230 | }; |
231 | |
232 | $scope.init = function (par) { |
233 | |
234 | $scope.whatnext = par.toString() |
235 | }; |
236 | |
237 | $scope.setdate = function (par) { |
238 | console.log("called") |
239 | console.log("av " + par) |
240 | $scope.send_date = par; |
241 | $scope.dt = par; |
242 | $scope.apply(); |
243 | }; |
244 | |
41f6e155 |
245 | |
fd843187 |
246 | $scope.incGroup = []; |
247 | $scope.excGroup = []; |
248 | |
493b91cf |
249 | $scope.create_abtest = function(){ |
250 | var result; |
41f6e155 |
251 | $scope.currentABTest.testing_criteria_id=$scope.template.val; |
252 | |
493b91cf |
253 | if($scope.abId =="" ) |
254 | result= crmApi('MailingAB','create',{testing_criteria_id: $scope.template.val}); |
255 | else{ |
256 | if (typeof $scope.currentABTest.mailing_id_a == 'undefined') |
257 | result= crmApi('MailingAB','create',{id:$scope.abId,testing_criteria_id: $scope.template.val}); |
258 | else{ |
259 | 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} ); |
260 | |
261 | } |
262 | |
263 | } |
264 | |
265 | |
266 | result.success(function(data) { |
267 | if (data.is_error == 0) { |
268 | $scope.abId = data.id; |
269 | console.log("ID "+$scope.abId); |
270 | } |
271 | }); |
272 | }; |
273 | |
41f6e155 |
274 | $scope.update_abtest = function(){ |
275 | |
276 | $scope.currentABTest.declare_winning_time= $scope.currentABTest.date + " " + $scope.currentABTest.time ; |
277 | |
278 | result= crmApi('MailingAB','create',{id:$scope.abId, |
279 | testing_criteria_id: $scope.template.val, |
280 | mailing_id_a:$scope.currentABTest.mailing_id_a, |
281 | mailing_id_b:$scope.currentABTest.mailing_id_b, |
282 | winner_criteria_id : $scope.currentABTest.winner_criteria_id, |
283 | group_percentage: $scope.currentABTest.group_percentage, |
284 | declare_winning_time: $scope.currentABTest.declare_winning_time |
285 | } ); |
286 | |
287 | }; |
288 | |
289 | |
290 | |
291 | |
292 | $scope.tmp = function (tst,aorb){ |
293 | if(aorb==1){ |
294 | $scope.mailA.msg_template_id=tst; |
295 | console.log($scope.mailA.msg_template_id+ "sasas"); |
296 | if($scope.mailA.msg_template_id == null){ |
297 | $scope.mailA.body_html=""; |
298 | } |
299 | else{ |
300 | for(var a in $scope.tmpList){ |
301 | |
302 | if($scope.tmpList[a].id==$scope.mailA.msg_template_id){ |
303 | $scope.mailA.body_html=$scope.tmpList[a].msg_html; |
304 | } |
305 | } |
306 | } |
307 | } |
308 | else if(aorb==2){ |
493b91cf |
309 | |
41f6e155 |
310 | $scope.mailB.msg_template_id=tst; |
311 | console.log($scope.mailB.msg_template_id+ "sasas"); |
312 | if($scope.mailB.msg_template_id == null){ |
313 | $scope.mailB.body_html=""; |
314 | } |
315 | else{ |
316 | for(var a in $scope.tmpList){ |
317 | |
318 | if($scope.tmpList[a].id==$scope.mailB.msg_template_id){ |
319 | $scope.mailB.body_html=$scope.tmpList[a].msg_html; |
320 | } |
321 | } |
322 | } |
493b91cf |
323 | |
493b91cf |
324 | } |
41f6e155 |
325 | else { |
326 | |
327 | $scope.mailA.msg_template_id=tst; |
328 | console.log($scope.mailA.msg_template_id+ "sasas"); |
329 | if($scope.mailA.msg_template_id == null){ |
330 | $scope.mailA.body_html=""; |
331 | } |
332 | else{ |
333 | for(var a in $scope.tmpList){ |
493b91cf |
334 | |
41f6e155 |
335 | if($scope.tmpList[a].id==$scope.mailA.msg_template_id){ |
336 | $scope.mailA.body_html=$scope.tmpList[a].msg_html; |
337 | } |
493b91cf |
338 | } |
339 | } |
41f6e155 |
340 | |
341 | $scope.mailB.msg_template_id=tst; |
342 | console.log($scope.mailB.msg_template_id+ "sasas"); |
343 | if($scope.mailB.msg_template_id == null){ |
344 | $scope.mailB.body_html=""; |
345 | } |
346 | else{ |
347 | for(var a in $scope.tmpList){ |
348 | |
349 | if($scope.tmpList[a].id==$scope.mailB.msg_template_id){ |
350 | $scope.mailB.body_html=$scope.tmpList[a].msg_html; |
351 | } |
352 | } |
353 | } |
354 | |
355 | |
493b91cf |
356 | } |
357 | }; |
358 | |
fd843187 |
359 | |
360 | }); |
361 | |
362 | crmMailingAB.directive('nexttab', function () { |
363 | return { |
364 | // Restrict it to be an attribute in this case |
365 | restrict: 'A', |
366 | |
367 | priority: 500, |
368 | // responsible for registering DOM listeners as well as updating the DOM |
369 | link: function (scope, element, attrs) { |
370 | |
371 | $(element).parent().parent().parent().parent().tabs(scope.$eval(attrs.nexttab)); |
372 | var myarr = new Array(1, 2, 3) |
373 | $(element).parent().parent().parent().parent().tabs({disabled: myarr}); |
374 | |
375 | $(element).on("click", function () { |
493b91cf |
376 | if(scope.tab_val==0){ |
493b91cf |
377 | scope.create_abtest(); |
378 | } |
41f6e155 |
379 | else if(scope.tab_val == 2){ |
380 | scope.update_abtest(); |
381 | if(scope.currentABTest.winner_criteria_id==1){ |
382 | scope.winner_criteria="Open"; |
383 | } |
384 | else if(scope.currentABTest.winner_criteria_id==2){ |
385 | scope.winner_criteria=" Total Unique Clicks"; |
386 | } |
387 | else if(scope.currentABTest.winner_criteria_id==3){ |
388 | scope.winner_criteria="Total Clicks on a particular link"; |
389 | } |
390 | } |
391 | |
fd843187 |
392 | scope.tab_val = scope.tab_val + 1; |
393 | |
394 | scope.max_tab = Math.max(scope.tab_val, scope.max_tab); |
395 | var myArray1 = new Array(); |
396 | for (var i = scope.max_tab + 1; i < 4; i++) { |
397 | myArray1.push(i); |
398 | } |
399 | $(element).parent().parent().parent().parent().parent().tabs("option", "disabled", myArray1); |
400 | $(element).parent().parent().parent().parent().parent().tabs("option", "active", scope.tab_val); |
401 | scope.$apply(); |
402 | console.log("Adir"); |
403 | }); |
404 | } |
405 | }; |
406 | }); |
407 | |
408 | crmMailingAB.directive('prevtab', function () { |
409 | return { |
410 | // Restrict it to be an attribute in this case |
411 | restrict: 'A', |
412 | priority: 500, |
413 | // responsible for registering DOM listeners as well as updating the DOM |
414 | link: function (scope, element, attrs) { |
415 | |
416 | |
417 | $(element).on("click", function () { |
418 | var temp = scope.tab_val - 1; |
419 | scope.tab_val = scope.tab_val - 1; |
420 | |
421 | console.log(temp); |
422 | if (temp == 3) { |
423 | |
424 | } |
425 | else { |
426 | $(element).parent().parent().parent().parent().parent().tabs("option", "active", temp); |
427 | } |
428 | |
429 | scope.$apply(); |
430 | |
431 | }); |
432 | } |
433 | }; |
434 | }); |
435 | |
493b91cf |
436 | crmMailingAB.directive('chsgroup', function () { |
fd843187 |
437 | return { |
438 | restrict: 'AE', |
439 | link: function (scope, element, attrs) { |
440 | function format(item) { |
441 | if (!item.id) { |
442 | // return `text` for optgroup |
443 | return item.text; |
444 | } |
445 | // return item template |
446 | var a = item.id.split(" "); |
447 | if (a[1] == "group" && a[2] == "include") { |
448 | return "<img src='../../sites/all/modules/civicrm/i/include.jpeg' height=12 width=12/>" + " " + "<img src='../../sites/all/modules/civicrm/i/group.png' height=12 width=12/>" + item.text; |
449 | } |
450 | if (a[1] == "group" && a[2] == "exclude") { |
451 | return "<img src='../../sites/all/modules/civicrm/i/Error.gif' height=12 width=12/>" + " " + "<img src='../../sites/all/modules/civicrm/i/group.png' height=12 width=12/>" + item.text; |
452 | } |
453 | if (a[1] == "mail" && a[2] == "include") { |
454 | return "<img src='../../sites/all/modules/civicrm/i/include.jpeg' height=12 width=12/>" + " " + "<img src='../../sites/all/modules/civicrm/i/EnvelopeIn.gif' height=12 width=12/>" + item.text; |
455 | } |
456 | if (a[1] == "mail" && a[2] == "exclude") { |
457 | return "<img src='../../sites/all/modules/civicrm/i/Error.gif' height=12 width=12/>" + " " + "<img src='../../sites/all/modules/civicrm/i/EnvelopeIn.gif' height=12 width=12/>" + item.text; |
458 | } |
459 | } |
460 | |
461 | $(element).select2({ |
462 | width: "400px", |
463 | placeholder: "Select the groups you wish to include", |
464 | formatResult: format, |
465 | formatSelection: format, |
466 | escapeMarkup: function (m) { |
467 | return m; |
468 | } |
469 | }); |
470 | |
471 | $(element).on('select2-selecting', function (e) { |
472 | var a = e.val.split(" "); |
473 | var l = a.length; |
474 | if (a[2] == "include") { |
475 | var str = ""; |
476 | for (i = 3; i < l; i++) { |
477 | str += a[i]; |
478 | str += " "; |
479 | } |
480 | scope.incGroup.push(str); |
481 | scope.$apply(); |
482 | } |
483 | |
484 | else { |
485 | var str = ""; |
486 | for (i = 3; i < l; i++) { |
487 | str += a[i]; |
488 | str += " "; |
489 | } |
490 | |
491 | scope.excGroup.push(str); |
492 | scope.$apply(); |
493 | } |
494 | |
495 | }); |
496 | $(element).on("select2-removed", function (e) { |
497 | if (e.val.split(" ")[2] == "exclude") { |
498 | var index = scope.excGroup.indexOf(e.val.split(" ")[3]); |
499 | scope.excGroup.splice(index, 1); |
500 | scope.$apply(); |
501 | } |
502 | else { |
503 | var index = scope.incGroup.indexOf(e.val.split(" ")[3]); |
504 | scope.incGroup.splice(index, 1); |
505 | scope.$apply(); |
506 | } |
507 | }); |
508 | } |
509 | }; |
510 | |
511 | }); |
512 | |
493b91cf |
513 | crmMailingAB.directive('groupselect',function(){ |
514 | return { |
515 | restrict : 'AE', |
516 | link: function(scope,element, attrs){ |
517 | $(element).select2({width:"200px", data: mltokens, placeholder:"Insert Token"}); |
518 | |
519 | |
520 | $(element).on('select2-selecting', function(e) { |
521 | scope.$evalAsync('_resetSelection()');console.log(mltokens); |
522 | /* if(scope.currentMailing.body_html == null){ |
523 | scope.currentMailing.body_html = e.val; |
524 | } |
525 | else |
526 | scope.currentMailing.body_html = scope.currentMailing.body_html + e.val; |
527 | */ |
528 | var msg = document.getElementById("body_html").value; |
529 | var cursorlen = document.getElementById("body_html").selectionStart; |
530 | console.log(cursorlen); |
531 | var textlen = msg.length; |
532 | document.getElementById("body_html").value = msg.substring(0, cursorlen) + e.val + msg.substring(cursorlen, textlen); |
533 | scope.currentMailing.body_html = msg.substring(0, cursorlen) + e.val + msg.substring(cursorlen, textlen); |
534 | console.log(document.getElementById("body_html").value); |
535 | console.log(scope.currentMailing.body_html); |
536 | var cursorPos = (cursorlen + e.val.length); |
537 | document.getElementById("body_html").selectionStart = cursorPos; |
538 | document.getElementById("body_html").selectionEnd = cursorPos; |
539 | document.getElementById("body_html").focus(); |
540 | scope.$apply(); |
541 | e.preventDefault(); |
542 | }) |
543 | |
544 | } |
545 | }; |
546 | |
547 | }); |
548 | |
fd843187 |
549 | crmMailingAB.directive('sliderbar', function () { |
550 | return{ |
551 | restrict: 'AE', |
552 | link: function (scope, element, attrs) { |
fbbff1a0 |
553 | if(typeof scope.currentABTest.group_percentage != 'undefined'){ |
41f6e155 |
554 | console.log("Yay"); |
555 | $(element).slider({value:scope.currentABTest.group_percentage}); |
556 | } |
fd843187 |
557 | $(element).slider({min: 1}); |
558 | $(element).slider({ |
559 | slide: function (event, ui) { |
41f6e155 |
560 | scope.currentABTest.group_percentage = ui.value; |
fd843187 |
561 | scope.$apply(); |
562 | } |
563 | }); |
564 | } |
565 | }; |
566 | }); |
567 | |
568 | crmMailingAB.directive('tpmax', function () { |
569 | return { |
570 | restrict: 'E', |
571 | link: function (scope, element, attr) { |
572 | scope.$watch('automated', function (val) { |
573 | if (val == "Yes") { |
574 | $(element).dialog({ |
575 | title: 'Automated A/B Testing', |
576 | width: 800, |
577 | height: 600, |
578 | closed: false, |
579 | cache: false, |
580 | modal: true |
581 | }); |
582 | } |
583 | }); |
584 | |
585 | $(element).find("#closebutton").on("click", function () { |
586 | $(element).dialog("close"); |
587 | }); |
588 | } |
589 | }; |
590 | }); |
591 | |
592 | crmMailingAB.directive('numbar', function () { |
593 | return{ |
594 | restrict: 'AE', |
595 | link: function (scope, element, attrs) { |
596 | $(element).spinner({max: attrs.numbar, min: 0}); |
597 | } |
598 | }; |
599 | }); |
600 | |
601 | crmMailingAB.directive('datepick', function () { |
602 | return { |
603 | |
604 | |
605 | restrict: 'AE', |
606 | link: function (scope, element, attrs) { |
607 | $(element).datepicker({ |
608 | dateFormat: "yy-mm-dd", |
609 | onSelect: function (date) { |
610 | $(".ui-datepicker a").removeAttr("href"); |
611 | |
612 | scope.scheddate.date = date.toString(); |
613 | scope.$apply(); |
614 | console.log(scope.scheddate.date); |
615 | |
616 | } |
617 | |
618 | |
619 | }); |
620 | } |
621 | }; |
622 | }); |
623 | |
624 | crmMailingAB.directive('submitform', function () { |
625 | return { |
626 | restrict: 'A', |
627 | priority: 1000, |
628 | link: function (scope, element, attrs) { |
629 | $(element).on("click", function () { |
630 | |
631 | console.log("clicked"); |
493b91cf |
632 | scope.savea({ |
633 | id: scope.mailA.id, |
634 | name: "Aditya Nambiar", |
635 | visibility: scope.mailA.visibility, |
636 | created_id: 1, |
637 | subject: scope.mailA.subject, |
638 | msg_template_id: scope.mailA.msg_template_id==null ? "" : scope.mailA.msg_template_id, |
639 | open_tracking: scope.mailA.open_tracking, |
640 | url_tracking: scope.mailA.url_tracking, |
641 | forward_replies: scope.mailA.forward_replies, |
642 | auto_responder: scope.mailA.auto_responder, |
643 | from_name: scope.mailA.from_name, |
644 | from_email: scope.mailA.from_email, |
645 | replyto_email: scope.mailA.replyto_email, |
646 | unsubscribe_id: scope.mailA.unsubscribe_id, |
647 | resubscribe_id: scope.mailA.resubscribe_id, |
648 | body_html: scope.mailA.body_html, |
649 | body_text: scope.mailA.body_text, |
650 | scheduled_date: scope.mailA.scheduled_date, |
651 | scheduled_id: scope.mailA.scheduled_id, |
652 | campaign_id: scope.mailA.campaign_id==null ? "" : scope.mailA.campaign_id, |
653 | header_id: scope.mailA.header_id, |
654 | footer_id: scope.mailA.footer_id, |
655 | |
656 | is_completed: scope.mailA.is_completed |
fd843187 |
657 | }); |
658 | console.log("Truth " + scope.whatnext) |
659 | |
660 | if (scope.whatnext == "3") { |
661 | console.log("sdf"); |
493b91cf |
662 | |
663 | scope.mailB.name= scope.mailA.name; |
664 | scope.mailB.visibility= scope.mailA.visibility; |
665 | scope.mailB.created_id= scope.mailA.created_id; |
666 | scope.mailB.subject= scope.mailA.subject; |
667 | scope.mailB.msg_template_id= scope.mailA.msg_template_id==null ? "" : scope.mailA.msg_template_id; |
668 | scope.mailB.open_tracking= scope.mailA.open_tracking; |
669 | scope.mailB.url_tracking= scope.mailA.url_tracking; |
670 | scope.mailB.forward_replies= scope.mailA.forward_replies; |
671 | scope.mailB.auto_responder= scope.mailA.auto_responder; |
672 | scope.mailB.from_name= scope.mailA.from_name; |
673 | scope.mailB.replyto_email= scope.mailA.replyto_email; |
674 | scope.mailB.unsubscribe_id= scope.mailA.unsubscribe_id; |
675 | scope.mailB.resubscribe_id= scope.mailA.resubscribe_id; |
676 | scope.mailB.body_html= scope.mailA.body_html; |
677 | scope.mailB.body_text= scope.mailA.body_text; |
678 | scope.mailB.scheduled_date= scope.mailA.scheduled_date; |
679 | scope.mailB.scheduled_id= scope.mailA.scheduled_id; |
680 | scope.mailB.campaign_id= scope.mailA.campaign_id==null ? "" : scope.mailA.campaign_id; |
681 | scope.mailB.header_id= scope.mailA.header_id; |
682 | scope.mailB.footer_id= scope.mailA.footer_id; |
683 | |
684 | scope.mailB.is_completed= scope.mailA.is_completed; |
fd843187 |
685 | |
686 | } |
687 | else { |
688 | if (scope.whatnext == "2") { |
689 | scope.mailB.fromEmail = scope.mailA.fromEmail; |
493b91cf |
690 | scope.mailB.name= scope.mailA.name; |
691 | scope.mailB.visibility= scope.mailA.visibility; |
692 | scope.mailB.created_id= scope.mailA.created_id; |
693 | scope.mailB.msg_template_id= scope.mailA.msg_template_id==null ? "" : scope.mailA.msg_template_id; |
694 | scope.mailB.open_tracking= scope.mailA.open_tracking; |
695 | scope.mailB.url_tracking= scope.mailA.url_tracking; |
696 | scope.mailB.forward_replies= scope.mailA.forward_replies; |
697 | scope.mailB.auto_responder= scope.mailA.auto_responder; |
698 | scope.mailB.from_name= scope.mailA.from_name; |
699 | scope.mailB.replyto_email= scope.mailA.replyto_email; |
700 | scope.mailB.unsubscribe_id= scope.mailA.unsubscribe_id; |
701 | scope.mailB.resubscribe_id= scope.mailA.resubscribe_id; |
702 | scope.mailB.body_html= scope.mailA.body_html; |
703 | scope.mailB.body_text= scope.mailA.body_text; |
704 | scope.mailB.scheduled_date= scope.mailA.scheduled_date; |
705 | scope.mailB.scheduled_id= scope.mailA.scheduled_id; |
706 | scope.mailB.campaign_id= scope.mailA.campaign_id==null ? "" : scope.mailA.campaign_id; |
707 | scope.mailB.header_id= scope.mailA.header_id; |
708 | scope.mailB.footer_id= scope.mailA.footer_id; |
709 | |
710 | scope.mailB.is_completed= scope.mailA.is_completed; |
fd843187 |
711 | |
712 | } |
713 | } |
714 | |
715 | |
493b91cf |
716 | scope.saveb({ |
717 | |
718 | id: scope.mailB.id, |
719 | name: "Aditya Nambiar", |
720 | visibility: scope.mailB.visibility, |
721 | created_id: 1, |
722 | subject: scope.mailB.subject, |
723 | msg_template_id: scope.mailB.msg_template_id==null ? "" : scope.mailB.msg_template_id, |
724 | open_tracking: scope.mailB.open_tracking, |
725 | url_tracking: scope.mailB.url_tracking, |
726 | forward_replies: scope.mailB.forward_replies, |
727 | auto_responder: scope.mailB.auto_responder, |
728 | from_name: scope.mailB.from_name, |
729 | from_email: scope.mailB.from_email, |
730 | replyto_email: scope.mailB.replyto_email, |
731 | unsubscribe_id: scope.mailB.unsubscribe_id, |
732 | resubscribe_id: scope.mailB.resubscribe_id, |
733 | body_html: scope.mailB.body_html, |
734 | body_text: scope.mailB.body_text, |
735 | scheduled_date: scope.mailB.scheduled_date, |
736 | scheduled_id: scope.mailB.scheduled_id, |
737 | campaign_id: scope.mailB.campaign_id==null ? "" : scope.mailB.campaign_id, |
738 | header_id: scope.mailB.header_id, |
739 | footer_id: scope.mailB.footer_id, |
740 | |
741 | is_completed: scope.mailA.is_completed |
fd843187 |
742 | |
743 | }); |
744 | |
493b91cf |
745 | |
fd843187 |
746 | }); |
747 | } |
748 | }; |
749 | |
750 | }); |
751 | |
493b91cf |
752 | |
753 | |
fd843187 |
754 | crmMailingAB.directive('nextbutton', function () { |
755 | return { |
756 | restrict: 'AE', |
757 | replace: 'true', |
758 | template: '<div class="crm-submit-buttons" id="campaignbutton">' + |
759 | '<div class = "crm-button crm-button-type-upload crm-button_qf_Contact_upload_view" >' + |
760 | '<input type="submit" value="Next" id="campaignbutton _qf_Contact_upload_view-top" class="btn btn-primary" nexttab={{tab_val}}>' + |
761 | '</div></div>' |
762 | |
763 | }; |
764 | }); |
765 | |
766 | crmMailingAB.directive('cancelbutton', function () { |
767 | return { |
768 | restrict: 'AE', |
769 | replace: 'true', |
770 | template: '<div class="crm-submit-buttons" id="campaignbutton">' + |
771 | '<div class = "crm-button crm-button-type-upload crm-button_qf_Contact_upload_view" >' + |
772 | '<input type="submit" value="Cancel" id="campaignbutton _qf_Contact_upload_view-top" class="btn btn-primary" >' + |
773 | '</div></div>' |
774 | |
775 | }; |
776 | }); |
777 | |
41f6e155 |
778 | crmMailingAB.directive('chsdate',function(){ |
779 | return { |
780 | restrict: 'AE', |
781 | link: function(scope,element,attrs){ |
782 | $(element).datepicker({ |
783 | dateFormat: "yy-mm-dd", |
784 | onSelect: function(date) { |
785 | $(".ui-datepicker a").removeAttr("href"); |
5cd34d46 |
786 | scope.currentABTest.date=date.toString(); |
41f6e155 |
787 | scope.$apply(); |
5cd34d46 |
788 | console.log(scope.currentABTest.date); |
41f6e155 |
789 | } |
790 | }); |
791 | } |
792 | }; |
793 | }); |
794 | |
fd843187 |
795 | crmMailingAB.directive('prevbutton', function () { |
796 | return { |
797 | restrict: 'AE', |
798 | replace: 'true', |
799 | template: '<div class="crm-submit-buttons" >' + |
800 | '<div class = "crm-button crm-button-type-upload crm-button_qf_Contact_upload_view" >' + |
801 | '<input type="submit" value="Previous" id="campaignbutton _qf_Contact_upload_view-top" class="btn btn-primary" prevtab={{tab_val}}>' + |
802 | '</div></div>' |
803 | |
804 | }; |
805 | }); |
ec57ad65 |
806 | |
807 | |
808 | })(angular, CRM.$, CRM._); |
d340146d |
809 | |