Tokens included
authoraditya-nambiar <aditya.nambiar007@gmail.com>
Sat, 16 Aug 2014 13:37:42 +0000 (19:07 +0530)
committeraditya-nambiar <aditya.nambiar007@gmail.com>
Sat, 16 Aug 2014 13:37:42 +0000 (19:07 +0530)
17 files changed:
CRM/Mailing/BAO/TrackableURL.php
CRM/Mailing/Info.php
api/v3/Mailing.php
api/v3/MailingAB.php
css/angular-crmMailingAB.css
js/angular-crmMailingAB.js
partials/abtesting/compose.html [new file with mode: 0755]
partials/abtesting/composeonScreen.html [deleted file]
partials/abtesting/from_name.html
partials/abtesting/main.html
partials/abtesting/report.html
partials/abtesting/subject_lines.html
partials/abtesting/tab1.html
partials/abtesting/tab2.html
partials/abtesting/tab3.html
partials/abtesting/tab4.html
partials/abtesting/two_emails.html

index 3204edd6b70baf2d48f8b18a051c047d275834d5..9daee9c8df54b686aa5e39bef98c837aac0c09a0 100644 (file)
@@ -102,6 +102,23 @@ class CRM_Mailing_BAO_TrackableURL extends CRM_Mailing_DAO_TrackableURL {
     return $returnUrl;
   }
 
+  /**
+   * @param $url
+   * @param $mailing_id
+   *
+   * return int Url id of the given url and mail
+   */
+  public static function getTrackerURLId($url, $mailing_id) {
+    $tracker = new CRM_Mailing_BAO_TrackableURL();
+    $tracker->url = $url;
+    $tracker->mailing_id = $mailing_id;
+    if ($tracker->find(TRUE)) {
+      return $tracker->id;
+    }
+
+    return NULL;
+  }
+
   /**
    * @param $msg
    * @param $mailing_id
index 201824e10b88fa476f92b1f0ae36219b93ff285d..188869b985983b4627465ed16ee968639ae24abb 100644 (file)
@@ -75,6 +75,7 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info {
       'return' => array("msg_html", "id", "msg_title"),
       'id' => array('>' => 58),
     ));
+    $mailTokens = civicrm_api3('Mailing', 'get_token', array( 'usage' => 'Mailing'));
 
     CRM_Core_Resources::singleton()->addSetting(array(
       'crmMailing' => array(
@@ -86,6 +87,7 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info {
         'headerfooterList' => array_values($headerfooterList['values']),
         'mesTemplate' => array_values($mesTemplate['values']),
         'emailAdd' => array_values($emailAdd['values']),
+        'mailTokens' => array_values($mailTokens),
       ),
     ));
 
index c550d04c95df42fd4e24f530852aced78f27b756..8d7afc9c04253e19d8a9fbd13d1e78f571e4056b 100755 (executable)
@@ -383,6 +383,30 @@ ORDER BY   e.is_bulkmail DESC, e.is_primary DESC
   return civicrm_api3_create_success($mailDelivered);
 }
 
+function civicrm_api3_mailing_get_token($params) {
+  if (!array_key_exists("usage", $params)) {
+    throw new API_Exception('Mandatory keys missing from params array: entity');
+  }
+
+  $tokens = CRM_Core_SelectValues::contactTokens();
+  switch ($params['usage']) {
+    case 'Mailing' :
+      $tokens = array_merge(CRM_Core_SelectValues::mailingTokens(), $tokens);
+      break;
+    case 'ScheduleEventReminder' :
+      $tokens = array_merge(CRM_Core_SelectValues::activityTokens(), $tokens);
+      $tokens = array_merge(CRM_Core_SelectValues::eventTokens(), $tokens);
+      $tokens = array_merge(CRM_Core_SelectValues::membershipTokens(), $tokens);
+      break;
+    case 'ManageEventScheduleReminder' :
+      $tokens = array_merge(CRM_Core_SelectValues::eventTokens(), $tokens);
+      break;
+  }
+
+  return CRM_Utils_Token::formatTokensForDisplay($tokens);
+
+}
+
 /**
  * Adjust Metadata for send_mail action
  *
index af225dca96624095a773653f50b0e60c276290ce..af06b8a512b9a9734140d8703c8a8861a561a3c4 100755 (executable)
@@ -147,4 +147,67 @@ function civicrm_api3_mailing_a_b_send_mail($params) {
   }
 
   return civicrm_api3_create_success();
+}
+
+/**
+ * Adjust Metadata for graph_stats action
+ *
+ * The metadata is used for setting defaults, documentation & validation
+ * @param array $params array or parameters determined by getfields
+ */
+function _civicrm_api3_mailing_a_b_graph_stats_spec(&$params) {
+   $params['split_count']['api.default'] = 6;
+   $params['split_count_select']['api.required'] = 1;
+  }
+
+/**
+ * Send graph detail for A/B tests mail
+ *
+ * @param array $params
+ * @return array
+ */
+function civicrm_api3_mailing_a_b_graph_stats($params) {
+   civicrm_api3_verify_mandatory($params,
+     'CRM_Mailing_DAO_MailingAB',
+     array('id'),
+ FALSE
+   );
+
+ $mailingAB = civicrm_api3('MailingAB', 'get', array('id' => $params['id']));
+ $mailingAB = $mailingAB['values'][$params['id']];
+
+ $optionGroupValue = civicrm_api3('OptionValue', 'get', array('option_group_name' => 'mailing_ab_winner_criteria', 'value' => $mailingAB['winner_criteria_id']));
+ $winningCriteria = $optionGroupValue['values'][$optionGroupValue['id']]['name'];
+
+ $graphStats = array();
+  $ABFormat = array('A' => 'mailing_id_a', 'B' => 'mailing_id_b');
+
+ foreach ($ABFormat as $name => $column) {
+     switch ($winningCriteria) {
+     case 'Open':
+         $totalCounts = CRM_Mailing_Event_BAO_Opened::getTotalCount($mailingAB[$column]);
+         $rowCount = round($totalCounts / $params['split_count']);
+         $offset = $rowCount * ($params['split_count_select'] - 1);
+         $graphStats[$name] = CRM_Mailing_Event_BAO_Opened::getRows($mailingAB[$column], NULL, FALSE, $offset, $rowCount, "{$open}.time_stamp ASC");
+         break;
+ case 'Total Unique Clicks':
+         $totalCounts = CRM_Mailing_Event_BAO_TrackableURLOpen::getTotalCount($mailingAB[$column]);
+         $rowCount = round($totalCounts / $params['split_count']);
+         $offset = $rowCount * ($params['split_count_select'] - 1);
+         $graphStats[$name] = CRM_Mailing_Event_BAO_TrackableURLOpen::getRows($mailingAB[$column], NULL, FALSE, NULL, $offset, $rowCount, "{$click}.time_stamp ASC");
+         break;
+ case 'Total Clicks on a particular link':
+         if (empty($params['url'])) {
+         throw new API_Exception("Provide url to get stats result for '{$winningCriteria}'");
+ }
+ $url_id = CRM_Mailing_BAO_TrackableURL::getTrackerURLId($mailingAB[$column], $params['url']);
+ $totalCounts = CRM_Mailing_Event_BAO_TrackableURLOpen::getTotalCount($params['mailing_id'], NULL, FALSE, $url_id);
+ $rowCount = round($totalCounts / $params['split_count']);
+ $offset = $rowCount * ($params['split_count_select'] - 1);
+ $graphStats[$name] = CRM_Mailing_Event_BAO_TrackableURLOpen::getRows($mailingAB[$column], NULL, FALSE, $url_id, $offset, $rowCount, "{$click}.time_stamp ASC");
+ break;
+ }
+ }
+
+ return civicrm_api3_create_success($graphStats);
 }
\ No newline at end of file
index 5b836814005ff9eb193459f2d88f99e3c9e2466e..0dc5927df3a21642b62abb0477b6a1ccaad703ff 100644 (file)
@@ -39,7 +39,7 @@ div#settings .ui-tabs-nav li.ui-tabs-selected {
 }
 
 div#frag1 {
-  height:500px;
+  height:600px;
   width:800px;
   overflow: auto;
   position: relative;
@@ -47,7 +47,7 @@ div#frag1 {
 }
 
 div#frag2 {
-  height:500px;
+  height:600px;
   width:800px;
   overflow: auto;
 }
\ No newline at end of file
index 297ccc5201a09d16a42072406f13861ae88d7bd2..b1f59f9a27e04151380487485e35ebf03a8dd152 100755 (executable)
@@ -6,7 +6,7 @@
   var partialUrl = function (relPath) {
     return CRM.resourceUrls['civicrm'] + '/partials/abtesting/' + relPath;
   };
-
+  var mltokens = [];
   var crmMailingAB = angular.module('crmMailingAB', ['ngRoute', 'ui.utils', 'ngSanitize']);
   var mltokens = [];
   crmMailingAB.run(function ($rootScope, $templateCache) {
       {
         time: 2,
         x: 6,
-        y: 8,
+        y: 8
       },
       {
         time: 3,
         x: 10,
-        y: 9,
+        y: 9
       },
       {
         time: 4,
         x: 13,
-        y: 11,
+        y: 11
       }
     ]
     console.log(selectedABTest);
     if (selectedABTest.winner_criteria_id == 1) {
-      $scope.winner_criteria = "Open";
+      $scope.winnercriteria = "Open";
     }
     else {
       if (selectedABTest.winner_criteria_id == 2) {
-        $scope.winner_criteria = "Total Unique Clicks";
+        $scope.winnercriteria = "Total Unique Clicks";
       }
       else {
         if (selectedABTest.winner_criteria_id == 3) {
-          $scope.winner_criteria = "Total Clicks on a particular link";
+          $scope.winnercriteria = "Total Clicks on a particular link";
         }
       }
     }
+
+    var result = crmApi('Mailing','stats',{mailing_id : selectedABTest.mailing_id_a});
+    $scope.r=[];
+    result.success(function (data) {
+      $scope.rtt= data;
+      $scope.r.push(data.values[selectedABTest.mailing_id_a]["Delivered"].toString());
+      $scope.r.push(data.values[selectedABTest.mailing_id_a]["Bounces"].toString());
+      $scope.r.push(data.values[selectedABTest.mailing_id_a]["Unsubscribers"].toString());
+      $scope.r.push(data.values[selectedABTest.mailing_id_a]["Opened"].toString());
+      $scope.r.push(data.values[selectedABTest.mailing_id_a]["Unique Clicks"].toString());
+     $scope.$apply();
+    });
+    console.log($scope.rtt)
+
+    $scope.d=[];
+    result = crmApi('Mailing','stats',{mailing_id : selectedABTest.mailing_id_b});
+    result.success(function (data) {
+      $scope.d.push(data.values[selectedABTest.mailing_id_b]["Delivered"].toString());
+      $scope.d.push(data.values[selectedABTest.mailing_id_b]["Bounces"].toString());
+      $scope.d.push(data.values[selectedABTest.mailing_id_b]["Unsubscribers"].toString());
+      $scope.d.push(data.values[selectedABTest.mailing_id_b]["Opened"].toString());
+      $scope.d.push(data.values[selectedABTest.mailing_id_b]["Unique Clicks"].toString());
+      $scope.$apply();
+    });
+    console.log($scope.d);
+
+    var numdiv = 5;
+
+    for (i = 0; i < numdiv; i++) {
+      var result = crmApi('MailingAB', 'graph_stats',{id : selectedABTest.id, stats_count : numdiv, stat_count_select : i});
+      result.success(function (data) {
+       console.log(data);
+      });
+    }
+
+
   });
 
   crmMailingAB.controller('crmABTestingTabsCtrl', function ($scope, crmApi, selectedABTest, $sce) {
     $scope.eMailing = CRM.crmMailing.emailAdd;
     $scope.tmpList = CRM.crmMailing.mesTemplate;
     $scope.headerfooter = CRM.crmMailing.headerfooterList;
-    $scope.emailadd = "";
+    $scope.sparestuff ={};
+    $scope.sparestuff.emailadd = "";
+    $scope.sparestuff.winnercriteria = "";
+    mltokens = CRM.crmMailing.mailTokens;
     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];
     }
+    $scope.token = [];
 
     if ($scope.currentABTest.just_created != 1) {
       $scope.abId = $scope.currentABTest.id;
       ];
 
     if ($scope.currentABTest.just_created != 1) {
-      $scope.template = $scope.templates[$scope.currentABTest.testing_criteria_id - 1];
+      $scope.sparestuff.template = $scope.templates[$scope.currentABTest.testing_criteria_id - 1];
     }
     else {
-      $scope.template = $scope.templates[0];
+      $scope.sparestuff.template = $scope.templates[0];
     }
 
-    mltokens = CRM.crmMailing.mailTokens;
+
     $scope.deliberatelyTrustDangerousSnippeta = function () {
-      return $sce.trustAsHtml($scope.previewa);
+      return $sce.trustAsHtml($scope.sparestuff.previewa);
     };
 
     $scope.deliberatelyTrustDangerousSnippetb = function () {
-      return $sce.trustAsHtml($scope.previewb);
+      return $sce.trustAsHtml($scope.sparestuff.previewb);
     };
 
     $scope.tab_val = 0;
       }
     };
 
-    $scope.winner_criteria = "";
     $scope.compose_clicked = function () {
       if ($scope.max_tab >= 1) {
         $scope.tab_val = 1;
       }
     };
 
-    $scope.reply = function () {
+/*    $scope.reply = function () {
       if ($scope.trackreplies == 0) {
         $scope.trackreplies = 1;
       }
       else {
         $scope.trackreplies = 0;
-        $scope.currentMailing.forward_replies = 0;
-        $scope.currentMailing.auto_responder = 0;
+        $scope.mailA.forward_replies = 0;
+        $scope.mailA.auto_responder = 0;
       }
     }
-
+*/
     $scope.isAuto = function (au) {
       return au.component_type == "Reply";
     };
     $scope.saveb = function (dat) {
       var flag = 0;
       var result = crmApi('Mailing', 'create', dat, true);
-      console.log(result);
       result.success(function (data) {
         if (data.is_error == 0) {
           $scope.mailB.id = data.id;
       });
     };
 
-    $scope.previewa = "";
+    $scope.sparestuff.previewa = "";
     $scope.pre = function () {
       $scope.preview = true;
     }
 
     $scope.init = function (par) {
       if (par == "3") {
-        $scope.template.url = partialUrl('from_name.html');
+        $scope.sparestuff.template.url = partialUrl('from_name.html');
       }
       else {
         if (par == "2") {
-          $scope.template.url = partialUrl('subject_lines.html');
+          $scope.sparestuff.template.url = partialUrl('subject_lines.html');
         }
         else {
-          $scope.template.url = partialUrl('two_emails.html');
+          $scope.sparestuff.template.url = partialUrl('two_emails.html');
         }
       }
       $scope.whatnext = par.toString()
     $scope.tp1 = {};
     $scope.create_abtest = function () {
       var result;
-      $scope.currentABTest.testing_criteria_id = $scope.template.val;
+      $scope.currentABTest.testing_criteria_id = $scope.sparestuff.template.val;
 
       if ($scope.abId == "") {
-        result = crmApi('MailingAB', 'create', {name: $scope.currentABTest.name, testing_criteria_id: $scope.template.val});
+        result = crmApi('MailingAB', 'create', {name: $scope.currentABTest.name, testing_criteria_id: $scope.sparestuff.template.val});
       }
       else {
         if (typeof $scope.currentABTest.mailing_id_a == 'undefined') {
-          result = crmApi('MailingAB', 'create', {id: $scope.abId, testing_criteria_id: $scope.template.val});
+          result = crmApi('MailingAB', 'create', {id: $scope.abId, testing_criteria_id: $scope.sparestuff.template.val});
         }
         else {
-          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});
+          result = crmApi('MailingAB', 'create', {id: $scope.abId, testing_criteria_id: $scope.sparestuff.template.val, mailing_id_a: $scope.currentABTest.mailing_id_a, mailing_id_b: $scope.currentABTest.mailing_id_b});
         }
       }
 
         }
       });
     };
+    $scope.tokenfunc = function(elem,e,chng){
+      var msg = document.getElementById(elem).value;
+      var cursorlen = document.getElementById(elem).selectionStart;
+      var textlen   = msg.length;
+      document.getElementById(elem).value = msg.substring(0, cursorlen) + e.val + msg.substring(cursorlen, textlen);
+      chng = msg.substring(0, cursorlen) + e.val + msg.substring(cursorlen, textlen);
+      var cursorPos = (cursorlen + e.val.length);
+      document.getElementById(elem).selectionStart = cursorPos;
+      document.getElementById(elem).selectionEnd   = cursorPos;
+      document.getElementById(elem).focus();
+    };
 
+    $scope.sparestuff.ingrps = "";
+    $scope.sparestuff.excgrps = "";
     $scope.a_b_update = function () {
       $scope.tp1.include = $scope.incGroupids;
       $scope.tp1.exclude = $scope.excGroupids;
       resulta.success(function (data) {
         if (data.is_error == 0) {
           console.log("came");
-          $scope.previewa = data.values.html;
+          $scope.sparestuff.previewa = data.values.html;
         }
       });
 
       resulta.success(function (data) {
         if (data.is_error == 0) {
           console.log("came");
-          console.log(data.values.html);
-          $scope.previewb = data.values.html;
+          $scope.sparestuff.previewb = data.values.html;
         }
       });
+
+      $scope.startabtest = function(){
+        console.log("yo");
+        var result = crmApi('MailingAB', 'send_mail', {id: $scope.abId,
+          scheduled_date : $scope.sparestuff.date , scheduled_date_time: $scope.currentABTest.latertime});
+
+      }
+
+      angular.forEach($scope.incGroup, function(value) {
+        $scope.sparestuff.ingrps += value.toString()+", ";
+      });
+      angular.forEach($scope.excGroup, function(value) {
+        $scope.sparestuff.excgrps += value.toString()+", ";
+      });
+      if($scope.sparestuff.ingrps.length != 0){
+        $scope.sparestuff.ingrps = $scope.sparestuff.ingrps.substr(0,$scope.sparestuff.ingrps.length-2);
+      }
+      if($scope.sparestuff.excgrps.length != 0){
+        $scope.sparestuff.excgrps = $scope.sparestuff.excgrps.substr(0,$scope.sparestuff.excgrps.length-2);
+      }
+
     }
     $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,
+        testing_criteria_id: $scope.sparestuff.template.val,
         mailing_id_a: $scope.currentABTest.mailing_id_a,
         mailing_id_b: $scope.currentABTest.mailing_id_b,
         mailing_id_c: $scope.currentABTest.mailing_id_c,
+        specific_url :$scope.currentABTest.acturl,
         winner_criteria_id: $scope.currentABTest.winner_criteria_id,
         group_percentage: $scope.currentABTest.group_percentage,
         declare_winning_time: $scope.currentABTest.declare_winning_time
       });
     };
-
+    $scope.currentABTest.latertime = "";
     $scope.tmp = function (tst, aorb) {
       if (aorb == 1) {
         $scope.mailA.msg_template_id = tst;
         $('#prevmail').dialog({
           title: 'Preview Mailing',
           width: 1080,
-          height: 800,
+          height: 700,
           closed: false,
           cache: false,
           modal: true,
+          position : {
+            my: 'left',
+            at: 'top',
+            of: $(".crmABTestingAllTabs")
+
+
+          },
+
           close: function () {
             console.log("close");
             $scope.preview = false;
             $scope.$apply();
           }
         });
+
+        $("#prevmail").dialog('option', 'position', [300, 50]);
       }
+
     }, true);
 
+    $scope.call = function(){
+      console.log($scope.emailadd);
+      $scope.$apply();
+      var result = crmApi('Mailing','send_test',{
+        mailing_id : $scope.currentABTest.mailing_id_a,
+        test_email : $scope.sparestuff.emailadd
+      });
+
+      var result = crmApi('Mailing','send_test',{
+        mailing_id : $scope.currentABTest.mailing_id_b,
+        test_email : $scope.sparestuff.emailadd
+      })
+      console.log($scope.sparestuff.emailadd);
+
+    }
     $scope.$watch('sendtest', function () {
+
       if ($scope.sendtest == true) {
         $('#sendtest').dialog({
           title: 'Send Test Mails',
-          width: 380,
-          height: 200,
+          width: 300,
+          height: 150,
           closed: false,
           cache: false,
           modal: true,
           buttons: {
             'Send': function () {
-              var result = crmApi('Mailing','send_test',{
-                mailing_id : $scope.currentABTest.mailing_id_a,
-                test_email : $scope.emailadd
-              });
-
-              var result = crmApi('Mailing','send_test',{
-                mailing_id : $scope.currentABTest.mailing_id_b,
-                test_email : $scope.emailadd
-              })
-              console.log($scope.emailadd);
+              $scope.call();
+
               $scope.sendtest = false;
               $('#sendtest').dialog("close");
 
             if (scope.tab_val == 2) {
               scope.update_abtest();
               if (scope.currentABTest.winner_criteria_id == 1) {
-                scope.winner_criteria = "Open";
+                scope.sparestuff.winnercriteria = "Open";
+                scope.$apply();
               }
               else {
                 if (scope.currentABTest.winner_criteria_id == 2) {
-                  scope.winner_criteria = " Total Unique Clicks";
+                  scope.sparestuff.winnercriteria = " Total Unique Clicks";
+                  scope.$apply();
                 }
                 else {
                   if (scope.currentABTest.winner_criteria_id == 3) {
-                    scope.winner_criteria = "Total Clicks on a particular link";
+                    scope.sparestuff.winnercriteria = "Total Clicks on a particular link";
+                    scope.$apply();
                   }
                 }
               }
 
   });
 
-  crmMailingAB.directive('groupselect', function () {
-    return {
-      restrict: 'AE',
-      link: function (scope, element, attrs) {
-        $(element).select2({width: "200px", data: mltokens, placeholder: "Insert Token"});
-
-
-        $(element).on('select2-selecting', function (e) {
-          scope.$evalAsync('_resetSelection()');
-          console.log(mltokens);
-          /* if(scope.currentMailing.body_html == null){
-           scope.currentMailing.body_html = e.val;
-           }
-           else
-           scope.currentMailing.body_html = scope.currentMailing.body_html + e.val;
-           */
-          var msg = document.getElementById("body_html").value;
-          var cursorlen = document.getElementById("body_html").selectionStart;
-          console.log(cursorlen);
-          var textlen = msg.length;
-          document.getElementById("body_html").value = msg.substring(0, cursorlen) + e.val + msg.substring(cursorlen, textlen);
-          scope.currentMailing.body_html = msg.substring(0, cursorlen) + e.val + msg.substring(cursorlen, textlen);
-          console.log(document.getElementById("body_html").value);
-          console.log(scope.currentMailing.body_html);
-          var cursorPos = (cursorlen + e.val.length);
-          document.getElementById("body_html").selectionStart = cursorPos;
-          document.getElementById("body_html").selectionEnd = cursorPos;
-          document.getElementById("body_html").focus();
-          scope.$apply();
-          e.preventDefault();
-        })
-
-      }
-    };
-
-  });
-
   crmMailingAB.directive('sliderbar', function () {
     return{
       restrict: 'AE',
       restrict: 'AE',
       link: function (scope, element, attrs) {
         $(element).datepicker({
-          dateFormat: "yy-mm-dd",
+          dateFormat: "dd-mm-yy",
           onSelect: function (date) {
             $(".ui-datepicker a").removeAttr("href");
-            scope.scheddate.date = date.toString();
+            scope.sparestuff.date = date.toString();
             scope.$apply();
-            console.log(scope.scheddate.date);
+            console.log(scope.sparestuff.date);
           }
         });
       }
         // map one colour each to x, y and z
         // keys grabs the key value or heading of each key value pair in the json
         // but not time
-        console.log("Key");
+       // console.log("Key");
 
-        console.log(d3.keys(data[0]));
+        //console.log(d3.keys(data[0]));
         color.domain(d3.keys(data[0]).filter(function (key) {
           return key !== "time";
         }));
         // create a nested series for passing to the line generator
         // it's best understood by console logging the data
         var series = color.domain().map(function (name) {
-          console.log(name);
+        //  console.log(name);
 
           return {
             name: name,
             values: data.map(function (d) {
-              console.log("------");
-              console.log(d);
+            //  console.log("------");
+             // console.log(d);
               return {
                 time: d.time,
                 score: +d[name]
             })
           };
         });
-        console.log("Series");
+        //console.log("Series");
 
-        console.log(series);
+       // console.log(series);
 
         // Set the dimensions of the canvas / graph
         var margin = {
         svg.append("text")      // text label for the x axis
 
           .style("text-anchor", "middle")
-          .text(scope.winner_criteria).attr("transform",function (d) {
+          .text(scope.winnercriteria).attr("transform",function (d) {
             return "rotate(-90)"
           }).attr("x", -height / 2)
           .attr("y", -30);
         series.append("path")
           .attr("class", "line")
           .attr("d", function (d) {
-            console.log(d); // to see how d3 iterates through series
+           // console.log(d); // to see how d3 iterates through series
             return valueline(d.values);
           })
           .style("stroke", function (d) {
     }
   });
 
+  crmMailingAB.directive('groupselect',function(){
+    return {
+      restrict : 'AE',
+      link: function(scope,element, attrs){
+        $(element).select2({width:"200px", data: mltokens, placeholder:"Insert Token"});
+        $(element).on('select2-selecting', function(e) {
+
+          scope.$evalAsync('_resetSelection()');console.log(mltokens);
+          var a = $(element).attr('id');
+          if(a=="htgroupcompose"){scope.tokenfunc("body_html",e,scope.mailA.body_html);}
+          else if(a=="htgroupcomposetwob"){scope.tokenfunc("twomailbbody_html",e,scope.mailB.body_html);}
+          else if(a=="htgroupcomposetwoa"){scope.tokenfunc("twomailabody_html",e,scope.mailA.body_html);}
+          else if(a=="textgroupcompose"){scope.tokenfunc("body_text",e,scope.mailA.body_text);}
+          else if(a=="textgroupcomposetwoa"){scope.tokenfunc("twomailabody_text",e,scope.mailA.body_text);}
+          else if(a=="textgroupcomposetwob"){scope.tokenfunc("twomailbbody_text",e,scope.mailB.body_text);}
+          else if(a=="subgroupsuba"){scope.tokenfunc("suba",e,scope.mailA.subject);}
+          else if(a=="subgroupsubb"){scope.tokenfunc("subb",e,scope.mailB.subject);}
+          else if(a=="subgroupfrom"){scope.tokenfunc("subfrom",e,scope.mailA.subject);}
+          else if(a=="subgrouptwoa"){scope.tokenfunc("twomaila",e,scope.mailA.subject);}
+          else if(a=="subgrouptwob"){scope.tokenfunc("twomailb",e,scope.mailB.subject);}
+
+
+          scope.$apply();
+          e.preventDefault();
+        })
+      }
+    };
+  });
+
+  crmMailingAB.directive('checktimeentry',function(){
+    return {
+      restrict :'AE',
+      link: function (scope, element, attrs) {
+      $(element).timeEntry({show24Hours:true});
+      }
+    }
+
+  });
+
 })(angular, CRM.$, CRM._);
 
diff --git a/partials/abtesting/compose.html b/partials/abtesting/compose.html
new file mode 100755 (executable)
index 0000000..46fea87
--- /dev/null
@@ -0,0 +1,30 @@
+<div class="crm-accordion-wrapper ">
+  <div class="crm-accordion-wrapper ">
+    <div class="crm-accordion-header">HTML Format</div>
+    <div class="crm-accordion-body">
+      <br>
+      &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
+      &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
+      &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
+      <input type="hidden" groupselect id= "htgroupcompose"  ></input><br><br>
+      &nbsp &nbsp &nbsp &nbsp
+      <textarea id = "body_html" ng-model="mailA.body_html" style="width: 600px; height: 300px;" required></textarea>
+      <br> <br>
+    </div>
+  </div>
+
+  <div class="crm-accordion-wrapper collapsed">
+    <div class="crm-accordion-header">Plain Text</div>
+    <div class="crm-accordion-body">
+      <br>
+      &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
+      &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
+      &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
+      <input type="hidden" groupselect id= "textgroupcompose"  ></input>
+      <br> <br>
+      &nbsp &nbsp &nbsp &nbsp
+      <textarea id = "body_text" ng-model="mailA.body_text" style="width: 600px; height: 300px;" > </textarea>
+      <br>
+    </div>
+  </div>
+</div>
\ No newline at end of file
diff --git a/partials/abtesting/composeonScreen.html b/partials/abtesting/composeonScreen.html
deleted file mode 100755 (executable)
index 32f95c0..0000000
+++ /dev/null
@@ -1 +0,0 @@
-hi
\ No newline at end of file
index 3f75e6999a95aa1ae170ab4462f8898f2235b9a3..a398b13ad3c49264f12d36d247a3eaa582f87e79 100755 (executable)
@@ -3,7 +3,7 @@
   <tr>
     <td class="label">From E-mail Address A</td>
     <td>
-      <select style="width: 200px" ng-model="mailA.from_email" ng-options="frm.email as frm.email for frm in eMailing">
+      <select style="width: 200px" ng-model="mailA.from_email" ng-options="frm.email as frm.email for frm in eMailing" required>
         <option value="">-none-</option>
       </select>
     </td>
@@ -11,7 +11,7 @@
   <tr>
     <td class="label">From E-mail Address B</td>
     <td>
-      <select style="width: 200px" ng-model="mailB.from_email" ng-options="frm.email as frm.email for frm in eMailing">
+      <select style="width: 200px" ng-model="mailB.from_email" ng-options="frm.email as frm.email for frm in eMailing" required>
         <option value="">-none-</option>
       </select>
     </td>
@@ -20,7 +20,7 @@
     <td class="label">Reply to E-mail Address</td>
     <td>
       <select style="width: 200px" ng-model="mailA.replyto_email"
-              ng-options="frm.email as frm.email for frm in eMailing">
+              ng-options="frm.email as frm.email for frm in eMailing" >
         <option value="">-none-</option>
       </select>
     </td>
   <tr>
     <td class="label">Mailing Subject</td>
     <td>
-      <input placeholder="Enter Subject" name="subject" type="text" ng-model="mailA.subject"/>
+      <input id= "subfrom" placeholder="Enter Subject" name="subject" type="text" ng-model="mailA.subject" required>
     </td>
   </tr>
+  <tr>
+  <td class="label">Mailing Subject Token</td>
+  <td>
+    <input type="hidden" groupselect id= "subgroupfrom" ng-model="token" ></input>
+  </td>
+  </tr>
   <tr>
     <td class="label" style="color:red" ng-show="mailing_form.subject.$invalid">
       Mailing subject required.
     <td class="label">Use Template</td>
     <td>
       <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">
+              ng-options="mstemp.id as mstemp.msg_title for mstemp in tmpList" >
         <option value="">-none-</option>
       </select>
     </td>
   </tr>
-  <tr ng-show="false">
-    <td class="label">I want to</td>
-    <td class="label">Compose on screen</td>
-    <td><input type="radio" ng-model="composeS" value="1"/></td>
-    <td class="label">Upload Content</td>
-    <td><input type="radio" ng-model="composeS" value="0"/></td>
-  </tr>
+
   </tbody>
 </table>
 
 <br>
 
-<div class="crm-accordion-wrapper collapsed">
-  <div class="crm-accordion-wrapper collapsed">
-    <div class="crm-accordion-header">HTML Format</div>
-    <div class="crm-accordion-body">
-      <br>
-      &nbsp &nbsp &nbsp &nbsp
-      <textarea ng-model="mailA.body_html" style="width: 600px; height: 300px;"></textarea>
-      <br> <br>
-    </div>
-  </div>
-
-  <div class="crm-accordion-wrapper collapsed">
-    <div class="crm-accordion-header">Plain Text</div>
-    <div class="crm-accordion-body">
-      <br>
-      &nbsp &nbsp &nbsp &nbsp
-      <textarea ng-model="mailA.body_text" style="width: 600px; height: 300px;"></textarea>
-      <br>
-    </div>
-  </div>
-
-  <table ng-show="false">
-    <tr>
-      <td>
-        <input type="checkbox">&nbsp Save Template</input>
-    </tr>
-  </table>
-</div>
-
+<div ng-include = "partialUrl('compose.html')"></div>
 <div ng-include="partialUrl('headerfooter.html')"></div>
\ No newline at end of file
index e295a8283d58d637915090d831d6328c51e8ebe2..6e12dd33fc0347c488e6ca1e22abca857cf8712b 100755 (executable)
@@ -1,4 +1,5 @@
-{{tab_val}}
+{{tab_val}}<br>
+  {{winnercriteria}}
 <div ui-jq="tabs" class="crmABTestingAllTabs" ui-options="{show: true, hide: true, collapsible: true}">
   <ul>
     <li><a href="#tabs-1" ng-click="campaign_clicked();">Campaign</a></li>
index 7a8973e53ec457c3ad4ca67f5fb5f6ad29b12b7d..99fa633a740585f81ec71a2ace7f2f26fa783246 100755 (executable)
@@ -6,36 +6,56 @@
     }
     .axis path, .axis line {
       fill: none;
-      stroke: #000;
+      stroke:#000;
       shape-rendering: crispEdges;
     }
   </style>
   <div id="grph" ></div>
   <div linegraph></div>
+  {{r5}}
   <table  style ="position: relative;  right :-425px; top:-250px; width :250px;">
     <tr  >
       <th>Details</th>
       <th style="width :90px;">Version A</th>
       <th style="width :90px;">Version B</th>
     </tr>
-    <tr ng-repeat="d in data">
-      <td></td>
-      <td></td>
-      <td></td>
+    <tr>
+      <td>Delivered</td>
+      <td>{{r[0]}}</td>
+      <td>{{d[0]}}</td>
+    </tr>
+    <tr>
+      <td>Bounces</td>
+      <td>{{r[1]}}</td>
+      <td>{{d[1]}}</td>
+    </tr>
+    <tr>
+      <td>Unsuscribers</td>
+      <td>{{r[2]}}</td>
+      <td>{{d[2]}}</td>
+    </tr>
+    <tr>
+      <td>Opened</td>
+      <td>{{r[3]}}</td>
+      <td>{{d[3]}}</td>
+    </tr>
+    <tr>
+      <td>Unique Clicks</td>
+      <td>{{r[4]}}</td>
+      <td>{{d[4]}}</td>
     </tr>
-
 
   </table>
   <br><br>
    <hr>
 
-  <table style="position: relative; left :40px;">
+  <table>
     <tbody>
 
     <tr >
 
       <td>
-        <input type="radio" name="stop">  Stop Test and Send Version A
+        <input type="radio" name="stop" >  Stop Test and Send Version A
       </td>
 
       <td>
index 18d9c60350efa063362a46a9efa4c18e4250d35f..9d72d536c0dc438a63a3bf15a4aece2cad361d70 100755 (executable)
@@ -3,7 +3,7 @@
   <tr>
     <td class="label">From E-mail Address</td>
     <td>
-      <select style="width: 200px" ng-model="mailA.from_email" ng-options="frm.email as frm.email for frm in eMailing">
+      <select style="width: 200px" ng-model="mailA.from_email" ng-options="frm.email as frm.email for frm in eMailing" >
         <option value="">-none-</option>
       </select>
     </td>
@@ -12,7 +12,7 @@
     <td class="label">Reply to E-mail Address</td>
     <td>
       <select style="width: 200px" ng-model="mailA.replyto_email"
-              ng-options="frm.email as frm.email for frm in eMailing">
+              ng-options="frm.email as frm.email for frm in eMailing" >
         <option value="">-none-</option>
       </select>
     </td>
   <tr>
     <td class="label">Mailing Subject A</td>
     <td>
-      <input placeholder="Enter Subject A" name="subject_a" type="text" ng-model="mailA.subject" required/>
+      <input placeholder="Enter Subject A" id="suba" name="subject_a" type="text" ng-model="mailA.subject" required/>
+    </td>
+  </tr>
+  <tr>
+    <td class="label">Mailing Subject Token</td>
+    <td>
+      <input type="hidden" groupselect id= "subgroupsuba"  ></input>
     </td>
   </tr>
   <tr>
     <td class="label">Mailing Subject B</td>
     <td>
-      <input placeholder="Enter Subject B" name="subject_b" type="text" ng-model="mailB.subject" required/>
+      <input placeholder="Enter Subject B" id="subb" name="subject_b" type="text" ng-model="mailB.subject" required/>
+    </td>
+  </tr>
+  <tr>
+    <td class="label">Mailing Subject Token</td>
+    <td>
+      <input type="hidden" groupselect id= "subgroupsubb"  ></input>
     </td>
   </tr>
-
   <tr>
     <td class="label" style="color:red" ng-show="mailing_form.subject.$invalid">
       Mailing subject required.
@@ -39,7 +50,7 @@
     <td class="label">Use Template</td>
     <td>
       <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">
+              ng-options="mstemp.id as mstemp.msg_title for mstemp in tmpList" >
         <option value="">-none-</option>
       </select>
     </td>
 
 <br>
 
-<div class="crm-accordion-wrapper collapsed">
-  <div class="crm-accordion-wrapper collapsed">
-    <div class="crm-accordion-header">HTML Format</div>
-    <div class="crm-accordion-body">
-      <br>
-      <!--<input type="hidden" groupselect ng-model="token" ></input>-->
-      <br> <br>
-      &nbsp &nbsp &nbsp &nbsp
-      <textarea id="body_html" ng-model="mailA.body_html" style="width: 600px; height: 300px;"></textarea>
-      <br> <br>
-    </div>
-  </div>
-
-  <div class="crm-accordion-wrapper collapsed">
-    <div class="crm-accordion-header">Plain Text</div>
-    <div class="crm-accordion-body">
-      <br>
-      &nbsp &nbsp &nbsp &nbsp
-      <textarea ng-model="mailA.body_text" style="width: 600px; height: 300px;"></textarea>
-      <br>
-    </div>
-  </div>
-
-  <table ng-show="false">
-    <tr>
-      <td>
-        <input type="checkbox">&nbsp Save Template</input>
-    </tr>
-  </table>
-</div>
 
+<div ng-include = "partialUrl('compose.html')"></div>
 <div ng-include="partialUrl('headerfooter.html')"></div>
index 2cde85f21c751ceb11fd2fb220d5c396f20bd8ca..75770b5ec7770556f10940e0ea2767404fda5f3b 100755 (executable)
@@ -4,14 +4,14 @@
     <input type="text" ng-model="currentABTest.name" class="big crm-form-text" required><br><br><br>
 
     <h3> What would you like to test?</h3><br><br>
-    &nbsp <input type="radio" ng-model="template" ng-value="templates[0]" ng-click="init(2)"
-                 ng-checked="template.val==1">
+    &nbsp <input type="radio" ng-model="sparestuff.template" ng-value="templates[0]" ng-click="init(2)"
+                 ng-checked="currentABTest.testing_criteria_id==1">
     Subject Lines <br/><br>
-    &nbsp <input type="radio" ng-model="template" ng-value="templates[1]" ng-click="init(3)"
-                 ng-checked="template.val==2">
+    &nbsp <input type="radio" ng-model="sparestuff.template" ng-value="templates[1]" ng-click="init(3)"
+                 ng-checked="currentABTest.testing_criteria_id==2">
     From Names <br/><br>
-    &nbsp <input type="radio" ng-model="template" ng-value="templates[2]" ng-click="init(1)"
-                 ng-checked="template.val==3">
+    &nbsp <input type="radio" ng-model="sparestuff.template" ng-value="templates[2]" ng-click="init(1)"
+                 ng-checked="currentABTest.testing_criteria_id==3">
     Two different Emails <br/><br>
     &nbsp
 
index ffb1d1a0636d77edf50bf7fa3fcef01ab6c6864a..7ad30af57b3948da2dbfca97bb5561fe8819b895 100755 (executable)
@@ -1,12 +1,12 @@
 <form name="tab2Form" unsaved-warning-form>
   <div class="crm-block crm-form-block crmABTesting">
-    <div ng-include="template.url"></div>
+    <div ng-include="sparestuff.template.url"></div>
     <div class="crm-submit-buttons">
       <span class="crm-button">
         <input type="submit" ng-click="tab2Form.$setPristine();" value="Previous" submitform prevtab/>
       </span>
       <span class="crm-button">
-        <input type="submit" ng-click="tab2Form.$setPristine();" value="Next" submitform nexttab="{{tab_val}}"/>
+        <input type="submit" ng-click="tab2Form.$setPristine();" value="Next" ng-disabled="tab2Form.$invalid" submitform nexttab="{{tab_val}}"/>
       </span>
       <span class="crm-button">
         <input type="submit" ng-click="tab2Form.$setPristine(); goto('mailing/abtesting');" value="Cancel"/>
index dad526b7efb6eb44ea4783eecdcc0663a6caf341..d3ba72301e4a633a0b76b6eef12af3da5a1bd723 100755 (executable)
     <h3>Select the size of your test group</h3><br>
     &nbsp Percentage Selected - {{currentABTest.group_percentage}}%
 
-    <div sliderbar id="trial" style="margin: 10px;"></div>
+    <div sliderbar id="trial" style="margin: 10px;" required></div>
 
     <h3>How will the winner be decided</h3><br>
     &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="currentABTest.winner_criteria_id" value=3 name="cri"> Total
-    Clicks on a particular link <br/><br>
+    Clicks on a particular link <br/>
+    &nbsp &nbsp &nbsp &nbsp<input type="text"  ng-show="currentABTest.winner_criteria_id==3" ng-model="currentABTest.acturl">
+    <br>
 
     <h3>Declare the winner by when?</h3><br>
     <table>
       <tr>
         <td class="label">Date</td>
         <td>
-          <input type="text" chsdate ng-model="currentABTest.date">
+          <input type="text" chsdate ng-model="currentABTest.date" required>
         </td>
         <td class="label">Time</td>
         <td>
-          <input type="text" placeholder="hh:mm:ss" ng-model="currentABTest.time">
+          <input type="text" placeholder="hh:mm" ng-model="currentABTest.time"  checktimeentry required>
         </td>
       </tr>
       </tbody>
@@ -49,7 +51,7 @@
         <input type="submit" ng-click="tab3Form.$setPristine();update_abtest();" value="Previous" prevtab/>
       </span>
       <span class="crm-button">
-        <input type="submit" ng-click="tab3Form.$setPristine();update_abtest();" value="Next" nexttab="{{tab_val}}"/>
+        <input type="submit" ng-click="tab3Form.$setPristine();update_abtest();" ng-disabled="tab3Form.$invalid" value="Next" nexttab="{{tab_val}}"/>
       </span>
       <span class="crm-button">
         <input type="submit" ng-click="tab3Form.$setPristine(); goto('mailing/abtesting');" value="Cancel"/>
index 52cea8376dceef7b863efe0d9a6db9810a6afb02..0402d98bfe9ab6dcfdf745f5bad005a4e269ac53 100755 (executable)
@@ -4,15 +4,15 @@
     <table>
       <tr>
         <td>Test Criteria</td>
-        <td>{{template.name}}</td>
+        <td>{{sparestuff.template.name}}</td>
       </tr>
       <tr>
         <td>Groups Included</td>
-        <td>{{incGroup}}</td>
+        <td>{{sparestuff.ingrps}}</td>
       </tr>
       <tr>
         <td>Groups Excluded</td>
-        <td>{{excGroup}}</td>
+        <td>{{sparestuff.excgrps}}</td>
       </tr>
       <tr>
         <td>Size of Test Group</td>
@@ -20,7 +20,7 @@
       </tr>
       <tr>
         <td>Winner Criteria</td>
-        <td>{{winner_criteria}}</td>
+        <td>{{sparestuff.winnercriteria}}</td>
       </tr>
       <tr>
         <td>Declare Winner By</td>
@@ -45,7 +45,7 @@
     <h3 ng-click="sendTestMailing();">Send Test Emails</h3>
 
     <div ng-show="sendtest" id="sendtest">
-      <input type="text" ng-model="emailadd">
+      Email-id : &nbsp<input placeholder = "abcd@civicrm.org" type="text" ng-model="sparestuff.emailadd">
     </div>
 
     <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="later"> Later
-      &nbsp &nbsp <input type="text" class="dateplugin" ng-show="start=='later'" ng-model="send_date" datepick>
+      <div ng-show="start=='later'">
+      &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>
 
     <br><br>
@@ -63,7 +66,7 @@
         <input type="submit" ng-click="tab4Form.$setPristine();" value="Previous" prevtab/>
       </span>
       <span class="crm-button">
-        <input type="submit" ng-click="tab4Form.$setPristine();" value="Submit & Send"/>
+        <input type="submit" ng-click="tab4Form.$setPristine();  startabtest(); goto('mailing/abtesting');" value="Submit & Send"/>
       </span>
       <span class="crm-button">
         <input type="submit" ng-click="tab4Form.$setPristine(); goto('mailing/abtesting');" value="Cancel"/>
index 74b1a8f8041283122142d47b78b15904fed3ec65..630353b5dff09a47cd4fe723313b1d1fd9f216c6 100755 (executable)
@@ -12,7 +12,7 @@
         <td class="label">From E-mail Address</td>
         <td>
           <select style="width: 200px" ng-model="mailA.from_email"
-                  ng-options="frm.email as frm.email for frm in eMailing">
+                  ng-options="frm.email as frm.email for frm in eMailing" >
             <option value="">-none-</option>
           </select>
         </td>
       <tr>
         <td class="label">Mailing Subject</td>
         <td>
-          <input placeholder="Enter Subject" name="subject" type="text" ng-model="mailA.subject"/>
+          <input placeholder="Enter Subject" name="subject" id="twomaila" type="text" ng-model="mailA.subject" required>
+        </td>
+      </tr>
+      <tr>
+        <td class="label">Mailing Subject Token</td>
+        <td>
+          <input type="hidden" groupselect id= "subgrouptwoa"  ></input>
         </td>
       </tr>
+
       <tr>
         <td class="label" style="color:red" ng-show="mailing_form.subject.$invalid">
           Mailing subject required.
 
     <br>
 
-    <div class="crm-accordion-wrapper collapsed">
-      <div class="crm-accordion-wrapper collapsed">
+    <div class="crm-accordion-wrapper ">
+      <div class="crm-accordion-wrapper ">
         <div class="crm-accordion-header">HTML Format</div>
         <div class="crm-accordion-body">
           <br>
-          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
-          &nbsp
-          &nbsp &nbsp &nbsp &nbsp &nbsp
-          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
-          &nbsp
-          &nbsp &nbsp &nbsp &nbsp &nbsp
+          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
+          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
           &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
-          ss
-          <!--  <input type="hidden" groupselect ng-model="token" ></input>-->
-          <br> <br>
+          <input type="hidden" groupselect id= "htgroupcomposetwoa"  ></input><br><br>
+
           &nbsp &nbsp &nbsp &nbsp
-          <textarea id="body_html" ng-model="mailA.body_html" style="width: 600px; height: 300px;"></textarea>
+          <textarea  ng-model="mailA.body_html" id="twomailabody_html" style="width: 600px; height: 300px;" required></textarea>
           <br> <br>
 
         </div>
       <div class="crm-accordion-wrapper collapsed">
         <div class="crm-accordion-header">Plain Text</div>
         <div class="crm-accordion-body">
-
           <br>
+          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
+          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
+          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
+          <input type="hidden" groupselect id= "textgroupcomposetwoa"  ></input><br><br>
+
           &nbsp &nbsp &nbsp &nbsp
-          <textarea ng-model="mailA.body_text" style="width: 600px; height: 300px;"></textarea>
+          <textarea ng-model="mailA.body_text" id="twomailabody_text" style="width: 600px; height: 300px;"></textarea>
           <br>
         </div>
       </div>
       <tr>
         <td class="label">Mailing Subject</td>
         <td>
-          <input placeholder="Enter Subject" name="subject" type="text" ng-model="mailB.subject"/>
+          <input placeholder="Enter Subject" id = "twomailb" name="subject" type="text" ng-model="mailB.subject"/>
+        </td>
+      </tr>
+      <tr>
+        <td class="label">Mailing Subject Token</td>
+        <td>
+          <input type="hidden" groupselect id= "subgrouptwob"  ></input>
         </td>
       </tr>
-
       <tr>
         <td class="label" style="color:red" ng-show="mailing_form.subject.$invalid">
           Mailing subject required.
     </table>
     <br>
 
-    <div class="crm-accordion-wrapper collapsed">
-      <div class="crm-accordion-wrapper collapsed">
+    <div class="crm-accordion-wrapper ">
+      <div class="crm-accordion-wrapper ">
         <div class="crm-accordion-header">HTML Format</div>
         <div class="crm-accordion-body">
           <br>
-          <br> <br>
+          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
+          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
+          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
+          <input type="hidden" groupselect id= "htgroupcomposetwob"  ></input><br><br>
           &nbsp &nbsp &nbsp &nbsp
-          <textarea id="body_html" ng-model="mailB.body_html" style="width: 600px; height: 300px;"></textarea>
+          <textarea id="twomailbbody_html"   ng-model="mailB.body_html" style="width: 600px; height: 300px;"></textarea>
           <br> <br>
         </div>
       </div>
         <div class="crm-accordion-header">Plain Text</div>
         <div class="crm-accordion-body">
           <br>
+          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
+          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
+          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
+          <input type="hidden" groupselect id= "textgroupcomposetwob"  ></input><br><br>
           &nbsp &nbsp &nbsp &nbsp
-          <textarea ng-model="mailB.body_text" style="width: 600px; height: 300px;"></textarea>
+          <textarea ng-model="mailB.body_text" id = "twomailbbody_text" style="width: 600px; height: 300px;"></textarea>
           <br>
         </div>
       </div>