Graphs are working
authoraditya-nambiar <aditya.nambiar007@gmail.com>
Tue, 26 Aug 2014 09:18:15 +0000 (14:48 +0530)
committeraditya-nambiar <aditya.nambiar007@gmail.com>
Tue, 26 Aug 2014 09:18:15 +0000 (14:48 +0530)
CRM/Mailing/Event/BAO/Opened.php
CRM/Mailing/Info.php
api/v3/MailingAB.php
js/angular-crmMailingAB.js
partials/abtesting/compose.html
partials/abtesting/report.html

index b79a25bd7f24bdcc4c835ed994a23fa29cb497e0..f39d7f79b1cf81de542c62ee411bc5fe3c679188 100755 (executable)
@@ -226,6 +226,8 @@ class CRM_Mailing_Event_BAO_Opened extends CRM_Mailing_Event_DAO_Opened {
   public static function &getRows($mailing_id, $job_id = NULL,
     $is_distinct = FALSE, $offset = NULL, $rowCount = NULL, $sort = NULL, $contact_id= NULL
   ) {
+    CRM_Core_Error::debug_var('3',$offset);
+    CRM_Core_Error::debug_var('4',$rowCount);
 
     $dao = new CRM_Core_Dao();
 
@@ -270,7 +272,10 @@ class CRM_Mailing_Event_BAO_Opened extends CRM_Mailing_Event_DAO_Opened {
     $orderBy = "sort_name ASC, {$open}.time_stamp DESC";
     if ($sort) {
       if (is_string($sort)) {
+
         $sort = CRM_Utils_Type::escape($sort, 'String');
+        CRM_Core_Error::debug_var('2',$sort);
+
         $orderBy = $sort;
       }
       else {
@@ -284,7 +289,7 @@ class CRM_Mailing_Event_BAO_Opened extends CRM_Mailing_Event_DAO_Opened {
       //Added "||$rowCount" to avoid displaying all records on first page
       $query .= ' LIMIT ' . CRM_Utils_Type::escape($offset, 'Integer') . ', ' . CRM_Utils_Type::escape($rowCount, 'Integer');
     }
-
+    CRM_Core_Error::debug_var('1',$query);
     $dao->query($query);
 
     $results = array();
index a86fb74f2867ce90e50353ed56b7561391890ec7..a602917a2d144f56127161a99cca2c8dbba88adc 100644 (file)
@@ -59,7 +59,7 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info {
     $result = array();
     $result['crmMailingAB'] = array(
       'ext' => 'civicrm',
-      'js' => array('js/angular-crmMailingAB.js','js/d3.min.js','js/angular-sanitize.js'),
+      'js' => array('js/angular-crmMailingAB.js','js/d3.min.js','js/angular-sanitize.js','packages/ckeditor/ckeditor.js'),
       'css' => array('css/angular-crmMailingAB.css'),
     );
 
index 847233ec3a4da57674ebc6c1a82af693a09e25a2..0ca759c16083566300dd32a13f03191c3245a5eb 100755 (executable)
@@ -83,7 +83,7 @@ function civicrm_api3_mailing_a_b_get($params) {
  * @return array
  */
 function civicrm_api3_mailing_a_b_recipients_update($params) {
-civicrm_api3_verify_mandatory($params,
+  civicrm_api3_verify_mandatory($params,
     'CRM_Mailing_DAO_MailingAB',
     array('id'),
     FALSE
@@ -99,7 +99,7 @@ civicrm_api3_verify_mandatory($params,
 
   //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);
+  $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);
@@ -141,7 +141,7 @@ function civicrm_api3_mailing_a_b_send_mail($params) {
   $mailingAB = civicrm_api3('MailingAB', 'get', array('id' => $params['id']));
   $mailingAB = $mailingAB['values'][$params['id']];
 
- foreach (array('mailing_id_a', 'mailing_id_b') as $columnName) {
 foreach (array('mailing_id_a', 'mailing_id_b') as $columnName) {
     $params['id'] = $mailingAB[$columnName];
     civicrm_api3('Mailing', 'create', $params);
   }
@@ -156,9 +156,9 @@ function civicrm_api3_mailing_a_b_send_mail($params) {
  * @param array $params array or parameters determined by getfields
  */
 function _civicrm_api3_mailing_a_b_graph_stats_spec(&$params) {
-   $params['split_count']['api.default'] = 6;
-   $params['split_count_select']['api.required'] = 1;
-  }
+  $params['split_count']['api.default'] = 6;
+  $params['split_count_select']['api.required'] = 1;
+}
 
 /**
  * Send graph detail for A/B tests mail
@@ -167,47 +167,69 @@ function _civicrm_api3_mailing_a_b_graph_stats_spec(&$params) {
  * @return array
  */
 function civicrm_api3_mailing_a_b_graph_stats($params) {
-   civicrm_api3_verify_mandatory($params,
-     'CRM_Mailing_DAO_MailingAB',
-     array('id'),
- FALSE
-   );
+  civicrm_api3_verify_mandatory($params,
+    'CRM_Mailing_DAO_MailingAB',
+    array('id'),
   FALSE
+  );
 
- $mailingAB = civicrm_api3('MailingAB', 'get', array('id' => $params['id']));
- $mailingAB = $mailingAB['values'][$params['id']];
 $mailingAB = civicrm_api3('MailingAB', 'get', array('id' => $params['id']));
 $mailingAB = $mailingAB['values'][$params['id']];
 
- $optionGroupValue = civicrm_api3('OptionValue', 'get', array('option_group_name' => 'mailing_ab_winner_criteria', 'value' => $mailingAB['winner_criteria_id']));
- $winningCriteria = $optionGroupValue['values'][$optionGroupValue['id']]['name'];
 $optionGroupValue = civicrm_api3('OptionValue', 'get', array('option_group_name' => 'mailing_ab_winner_criteria', 'value' => $mailingAB['winner_criteria_id']));
 $winningCriteria = $optionGroupValue['values'][$optionGroupValue['id']]['name'];
 
- $graphStats = array();
+  $declareWinnerDate = CRM_Utils_Date::processDate($mailingAB['declare_winning_time']);
+
+  $graphStats = array();
   $ABFormat = array('A' => 'mailing_id_a', 'B' => 'mailing_id_b');
 
- foreach ($ABFormat as $name => $column) {
-     switch ($winningCriteria) {
-     case 'Open':
-         $totalCounts = CRM_Mailing_Event_BAO_Opened::getTotalCount($mailingAB[$column]);
-         $rowCount = round($totalCounts / $params['split_count']);
-         $offset = $rowCount * ($params['split_count_select'] - 1);
-         $graphStats[$name] = CRM_Mailing_Event_BAO_Opened::getRows($mailingAB[$column], NULL, FALSE, $offset, $rowCount, "{$open}.time_stamp ASC");
-         break;
- case 'Total Unique Clicks':
-         $totalCounts = CRM_Mailing_Event_BAO_TrackableURLOpen::getTotalCount($mailingAB[$column]);
-         $rowCount = round($totalCounts / $params['split_count']);
-         $offset = $rowCount * ($params['split_count_select'] - 1);
-         $graphStats[$name] = CRM_Mailing_Event_BAO_TrackableURLOpen::getRows($mailingAB[$column], NULL, FALSE, NULL, $offset, $rowCount, "{$click}.time_stamp ASC");
-         break;
- case 'Total Clicks on a particular link':
-         if (empty($params['url'])) {
-         throw new API_Exception("Provide url to get stats result for '{$winningCriteria}'");
- }
- $url_id = CRM_Mailing_BAO_TrackableURL::getTrackerURLId($mailingAB[$column], $params['url']);
- $totalCounts = CRM_Mailing_Event_BAO_TrackableURLOpen::getTotalCount($params['mailing_id'], NULL, FALSE, $url_id);
- $rowCount = round($totalCounts / $params['split_count']);
- $offset = $rowCount * ($params['split_count_select'] - 1);
- $graphStats[$name] = CRM_Mailing_Event_BAO_TrackableURLOpen::getRows($mailingAB[$column], NULL, FALSE, $url_id, $offset, $rowCount, "{$click}.time_stamp ASC");
- break;
- }
- }
-
- return civicrm_api3_create_success($graphStats);
+  foreach ($ABFormat as $name => $column) {
+    switch ($winningCriteria) {
+      case 'Open':
+        $result = CRM_Mailing_Event_BAO_Opened::getRows($mailingAB['mailing_id_a'], NULL, TRUE, 0, 1, "civicrm_mailing_event_opened.time_stamp ASC");        $startDate = CRM_Utils_Date::processDate($result[0]['date']);
+        $dateDuration = round(round(strtotime($declareWinnerDate) - strtotime($startDate))/$params['split_count']);
+        $toDate = strtotime($startDate) + ($dateDuration * $params['split_count_select']);
+        $toDate = date('YmdHis', $toDate);
+        $graphStats[$name] = array(
+          $params['split_count_select'] => array(
+            'count' => CRM_Mailing_Event_BAO_Opened::getTotalCount($mailingAB[$column], NULL, TRUE, $toDate),
+            'time' =>  CRM_Utils_Date::customFormat($toDate)
+          )
+        );
+        break;
+      case 'Total Unique Clicks':
+        $result = CRM_Mailing_Event_BAO_TrackableURLOpen::getRows($mailingAB['mailing_id_a'], NULL, TRUE, 0, 1, "civicrm_mailing_event_trackable_url_open.time_stamp ASC");
+        $startDate = CRM_Utils_Date::processDate($result[0]['date']);
+        $dateDuration = round(abs(strtotime($declareWinnerDate) - strtotime($startDate))/$params['split_count']);
+        $toDate = strtotime($startDate) + ($dateDuration * $params['split_count_select']);
+        $toDate = date('YmdHis', $toDate);
+        $graphStats[$name] = array(
+          $params['split_count_select'] => array(
+            'count' => CRM_Mailing_Event_BAO_TrackableURLOpen::getTotalCount($params['mailing_id'], NULL, FALSE, NULL, $toDate),
+            'time' =>  CRM_Utils_Date::customFormat($toDate)
+          )
+        );
+        break;
+      case 'Total Clicks on a particular link':
+        if (empty($params['url'])) {
+          throw new API_Exception("Provide url to get stats result for '{$winningCriteria}'");
+        }
+        $url_id = CRM_Mailing_BAO_TrackableURL::getTrackerURLId($mailingAB[$column], $params['url']);
+        $result = CRM_Mailing_Event_BAO_TrackableURLOpen::getRows($mailingAB['mailing_id_a'], NULL, FALSE, $url_id, 0, 1, "civicrm_mailing_event_trackable_url_open.time_stamp ASC");
+        $startDate = CRM_Utils_Date::processDate($result[0]['date']);
+        $dateDuration = round(abs(strtotime($declareWinnerDate) - strtotime($startDate))/$params['split_count']);
+        $toDate = strtotime($startDate) + ($dateDuration * $params['split_count_select']);
+        $toDate = CRM_Utils_Date::processDate($toDate);
+        $graphStats[$name] = array(
+          $params['split_count_select'] => array(
+            'count' => CRM_Mailing_Event_BAO_TrackableURLOpen::getTotalCount($params['mailing_id'], NULL, FALSE, $url_id, $toDate),
+            'time' =>  CRM_Utils_Date::customFormat($toDate)
+          )
+        );
+        break;
+    }
+  }
+
+  return civicrm_api3_create_success($graphStats);
 }
\ No newline at end of file
index 599393978d6f3ed9c67a30dd2d8995b7c31fd1ab..93c57a8d5bdf2cc9836d0447721fb81ec455dd65 100755 (executable)
     $scope.mailingABList = mailingABList.values;
   });
 
-  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,$location) {
+    $scope.graph_data = [{},{},{},{},{}];
+
+    $scope.graphload = false;
     if (selectedABTest.winner_criteria_id == 1) {
       $scope.winnercriteria = "Open";
     }
       }
     }
 
+    $scope.copyatoc = function(){
+      var res = crmApi('Mailing','get',{id:selectedABTest.mailing_id_a});
+      res.success(function(data){
+        for( var key in data.values){
+          var mail = data.values[key];
+        }
+        mail.id = selectedABTest.mailing_id_c;
+        crmApi('Mailing','create',mail);
+      });
+      $location.path('mailing/abtesting');
+    };
+
+    $scope.sendc = function(){
+      var res = crmApi('Mailing','get',{id:selectedABTest.mailing_id_b});
+      res.success(function(data){
+        for( var key in data.values){
+          var mail = data.values[key];
+        }
+        mail.id = selectedABTest.mailing_id_c;
+        crmApi('Mailing','create',mail);
+      });
+      $location.path('mailing/abtesting');
+    }
     var result = crmApi('Mailing','stats',{mailing_id : selectedABTest.mailing_id_a});
     $scope.r=[];
     result.success(function (data) {
       $scope.d.push(data.values[selectedABTest.mailing_id_b]["Unique Clicks"].toString());
       $scope.$apply();
     });
-
-    var numdiv = 5;
-
-    for (i = 0; i < numdiv; i++) {
-      var result = crmApi('MailingAB', 'graph_stats',{id : selectedABTest.id, stats_count : numdiv, stat_count_select : i});
-      result.success(function (data) {
-      });
+    $scope.aastop = false;
+    $scope.asure = function(){
+      $scope.aastop = true;
+    }
+    $scope.bbstop = false;
+    $scope.bsure = function(){
+      $scope.bbstop = true;
     }
 
-
+      var numdiv = 5;
+      var keep_cnt =0;
+      for (i = 1; i <= numdiv; i++) {
+        var result = crmApi('MailingAB', 'graph_stats',{id : selectedABTest.id, split_count : numdiv, split_count_select : i});
+        result.success(function (data) {
+          var temp=0;
+          keep_cnt ++;
+          for( var key in data.values.A){
+            temp = key;
+          }
+          var t = data.values.A[temp].time.split(" ");
+          var m = t[0];
+          var year = t[2];
+          var day = t[1].substr(0,t[1].length-3);
+          if(t[3]==""){
+            var t1= t[4].split(":");
+            var hur = t1[0];
+            if(t[5] == "AM"){hour = hur; if(hour == 12)hour = 0;}
+            if(t[5] == "PM")hour = parseInt(hur)+12;
+            var min = t1[1];
+          }
+          else{
+            var t1= t[3].split(":");
+            var hur = t1[0];
+            if(t[4] == "AM"){hour = hur; if(hour == 12)hour = 0;}
+            if(t[4] == "PM")hour = parseInt(hur)+12;
+            var min = t1[1];
+          }
+          var month = 0;
+         switch (m) {
+           case "January":
+             month = 0;break;
+           case "February":
+             month = 1;break;
+           case "March":
+             month = 2;break;
+           case "April":
+             month = 3;break;
+           case "May":
+             month = 4;break;
+           case "June":
+             month = 5;break;
+           case "July":
+             month = 6;break;
+           case "August":
+             month = 7;break;
+           case "September":
+             month = 8;break;
+           case "October":
+             month = 9;break;
+           case "November":
+             month = 10;break;
+           case "December":
+             month = 11;break;
+
+         }
+          var tp = new Date(year, month, day, hour, min, 0, 0);
+          $scope.graph_data[temp-1] = {
+            time:tp,
+            x:data.values.A[temp].count,
+            y:data.values.B[temp].count}
+
+          if(keep_cnt == numdiv){
+            $scope.graphload = true;
+            $scope.$apply();
+            var data = $scope.graph_data;
+
+              // set up a colour variable
+              var color = d3.scale.category10();
+
+              // map one colour each to x, y and z
+              // keys grabs the key value or heading of each key value pair in the json
+              // but not time
+              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) {
+                return {
+                  name: name,
+                  values: data.map(function (d) {
+                    return {
+                      time: d.time,
+                      score: +d[name]
+                    };
+                  })
+                };
+              });
+
+              // Set the dimensions of the canvas / graph
+              var margin = {
+                  top: 30,
+                  right: 20,
+                  bottom: 40,
+                  left: 75
+                },
+                width = 550 - margin.left - margin.right,
+                height = 350 - margin.top - margin.bottom;
+
+              // Set the ranges
+              //var x = d3.time.scale().range([0, width]).domain([0,10]);
+              var x = d3.time.scale().range([0, width]);
+              var y = d3.scale.linear().range([height, 0]);
+
+              // Define the axes
+              var xAxis = d3.svg.axis().scale(x)
+                .orient("bottom").ticks(10);
+
+              var yAxis = d3.svg.axis().scale(y)
+                .orient("left").ticks(5);
+
+              // Define the line
+              // Note you plot the time / score pair from each key you created ealier
+              var valueline = d3.svg.line()
+                .x(function (d) {
+                  return x(d.time);
+                })
+                .y(function (d) {
+                  return y(d.score);
+                });
+
+              // Adds the svg canvas
+              var svg = d3.select("#linegraph")
+                .append("svg")
+                .attr("width", width + margin.left + margin.right)
+                .attr("height", height + margin.top + margin.bottom)
+                .append("g")
+                .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
+
+              // Scale the range of the data
+              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) {
+                    return v.score;
+                  });
+                }),
+                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)
+                .style("text-anchor", "middle")
+                .text("Time");
+
+              svg.append("text")      // text label for the x axis
+
+                .style("text-anchor", "middle")
+                .text($scope.winnercriteria).attr("transform",function (d) {
+                  return "rotate(-90)"
+                }).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
+              var series = svg.selectAll(".series")
+                .data(series)
+                .enter().append("g")
+                .attr("class", "series");
+
+              // create the path for each series in the variable series i.e. x, y and z
+              // pass each object called x, y nad z to the lne generator
+              series.append("path")
+                .attr("class", "line")
+                .attr("d", function (d) {
+                  // console.log(d); // to see how d3 iterates through series
+                  return valueline(d.values);
+                })
+                .style("stroke", function (d) {
+                  return color(d.name);
+                });
+
+              // Add the X Axis
+              svg.append("g") // Add the X Axis
+                .attr("class", "x axis")
+                .attr("transform", "translate(0," + height + ")")
+                .call(xAxis)
+                .selectAll("text")
+                .attr("transform", function(d) {
+                  return "rotate(-30)";});
+
+            // Add the Y Axis
+              svg.append("g") // Add the Y Axis
+                .attr("class", "y axis")
+                .call(yAxis);
+          }
+        });
+      }
+      console.log($scope.graph_data);
   });
 
   crmMailingAB.controller('crmABTestingTabsCtrl', function ($scope, crmApi, selectedABTest, $sce) {
     $scope.mailid = [];
     $scope.preventsubmit = false;
 
-    
+
     mltokens = CRM.crmMailing.mailTokens;
     if ($scope.currentABTest.declare_winning_time != null) {
       $scope.ans = $scope.currentABTest.declare_winning_time.split(" ");
     $scope.a_b_update = function () {
       $scope.tp1.include = $scope.incGroupids;
       $scope.tp1.exclude = $scope.excGroupids;
-
+      console.log($scope.tp1);
       var result = crmApi('MailingAB', 'recipients_update', {
         id: $scope.currentABTest.id,
         groups: $scope.tp1
 
     }
 
+
     $scope.update_abtest = function () {
       $scope.currentABTest.declare_winning_time = $scope.currentABTest.date + " " + $scope.currentABTest.time;
       result = crmApi('MailingAB', 'create', {
       }
     };*/
 
+
     $scope.$watch('preview', function () {
       if ($scope.preview == true) {
         $('#prevmail').dialog({
             header_id: scope.mailB.header_id,
             footer_id: scope.mailB.footer_id,
             is_completed: scope.mailA.is_completed,
-//            api.mailing_job.create: 0
+            'api.mailing_job.create': 0
           });
         });
       }
     };
   });
 
-  crmMailingAB.directive('linegraph', function () {
-    return {
-      restrict: 'AE',
-      link: function (scope, element, attrs) {
-        var data = scope.graph_data;
-        // set up a colour variable
-        var color = d3.scale.category10();
-
-        // map one colour each to x, y and z
-        // keys grabs the key value or heading of each key value pair in the json
-        // but not time
-
-        //console.log(d3.keys(data[0]));
-        color.domain(d3.keys(data[0]).filter(function (key) {
-          return key !== "time";
-        }));
-
-        // create a nested series for passing to the line generator
-        // it's best understood by console logging the data
-        var series = color.domain().map(function (name) {
-        //  console.log(name);
-
-          return {
-            name: name,
-            values: data.map(function (d) {
-            //  console.log("------");
-             // console.log(d);
-              return {
-                time: d.time,
-                score: +d[name]
-              };
-            })
-          };
-        });
-        //console.log("Series");
-
-       // console.log(series);
-
-        // Set the dimensions of the canvas / graph
-        var margin = {
-            top: 30,
-            right: 20,
-            bottom: 40,
-            left: 75
-          },
-          width = 375 - margin.left - margin.right,
-          height = 250 - margin.top - margin.bottom;
-
-        // Set the ranges
-        //var x = d3.time.scale().range([0, width]).domain([0,10]);
-        var x = d3.scale.linear().range([0, width]);
-        var y = d3.scale.linear().range([height, 0]);
-
-        // Define the axes
-        var xAxis = d3.svg.axis().scale(x)
-          .orient("bottom").ticks(10);
-
-        var yAxis = d3.svg.axis().scale(y)
-          .orient("left").ticks(5);
-
-        // Define the line
-        // Note you plot the time / score pair from each key you created ealier
-        var valueline = d3.svg.line()
-          .x(function (d) {
-            return x(d.time);
-          })
-          .y(function (d) {
-            return y(d.score);
-          });
-
-        // Adds the svg canvas
-        var svg = d3.select(element[0])
-          .append("svg")
-          .attr("width", width + margin.left + margin.right)
-          .attr("height", height + margin.top + margin.bottom)
-          .append("g")
-          .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
-
-        // Scale the range of the data
-        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) {
-              return v.score;
-            });
-          }),
-          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)
-          .style("text-anchor", "middle")
-          .text("Time");
-
-        svg.append("text")      // text label for the x axis
-
-          .style("text-anchor", "middle")
-          .text(scope.winnercriteria).attr("transform",function (d) {
-            return "rotate(-90)"
-          }).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
-        var series = svg.selectAll(".series")
-          .data(series)
-          .enter().append("g")
-          .attr("class", "series");
-
-        // create the path for each series in the variable series i.e. x, y and z
-        // pass each object called x, y nad z to the lne generator
-        series.append("path")
-          .attr("class", "line")
-          .attr("d", function (d) {
-           // console.log(d); // to see how d3 iterates through series
-            return valueline(d.values);
-          })
-          .style("stroke", function (d) {
-            return color(d.name);
-          });
-
-        // Add the X Axis
-        svg.append("g") // Add the X Axis
-          .attr("class", "x axis")
-          .attr("transform", "translate(0," + height + ")")
-          .call(xAxis);
-
-        // Add the Y Axis
-        svg.append("g") // Add the Y Axis
-          .attr("class", "y axis")
-          .call(yAxis);
-      }
-    }
-  });
-
   crmMailingAB.directive('groupselect',function(){
     return {
       restrict : 'AE',
     };
   });
 
+  crmMailingAB.directive('stopa',function(){
+    return {
+      restrict :'AE',
+      link: function(scope,element,attrs){
+        scope.$watch('aastop', function () {
+          if(scope.aastop == true ){
+            $(element).dialog({
+              title: 'Confirmation',
+              width: 300,
+              height: 150,
+              closed: false,
+              cache: false,
+              modal: true,
+              buttons: {
+                'Yes': function () {
+                  scope.aastop = false;
+                  scope.copyatoc();
+                  $(element).dialog("close");
+                },
+                'No':function(){
+                    scope.aastop = false;
+                  $(element).dialog("close");
+                }
+              },
+              close: function () {
+                  scope.aastop = false;
+
+                scope.$apply();
+              }
+            });
+          }
+        });
+      }
+    }
+  });
+
+  crmMailingAB.directive('stopb',function(){
+    return {
+      restrict :'AE',
+      link: function(scope,element,attrs){
+
+              scope.$watch('bbstop', function () {
+                if(scope.bbstop == true ){
+                  $(element).dialog({
+                    title: 'Confirmation',
+                    width: 300,
+                    height: 150,
+                    closed: false,
+                    cache: false,
+                    modal: true,
+                    buttons: {
+                      'Yes': function () {
+                        scope.bbstop = false;
+                        scope.sendc();
+                        $(element).dialog("close");
+                      },
+                      'No':function(){
+                        scope.bbstop = false;
+                        $(element).dialog("close");
+                      }
+                    },
+                    close: function () {
+                      scope.bbstop = false;
+
+                      scope.$apply();
+                    }
+                  });
+                }
+              });
+      }
+    }
+  });
+
+
   crmMailingAB.directive('checktimeentry',function(){
     return {
       restrict :'AE',
       $(element).timeEntry({show24Hours:true});
       }
     }
+  });
+
+  crmMailingAB.directive('ckedit', function ($parse) {
+    CKEDITOR.disableAutoInline = true;
+    var counter = 0,
+      prefix = '__ckd_';
+
+    return {
+      restrict: 'A',
+      link: function (scope, element, attrs, controller) {
+        var getter = $parse(attrs.ckedit),
+          setter = getter.assign;
+
+        attrs.$set('contenteditable', true); // inline ckeditor needs this
+        if (!attrs.id) {
+          attrs.$set('id', prefix + (++counter));
+        }
+
+        // CKEditor stuff
+        // Override the normal CKEditor save plugin
+
+        CKEDITOR.plugins.registered['save'] =
+        {
+          init: function (editor) {
+            editor.addCommand('save',
+              {
+                modes: { wysiwyg: 1, source: 1 },
+                exec: function (editor) {
+                  if (editor.checkDirty()) {
+                    var ckValue = editor.getData();
+                    scope.$apply(function () {
+                      setter(scope, ckValue);
+                    });
+                    ckValue = null;
+                    editor.resetDirty();
+                  }
+                }
+              }
+            );
+            editor.ui.addButton('Save', { label: 'Save', command: 'save', toolbar: 'document' });
+          }
+        };
+        var options = {};
+        options.on = {
+          blur: function (e) {
+            if (e.editor.checkDirty()) {
+              var ckValue = e.editor.getData();
+              scope.$apply(function () {
+                setter(scope, ckValue);
+              });
+              ckValue = null;
+              e.editor.resetDirty();
+            }
+          }
+        };
+        options.extraPlugins = 'sourcedialog';
+        options.removePlugins = 'sourcearea';
+        var editorangular = CKEDITOR.inline(element[0], options); //invoke
+
+        scope.$watch(attrs.ckedit, function (value) {
+          editorangular.setData(value);
+        });
+      }
+    }
 
   });
 
index 46fea8729bd373b1b580846fa830f4988c1490d3..fe79304e2e3e04226877e37b039e1d17afeafc0d 100755 (executable)
@@ -1,14 +1,14 @@
 <div class="crm-accordion-wrapper ">
   <div class="crm-accordion-wrapper ">
     <div class="crm-accordion-header">HTML Format</div>
-    <div class="crm-accordion-body">
+    <div class="crm-accordion-body" >
       <br>
       &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
       &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
       &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
       <input type="hidden" groupselect id= "htgroupcompose"  ></input><br><br>
       &nbsp &nbsp &nbsp &nbsp
-      <textarea id = "body_html" ng-model="mailA.body_html" style="width: 600px; height: 300px;" required></textarea>
+      <div ckedit id = "body_html" ng-model="mailA.body_html" style="width: 600px; height: 300px;" required></div>
       <br> <br>
     </div>
   </div>
index 99fa633a740585f81ec71a2ace7f2f26fa783246..dbc840cb9c16db33f3dab5bb99ca14d8aa1102ea 100755 (executable)
@@ -11,9 +11,9 @@
     }
   </style>
   <div id="grph" ></div>
-  <div linegraph></div>
+  <div id="linegraph"></div>
   {{r5}}
-  <table  style ="position: relative;  right :-425px; top:-250px; width :250px;">
+  <table  style ="position: relative;  right :-575px; top:-250px; width :250px;" ng-show= "graphload">
     <tr  >
       <th>Details</th>
       <th style="width :90px;">Version A</th>
@@ -46,7 +46,7 @@
     </tr>
 
   </table>
-  <br><br>
+
    <hr>
 
   <table>
     <tr >
 
       <td>
-        <input type="radio" name="stop" >  Stop Test and Send Version A
+        <input type="radio"  ng-click = "asure();" name="stop"  >  Stop Test and Send Version A
+        <div ng-show = "aastop" stopa>Are you Sure?</div>
       </td>
 
       <td>
-        <input type="radio" name="stop">  Stop Test and Send Version B
+        <input type="radio" ng-click="bsure(); " name="stop" id="bstop">  Stop Test and Send Version B
+        <div ng-show = "bbstop" stopb>Are you Sure?</div>
       </td>
     </tr>