Major changes
authoraditya-nambiar <aditya.nambiar007@gmail.com>
Sat, 9 Aug 2014 13:41:48 +0000 (19:11 +0530)
committeraditya-nambiar <aditya.nambiar007@gmail.com>
Sat, 9 Aug 2014 13:41:48 +0000 (19:11 +0530)
30 files changed:
CRM/Mailing/Event/BAO/Bounce.php [changed mode: 0644->0755]
CRM/Mailing/Event/BAO/Delivered.php [changed mode: 0644->0755]
CRM/Mailing/Event/BAO/Opened.php [changed mode: 0644->0755]
CRM/Mailing/Event/BAO/TrackableURLOpen.php [changed mode: 0644->0755]
CRM/Mailing/Event/BAO/Unsubscribe.php [changed mode: 0644->0755]
api/v3/Mailing.php [changed mode: 0644->0755]
api/v3/MailingAB.php [changed mode: 0644->0755]
css/angular-crmMailingAB.css
js/angular-crmMailingAB.js [changed mode: 0644->0755]
partials/abtesting/attachments.html [changed mode: 0644->0755]
partials/abtesting/composeonScreen.html [changed mode: 0644->0755]
partials/abtesting/from_name.html [changed mode: 0644->0755]
partials/abtesting/headerandFooter.html [deleted file]
partials/abtesting/headerfooter.html [new file with mode: 0755]
partials/abtesting/list.html [changed mode: 0644->0755]
partials/abtesting/main.html [changed mode: 0644->0755]
partials/abtesting/modal.html [changed mode: 0644->0755]
partials/abtesting/next.html [changed mode: 0644->0755]
partials/abtesting/report.html [changed mode: 0644->0755]
partials/abtesting/subject_lines.html [changed mode: 0644->0755]
partials/abtesting/tab1.html [changed mode: 0644->0755]
partials/abtesting/tab2.html [changed mode: 0644->0755]
partials/abtesting/tab3.html [changed mode: 0644->0755]
partials/abtesting/tab4.html [changed mode: 0644->0755]
partials/abtesting/trackandRespond.html [changed mode: 0644->0755]
partials/abtesting/two_emails.html [changed mode: 0644->0755]
partials/abtesting/uploadContent.html [changed mode: 0644->0755]
tests/phpunit/CiviTest/CiviUnitTestCase.php [changed mode: 0644->0755]
tests/phpunit/api/v3/MailingABTest.php [changed mode: 0644->0755]
tests/phpunit/api/v3/MailingTest.php [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index c6f3808..130acf8
@@ -129,9 +129,7 @@ class CRM_Mailing_Event_BAO_Bounce extends CRM_Mailing_Event_DAO_Bounce {
    * @access public
    * @static
    */
-  public static function getTotalCount($mailing_id, $job_id = NULL,
-    $is_distinct = FALSE
-  ) {
+  public static function getTotalCount($mailing_id, $job_id = NULL, $is_distinct = FALSE, $toDate = NULL) {
     $dao = new CRM_Core_DAO();
 
     $bounce  = self::getTableName();
@@ -150,6 +148,10 @@ class CRM_Mailing_Event_BAO_Bounce extends CRM_Mailing_Event_DAO_Bounce {
                     ON  $job.mailing_id = $mailing.id
             WHERE       $mailing.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
 
+    if (!empty($toDate)) {
+      $query .= " AND $bounce.time_stamp <= $toDate";
+    }
+
     if (!empty($job_id)) {
       $query .= " AND $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
     }
@@ -266,4 +268,3 @@ class CRM_Mailing_Event_BAO_Bounce extends CRM_Mailing_Event_DAO_Bounce {
     return $results;
   }
 }
-
old mode 100644 (file)
new mode 100755 (executable)
index 86ea913..7c42410
@@ -92,7 +92,7 @@ class CRM_Mailing_Event_BAO_Delivered extends CRM_Mailing_Event_DAO_Delivered {
    * @access public
    * @static
    */
-  public static function getTotalCount($mailing_id, $job_id = NULL, $is_distinct = FALSE) {
+  public static function getTotalCount($mailing_id, $job_id = NULL, $is_distinct = FALSE, $toDate = NULL) {
     $dao = new CRM_Core_DAO();
 
     $delivered = self::getTableName();
@@ -116,6 +116,10 @@ class CRM_Mailing_Event_BAO_Delivered extends CRM_Mailing_Event_DAO_Delivered {
             WHERE       $bounce.id IS null
                 AND     $mailing.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
 
+    if (!empty($toDate)) {
+      $query .= " AND $delivered.time_stamp <= $toDate";
+    }
+
     if (!empty($job_id)) {
       $query .= " AND $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
     }
@@ -149,7 +153,7 @@ class CRM_Mailing_Event_BAO_Delivered extends CRM_Mailing_Event_DAO_Delivered {
    * @static
    */
   public static function &getRows($mailing_id, $job_id = NULL,
-    $is_distinct = FALSE, $offset = NULL, $rowCount = NULL, $sort = NULL, $is_test = 0
+    $is_distinct = FALSE, $offset = NULL, $rowCount = NULL, $sort = NULL, $is_test = FALSE
   ) {
 
     $dao = new CRM_Core_Dao();
old mode 100644 (file)
new mode 100755 (executable)
index 57c94d7..b79a25b
@@ -81,7 +81,8 @@ class CRM_Mailing_Event_BAO_Opened extends CRM_Mailing_Event_DAO_Opened {
    */
   public static function getTotalCount($mailing_id,
     $job_id = NULL,
-    $is_distinct = FALSE
+    $is_distinct = FALSE,
+    $toDate = NULL
   ) {
     $dao = new CRM_Core_DAO();
 
@@ -102,6 +103,10 @@ class CRM_Mailing_Event_BAO_Opened extends CRM_Mailing_Event_DAO_Opened {
                     AND $job.is_test = 0
             WHERE       $mailing.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
 
+    if (!empty($toDate)) {
+      $query .= " AND $open.time_stamp <= $toDate";
+    }
+
     if (!empty($job_id)) {
       $query .= " AND $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
     }
@@ -297,4 +302,3 @@ class CRM_Mailing_Event_BAO_Opened extends CRM_Mailing_Event_DAO_Opened {
     return $results;
   }
 }
-
old mode 100644 (file)
new mode 100755 (executable)
index 3cc24d7..22cad88
@@ -108,7 +108,7 @@ class CRM_Mailing_Event_BAO_TrackableURLOpen extends CRM_Mailing_Event_DAO_Track
    * @static
    */
   public static function getTotalCount($mailing_id, $job_id = NULL,
-    $is_distinct = FALSE, $url_id = NULL
+    $is_distinct = FALSE, $url_id = NULL, $toDate = NULL
   ) {
     $dao = new CRM_Core_DAO();
 
@@ -129,6 +129,10 @@ class CRM_Mailing_Event_BAO_TrackableURLOpen extends CRM_Mailing_Event_DAO_Track
                     AND $job.is_test = 0
             WHERE       $mailing.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
 
+    if (!empty($toDate)) {
+      $query .= " AND $click.time_stamp <= $toDate";
+    }
+
     if (!empty($job_id)) {
       $query .= " AND $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
     }
@@ -338,4 +342,3 @@ class CRM_Mailing_Event_BAO_TrackableURLOpen extends CRM_Mailing_Event_DAO_Track
     return $results;
   }
 }
-
old mode 100644 (file)
new mode 100755 (executable)
index 75724ef..0e478c9
@@ -418,7 +418,7 @@ WHERE  email = %2
    * @static
    */
   public static function getTotalCount($mailing_id, $job_id = NULL,
-    $is_distinct = FALSE, $org_unsubscribe = NULL
+    $is_distinct = FALSE, $org_unsubscribe = NULL, $toDate = NULL
   ) {
     $dao = new CRM_Core_DAO();
 
@@ -442,6 +442,10 @@ WHERE  email = %2
                     AND $job.is_test = 0
             WHERE       $mailing.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
 
+    if (!empty($toDate)) {
+      $query .= " AND $unsub.time_stamp <= $toDate";
+    }
+
     if (!empty($job_id)) {
       $query .= " AND $job.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
     }
@@ -595,4 +599,3 @@ SELECT DISTINCT(civicrm_mailing_event_queue.contact_id) as contact_id,
     return array($displayName, $email);
   }
 }
-
old mode 100644 (file)
new mode 100755 (executable)
index dfcb41c..c550d04
@@ -68,79 +68,6 @@ function _civicrm_api3_mailing_create_spec(&$params) {
   $params['api.mailing_job.create']['api.default'] = 1;
 }
 
-
-
-
-function civicrm_api3_mailing_stats($params) {
-  civicrm_api3_verify_mandatory($params,
-    'CRM_Mailing_DAO_MailingJob',
-    array('mailing_id'),
-    FALSE
-  );
-  $stats[$params['mailing_id']] = array();
-  if (empty($params['job_id'])) {
-    $params['job_id'] = NULL;
-  }
-  foreach (array('Delivered', 'Bounces', 'Unsubscribers', 'Unique Clicks', 'Opened') as $detail) {
-    switch ($detail) {
-      case 'Delivered':
-        $stats[$params['mailing_id']] += array(
-          $detail =>  CRM_Mailing_Event_BAO_Delivered::getTotalCount($params['mailing_id'], $params['job_id'])
-        );
-        break;
-      case 'Bounces':
-        $stats[$params['mailing_id']] += array(
-          $detail =>  CRM_Mailing_Event_BAO_Bounce::getTotalCount($params['mailing_id'], $params['job_id'])
-        );
-        break;
-      case 'Unsubscribers':
-        $stats[$params['mailing_id']] += array(
-          $detail =>  CRM_Mailing_Event_BAO_Unsubscribe::getTotalCount($params['mailing_id'], $params['job_id'])
-        );
-        break;
-      case 'Unique Clicks':
-        $stats[$params['mailing_id']] += array(
-          $detail =>  CRM_Mailing_Event_BAO_TrackableURLOpen::getTotalCount($params['mailing_id'], $params['job_id'])
-        );
-        break;
-      case 'Opened':
-        $stats[$params['mailing_id']] += array(
-          $detail =>  CRM_Mailing_Event_BAO_Opened::getTotalCount($params['mailing_id'], $params['job_id'])
-        );
-        break;
-    }
-  }
-  return civicrm_api3_create_success($stats);
-}
-
-
-
-function civicrm_api3_mailing_a_b_recipients_update($params) {
-  civicrm_api3_verify_mandatory($params,
-    'CRM_Mailing_DAO_MailingAB',
-    array('id'),
-    FALSE
-  );
-
-
-  $mailingAB = civicrm_api3('MailingAB', 'get', $params);
-  $mailingAB = $mailingAB['values'][$params['id']];
-
-  //update mailingC with include/exclude group id(s) provided
-  civicrm_api3('Mailing', 'create', array('id' => $mailingAB['mailing_id_c'], 'groups' =>  $params['groups']));
-  //update recipients for mailing_id_c
-  CRM_Mailing_BAO_Mailing::getRecipients($mailingAB['mailing_id_c'], $mailingAB['mailing_id_c'], NULL, NULL, TRUE);
-  //calulate total number of random recipients for mail C from group_percentage selected
-  $totalCount =  civicrm_api3('MailingRecipients', 'getcount', array('mailing_id' => $mailingAB['mailing_id_c']));
-  $totalSelected = round(($totalCount * $mailingAB['group_percentage'])/100);
-  foreach (array('mailing_id_a', 'mailing_id_b') as $columnName) {
-    CRM_Mailing_BAO_Recipients::updateRandomRecipients($mailingAB['mailing_id_c'], $mailingAB[$columnName], $totalSelected);
-  }
-  return civicrm_api3_create_success();
-}
-
-
-
 /**
  * Handle a delete event.
  *
@@ -149,38 +76,6 @@ function civicrm_api3_mailing_a_b_recipients_update($params) {
  *
  * @return array API Success Array
  */
-
-function civicrm_api3_mailing_preview($params) {
-  civicrm_api3_verify_mandatory($params,
-    'CRM_Mailing_DAO_Mailing',
-    array('id'),
-    FALSE
-  );
-  $fromEmail = NULL;
-  if (!empty($params['from_email'])) {
-    $fromEmail = $params['from_email'];
-  }
-  $session = CRM_Core_Session::singleton();
-  $mailing = new CRM_Mailing_BAO_Mailing();
-  $mailing->id = $params['id'];
-  $mailing->find(TRUE);
-  CRM_Mailing_BAO_Mailing::tokenReplace($mailing);
-  // get and format attachments
-  $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id);
-  $returnProperties = $mailing->getReturnProperties();
-  $contactID = CRM_Utils_Array::value('contact_id', $params);
-  if (!$contactID) {
-    $contactID = $session->get('userID');
-  }
-  $mailingParams = array('contact_id' => $contactID);
-  $details = CRM_Utils_Token::getTokenDetails($mailingParams, $returnProperties, TRUE, TRUE, NULL, $mailing->getFlattenedToken());
-  $mime = &$mailing->compose(NULL, NULL, NULL, $session->get('userID'), $fromEmail, $fromEmail,
-    TRUE, $details[0][$contactID], $attachments
-  );
-  return civicrm_api3_create_success(array('html' => $mime->getHTMLBody(), 'text' => $mime->getTXTBody()));
-}
-
-
 function civicrm_api3_mailing_delete($params, $ids = array()) {
   return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
 }
@@ -374,17 +269,42 @@ function civicrm_api3_mailing_event_open($params) {
   return civicrm_api3_create_success($params);
 }
 
-/**
- * Fix the reset dates on the email record based on when a mail was last delivered
- * We only consider mailings that were completed and finished in the last 3 to 7 days
- * Both the min and max days can be set via the params
- */
-function civicrm_api3_mailing_update_email_resetdate($params) {
-  CRM_Mailing_Event_BAO_Delivered::updateEmailResetDate(
-    CRM_Utils_Array::value('minDays', $params, 3),
-    CRM_Utils_Array::value('maxDays', $params, 3)
+function civicrm_api3_mailing_preview($params) {
+  civicrm_api3_verify_mandatory($params,
+    'CRM_Mailing_DAO_Mailing',
+    array('id'),
+    FALSE
   );
-  return civicrm_api3_create_success();
+
+  $fromEmail = NULL;
+  if (!empty($params['from_email'])) {
+    $fromEmail = $params['from_email'];
+  }
+
+  $session = CRM_Core_Session::singleton();
+  $mailing = new CRM_Mailing_BAO_Mailing();
+  $mailing->id = $params['id'];
+  $mailing->find(TRUE);
+
+  CRM_Mailing_BAO_Mailing::tokenReplace($mailing);
+
+  // get and format attachments
+  $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id);
+
+  $returnProperties = $mailing->getReturnProperties();
+  $contactID = CRM_Utils_Array::value('contact_id', $params);
+  if (!$contactID) {
+    $contactID = $session->get('userID');
+  }
+  $mailingParams = array('contact_id' => $contactID);
+
+  $details = CRM_Utils_Token::getTokenDetails($mailingParams, $returnProperties, TRUE, TRUE, NULL, $mailing->getFlattenedToken());
+
+  $mime = &$mailing->compose(NULL, NULL, NULL, $session->get('userID'), $fromEmail, $fromEmail,
+    TRUE, $details[0][$contactID], $attachments
+  );
+
+  return civicrm_api3_create_success(array('subject' => $mime->_headers['Subject'], 'html' => $mime->getHTMLBody(), 'text' => $mime->getTXTBody()));
 }
 
 function civicrm_api3_mailing_send_test($params) {
@@ -396,8 +316,10 @@ function civicrm_api3_mailing_send_test($params) {
     array('mailing_id'),
     FALSE
   );
+
   $testEmailParams = _civicrm_api3_generic_replace_base_params($params);
-  $job = civicrm_api3('MailingJob', 'create', array('mailing_id' => $testEmailParams['mailing_id'], 'is_test' => 1));
+  $testEmailParams['is_test'] = 1;
+  $job = civicrm_api3('MailingJob', 'create', $testEmailParams);
   $testEmailParams['job_id'] = $job['id'];
   $testEmailParams['emails'] = explode(',', $testEmailParams['test_email']);
   if (!empty($params['test_email'])) {
@@ -449,11 +371,87 @@ ORDER BY   e.is_bulkmail DESC, e.is_primary DESC
       );
     }
   }
+
   $isComplete = FALSE;
   while (!$isComplete) {
     $isComplete = CRM_Mailing_BAO_MailingJob::runJobs($testEmailParams);
   }
-  return $isComplete;
+
+  //return delivered mail info
+  $mailDelivered = CRM_Mailing_Event_BAO_Delivered::getRows($params['mailing_id'], $job['id'], TRUE, NULL, NULL, NULL, TRUE);
+
+  return civicrm_api3_create_success($mailDelivered);
 }
 
+/**
+ * Adjust Metadata for send_mail action
+ *
+ * The metadata is used for setting defaults, documentation & validation
+ * @param array $params array or parameters determined by getfields
+ */
+function _civicrm_api3_mailing_stats_spec(&$params) {
+  $params['date']['api.default'] = 'now';
+}
 
+function civicrm_api3_mailing_stats($params) {
+  civicrm_api3_verify_mandatory($params,
+    'CRM_Mailing_DAO_MailingJob',
+    array('mailing_id'),
+    FALSE
+  );
+
+  if ($params['date'] == 'now') {
+    $params['date'] = date('YmdHis');
+  }
+  else {
+    $params['date'] = CRM_Utils_Date::processDate($params['date'] . ' ' . $params['date_time']);
+  }
+
+  $stats[$params['mailing_id']] = array();
+  if (empty($params['job_id'])) {
+    $params['job_id'] = NULL;
+  }
+  foreach (array('Delivered', 'Bounces', 'Unsubscribers', 'Unique Clicks', 'Opened') as $detail) {
+    switch ($detail) {
+      case 'Delivered':
+        $stats[$params['mailing_id']] += array(
+          $detail =>  CRM_Mailing_Event_BAO_Delivered::getTotalCount($params['mailing_id'], $params['job_id'], FALSE, $params['date'])
+        );
+        break;
+      case 'Bounces':
+        $stats[$params['mailing_id']] += array(
+          $detail =>  CRM_Mailing_Event_BAO_Bounce::getTotalCount($params['mailing_id'], $params['job_id'], FALSE, $params['date'])
+        );
+        break;
+      case 'Unsubscribers':
+        $stats[$params['mailing_id']] += array(
+          $detail =>  CRM_Mailing_Event_BAO_Unsubscribe::getTotalCount($params['mailing_id'], $params['job_id'], FALSE, NULL, $params['date'])
+        );
+        break;
+      case 'Unique Clicks':
+        $stats[$params['mailing_id']] += array(
+          $detail =>  CRM_Mailing_Event_BAO_TrackableURLOpen::getTotalCount($params['mailing_id'], $params['job_id'], FALSE, NULL, $params['date'])
+        );
+        break;
+      case 'Opened':
+        $stats[$params['mailing_id']] += array(
+          $detail =>  CRM_Mailing_Event_BAO_Opened::getTotalCount($params['mailing_id'], $params['job_id'], FALSE, $params['date'])
+        );
+        break;
+    }
+  }
+  return civicrm_api3_create_success($stats);
+}
+
+/**
+ * Fix the reset dates on the email record based on when a mail was last delivered
+ * We only consider mailings that were completed and finished in the last 3 to 7 days
+ * Both the min and max days can be set via the params
+ */
+function civicrm_api3_mailing_update_email_resetdate($params) {
+  CRM_Mailing_Event_BAO_Delivered::updateEmailResetDate(
+    CRM_Utils_Array::value('minDays', $params, 3),
+    CRM_Utils_Array::value('maxDays', $params, 3)
+  );
+  return civicrm_api3_create_success();
+}
old mode 100644 (file)
new mode 100755 (executable)
index f853209..af225dc
@@ -76,3 +76,75 @@ function civicrm_api3_mailing_a_b_get($params) {
 }
 
 
+/**
+ * Update recipients of A/B mail randomly based on group percentage selected.
+ *
+ * @param array $params
+ * @return array
+ */
+function civicrm_api3_mailing_a_b_recipients_update($params) {
+civicrm_api3_verify_mandatory($params,
+    'CRM_Mailing_DAO_MailingAB',
+    array('id'),
+    FALSE
+  );
+
+  $mailingAB = civicrm_api3('MailingAB', 'get', $params);
+  $mailingAB = $mailingAB['values'][$params['id']];
+
+  //update mailingC with include/exclude group id(s) provided
+  civicrm_api3('Mailing', 'create', array('id' => $mailingAB['mailing_id_c'], 'groups' =>  $params['groups']));
+  //update recipients for mailing_id_c
+  CRM_Mailing_BAO_Mailing::getRecipients($mailingAB['mailing_id_c'], $mailingAB['mailing_id_c'], NULL, NULL, TRUE);
+
+  //calulate total number of random recipients for mail C from group_percentage selected
+  $totalCount =  civicrm_api3('MailingRecipients', 'getcount', array('mailing_id' => $mailingAB['mailing_id_c']));
+  $totalSelected = round(($totalCount * $mailingAB['group_percentage'])/200);
+
+  foreach (array('mailing_id_a', 'mailing_id_b') as $columnName) {
+    CRM_Mailing_BAO_Recipients::updateRandomRecipients($mailingAB['mailing_id_c'], $mailingAB[$columnName], $totalSelected);
+  }
+
+  return civicrm_api3_create_success();
+}
+
+/**
+ * Adjust Metadata for send_mail 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_send_mail_spec(&$params) {
+  $params['scheduled_date']['api.default'] = 'now';
+}
+
+/**
+ * Send A/B mail to A/B recipients respectively
+ *
+ * @param array $params
+ * @return array
+ */
+function civicrm_api3_mailing_a_b_send_mail($params) {
+  civicrm_api3_verify_mandatory($params,
+    'CRM_Mailing_DAO_MailingAB',
+    array('id'),
+    FALSE
+  );
+
+  if ($params['scheduled_date'] == 'now') {
+    $params['scheduled_date'] = date('YmdHis');
+  }
+  else {
+    $params['scheduled_date'] = CRM_Utils_Date::processDate($params['scheduled_date'] . ' ' . $params['scheduled_date_time']);
+  }
+
+
+  $mailingAB = civicrm_api3('MailingAB', 'get', array('id' => $params['id']));
+  $mailingAB = $mailingAB['values'][$params['id']];
+
+  foreach (array('mailing_id_a', 'mailing_id_b') as $columnName) {
+    civicrm_api3('Mailing', 'create', $params + array('id' => $mailingAB[$columnName]));
+  }
+
+  return civicrm_api3_create_success();
+}
\ No newline at end of file
index b97db241bf23fd395e905e7360db646f4efd17c6..5b836814005ff9eb193459f2d88f99e3c9e2466e 100644 (file)
@@ -42,6 +42,8 @@ div#frag1 {
   height:500px;
   width:800px;
   overflow: auto;
+  position: relative;
+
 }
 
 div#frag2 {
old mode 100644 (file)
new mode 100755 (executable)
index 47bd50f..dc9bcd5
@@ -1,15 +1,13 @@
 /**
  * Created by aditya on 6/12/14.
  */
-
-
 (function (angular, $, _) {
 
   var partialUrl = function (relPath) {
     return CRM.resourceUrls['civicrm'] + '/partials/abtesting/' + relPath;
   };
 
-  var crmMailingAB = angular.module('crmMailingAB', ['ngRoute', 'ui.utils','ngSanitize']);
+  var crmMailingAB = angular.module('crmMailingAB', ['ngRoute', 'ui.utils', 'ngSanitize']);
   var mltokens = [];
   crmMailingAB.run(function ($rootScope, $templateCache) {
     $rootScope.$on('$viewContentLoaded', function () {
         templateUrl: partialUrl('report.html'),
         controller: 'ReportCtrl',
         resolve: {
-          selectedABTest: function($route, crmApi) {
-              return crmApi('MailingAB', 'getsingle', {id: $route.current.params.id});
-
+          selectedABTest: function ($route, crmApi) {
+            return crmApi('MailingAB', 'getsingle', {id: $route.current.params.id});
           }
         }
-
       });
       $routeProvider.when('/mailing/abtesting/:id', {
         templateUrl: partialUrl('main.html'),
-        controller: 'TabsDemoCtrl',
+        controller: 'crmABTestingTabsCtrl',
         resolve: {
-          selectedABTest: function($route, crmApi) {
-            if ( $route.current.params.id !== 'new') {
+          selectedABTest: function ($route, crmApi) {
+            if ($route.current.params.id !== 'new') {
 
               return crmApi('MailingAB', 'getsingle', {id: $route.current.params.id});
             }
             else {
               console.log("created");
               //created_id has been set to my id. Does not save without created_id. Needs to made generic based on the user
-              return { just_created:"1"
+              return { just_created: "1"
               };
             }
           }
   // Ex: <crmAddName crm-options="['Alpha','Beta','Gamma']" crm-var="newItem" crm-on-add="callMyCreateFunction(newItem)" />
   crmMailingAB.controller('ABListingCtrl', function ($scope, crmApi) {
     $scope.abmailList = CRM.crmMailing.mailingabNames;
-    console.log($scope.abmailList);
-
-
   });
-  crmMailingAB.controller('ReportCtrl', function ($scope, crmApi,selectedABTest) {
-
-
-    $scope.graph_data =  [{
-      time: 1,
-      x: 3,
-      y: 4
-    }, {
-      time: 2,
-      x: 6,
-      y: 8,
-    }, {
-      time: 3,
-      x: 10,
-      y: 9,
-    }, {
-      time: 4,
-      x: 13,
-      y: 11,
-    }]
+
+  crmMailingAB.controller('ReportCtrl', function ($scope, crmApi, selectedABTest) {
+    $scope.graph_data = [
+      {
+        time: 1,
+        x: 3,
+        y: 4
+      },
+      {
+        time: 2,
+        x: 6,
+        y: 8,
+      },
+      {
+        time: 3,
+        x: 10,
+        y: 9,
+      },
+      {
+        time: 4,
+        x: 13,
+        y: 11,
+      }
+    ]
     console.log(selectedABTest);
-    if(selectedABTest.winner_criteria_id==1){
+    if (selectedABTest.winner_criteria_id == 1) {
       $scope.winner_criteria = "Open";
     }
-    else if(selectedABTest.winner_criteria_id ==2){
-      $scope.winner_criteria ="Total Unique Clicks";
-    }
-    else if(selectedABTest.winner_criteria_id ==3){
-        $scope.winner_criteria ="Total Clicks on a particular link";
-
+    else {
+      if (selectedABTest.winner_criteria_id == 2) {
+        $scope.winner_criteria = "Total Unique Clicks";
       }
+      else {
+        if (selectedABTest.winner_criteria_id == 3) {
+          $scope.winner_criteria = "Total Clicks on a particular link";
+        }
+      }
+    }
+  });
 
-
-
-  })
-  crmMailingAB.controller('TabsDemoCtrl', function ($scope, crmApi,selectedABTest,$sce) {
+  crmMailingAB.controller('crmABTestingTabsCtrl', function ($scope, crmApi, selectedABTest, $sce) {
     $scope.partialUrl = partialUrl;
     $scope.abId = "";
-    $scope.whatnext=2;
-    $scope.currentABTest=selectedABTest
+    $scope.whatnext = 2;
+    $scope.currentABTest = selectedABTest;
     $scope.groups = CRM.crmMailing.groupNames;
     $scope.mailList = CRM.crmMailing.civiMails;
     $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];
-
+    $scope.emailadd = "";
+    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) {
+      $scope.abId = $scope.currentABTest.id;
+      var abmailA = crmApi('Mailing', 'getsingle', {id: $scope.currentABTest.mailing_id_a});
+      var abmailB = crmApi('Mailing', 'getsingle', {id: $scope.currentABTest.mailing_id_b});
+      var abmailC = crmApi('Mailing', 'getsingle', {id: $scope.currentABTest.mailing_id_c});
+      abmailA.success(function (data) {
+        if (data.is_error == 0) {
+          $scope.mailA = data;
+        }
+      });
+      abmailB.success(function (data) {
+        if (data.is_error == 0) {
+          $scope.mailB = data;
+        }
+      });
+      abmailC.success(function (data) {
+        if (data.is_error == 0) {
+          $scope.mailC = data;
+        }
+      });
+    }
+    else {
+      $scope.mailA = {};
+      $scope.mailB = {};
+      $scope.mailC = {};
+    }
 
-      if($scope.currentABTest.just_created != 1){
-        console.log("Prithvi");
-        console.log($scope.currentABTest);
-        console.log($scope.currentABTest.mailing_id_a);
-
-        $scope.abId = $scope.currentABTest.id;
-        var abmailA = crmApi('Mailing','getsingle',{id:$scope.currentABTest.mailing_id_a});
-        var abmailB= crmApi('Mailing','getsingle',{id:$scope.currentABTest.mailing_id_b});
-        var abmailC = crmApi('Mailing','getsingle',{id:$scope.currentABTest.mailing_id_c});
-        abmailA.success(function (data) {
-          if (data.is_error == 0) {
-            $scope.mailA = data;
-
-          };
-        });
-        abmailB.success(function(data) {
-          if (data.is_error == 0) {
-            $scope.mailB = data;
-
-          };
-        });
-        abmailC.success(function(data) {
-          if (data.is_error == 0) {
-            $scope.mailC = data;
-
-          };
-        });
-      }
-      else{
-        console.log("Prithvila");
-        console.log($scope.currentABTest);
-        $scope.mailA = {};
-        $scope.mailB = {};
-        $scope.mailC = {};
-      }
-
-    $scope.sendtest=false;
-    if(typeof $scope.mailA == 'undefined')$scope.mailA={};
-    if(typeof $scope.mailB == 'undefined')$scope.mailB={};
-    if(typeof $scope.mailB == 'undefined')$scope.mailC={};
+    $scope.sendtest = false;
+    if (typeof $scope.mailA == 'undefined') {
+      $scope.mailA = {};
+    }
+    if (typeof $scope.mailB == 'undefined') {
+      $scope.mailB = {};
+    }
+    if (typeof $scope.mailB == 'undefined') {
+      $scope.mailC = {};
+    }
 
     $scope.templates =
       [
-        { name: 'Subject Lines', url: partialUrl('subject_lines.html'),val: 1},
-        { name: 'From Name', url: partialUrl('from_name.html'),val:2},
-        {name: 'Two different Emails', url: partialUrl('two_emails.html'),val:3}
+        { name: 'Subject Lines', url: partialUrl('subject_lines.html'), val: 1},
+        { name: 'From Name', url: partialUrl('from_name.html'), val: 2},
+        { name: 'Two different Emails', url: partialUrl('two_emails.html'), val: 3}
       ];
-    if($scope.currentABTest.just_created != 1){
 
-      console.log("adit "+$scope.currentABTest.testing_criteria_id);
-
-      $scope.template=$scope.templates[$scope.currentABTest.testing_criteria_id-1];
-      console.log($scope.template.val);
-  }
-    else{
-      console.log("adi");
+    if ($scope.currentABTest.just_created != 1) {
+      $scope.template = $scope.templates[$scope.currentABTest.testing_criteria_id - 1];
+    }
+    else {
       $scope.template = $scope.templates[0];
     }
 
     mltokens = CRM.crmMailing.mailTokens;
-    $scope.deliberatelyTrustDangerousSnippeta = function() {
+    $scope.deliberatelyTrustDangerousSnippeta = function () {
       return $sce.trustAsHtml($scope.previewa);
     };
 
-    $scope.deliberatelyTrustDangerousSnippetb = function() {
+    $scope.deliberatelyTrustDangerousSnippetb = function () {
       return $sce.trustAsHtml($scope.previewb);
     };
 
       }
     };
 
-    $scope.winner_criteria="";
+    $scope.winner_criteria = "";
     $scope.compose_clicked = function () {
       if ($scope.max_tab >= 1) {
         $scope.tab_val = 1;
         $scope.tab_val = 3;
       }
     };
+
     $scope.preview = false;
     $scope.slide_value = 0;
 
       }
     };
 
-    $scope.reply = function(){
-      if($scope.trackreplies==0){
-        $scope.trackreplies=1;
+    $scope.reply = function () {
+      if ($scope.trackreplies == 0) {
+        $scope.trackreplies = 1;
       }
-      else{
-        $scope.trackreplies=0;
-        $scope.currentMailing.forward_replies=0;
-        $scope.currentMailing.auto_responder=0;
+      else {
+        $scope.trackreplies = 0;
+        $scope.currentMailing.forward_replies = 0;
+        $scope.currentMailing.auto_responder = 0;
       }
     }
 
-    $scope.isAuto= function(au){
+    $scope.isAuto = function (au) {
       return au.component_type == "Reply";
     };
 
-    $scope.trackr= function(trackreplies){
-      if(trackreplies=="1"){
+    $scope.trackr = function (trackreplies) {
+      if (trackreplies == "1") {
         return true;
       }
-      else
+      else {
         return false;
+      }
     }
 
-    $scope.sen = function(){
-      $scope.sendtest=true;
+    $scope.sendTestMailing = function () {
+      $scope.sendtest = true;
     }
 
-    $scope.isHeader= function(hf){
+    $scope.isHeader = function (hf) {
       return hf.component_type == "Header";
     };
     //filter so we only get footers from mailing component
-    $scope.isFooter= function(f){
+    $scope.isFooter = function (f) {
       return f.component_type == "Footer";
     };
 
     $scope.send_date = "01/01/2000";
-
     $scope.dt = "";
 
-
     $scope.savea = function (dat) {
 
       var result = crmApi('Mailing', 'create', dat, true);
       console.log(result);
-      result.success(function(data) {
+      result.success(function (data) {
         if (data.is_error == 0) {
           $scope.mailA.id = data.id;
-          $scope.currentABTest.mailing_id_a=$scope.mailA.id;
-          console.log("Mail a Id "+ $scope.mailA.id);
+          $scope.currentABTest.mailing_id_a = $scope.mailA.id;
+          console.log("Mail a Id " + $scope.mailA.id);
         }
       });
     };
 
-    $scope.append_mails = function(){
-      crmApi('MailingAB','create',{id:$scope.abId,mailing_id_a:$scope.mailA.id,mailing_id_b:$scope.mailB.id,mailing_id_c:$scope.mailC.id});
-      $scope.currentABTest.id= $scope.abId;
+    $scope.append_mails = function () {
+      crmApi('MailingAB', 'create', {id: $scope.abId, mailing_id_a: $scope.mailA.id, mailing_id_b: $scope.mailB.id, mailing_id_c: $scope.mailC.id});
+      $scope.currentABTest.id = $scope.abId;
     };
 
     $scope.saveb = function (dat) {
-     var flag =0;
+      var flag = 0;
       var result = crmApi('Mailing', 'create', dat, true);
       console.log(result);
-      result.success(function(data) {
+      result.success(function (data) {
         if (data.is_error == 0) {
           $scope.mailB.id = data.id;
-          console.log("Mail b Id "+ $scope.mailB.id);
-          $scope.currentABTest.mailing_id_b=$scope.mailB.id;
-
+          console.log("Mail b Id " + $scope.mailB.id);
+          $scope.currentABTest.mailing_id_b = $scope.mailB.id;
           $scope.append_mails();
-
-
         }
       });
-
     };
 
     $scope.savec = function (dat) {
-      var flag =0;
+      var flag = 0;
       console.log("C is called");
       var result = crmApi('Mailing', 'create', dat, true);
       console.log(result);
-      result.success(function(data) {
+      result.success(function (data) {
         if (data.is_error == 0) {
           $scope.mailC.id = data.id;
-          console.log("Mail C Id "+ $scope.mailC.id);
-          $scope.currentABTest.mailing_id_c=$scope.mailC.id;
-
+          console.log("Mail C Id " + $scope.mailC.id);
+          $scope.currentABTest.mailing_id_c = $scope.mailC.id;
           $scope.append_mails();
-
-
         }
       });
-
     };
-    $scope.previewa="";
-    $scope.pre= function(){
-      $scope.preview=true;
 
+    $scope.previewa = "";
+    $scope.pre = function () {
+      $scope.preview = true;
     }
-    $scope.init = function (par) {
 
+    $scope.init = function (par) {
+      if (par == "3") {
+        $scope.template.url = partialUrl('from_name.html');
+      }
+      else {
+        if (par == "2") {
+          $scope.template.url = partialUrl('subject_lines.html');
+        }
+        else {
+          $scope.template.url = partialUrl('two_emails.html');
+        }
+      }
       $scope.whatnext = par.toString()
     };
-    $scope.tab_upd = function(){
+
+    $scope.tab_upd = function () {
       $scope.tab_val = $scope.tab_val + 1;
-      $scope.max_tab=Math.max($scope.tab_val, $scope.max_tab);
+      $scope.max_tab = Math.max($scope.tab_val, $scope.max_tab);
+    }
 
-    };
-    $scope.tab_upd_dec = function(){
+    $scope.tab_upd_dec = function () {
       $scope.tab_val = $scope.tab_val - 1;
-
     }
+
     $scope.setdate = function (par) {
       console.log("called")
       console.log("av " + par)
       $scope.apply();
     };
 
-    $scope.testmailid ="";
+    $scope.testmailid = "";
     $scope.incGroup = [];
     $scope.excGroup = [];
-    $scope.incGroupids =[];
-    $scope.excGroupids =[];
+    $scope.incGroupids = [];
+    $scope.excGroupids = [];
     $scope.tp1 = {};
-    $scope.create_abtest = function(){
+    $scope.create_abtest = function () {
       var result;
-      $scope.currentABTest.testing_criteria_id=$scope.template.val;
-
-      if($scope.abId =="" )
-      result= crmApi('MailingAB','create',{name: $scope.currentABTest.name,testing_criteria_id: $scope.template.val});
-      else{
-        if (typeof $scope.currentABTest.mailing_id_a == 'undefined')
-      result= crmApi('MailingAB','create',{id:$scope.abId,testing_criteria_id: $scope.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} );
+      $scope.currentABTest.testing_criteria_id = $scope.template.val;
 
+      if ($scope.abId == "") {
+        result = crmApi('MailingAB', 'create', {name: $scope.currentABTest.name, testing_criteria_id: $scope.template.val});
+      }
+      else {
+        if (typeof $scope.currentABTest.mailing_id_a == 'undefined') {
+          result = crmApi('MailingAB', 'create', {id: $scope.abId, testing_criteria_id: $scope.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.success(function(data) {
+      result.success(function (data) {
         if (data.is_error == 0) {
           $scope.abId = data.id;
-          console.log("ID "+$scope.abId);
+          console.log("ID " + $scope.abId);
         }
       });
     };
 
-
-
-    $scope.a_b_update = function(){
-
-      $scope.tp1.include =$scope.incGroupids;
-      $scope.tp1.exclude=$scope.excGroupids;
+    $scope.a_b_update = function () {
+      $scope.tp1.include = $scope.incGroupids;
+      $scope.tp1.exclude = $scope.excGroupids;
 
       console.log($scope.tp1);
       console.log($scope.currentABTest.id);
 
       console.log("--------");
-      var result= crmApi('Mailing','a_b_recipients_update',{
-        id:$scope.currentABTest.id,
+      var result = crmApi('Mailing', 'a_b_recipients_update', {
+        id: $scope.currentABTest.id,
         groups: $scope.tp1
       });
 
-      var resulta =crmApi('Mailing','preview',{id:$scope.currentABTest.mailing_id_a});
+      var resulta = crmApi('Mailing', 'preview', {id: $scope.currentABTest.mailing_id_a});
 
-      resulta.success(function(data) {
+      resulta.success(function (data) {
         if (data.is_error == 0) {
           console.log("came");
-
-          $scope.previewa=data.values.html;
-
-
-
+          $scope.previewa = data.values.html;
         }
       });
 
-      resulta =crmApi('Mailing','preview',{id:$scope.currentABTest.mailing_id_b});
+      resulta = crmApi('Mailing', 'preview', {id: $scope.currentABTest.mailing_id_b});
 
-      resulta.success(function(data) {
+      resulta.success(function (data) {
         if (data.is_error == 0) {
           console.log("came");
           console.log(data.values.html);
-          $scope.previewb=data.values.html;
-
-
+          $scope.previewb = data.values.html;
         }
       });
     }
-    $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,
-                      mailing_id_c:$scope.currentABTest.mailing_id_c,
-                      winner_criteria_id : $scope.currentABTest.winner_criteria_id,
-                      group_percentage: $scope.currentABTest.group_percentage,
-                      declare_winning_time: $scope.currentABTest.declare_winning_time
-                      } );
-
-
-
+    $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,
+        mailing_id_c: $scope.currentABTest.mailing_id_c,
+        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="";
+    $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 {
+          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;
+      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;
+              }
             }
           }
         }
-
-      }
-      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.mailA.msg_template_id){
-              $scope.mailA.body_html=$scope.tmpList[a].msg_html;
+        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.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;
+          $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.$watch('preview', function () {
+      console.log("dsfdfsfds");
+      if ($scope.preview == true) {
+        $('#prevmail').dialog({
+          title: 'Preview Mailing',
+          width: 1080,
+          height: 800,
+          closed: false,
+          cache: false,
+          modal: true,
+          close: function () {
+            console.log("close");
+            $scope.preview = false;
+            $scope.$apply();
+          }
+        });
       }
-    };
+    }, true);
+
+    $scope.$watch('sendtest', function () {
+      if ($scope.sendtest == true) {
+        $('#sendtest').dialog({
+          title: 'Send Test Mails',
+          width: 380,
+          height: 200,
+          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.sendtest = false;
+              $('#sendtest').dialog("close");
 
+            }
+          },
+          close: function () {
+            console.log("close");
+            scope.sendtest = false;
+            $scope.$apply()
+          }
+        });
+      }
+    });
 
   });
 
     return {
       // Restrict it to be an attribute in this case
       restrict: 'A',
-
       priority: 500,
       // responsible for registering DOM listeners as well as updating the DOM
       link: function (scope, element, attrs) {
 
-        $(element).parent().parent().parent().parent().parent().parent().tabs(scope.$eval(attrs.nexttab));
+        var tabselector = $(".crmABTestingAllTabs");
+        tabselector.tabs(scope.$eval(attrs.nexttab));
         var myarr = new Array(1, 2, 3)
-        $(element).parent().parent().parent().parent().parent().parent().tabs({disabled: myarr});
+
+        // disable remaining tabs
+        tabselector.tabs({disabled: myarr});
 
         $(element).on("click", function () {
-          if(scope.tab_val==0){
+          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";
+          else {
+            if (scope.tab_val == 2) {
+              scope.update_abtest();
+              if (scope.currentABTest.winner_criteria_id == 1) {
+                scope.winner_criteria = "Open";
               }
-
-
-            scope.a_b_update();
-
+              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.a_b_update();
+            }
           }
 
           scope.tab_upd();
 
-          console.log("kurund "+scope.tab_val);
-
           var myArray1 = new Array();
           for (var i = scope.max_tab + 1; i < 4; i++) {
             myArray1.push(i);
           }
-          $(element).parent().parent().parent().parent().parent().parent().tabs("option", "disabled", myArray1);
-          $(element).parent().parent().parent().parent().parent().parent().tabs("option", "active", scope.tab_val);
+          tabselector.tabs("option", "disabled", myArray1);
+          tabselector.tabs("option", "active", scope.tab_val);
           scope.$apply();
-          console.log("Adir");
         });
       }
     };
       priority: 500,
       // responsible for registering DOM listeners as well as updating the DOM
       link: function (scope, element, attrs) {
-
-
         $(element).on("click", function () {
           var temp = scope.tab_val - 1;
           scope.tab_upd_dec();
           scope.$apply();
           console.log(temp);
-          if (temp == 3) {
-
-          }
-          else {
-            $(element).parent().parent().parent().parent().parent().parent().tabs("option", "active", temp);
+          if (temp != 3) {
+            $(".crmABTestingAllTabs").tabs("option", "active", temp);
           }
-
           scope.$apply();
-
         });
       }
     };
           if (e.val.split(" ")[2] == "exclude") {
             var index = scope.excGroup.indexOf(e.val.split(" ")[3]);
             scope.excGroup.splice(index, 1);
-            scope.excGroupids.splice(index,1);
+            scope.excGroupids.splice(index, 1);
             scope.$apply();
           }
           else {
             var index = scope.incGroup.indexOf(e.val.split(" ")[3]);
             scope.incGroup.splice(index, 1);
-            scope.incGroupids.splice(index,1);
+            scope.incGroupids.splice(index, 1);
             scope.$apply();
           }
         });
 
   });
 
-  crmMailingAB.directive('groupselect',function(){
+  crmMailingAB.directive('groupselect', function () {
     return {
-      restrict : 'AE',
-      link: function(scope,element, attrs){
-        $(element).select2({width:"200px", data: mltokens, placeholder:"Insert Token"});
+      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);
+        $(element).on('select2-selecting', function (e) {
+          scope.$evalAsync('_resetSelection()');
+          console.log(mltokens);
           /* if(scope.currentMailing.body_html == null){
            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;
+          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").selectionEnd = cursorPos;
           document.getElementById("body_html").focus();
           scope.$apply();
           e.preventDefault();
     return{
       restrict: 'AE',
       link: function (scope, element, attrs) {
-        if(typeof scope.currentABTest.group_percentage != 'undefined'){
+        if (typeof scope.currentABTest.group_percentage != 'undefined') {
           console.log("Yay");
-          $(element).slider({value:scope.currentABTest.group_percentage});
+          $(element).slider({value: scope.currentABTest.group_percentage});
         }
         $(element).slider({min: 1});
         $(element).slider({
     };
   });
 
-  crmMailingAB.directive('tpmax', function () {
-    return {
-      restrict: 'E',
-      link: function (scope, element, attr) {
-        scope.$watch('automated', function (val) {
-          if (val == "Yes") {
-            $(element).dialog({
-              title: 'Automated A/B Testing',
-              width: 800,
-              height: 600,
-              closed: false,
-              cache: false,
-              modal: true
-            });
-          }
-        });
-
-        $(element).find("#closebutton").on("click", function () {
-          $(element).dialog("close");
-        });
-      }
-    };
-  });
-
-  crmMailingAB.directive('previewmail', function () {
-    return {
-      // Restrict it to be an attribute in this case
-      restrict: 'AE',
-
-      priority: 500,
-      // responsible for registering DOM listeners as well as updating the DOM
-      link: function (scope, element, attrs) {
-
-        scope.$watch('preview', function () {
-          if(scope.preview == true){
-
-          $(element).dialog({
-            title: 'Preview Mailing',
-            width: 1080,
-            height: 800,
-            closed: false,
-            cache: false,
-            modal: true,
-
-            close :function(){console.log("close");
-                            scope.preview = false;scope.$apply()}
-
-
-          });}
-
-        });
-
-
-        $(element).find("#closebutton").on("click", function () {
-          console.log("close");
-          scope.preview = false;
-          $(element).dialog("close");
-        });
-      }
-    };
-  });
-
-  crmMailingAB.directive('sendmailtest', function () {
-    return {
-      // Restrict it to be an attribute in this case
-      restrict: 'AE',
-
-      link: function (scope, element, attrs) {
-
-        scope.$watch('sendtest', function () {
-          if(scope.sendtest == true){
-
-            $(element).dialog({
-              title: 'Send Test Mails',
-              width: 1080,
-              height: 800,
-              closed: false,
-              cache: false,
-              modal: true,
-              button:{
-                'Send': function() {
-                  /* Do stuff */
-                  $(this).dialog('close');
-                }
-              },
-              close :function(){console.log("close");
-                scope.sendtest = false;scope.$apply()}
-
-
-            });
-          }
-
-        });
-
-
-        $(element).find("#closebutton").on("click", function () {
-          console.log("close");
-          scope.preview = false;
-          $(element).dialog("close");
-        });
-      }
-    };
-  });
-
-  crmMailingAB.directive('numbar', function () {
-    return{
-      restrict: 'AE',
-      link: function (scope, element, attrs) {
-        $(element).spinner({max: attrs.numbar, min: 0});
-      }
-    };
-  });
-
   crmMailingAB.directive('datepick', 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);
-
           }
-
-
         });
       }
     };
       priority: 1000,
       link: function (scope, element, attrs) {
         $(element).on("click", function () {
-
           console.log("clicked");
           scope.savea({
             id: scope.mailA.id,
-            name: "Aditya Nambiar",
-            visibility:  scope.mailA.visibility,
+            name: "mailing a",
+            visibility: scope.mailA.visibility,
             created_id: 1,
             subject: scope.mailA.subject,
-            msg_template_id: scope.mailA.msg_template_id==null ? "" : scope.mailA.msg_template_id,
+            msg_template_id: scope.mailA.msg_template_id == null ? "" : scope.mailA.msg_template_id,
             open_tracking: scope.mailA.open_tracking,
             url_tracking: scope.mailA.url_tracking,
             forward_replies: scope.mailA.forward_replies,
             body_text: scope.mailA.body_text,
             scheduled_date: scope.mailA.scheduled_date,
             scheduled_id: scope.mailA.scheduled_id,
-            campaign_id:       scope.mailA.campaign_id==null ? "" : scope.mailA.campaign_id,
-            header_id: scope.mailA.header_id,
+            campaign_id: scope.mailA.campaign_id == null ? "" : scope.mailA.campaign_id,
+            header_id: scope.mailA.header_id,
             footer_id: scope.mailA.footer_id,
-
             is_completed: scope.mailA.is_completed
           });
 
-          console.log("Truth " + scope.whatnext)
-
           if (scope.whatnext == "3") {
             console.log("sdf");
-
-              scope.mailB.name= scope.mailA.name;
-              scope.mailB.visibility=  scope.mailA.visibility;
-              scope.mailB.created_id= scope.mailA.created_id;
-              scope.mailB.subject= scope.mailA.subject;
-              scope.mailB.msg_template_id= scope.mailA.msg_template_id==null ? "" : scope.mailA.msg_template_id;
-              scope.mailB.open_tracking= scope.mailA.open_tracking;
-              scope.mailB.url_tracking= scope.mailA.url_tracking;
-              scope.mailB.forward_replies= scope.mailA.forward_replies;
-              scope.mailB.auto_responder= scope.mailA.auto_responder;
-              scope.mailB.from_name= scope.mailA.from_name;
-              scope.mailB.replyto_email= scope.mailA.replyto_email;
-              scope.mailB.unsubscribe_id= scope.mailA.unsubscribe_id;
-              scope.mailB.resubscribe_id= scope.mailA.resubscribe_id;
-              scope.mailB.body_html= scope.mailA.body_html;
-              scope.mailB.body_text= scope.mailA.body_text;
-              scope.mailB.scheduled_date= scope.mailA.scheduled_date;
-              scope.mailB.scheduled_id= scope.mailA.scheduled_id;
-              scope.mailB.campaign_id= scope.mailA.campaign_id==null ? "" : scope.mailA.campaign_id;
-              scope.mailB.header_id=   scope.mailA.header_id;
-              scope.mailB.footer_id=   scope.mailA.footer_id;
-
-              scope.mailB.is_completed= scope.mailA.is_completed;
-
+            scope.mailB.name = scope.mailA.name;
+            scope.mailB.visibility = scope.mailA.visibility;
+            scope.mailB.created_id = scope.mailA.created_id;
+            scope.mailB.subject = scope.mailA.subject;
+            scope.mailB.msg_template_id = scope.mailA.msg_template_id == null ? "" : scope.mailA.msg_template_id;
+            scope.mailB.open_tracking = scope.mailA.open_tracking;
+            scope.mailB.url_tracking = scope.mailA.url_tracking;
+            scope.mailB.forward_replies = scope.mailA.forward_replies;
+            scope.mailB.auto_responder = scope.mailA.auto_responder;
+            scope.mailB.from_name = scope.mailA.from_name;
+            scope.mailB.replyto_email = scope.mailA.replyto_email;
+            scope.mailB.unsubscribe_id = scope.mailA.unsubscribe_id;
+            scope.mailB.resubscribe_id = scope.mailA.resubscribe_id;
+            scope.mailB.body_html = scope.mailA.body_html;
+            scope.mailB.body_text = scope.mailA.body_text;
+            scope.mailB.scheduled_date = scope.mailA.scheduled_date;
+            scope.mailB.scheduled_id = scope.mailA.scheduled_id;
+            scope.mailB.campaign_id = scope.mailA.campaign_id == null ? "" : scope.mailA.campaign_id;
+            scope.mailB.header_id = scope.mailA.header_id;
+            scope.mailB.footer_id = scope.mailA.footer_id;
+            scope.mailB.is_completed = scope.mailA.is_completed;
           }
           else {
             if (scope.whatnext == "2") {
               scope.mailB.fromEmail = scope.mailA.fromEmail;
-              scope.mailB.name= scope.mailA.name;
-              scope.mailB.visibility=  scope.mailA.visibility;
-              scope.mailB.created_id= scope.mailA.created_id;
-              scope.mailB.msg_template_id= scope.mailA.msg_template_id==null ? "" : scope.mailA.msg_template_id;
-              scope.mailB.open_tracking= scope.mailA.open_tracking;
-              scope.mailB.url_tracking= scope.mailA.url_tracking;
-              scope.mailB.forward_replies= scope.mailA.forward_replies;
-              scope.mailB.auto_responder= scope.mailA.auto_responder;
-              scope.mailB.from_name= scope.mailA.from_name;
-              scope.mailB.replyto_email= scope.mailA.replyto_email;
-              scope.mailB.unsubscribe_id= scope.mailA.unsubscribe_id;
-              scope.mailB.resubscribe_id= scope.mailA.resubscribe_id;
-              scope.mailB.body_html= scope.mailA.body_html;
-              scope.mailB.body_text= scope.mailA.body_text;
-              scope.mailB.scheduled_date= scope.mailA.scheduled_date;
-              scope.mailB.scheduled_id= scope.mailA.scheduled_id;
-              scope.mailB.campaign_id= scope.mailA.campaign_id==null ? "" : scope.mailA.campaign_id;
-              scope.mailB.header_id=   scope.mailA.header_id;
-              scope.mailB.footer_id=   scope.mailA.footer_id;
-
-              scope.mailB.is_completed= scope.mailA.is_completed;
-
+              scope.mailB.name = scope.mailA.name;
+              scope.mailB.visibility = scope.mailA.visibility;
+              scope.mailB.created_id = scope.mailA.created_id;
+              scope.mailB.msg_template_id = scope.mailA.msg_template_id == null ? "" : scope.mailA.msg_template_id;
+              scope.mailB.open_tracking = scope.mailA.open_tracking;
+              scope.mailB.url_tracking = scope.mailA.url_tracking;
+              scope.mailB.forward_replies = scope.mailA.forward_replies;
+              scope.mailB.auto_responder = scope.mailA.auto_responder;
+              scope.mailB.from_name = scope.mailA.from_name;
+              scope.mailB.replyto_email = scope.mailA.replyto_email;
+              scope.mailB.unsubscribe_id = scope.mailA.unsubscribe_id;
+              scope.mailB.resubscribe_id = scope.mailA.resubscribe_id;
+              scope.mailB.body_html = scope.mailA.body_html;
+              scope.mailB.body_text = scope.mailA.body_text;
+              scope.mailB.scheduled_date = scope.mailA.scheduled_date;
+              scope.mailB.scheduled_id = scope.mailA.scheduled_id;
+              scope.mailB.campaign_id = scope.mailA.campaign_id == null ? "" : scope.mailA.campaign_id;
+              scope.mailB.header_id = scope.mailA.header_id;
+              scope.mailB.footer_id = scope.mailA.footer_id;
+              scope.mailB.is_completed = scope.mailA.is_completed;
             }
           }
           console.log("call B");
           scope.saveb({
-
             id: scope.mailB.id,
-            name: "Aditya Nambiar",
-            visibility:  scope.mailB.visibility,
+            name: "mailing b",
+            visibility: scope.mailB.visibility,
             created_id: 1,
             subject: scope.mailB.subject,
-            msg_template_id: scope.mailB.msg_template_id==null ? "" : scope.mailB.msg_template_id,
+            msg_template_id: scope.mailB.msg_template_id == null ? "" : scope.mailB.msg_template_id,
             open_tracking: scope.mailB.open_tracking,
             url_tracking: scope.mailB.url_tracking,
             forward_replies: scope.mailB.forward_replies,
             body_text: scope.mailB.body_text,
             scheduled_date: scope.mailB.scheduled_date,
             scheduled_id: scope.mailB.scheduled_id,
-            campaign_id:       scope.mailB.campaign_id==null ? "" : scope.mailB.campaign_id,
-            header_id: scope.mailB.header_id,
-            footer_id: scope.mailB.footer_id,
-
+            campaign_id: scope.mailB.campaign_id == null ? "" : scope.mailB.campaign_id,
+            header_id: scope.mailB.header_id,
+            footer_id: scope.mailB.footer_id,
             is_completed: scope.mailA.is_completed
-
           });
+
           console.log("call C");
           scope.savec({
             id: scope.mailC.id,
-            name: "Aditya Nambiar",
-            visibility:  scope.mailB.visibility,
+            name: "mailing c",
+            visibility: scope.mailB.visibility,
             created_id: 1,
             subject: scope.mailB.subject,
-            msg_template_id: scope.mailB.msg_template_id==null ? "" : scope.mailB.msg_template_id,
+            msg_template_id: scope.mailB.msg_template_id == null ? "" : scope.mailB.msg_template_id,
             open_tracking: scope.mailB.open_tracking,
             url_tracking: scope.mailB.url_tracking,
             forward_replies: scope.mailB.forward_replies,
             resubscribe_id: scope.mailB.resubscribe_id,
             body_html: scope.mailB.body_html,
             body_text: scope.mailB.body_text,
-            campaign_id:       scope.mailB.campaign_id==null ? "" : scope.mailB.campaign_id,
-            header_id: scope.mailB.header_id,
-            footer_id: scope.mailB.footer_id,
-
+            campaign_id: scope.mailB.campaign_id == null ? "" : scope.mailB.campaign_id,
+            header_id: scope.mailB.header_id,
+            footer_id: scope.mailB.footer_id,
             is_completed: scope.mailA.is_completed
           });
-
-
         });
       }
     };
-
   });
 
-
-
-  crmMailingAB.directive('nextbutton', function () {
+  crmMailingAB.directive('chsdate', function () {
     return {
       restrict: 'AE',
-      replace: 'true',
-      template: '<div class="crm-submit-buttons" id="campaignbutton">' +
-        '<div class = "crm-button crm-button-type-upload crm-button_qf_Contact_upload_view"   >' +
-        '<input type="submit" value="Next"  id="campaignbutton _qf_Contact_upload_view-top" class="btn btn-primary" nexttab={{tab_val}}>' +
-        '</div></div>'
-
-    };
-  });
-
-  crmMailingAB.directive('cancelbutton', function () {
-    return {
-      restrict: 'AE',
-      replace: 'true',
-      template: '<div class="crm-submit-buttons" id="campaignbutton">' +
-        '<div class = "crm-button crm-button-type-upload crm-button_qf_Contact_upload_view"   >' +
-        '<input type="submit" value="Cancel"  id="campaignbutton _qf_Contact_upload_view-top" class="btn btn-primary" >' +
-        '</div></div>'
-
-    };
-  });
-
-  crmMailingAB.directive('chsdate',function(){
-    return {
-      restrict: 'AE',
-      link: function(scope,element,attrs){
+      link: function (scope, element, attrs) {
         $(element).datepicker({
           dateFormat: "yy-mm-dd",
-          onSelect: function(date) {
+          onSelect: function (date) {
             $(".ui-datepicker a").removeAttr("href");
-            scope.currentABTest.date=date.toString();
+            scope.currentABTest.date = date.toString();
             scope.$apply();
             console.log(scope.currentABTest.date);
           }
         '<div class = "crm-button crm-button-type-upload crm-button_qf_Contact_upload_view"   >' +
         '<input type="submit" value="Previous"  id="campaignbutton _qf_Contact_upload_view-top" class="btn btn-primary" prevtab={{tab_val}}>' +
         '</div></div>'
-
     };
   });
 
-  crmMailingAB.directive('linegraph',function(){
+  crmMailingAB.directive('linegraph', function () {
     return {
       restrict: 'AE',
-      link: function(scope,element,attrs){
-          console.log("try");
-        var data= scope.graph_data;
-
-        // see wht it looks like in the console
-        console.log("Data");
-        console.log(data);
-
+      link: function (scope, element, attrs) {
+        var data = scope.graph_data;
         // set up a colour variable
         var color = d3.scale.category10();
 
         console.log("Key");
 
         console.log(d3.keys(data[0]));
-        color.domain(d3.keys(data[0]).filter(function(key) {
+        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) {
+        var series = color.domain().map(function (name) {
           console.log(name);
 
           return {
             name: name,
-            values: data.map(function(d) {
+            values: data.map(function (d) {
               console.log("------");
               console.log(d);
               return {
                 time: d.time,
                 score: +d[name]
-
               };
             })
           };
 
         // Set the ranges
         //var x = d3.time.scale().range([0, width]).domain([0,10]);
-        var x = d3.scale.linear().range([0,width]);
+        var x = d3.scale.linear().range([0, width]);
         var y = d3.scale.linear().range([height, 0]);
 
         // Define the axes
         // Define the line
         // Note you plot the time / score pair from each key you created ealier
         var valueline = d3.svg.line()
-          .x(function(d) {
+          .x(function (d) {
             return x(d.time);
           })
-          .y(function(d) {
+          .y(function (d) {
             return y(d.score);
           });
 
-
         // Adds the svg canvas
         var svg = d3.select(element[0])
           .append("svg")
           .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
 
         // Scale the range of the data
-        x.domain(d3.extent(data, function(d) {
+        x.domain(d3.extent(data, function (d) {
           return d.time;
         }));
 
         // note the nested nature of this you need to dig an additional level
         y.domain([
-          d3.min(series, function(c) {
-            return d3.min(c.values, function(v) {
+          d3.min(series, function (c) {
+            return d3.min(c.values, function (v) {
               return v.score;
             });
           }),
-          d3.max(series, function(c) {
-            return d3.max(c.values, function(v) {
+          d3.max(series, function (c) {
+            return d3.max(c.values, function (v) {
               return v.score;
             });
           })
         ]);
         svg.append("text")      // text label for the x axis
-          .attr("x", width / 2  )
-          .attr("y", height + margin.bottom )
+          .attr("x", width / 2)
+          .attr("y", height + margin.bottom)
           .style("text-anchor", "middle")
           .text("Time");
 
         svg.append("text")      // text label for the x axis
 
           .style("text-anchor", "middle")
-          .text(scope.winner_criteria).attr("transform", function(d) {
+          .text(scope.winner_criteria).attr("transform",function (d) {
             return "rotate(-90)"
-          }).attr("x", -height/2 )
-          .attr("y", -30 );
+          }).attr("x", -height / 2)
+          .attr("y", -30);
         ;
         // create a variable called series and bind the date
         // for each series append a g element and class it as series for css styling
         // pass each object called x, y nad z to the lne generator
         series.append("path")
           .attr("class", "line")
-          .attr("d", function(d) {
+          .attr("d", function (d) {
             console.log(d); // to see how d3 iterates through series
             return valueline(d.values);
           })
-          .style("stroke", function(d) {
+          .style("stroke", function (d) {
             return color(d.name);
           });
 
         svg.append("g") // Add the Y Axis
           .attr("class", "y axis")
           .call(yAxis);
-
-
       }
-
     }
-
   });
 
 })(angular, CRM.$, CRM._);
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index db46d4f..3f75e69
-
-<div>
-
 <table class="form-layout-compressed">
-    <tbody>
-    <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">
-                <option value="">-none-</option>
-            </select>
-        </td>
-    </tr>
-    <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">
-                <option value="">-none-</option>
-            </select>
-        </td>
-    </tr>
-    <tr>
-        <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">
-                <option value="">-none-</option>
-            </select>
-        </td>
-    </tr>
-    <tr>
-        <td class="label">Mailing Subject</td>
-        <td>
-            <input placeholder="Enter Subject"  name="subject" type="text" ng-model="mailA.subject"/>
-        </td>
-    </tr>
-    <tr>
-        <td class="label" style= "color:red" ng-show="mailing_form.subject.$invalid">
-            Mailing subject required.
-        </td>
-    </tr>
-    <tr>
-        <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">
-                <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>
+  <tbody>
+  <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">
+        <option value="">-none-</option>
+      </select>
+    </td>
+  </tr>
+  <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">
+        <option value="">-none-</option>
+      </select>
+    </td>
+  </tr>
+  <tr>
+    <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">
+        <option value="">-none-</option>
+      </select>
+    </td>
+  </tr>
+  <tr>
+    <td class="label">Mailing Subject</td>
+    <td>
+      <input placeholder="Enter Subject" name="subject" type="text" ng-model="mailA.subject"/>
+    </td>
+  </tr>
+  <tr>
+    <td class="label" style="color:red" ng-show="mailing_form.subject.$invalid">
+      Mailing subject required.
+    </td>
+  </tr>
+  <tr>
+    <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">
+        <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 class="crm-accordion-wrapper collapsed">
-    <div class="crm-accordion-header">Header and Footer</div>
-    <div class="crm-accordion-body" >
-
-
-        <body>
-        <table>
-            <tr>
-                <td class="label">Mailing Header</td>
-                <td>
-                    <select ng-model="mailA.header_id" ng-options="hf.id as hf.name for hf in headerfooter| filter:isHeader">
-                        <option value="">-none-</option>
-                    </select>
-                </td>
-            </tr>
-            <tr>
-                <td class="label">Mailing Footer</td>
-                <td>
-                    <select ng-model="mailA.footer_id" ng-options="f.id as f.name for f in headerfooter| filter:isFooter">
-                        <option value="">-none-</option>
-                    </select>
-                </td>
-            </tr>
-        </table>
-        </body>
+  <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">Track and Respond</div>
-    <div class="crm-accordion-body" >
+  </div>
 
-        <table class="form-layout-compressed">
-            <tbody>
-            <tr>
-                <td>
-                    <h3 style ="text-decoration:underline"> Tracking</h3>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <input type="checkbox" ng-model="mailA.url_tracking" ng-true-value="1" ng-false-value="0">&nbsp Track Click Throughs</input>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <div id="help">
-                        Track the number of times recipients click each link in this mailing. NOTE: When this feature is enabled, all links in the message body will be automaticallly re-written to route through your CiviCRM server prior to redirecting to the target page.
-                    </div>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <input type="checkbox" ng-model="mailA.open_tracking" ng-true-value="1" ng-false-value="0">&nbsp Track Opens</input>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <div id="help">
-                        Track the number of times recipients open this mailing in their email software.
-                    </div>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <h3 style ="text-decoration:underline">Responding</h3>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <input type="checkbox" ng-model="trackreplies" ng-change= "reply()" ng-true-value="1" ng-false-value="0">&nbsp Track Replies</input>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <div id="help">
-                        Recipients' replies are sent to a CiviMail specific address instead of the sender's address so they can be stored within CiviCRM.
-                    </div>
-                </td>
-            </tr>
-            <tr ng-show= "trackr(trackreplies)">
-                <td>
-                    <input type="checkbox" ng-model="mailA.forward_replies" ng-true-value="1" ng-false-value="0">&nbsp Forward Replies</input>
-                </td>
-            </tr>
-            <tr ng-show= "trackr(trackreplies)">
-                <td>
-                    <div id="help">
-                        If a recipient replies to this mailing, forward the reply to the FROM Email address specified for the mailing.
-                    </div>
-                </td>
-            </tr>
-            <tr ng-show= "trackr(trackreplies)">
-                <td>
-                    <input type="checkbox" ng-model="mailA.auto_responder" ng-true-value="1" ng-false-value="0">&nbsp Auto-Respond to Replies &nbsp &nbsp</input>
-                    <select ng-model="mailAutoResponder" ng-options="au.id as au.name for au in headerfooter| filter:isAuto">
-                        <option value="">-none-</option>
-                    </select>
-                </td>
-            </tr>
-            <tr ng-show= "trackr(trackreplies)">
-                <td>
-                    <div id="help">
-                        If a recipient replies to this mailing, send an automated reply using the selected message.
-                    </div>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <h3 style ="text-decoration:underline"> Online Publication</h3>
-                </td>
-            </tr>
-        </table>
-
-        <table class="form-layout-compressed">
-            <tr>
-                <td class="label">Mailing Visibility</td>
-                <td>
-                    <select ng-model="mailA.visibility">
-                        <option value="Public Pages">Public Pages</option>
-                        <option value="User and User Admin Only">User and User Admin Only</option>
-                    </select>
-                </td>
-                </tbody>
-        </table>
+  <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>
\ No newline at end of file
+
+<div ng-include="partialUrl('headerfooter.html')"></div>
\ No newline at end of file
diff --git a/partials/abtesting/headerandFooter.html b/partials/abtesting/headerandFooter.html
deleted file mode 100644 (file)
index 00bc81d..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
-Controller: MailCtrl
-Required vars: currentMailing and headerfooter
--->
-<br>
-<body>
-<table>
-    <tr>
-        <td class="label">Mailing Header</td>
-        <td>
-            <select ng-model="currentMailing.header_id" ng-options="hf.id as hf.name for hf in headerfooter| filter:isHeader">
-                <option value="">-none-</option>
-            </select>
-        </td>
-    </tr>
-    <tr>
-        <td class="label">Mailing Footer</td>
-        <td>
-            <select ng-model="currentMailing.footer_id" ng-options="f.id as f.name for f in headerfooter| filter:isFooter">
-                <option value="">-none-</option>
-            </select>
-        </td>
-    </tr>
-</table>
-</body>
\ No newline at end of file
diff --git a/partials/abtesting/headerfooter.html b/partials/abtesting/headerfooter.html
new file mode 100755 (executable)
index 0000000..3d55f30
--- /dev/null
@@ -0,0 +1,29 @@
+<!--
+Controller: crmABTestingTabsCtrl
+Required vars: headerfooter
+-->
+<div class="crm-accordion-wrapper collapsed">
+  <div class="crm-accordion-header">Header and Footer</div>
+  <div class="crm-accordion-body">
+    <body>
+    <table>
+      <tr>
+        <td class="label">Mailing Header</td>
+        <td>
+          <select ng-model="mailA.header_id" ng-options="hf.id as hf.name for hf in headerfooter| filter:isHeader">
+            <option value="">-none-</option>
+          </select>
+        </td>
+      </tr>
+      <tr>
+        <td class="label">Mailing Footer</td>
+        <td>
+          <select ng-model="mailA.footer_id" ng-options="f.id as f.name for f in headerfooter| filter:isFooter">
+            <option value="">-none-</option>
+          </select>
+        </td>
+      </tr>
+    </table>
+    </body>
+  </div>
+</div>
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index 2a0b78f..e295a82
@@ -1,28 +1,22 @@
-<div>
-  {{tab_val}}<br>
-
-
-  <div ui-jq="tabs" id="alltabs">
-    <ul>
-
-      <li><a href="#tabs-1" ng-click="campaign_clicked()">Campaign</a></li>
-      <li><a href="#tabs-2" ng-click="compose_clicked()">Compose</a></li>
-      <li><a href="#tabs-3" ng-click="rec_clicked()">Recipients and Winner Criteria</a></li>
-      <li><a href="#tabs-4" ng-click="preview_clicked()">Preview and Send</a></li>
-    </ul>
-
-    <div id="tabs-1">
-    <div ng-include = "partialUrl('tab1.html')"></div>
-    </div>
-    <div id="tabs-2">
-     <div ng-include = "partialUrl('tab2.html')"></div>
-     </div>
-    <div id="tabs-3">
-    <div ng-include = "partialUrl('tab3.html')"></div>
-    </div>
-    <div id="tabs-4">
-    <div ng-include = "partialUrl('tab4.html')"></div>
-    </div>
+{{tab_val}}
+<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>
+    <li><a href="#tabs-2" ng-click="compose_clicked();">Compose</a></li>
+    <li><a href="#tabs-3" ng-click="rec_clicked();">Recipients and Winner Criteria</a></li>
+    <li><a href="#tabs-4" ng-click="preview_clicked();">Preview and Send</a></li>
+  </ul>
 
+  <div id="tabs-1">
+    <div ng-include="partialUrl('tab1.html')"></div>
+  </div>
+  <div id="tabs-2">
+    <div ng-include="partialUrl('tab2.html')"></div>
+  </div>
+  <div id="tabs-3">
+    <div ng-include="partialUrl('tab3.html')"></div>
+  </div>
+  <div id="tabs-4">
+    <div ng-include="partialUrl('tab4.html')"></div>
   </div>
-</div>
\ No newline at end of file
+</div>
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index 3cd9215..18d9c60
@@ -1,15 +1,9 @@
-
-<div>
-
-<div>
-
-
 <table class="form-layout-compressed">
   <tbody>
   <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>
   <tr>
     <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">
+      <select style="width: 200px" ng-model="mailA.replyto_email"
+              ng-options="frm.email as frm.email for frm in eMailing">
         <option value="">-none-</option>
       </select>
     </td>
   </tr>
   <tr>
-    <td class="label">Mailing Subject</td>
+    <td class="label">Mailing Subject A</td>
     <td>
-      <input placeholder="Enter Subject"  name="subject" type="text" ng-model="mailA.subject"/>
+      <input placeholder="Enter Subject A" name="subject_a" type="text" ng-model="mailA.subject" required/>
     </td>
   </tr>
   <tr>
-    <td class="label">Mailing Subject</td>
+    <td class="label">Mailing Subject B</td>
     <td>
-      <input placeholder="Enter Subject"  name="subject" type="text" ng-model="mailB.subject"/>
+      <input placeholder="Enter Subject B" name="subject_b" type="text" ng-model="mailB.subject" required/>
     </td>
   </tr>
 
   <tr>
-    <td class="label" style= "color:red" ng-show="mailing_form.subject.$invalid">
+    <td class="label" style="color:red" ng-show="mailing_form.subject.$invalid">
       Mailing subject required.
     </td>
   </tr>
   <tr>
     <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">
+      <select ng-change="tmp(mailA.msg_template_id,3)" ng-model="mailA.msg_template_id"
+              ng-options="mstemp.id as mstemp.msg_title for mstemp in tmpList">
         <option value="">-none-</option>
       </select>
     </td>
   </tr>
-
   </tbody>
 </table>
 
 <br>
-<div class="crm-accordion-wrapper collapsed" >
-
 
+<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 &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
-      &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &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 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" >
-
+    <div class="crm-accordion-body">
       <br>
       &nbsp &nbsp &nbsp &nbsp
       <textarea ng-model="mailA.body_text" style="width: 600px; height: 300px;"></textarea>
     </div>
   </div>
 
-  <table  ng-show= "false">
+  <table ng-show="false">
     <tr>
       <td>
         <input type="checkbox">&nbsp Save Template</input>
     </tr>
   </table>
-
 </div>
 
-<div class="crm-accordion-wrapper collapsed">
-  <div class="crm-accordion-header">Header and Footer</div>
-  <div class="crm-accordion-body" >
-
-
-    <body>
-    <table>
-      <tr>
-        <td class="label">Mailing Header</td>
-        <td>
-          <select ng-model="mailA.header_id" ng-options="hf.id as hf.name for hf in headerfooter| filter:isHeader">
-            <option value="">-none-</option>
-          </select>
-        </td>
-      </tr>
-      <tr>
-        <td class="label">Mailing Footer</td>
-        <td>
-          <select ng-model="mailA.footer_id" ng-options="f.id as f.name for f in headerfooter| filter:isFooter">
-            <option value="">-none-</option>
-          </select>
-        </td>
-      </tr>
-    </table>
-    </body>
-  </div>
-</div>
-<div class="crm-accordion-wrapper collapsed">
-  <div class="crm-accordion-header">Track and Respond</div>
-  <div class="crm-accordion-body" >
-
-    <table class="form-layout-compressed">
-      <tbody>
-      <tr>
-        <td>
-          <h3 style ="text-decoration:underline"> Tracking</h3>
-        </td>
-      </tr>
-      <tr>
-        <td>
-          <input type="checkbox" ng-model="mailA.url_tracking" ng-true-value="1" ng-false-value="0">&nbsp Track Click Throughs</input>
-        </td>
-      </tr>
-      <tr>
-        <td>
-          <div id="help">
-            Track the number of times recipients click each link in this mailing. NOTE: When this feature is enabled, all links in the message body will be automaticallly re-written to route through your CiviCRM server prior to redirecting to the target page.
-          </div>
-        </td>
-      </tr>
-      <tr>
-        <td>
-          <input type="checkbox" ng-model="mailA.open_tracking" ng-true-value="1" ng-false-value="0">&nbsp Track Opens</input>
-        </td>
-      </tr>
-      <tr>
-        <td>
-          <div id="help">
-            Track the number of times recipients open this mailing in their email software.
-          </div>
-        </td>
-      </tr>
-      <tr>
-        <td>
-          <h3 style ="text-decoration:underline">Responding</h3>
-        </td>
-      </tr>
-      <tr>
-        <td>
-          <input type="checkbox" ng-model="trackreplies" ng-change= "reply()" ng-true-value="1" ng-false-value="0">&nbsp Track Replies</input>
-        </td>
-      </tr>
-      <tr>
-        <td>
-          <div id="help">
-            Recipients' replies are sent to a CiviMail specific address instead of the sender's address so they can be stored within CiviCRM.
-          </div>
-        </td>
-      </tr>
-      <tr ng-show= "trackr(trackreplies)">
-        <td>
-          <input type="checkbox" ng-model="mailA.forward_replies" ng-true-value="1" ng-false-value="0">&nbsp Forward Replies</input>
-        </td>
-      </tr>
-      <tr ng-show= "trackr(trackreplies)">
-        <td>
-          <div id="help">
-            If a recipient replies to this mailing, forward the reply to the FROM Email address specified for the mailing.
-          </div>
-        </td>
-      </tr>
-      <tr ng-show= "trackr(trackreplies)">
-        <td>
-          <input type="checkbox" ng-model="mailA.auto_responder" ng-true-value="1" ng-false-value="0">&nbsp Auto-Respond to Replies &nbsp &nbsp</input>
-          <select ng-model="mailAutoResponder" ng-options="au.id as au.name for au in headerfooter| filter:isAuto">
-            <option value="">-none-</option>
-          </select>
-        </td>
-      </tr>
-      <tr ng-show= "trackr(trackreplies)">
-        <td>
-          <div id="help">
-            If a recipient replies to this mailing, send an automated reply using the selected message.
-          </div>
-        </td>
-      </tr>
-      <tr>
-        <td>
-          <h3 style ="text-decoration:underline"> Online Publication</h3>
-        </td>
-      </tr>
-    </table>
-
-    <table class="form-layout-compressed">
-      <tr>
-        <td class="label">Mailing Visibility</td>
-        <td>
-          <select ng-model="mailA.visibility">
-            <option value="Public Pages">Public Pages</option>
-            <option value="User and User Admin Only">User and User Admin Only</option>
-          </select>
-        </td>
-        </tbody>
-    </table>
-  </div>
-</div>
-</div>
-</div>
\ No newline at end of file
+<div ng-include="partialUrl('headerfooter.html')"></div>
old mode 100644 (file)
new mode 100755 (executable)
index 41ada15..2cde85f
@@ -1,15 +1,27 @@
+<form name="tab1Form" unsaved-warning-form>
+  <div class="crm-block crm-form-block crmABTesting">
+    <h3> What would you like to name the Test?</h3><br>
+    <input type="text" ng-model="currentABTest.name" class="big crm-form-text" required><br><br><br>
 
-<form name="myForm">
-  <h3> What would you like to Name the Test ?</h3><br>
-  <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">
-  Subject Lines <br/><br>
-  &nbsp <input type="radio" ng-model="template" ng-value="templates[1]" ng-click="init(3)" ng-checked="template.val==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">
-  Two different Emails <br/><br>
-  &nbsp
-  <div style="position:relative; left:220px; top: 30px;" nextbutton></div>
-  <div style="position:relative; left:300px; top:-1px;" cancelbutton></div>
+    <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">
+    Subject Lines <br/><br>
+    &nbsp <input type="radio" ng-model="template" ng-value="templates[1]" ng-click="init(3)"
+                 ng-checked="template.val==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">
+    Two different Emails <br/><br>
+    &nbsp
+
+    <div class="crm-submit-buttons">
+    <span class="crm-button">
+      <input type="submit" ng-click="tab1Form.$setPristine(); create_abtest();" ng-disabled="tab1Form.$invalid" value="Next" nexttab="{{tab_val}}"/>
+    </span>
+    <span class="crm-button">
+      <input type="submit" ng-click="tab1Form.$setPristine(); goto('mailing/abtesting');" value="Cancel"/>
+    </span>
+    </div>
+  </div>
 </form>
old mode 100644 (file)
new mode 100755 (executable)
index df5791b..ffb1d1a
@@ -1,11 +1,16 @@
-
-
-  <form>
-    <div  ng-include="template.url">
-
+<form name="tab2Form" unsaved-warning-form>
+  <div class="crm-block crm-form-block crmABTesting">
+    <div ng-include="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}}"/>
+      </span>
+      <span class="crm-button">
+        <input type="submit" ng-click="tab2Form.$setPristine(); goto('mailing/abtesting');" value="Cancel"/>
+      </span>
     </div>
-    <div style="position:relative; left:200px; top:61px;" prevbutton></div>
-    <div style="position:relative; left:300px; top: 30px;" submitform nextbutton></div>
-    <div style="position:relative; left:375px; top:-1px;" cancelbutton></div>
-
-  </form >
+  </div>
+</form>
old mode 100644 (file)
new mode 100755 (executable)
index cfe229c..dad526b
@@ -1,11 +1,8 @@
-
-
-  <form name="impform" novalidate>
+<form name="tab3Form" unsaved-warning-form>
+  <div class="crm-block crm-form-block crmABTesting">
     <h3>Select the groups you would like to add</h3><br>
-
-
     &nbsp<br>
-    <select multiple chsgroup>
+    <select multiple chsgroup required>
       <option id="1" ng-repeat="grp in groups" value="{{grp.id}} group include {{grp.title}}"> {{grp.title}}
       </option>
       <option ng-repeat="grp in groups" value="{{grp.id}} group exclude {{grp.title}}"> {{grp.title}}</option>
     </select>
     <br> <br><br><br>
 
-
     <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;"></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>
     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>
-    <!-- Remove automated
-                   <h3>Do you want the A/B test to be automated </h3>
-                   &nbsp<input type="radio" ng-model="automated" value="Yes" ng-click="setifyes(1)" name="auto" required>Yes &nbsp
-                   &nbsp<input type="radio" ng-model="automated" value="No" ng-click="setifyes(2)" name="auto" checked="checked"> No <br/><br>
-
-                   <tpmax ng-show="ifyes">
-
-                       <h3> Please enter the confidence level at which a decision can be made</h3>
-                       &nbsp &nbsp <input type="text" style="height: 20px; width: 25px;" ng-model="conf" numbar=99 ><br><br>
-                       <div ng-show="conf==null || conf ==0 || conf>99" style="color: red;">&nbsp Please Enter a Valid Number</div>
-
-                       <h3>If the confidence level is not reached what do you want us to do?</h3>
-                       &nbsp <input type="radio" ng-model="ifnot" value="Inform me" name="ifnot"/> Inform me <br/><br>
-                       &nbsp <input type="radio" checked="checked" ng-model="ifnot" value="Send Version A" name="ifnot" /> Send Version A <br/><br>
-                       &nbsp <input type="radio" ng-model="ifnot" value="Send Version B" name="ifnot"/> Send Version B <br/><br>
 
-
-                       <div nextbutton></div>
-
-                   </tpmax>
--       -->
     <h3>Declare the winner by when?</h3><br>
     <table>
       <tbody>
-
-      <tr >
+      <tr>
         <td class="label">Date</td>
         <td>
-          <input type="text" chsdate ng-model="currentABTest.date" >
+          <input type="text" chsdate ng-model="currentABTest.date">
         </td>
-        <td class="label" >Time</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" >
+    <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>
-
-
-    <div style="position:relative; left:200px; top:30px;" prevbutton></div>
-    <div style="position:relative; left:300px; top: 00px;" nextbutton></div>
-    <div style="position:relative; left:375px; top: -31px;" cancelbutton></div>
-
-  </form>
+    <div class="crm-submit-buttons">
+      <span class="crm-button">
+        <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}}"/>
+      </span>
+      <span class="crm-button">
+        <input type="submit" ng-click="tab3Form.$setPristine(); goto('mailing/abtesting');" value="Cancel"/>
+      </span>
+    </div>
+  </div>
+</form>
old mode 100644 (file)
new mode 100755 (executable)
index 4d97dc5..52cea83
@@ -1,91 +1,74 @@
-
-  <h3>Details</h3><br>
-  <table>
-    <tr>
-      <td>Test Criteria</td>
-      <td>{{template.name}}</td>
-    </tr>
-    <tr>
-      <td>Groups Included</td>
-      <td>{{incGroup}}</td>
-    </tr>
-    <tr>
-      <td>Groups Excluded</td>
-      <td>{{excGroup}}</td>
-    </tr>
-    <tr>
-      <td>Size of Test Group</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>
-            </tr>
-            <tr ng-show="automated=='Yes'">
-              <td>If Level not Achieved</td>
-              <td>{{ifnot}}</td>
-            </tr>
-    -->
-    <tr>
-      <td>Declare Winner By</td>
-      <td>{{currentABTest.date}} Date &nbsp {{currentABTest.time}} Time</td>
-    </tr>
-  </table>
-  <h3 ng-click="pre()">Preview Mail</h3>
-  <previewmail ng-show ="preview">
-
-    <div  ui-jq="tabs" id="settings">
-      <ul>
-        <li>
-          <a href="#frag1"><span>Mail A</span></a>
-        </li>
-        <li>
-          <a href="#frag2"><span>Mail B</span></a>
-        </li>
-
-      </ul>
-      <div id="frag1" ng-bind-html="deliberatelyTrustDangerousSnippeta()" >
-
+<form name="tab4Form" unsaved-warning-form>
+  <div class="crm-block crm-form-block crmABTesting">
+    <h3>Details</h3><br>
+    <table>
+      <tr>
+        <td>Test Criteria</td>
+        <td>{{template.name}}</td>
+      </tr>
+      <tr>
+        <td>Groups Included</td>
+        <td>{{incGroup}}</td>
+      </tr>
+      <tr>
+        <td>Groups Excluded</td>
+        <td>{{excGroup}}</td>
+      </tr>
+      <tr>
+        <td>Size of Test Group</td>
+        <td>{{currentABTest.group_percentage}}</td>
+      </tr>
+      <tr>
+        <td>Winner Criteria</td>
+        <td>{{winner_criteria}}</td>
+      </tr>
+      <tr>
+        <td>Declare Winner By</td>
+        <td>{{currentABTest.date}} Date &nbsp {{currentABTest.time}} Time</td>
+      </tr>
+    </table>
+    <h3 ng-click="pre()">Preview Mail</h3>
+    <div ng-show="preview" id="prevmail">
+      <div ui-jq="tabs" id="settings">
+        <ul>
+          <li>
+            <a href="#frag1"><span>Mail A</span></a>
+          </li>
+          <li>
+            <a href="#frag2"><span>Mail B</span></a>
+          </li>
+        </ul>
+        <div id="frag1" ng-bind-html="deliberatelyTrustDangerousSnippeta();"></div>
+        <div id="frag2" ng-bind-html="deliberatelyTrustDangerousSnippetb();"></div>
       </div>
-      <div id="frag2" ng-bind-html="deliberatelyTrustDangerousSnippetb()">
-
-      </div>
-
-
     </div>
-  </previewmail>
-  <h3 ng-click="sen()">Send Test Mails</h3>
-  <sendmailtest ng-show="sendtest">
-    <input type="text" ng-model="testmailid">
-  </sendmailtest>
+    <h3 ng-click="sendTestMailing();">Send Test Emails</h3>
 
-  <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>
-
-
-  <br><br>
+    <div ng-show="sendtest" id="sendtest">
+      <input type="text" ng-model="emailadd">
+    </div>
 
-  <div>
+    <h3>When to Start</h3><br>
 
-    <div style="position:relative; left:200px; top:60px;" prevbutton></div>
-    <div class="crm-submit-buttons" style="position:relative; left:295px; top: 30px;">
-      <div class="crm-button crm-button-type-upload crm-button_qf_Contact_upload_view">
-        <input type="submit" value="Submit & Send" id="campaignbutton _qf_Contact_upload_view-top"
-               class="btn btn-primary" nexttab={{tab_val}}>
-      </div>
+    <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>
-    <div style="position:relative; left:430px; top:-1px;" cancelbutton></div>
 
+    <br><br>
+
+    <div class="crm-submit-buttons">
+      <span class="crm-button">
+        <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"/>
+      </span>
+      <span class="crm-button">
+        <input type="submit" ng-click="tab4Form.$setPristine(); goto('mailing/abtesting');" value="Cancel"/>
+      </span>
+    </div>
   </div>
+</form>
 
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index 163fb6a..74b1a8f
-<div>
-  <div ui-jq="tabs">
-
-      <ul>
-          <li><a href="#tabs-21"><span>Email A</span></a></li>
-          <li><a href="#tabs-22"><span>Email B</span></a></li>
+<div ui-jq="tabs">
+
+<ul>
+  <li><a href="#tabs-21"><span>Email A</span></a></li>
+  <li><a href="#tabs-22"><span>Email B</span></a></li>
+</ul>
+
+<div id="tabs-21">
+    <table class="form-layout-compressed">
+      <tbody>
+      <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">
+            <option value="">-none-</option>
+          </select>
+        </td>
+      </tr>
+      <tr>
+        <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">
+            <option value="">-none-</option>
+          </select>
+        </td>
+      </tr>
+      <tr>
+        <td class="label">Mailing Subject</td>
+        <td>
+          <input placeholder="Enter Subject" name="subject" type="text" ng-model="mailA.subject"/>
+        </td>
+      </tr>
+      <tr>
+        <td class="label" style="color:red" ng-show="mailing_form.subject.$invalid">
+          Mailing subject required.
+        </td>
+      </tr>
+      <tr>
+        <td class="label">Use Template</td>
+        <td>
+          <select ng-change="tmp(mailA.msg_template_id,1)" ng-model="mailA.msg_template_id"
+                  ng-options="mstemp.id as mstemp.msg_title for mstemp in tmpList">
+            <option value="">-none-</option>
+          </select>
+        </td>
+      </tr>
+      </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 &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
+          &nbsp
+          &nbsp &nbsp &nbsp &nbsp &nbsp
+          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &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>
+          &nbsp &nbsp &nbsp &nbsp
+          <textarea id="body_html" ng-model="mailA.body_html" style="width: 600px; height: 300px;"></textarea>
+          <br> <br>
 
-      </ul>
+        </div>
+      </div>
 
-      <div id="tabs-21">
+      <div class="crm-accordion-wrapper collapsed">
+        <div class="crm-accordion-header">Plain Text</div>
+        <div class="crm-accordion-body">
 
-      <div>
+          <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>
 
-      <table class="form-layout-compressed">
+    </div>
 
-          <tbody>
+    <div class="crm-accordion-wrapper collapsed">
+      <div class="crm-accordion-header">Header and Footer</div>
+      <div class="crm-accordion-body">
+        <table>
           <tr>
-            <td class="label">From E-mail Address</td>
+            <td class="label">Mailing Header</td>
             <td>
-
-              <select  style="width: 200px" ng-model="mailA.from_email" ng-options="frm.email as frm.email for frm in eMailing">
+              <select ng-model="mailA.header_id" ng-options="hf.id as hf.name for hf in headerfooter| filter:isHeader">
                 <option value="">-none-</option>
               </select>
             </td>
           </tr>
           <tr>
-            <td class="label">Reply to E-mail Address</td>
+            <td class="label">Mailing Footer</td>
             <td>
-              <select  style="width: 200px" ng-model="mailA.replyto_email" ng-options="frm.email as frm.email for frm in eMailing">
+              <select ng-model="mailA.footer_id" ng-options="f.id as f.name for f in headerfooter| filter:isFooter">
                 <option value="">-none-</option>
               </select>
             </td>
           </tr>
-          <tr>
-              <td class="label">Mailing Subject</td>
-              <td>
-                  <input placeholder="Enter Subject"  name="subject" type="text" ng-model="mailA.subject"/>
-              </td>
-          </tr>
-
-          <tr>
-              <td class="label" style= "color:red" ng-show="mailing_form.subject.$invalid">
-                  Mailing subject required.
-              </td>
-          </tr>
-          <tr>
-            <td class="label">Use Template</td>
-            <td>
-              <select ng-change="tmp(mailA.msg_template_id,1)" ng-model="mailA.msg_template_id" ng-options= "mstemp.id as mstemp.msg_title for mstemp in tmpList">
-                <option value="">-none-</option>
-              </select>
-            </td>
-          </tr>
-
-          </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 &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
-                &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &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>
-                &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>
-
+        </table>
       </div>
+    </div>
+</div>
 
+<!-- ---------------------------------------- ######## ------------------------------------------  -->
+
+<div id="tabs-22">
+    <table class="form-layout-compressed">
+      <tbody>
+      <tr>
+        <td class="label">From E-mail Address</td>
+        <td>
+          <select style="width: 200px" ng-model="mailB.from_email"
+                  ng-options="frm.email as frm.email for frm in eMailing">
+            <option value="">-none-</option>
+          </select>
+        </td>
+      </tr>
+      <tr>
+        <td class="label">Reply to E-mail Address</td>
+        <td>
+          <select style="width: 200px" ng-model="mailB.replyto_email"
+                  ng-options="frm.email as frm.email for frm in eMailing">
+            <option value="">-none-</option>
+          </select>
+        </td>
+      </tr>
+      <tr>
+        <td class="label">Mailing Subject</td>
+        <td>
+          <input placeholder="Enter Subject" name="subject" type="text" ng-model="mailB.subject"/>
+        </td>
+      </tr>
+
+      <tr>
+        <td class="label" style="color:red" ng-show="mailing_form.subject.$invalid">
+          Mailing subject required.
+        </td>
+      </tr>
+      <tr>
+        <td class="label">Use Template</td>
+        <td>
+          <select ng-change="tmp(mailB.msg_template_id,2)" ng-model="mailB.msg_template_id"
+                  ng-options="mstemp.id as mstemp.msg_title for mstemp in tmpList">
+            <option value="">-none-</option>
+          </select>
+        </td>
+      </tr>
+      </tbody>
+    </table>
+    <br>
+
+    <div class="crm-accordion-wrapper collapsed">
       <div class="crm-accordion-wrapper collapsed">
-          <div class="crm-accordion-header">Header and Footer</div>
-          <div class="crm-accordion-body" >
-
-
-              <body>
-              <table>
-                  <tr>
-                      <td class="label">Mailing Header</td>
-                      <td>
-                          <select ng-model="mailA.header_id" ng-options="hf.id as hf.name for hf in headerfooter| filter:isHeader">
-                              <option value="">-none-</option>
-                          </select>
-                      </td>
-                  </tr>
-                  <tr>
-                      <td class="label">Mailing Footer</td>
-                      <td>
-                          <select ng-model="mailA.footer_id" ng-options="f.id as f.name for f in headerfooter| filter:isFooter">
-                              <option value="">-none-</option>
-                          </select>
-                      </td>
-                  </tr>
-              </table>
-              </body>
-          </div>
+        <div class="crm-accordion-header">HTML Format</div>
+        <div class="crm-accordion-body">
+          <br>
+          <br> <br>
+          &nbsp &nbsp &nbsp &nbsp
+          <textarea id="body_html" ng-model="mailB.body_html" style="width: 600px; height: 300px;"></textarea>
+          <br> <br>
+        </div>
       </div>
-      <div class="crm-accordion-wrapper collapsed">
-          <div class="crm-accordion-header">Track and Respond</div>
-          <div class="crm-accordion-body" >
-
-              <table class="form-layout-compressed">
-                  <tbody>
-                  <tr>
-                      <td>
-                          <h3 style ="text-decoration:underline"> Tracking</h3>
-                      </td>
-                  </tr>
-                  <tr>
-                      <td>
-                          <input type="checkbox" ng-model="mailA.url_tracking" ng-true-value="1" ng-false-value="0">&nbsp Track Click Throughs</input>
-                      </td>
-                  </tr>
-                  <tr>
-                      <td>
-                          <div id="help">
-                              Track the number of times recipients click each link in this mailing. NOTE: When this feature is enabled, all links in the message body will be automaticallly re-written to route through your CiviCRM server prior to redirecting to the target page.
-                          </div>
-                      </td>
-                  </tr>
-                  <tr>
-                      <td>
-                          <input type="checkbox" ng-model="mailA.open_tracking" ng-true-value="1" ng-false-value="0">&nbsp Track Opens</input>
-                      </td>
-                  </tr>
-                  <tr>
-                      <td>
-                          <div id="help">
-                              Track the number of times recipients open this mailing in their email software.
-                          </div>
-                      </td>
-                  </tr>
-                  <tr>
-                      <td>
-                          <h3 style ="text-decoration:underline">Responding</h3>
-                      </td>
-                  </tr>
-                  <tr>
-                      <td>
-                          <input type="checkbox" ng-model="trackreplies" ng-change= "reply()" ng-true-value="1" ng-false-value="0">&nbsp Track Replies</input>
-                      </td>
-                  </tr>
-                  <tr>
-                      <td>
-                          <div id="help">
-                              Recipients' replies are sent to a CiviMail specific address instead of the sender's address so they can be stored within CiviCRM.
-                          </div>
-                      </td>
-                  </tr>
-                  <tr ng-show= "trackr(trackreplies)">
-                      <td>
-                          <input type="checkbox" ng-model="mailA.forward_replies" ng-true-value="1" ng-false-value="0">&nbsp Forward Replies</input>
-                      </td>
-                  </tr>
-                  <tr ng-show= "trackr(trackreplies)">
-                      <td>
-                          <div id="help">
-                              If a recipient replies to this mailing, forward the reply to the FROM Email address specified for the mailing.
-                          </div>
-                      </td>
-                  </tr>
-                  <tr ng-show= "trackr(trackreplies)">
-                      <td>
-                          <input type="checkbox" ng-model="mailA.auto_responder" ng-true-value="1" ng-false-value="0">&nbsp Auto-Respond to Replies &nbsp &nbsp</input>
-                          <select ng-model="mailAutoResponder" ng-options="au.id as au.name for au in headerfooter| filter:isAuto">
-                              <option value="">-none-</option>
-                          </select>
-                      </td>
-                  </tr>
-                  <tr ng-show= "trackr(trackreplies)">
-                      <td>
-                          <div id="help">
-                              If a recipient replies to this mailing, send an automated reply using the selected message.
-                          </div>
-                      </td>
-                  </tr>
-                  <tr>
-                      <td>
-                          <h3 style ="text-decoration:underline"> Online Publication</h3>
-                      </td>
-                  </tr>
-              </table>
 
-              <table class="form-layout-compressed">
-                  <tr>
-                      <td class="label">Mailing Visibility</td>
-                      <td>
-                          <select ng-model="mailA.visibility">
-                              <option value="Public Pages">Public Pages</option>
-                              <option value="User and User Admin Only">User and User Admin Only</option>
-                          </select>
-                      </td>
-                      </tbody>
-              </table>
-          </div>
-      </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="mailB.body_text" style="width: 600px; height: 300px;"></textarea>
+          <br>
+        </div>
       </div>
 
-      <!-- ---------------------------------------- ######## ------------------------------------------  -->
-
-        <div id="tabs-22">
-
-
-        <div>
+      <table ng-show="false">
+        <tr>
+          <td>
+            <input type="checkbox">&nbsp Save Template</input>
+        </tr>
+      </table>
+    </div>
 
-        <table class="form-layout-compressed">
-          <tbody>
+    <div class="crm-accordion-wrapper collapsed">
+      <div class="crm-accordion-header">Header and Footer</div>
+      <div class="crm-accordion-body">
+        <body>
+        <table>
           <tr>
-            <td class="label">From E-mail Address</td>
+            <td class="label">Mailing Header</td>
             <td>
-              <select  style="width: 200px" ng-model="mailB.from_email" ng-options="frm.email as frm.email for frm in eMailing">
+              <select ng-model="mailB.header_id" ng-options="hf.id as hf.name for hf in headerfooter| filter:isHeader">
                 <option value="">-none-</option>
               </select>
             </td>
           </tr>
           <tr>
-            <td class="label">Reply to E-mail Address</td>
+            <td class="label">Mailing Footer</td>
             <td>
-              <select  style="width: 200px" ng-model="mailB.replyto_email" ng-options="frm.email as frm.email for frm in eMailing">
+              <select ng-model="mailB.footer_id" ng-options="f.id as f.name for f in headerfooter| filter:isFooter">
                 <option value="">-none-</option>
               </select>
             </td>
           </tr>
-          <tr>
-            <td class="label">Mailing Subject</td>
-            <td>
-              <input placeholder="Enter Subject"  name="subject" type="text" ng-model="mailB.subject"/>
-            </td>
-          </tr>
-
-          <tr>
-            <td class="label" style= "color:red" ng-show="mailing_form.subject.$invalid">
-              Mailing subject required.
-            </td>
-          </tr>
-          <tr>
-            <td class="label">Use Template</td>
-            <td>
-              <select ng-change="tmp(mailB.msg_template_id,2)" ng-model="mailB.msg_template_id" ng-options= "mstemp.id as mstemp.msg_title for mstemp in tmpList">
-                <option value="">-none-</option>
-              </select>
-            </td>
-          </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 &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
-              &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &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 ng-model="token" ></input>-->
-              <br> <br>
-              &nbsp &nbsp &nbsp &nbsp
-              <textarea id="body_html" ng-model="mailB.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="mailB.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 class="crm-accordion-wrapper collapsed">
-          <div class="crm-accordion-header">Header and Footer</div>
-          <div class="crm-accordion-body" >
-
-
-            <body>
-            <table>
-              <tr>
-                <td class="label">Mailing Header</td>
-                <td>
-                  <select ng-model="mailB.header_id" ng-options="hf.id as hf.name for hf in headerfooter| filter:isHeader">
-                    <option value="">-none-</option>
-                  </select>
-                </td>
-              </tr>
-              <tr>
-                <td class="label">Mailing Footer</td>
-                <td>
-                  <select ng-model="mailB.footer_id" ng-options="f.id as f.name for f in headerfooter| filter:isFooter">
-                    <option value="">-none-</option>
-                  </select>
-                </td>
-              </tr>
-            </table>
-            </body>
-          </div>
-        </div>
-        <div class="crm-accordion-wrapper collapsed">
-          <div class="crm-accordion-header">Track and Respond</div>
-          <div class="crm-accordion-body" >
-
-            <table class="form-layout-compressed">
-              <tbody>
-              <tr>
-                <td>
-                  <h3 style ="text-decoration:underline"> Tracking</h3>
-                </td>
-              </tr>
-              <tr>
-                <td>
-                  <input type="checkbox" ng-model="mailB.url_tracking" ng-true-value="1" ng-false-value="0">&nbsp Track Click Throughs</input>
-                </td>
-              </tr>
-              <tr>
-                <td>
-                  <div id="help">
-                    Track the number of times recipients click each link in this mailing. NOTE: When this feature is enabled, all links in the message body will be automaticallly re-written to route through your CiviCRM server prior to redirecting to the target page.
-                  </div>
-                </td>
-              </tr>
-              <tr>
-                <td>
-                  <input type="checkbox" ng-model="mailB.open_tracking" ng-true-value="1" ng-false-value="0">&nbsp Track Opens</input>
-                </td>
-              </tr>
-              <tr>
-                <td>
-                  <div id="help">
-                    Track the number of times recipients open this mailing in their email software.
-                  </div>
-                </td>
-              </tr>
-              <tr>
-                <td>
-                  <h3 style ="text-decoration:underline">Responding</h3>
-                </td>
-              </tr>
-              <tr>
-                <td>
-                  <input type="checkbox" ng-model="trackreplies" ng-change= "reply()" ng-true-value="1" ng-false-value="0">&nbsp Track Replies</input>
-                </td>
-              </tr>
-              <tr>
-                <td>
-                  <div id="help">
-                    Recipients' replies are sent to a CiviMail specific address instead of the sender's address so they can be stored within CiviCRM.
-                  </div>
-                </td>
-              </tr>
-              <tr ng-show= "trackr(trackreplies)">
-                <td>
-                  <input type="checkbox" ng-model="mailB.forward_replies" ng-true-value="1" ng-false-value="0">&nbsp Forward Replies</input>
-                </td>
-              </tr>
-              <tr ng-show= "trackr(trackreplies)">
-                <td>
-                  <div id="help">
-                    If a recipient replies to this mailing, forward the reply to the FROM Email address specified for the mailing.
-                  </div>
-                </td>
-              </tr>
-              <tr ng-show= "trackr(trackreplies)">
-                <td>
-                  <input type="checkbox" ng-model="mailB.auto_responder" ng-true-value="1" ng-false-value="0">&nbsp Auto-Respond to Replies &nbsp &nbsp</input>
-                  <select ng-model="mailAutoResponder" ng-options="au.id as au.name for au in headerfooter| filter:isAuto">
-                    <option value="">-none-</option>
-                  </select>
-                </td>
-              </tr>
-              <tr ng-show= "trackr(trackreplies)">
-                <td>
-                  <div id="help">
-                    If a recipient replies to this mailing, send an automated reply using the selected message.
-                  </div>
-                </td>
-              </tr>
-              <tr>
-                <td>
-                  <h3 style ="text-decoration:underline"> Online Publication</h3>
-                </td>
-              </tr>
-            </table>
-
-            <table class="form-layout-compressed">
-              <tr>
-                <td class="label">Mailing Visibility</td>
-                <td>
-                  <select ng-model="mailB.visibility">
-                    <option value="Public Pages">Public Pages</option>
-                    <option value="User and User Admin Only">User and User Admin Only</option>
-                  </select>
-                </td>
-                </tbody>
-            </table>
-          </div>
-        </div>
-        </div>
-
-        </div>
+        </body>
+      </div>
+    </div>
   </div>
-
 </div>
+</div>
+
 
 
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index 3a65dfa..3a45fd2
@@ -1709,13 +1709,14 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
     return $result['id'];
   }
 
-  /**
-   * Function to add contact(s) to a Group
+
+ /**
+   * Function to add a Group
    *
-   * @params int  $groupID Group ID
-   * @params int  $totalCount of contacts to be added
+   * @params array to add group
    *
-   * @return array $result
+   * @param array $params
+   * @return int groupId of created group
    */
   function groupContactCreate($groupID, $totalCount = 10) {
     $params = array('group_id' => $groupID);
@@ -1729,6 +1730,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
       }
     }
     $result = $this->callAPISuccess('GroupContact', 'create', $params);
+
     return $result;
   }
 
old mode 100644 (file)
new mode 100755 (executable)
index a60eac0..71ec78e
@@ -56,6 +56,7 @@ class api_v3_MailingABTest extends CiviUnitTestCase {
     $this->_mailingID_A = $this->createMailing();
     $this->_mailingID_B = $this->createMailing();
     $this->_mailingID_C = $this->createMailing();
+    $this->_groupID = $this->groupCreate();
 
     $this->_params = array(
       'mailing_id_a' => $this->_mailingID_A,
@@ -72,6 +73,7 @@ class api_v3_MailingABTest extends CiviUnitTestCase {
     $this->deleteMailing($this->_mailingID_A);
     $this->deleteMailing($this->_mailingID_B);
     $this->deleteMailing($this->_mailingID_C);
+    $this->groupDelete($this->_groupID);
   }
 
   /**
@@ -91,17 +93,20 @@ class api_v3_MailingABTest extends CiviUnitTestCase {
     $this->callAPISuccess($this->_entity, 'delete', array('id' => $result['id']));
   }
 
-
   public function testMailingABRecipientsUpdate() {
     //create 100 contacts for group $this->_groupID
     $totalGroupContacts = 100;
+
     $result = $this->groupContactCreate($this->_groupID, $totalGroupContacts);
     //check if 100 group contacts are included on desired group
     $this->assertEquals($totalGroupContacts, $result['added'], "in line " . __LINE__);
+
     $result = $this->callAPISuccess($this->_entity, 'create', $this->_params);
     $totalSelectedContacts = round(($totalGroupContacts * $result['values'][$result['id']]['group_percentage'])/100);
+
     $params = array('id' => $result['id'], 'groups' => array('include' => array($this->_groupID)));
-    $this->callAPISuccess('Mailing', 'a_b_recipients_update', $params);
+    $this->callAPISuccess('MailingAB', 'recipients_update', $params);
+
     //check total number of A/B mail recipients is what selected percentage of Mail C
     $countA = $this->callAPISuccess('MailingRecipients', 'getcount', array('mailing_id' =>  $this->_mailingID_A));
     $this->assertEquals($countA, $totalSelectedContacts, "in line " . __LINE__);
@@ -110,4 +115,3 @@ class api_v3_MailingABTest extends CiviUnitTestCase {
   }
 
 }
-
old mode 100644 (file)
new mode 100755 (executable)
index ea7d79c..1bb3a0e
@@ -56,7 +56,7 @@ class api_v3_MailingTest extends CiviUnitTestCase {
     $this->_email = 'test@test.test';
     $this->_params = array(
       'subject' => 'maild',
-      'body_text' => 'bdkfhdskfhduew',
+      'body_text' => "This is {contact.display_name}",
       'name' => 'mailing name',
       'created_id' => 1,
     );
@@ -81,33 +81,45 @@ class api_v3_MailingTest extends CiviUnitTestCase {
     $contactID =  $this->individualCreate();
     $displayName = $this->callAPISuccess('contact', 'get', array('id' => $contactID));
     $displayName = $displayName['values'][$contactID]['display_name'];
+
     $result = $this->callAPISuccess('mailing', 'create', $this->_params);
+
     $params = array('id' => $result['id'], 'contact_id' => $contactID);
     $result = $this->callAPISuccess('mailing', 'preview', $params);
     $text = $result['values']['text'];
-    print_r($result  );
-    print_r($text  );
     $this->assertEquals("This is $displayName", $text); // verify the text returned is correct, with replaced token
     $this->deleteMailing($result['id']);
   }
+
   public function testMailerSendTestMail() {
     $contactID =  $this->individualCreate();
     $result = $this->callAPISuccess('contact', 'get', array('id' => $contactID));
     $email = $result['values'][$contactID]['email'];
+
     $mail = $this->callAPISuccess('mailing', 'create', $this->_params);
+
     $params = array('mailing_id' => $mail['id'], 'test_email' => $email, 'test_group' => NULL);
     $deliveredInfo = $this->callAPISuccess($this->_entity, 'send_test', $params);
     $this->assertEquals(1, $deliveredInfo['count'], "in line " . __LINE__); // verify mail has been sent to user by count
     $this->assertEquals($contactID, $deliveredInfo['values'][$deliveredInfo['id']]['contact_id'], "in line " . __LINE__); //verify the contact_id of the recipient
     $this->deleteMailing($mail['id']);
   }
+
   public function testMailerStats() {
     $result = $this->groupContactCreate($this->_groupID, 100);
     $this->assertEquals(100, $result['added']); //verify if 100 contacts are added for group
+
+    //Create and send test mail first and change the mail job to live,
+    //because stats api only works on live mail
     $mail = $this->callAPISuccess('mailing', 'create', $this->_params);
-    $params = array('mailing_id' => $mail['id'], 'test_email' => NULL, 'test_group' => $this->_groupID, 'is_test' => 0);
+    $params = array('mailing_id' => $mail['id'], 'test_email' => NULL, 'test_group' => $this->_groupID);
     $deliveredInfo = $this->callAPISuccess($this->_entity, 'send_test', $params);
     $deliveredIds  = implode(',', array_keys($deliveredInfo['values']));
+
+    //Change the test mail into live
+    $sql = "UPDATE civicrm_mailing_job SET is_test = 0 WHERE mailing_id = {$mail['id']}";
+    CRM_Core_DAO::executeQuery($sql);
+
     foreach (array('bounce', 'unsubscribe', 'opened') as $type) {
       $sql = "CREATE TEMPORARY TABLE mail_{$type}_temp
 (event_queue_id int, time_stamp datetime, delivered_id int)
@@ -115,10 +127,11 @@ SELECT event_queue_id, time_stamp, id
  FROM civicrm_mailing_event_delivered
  WHERE id IN ($deliveredIds)
  ORDER BY RAND() LIMIT 0,20;";
-      print_r($sql  );
       CRM_Core_DAO::executeQuery($sql);
+
       $sql = "DELETE FROM civicrm_mailing_event_delivered WHERE id IN (SELECT delivered_id FROM mail_{$type}_temp);";
       CRM_Core_DAO::executeQuery($sql);
+
       if ($type == 'unsubscribe') {
         $sql = "INSERT INTO civicrm_mailing_event_{$type} (event_queue_id, time_stamp, org_unsubscribe)
 SELECT event_queue_id, time_stamp, 1 FROM mail_{$type}_temp";
@@ -129,6 +142,7 @@ SELECT event_queue_id, time_stamp FROM mail_{$type}_temp";
       }
       CRM_Core_DAO::executeQuery($sql);
     }
+
     $result = $this->callAPISuccess('mailing', 'stats', array('mailing_id' => $mail['id']));
     $expectedResult = array(
       'Delivered' => 80, //since among 100 mails 20 has been bounced
@@ -137,10 +151,9 @@ SELECT event_queue_id, time_stamp FROM mail_{$type}_temp";
       'Unique Clicks' => 0,
       'Unsubscribers' => 20
     );
-
     $this->checkArrayEquals($expectedResult, $result['values'][$mail['id']]);
+    $this->deleteMailing($mail['id']);
   }
-
   /**
    * Test civicrm_mailing_delete
    */