Guest User

Untitled

a guest
Feb 21st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. function getAutomationSendSummary($TM_SERVICE=null,$param){
  2. $response = array();
  3. $automation_id = $param['AutomationID'];
  4. $check_automation = $TM_SERVICE->checkAutomation($automation_id);
  5. if(!$check_automation['status']){
  6. return $check_automation;
  7. }
  8. $sql = "SELECT emailed,
  9. completed,
  10. unique_opens,
  11. unique_clicks,
  12. contacts
  13. FROM automation_list
  14. WHERE automation_id = @automation_id";
  15.  
  16. $sql_param = array();
  17. $sql_param['automation_id'] = $automation_id;
  18. $ds = null;
  19. $res = $TM_SERVICE::$DB->query($ds,$sql,$sql_param,0,-1,"ASSOC");
  20.  
  21. $item = array();
  22. $item['finished'] = $ds[0]['completed'];
  23. $item['emails_sent'] = $ds[0]['emailed'];
  24. $item['opens'] = $ds[0]['unique_opens'];
  25. $item['clicks'] = $ds[0]['unique_clicks'];
  26.  
  27. $data = array();
  28. $data['contacts'] = $ds[0]['contacts'];
  29. $data['summary'] = $item;
  30.  
  31. if($res > 0){
  32. $response['status'] = true;
  33. $response['error_code']['code'] = "";
  34. $response['error_code']['message'] = "";
  35. $response['data'] = $data;
  36. }else{
  37. $response['status'] = false;
  38. $response['error_code'] = $TM_SERVICE::$RESPONSE_ERROR_CODE['AUTOMATION_NOT_FOUND'];
  39. $response['data'] = "";
  40. }
  41. return $response;
  42. }
  43.  
  44. function summaryData(){
  45.  
  46. $.ajax({
  47. type: "post",
  48. url: BASE_CALL_API,
  49. data: {
  50. "Command": "Automations.GetSendSummary",
  51. "AutomationID": automation_id,
  52. },
  53. dataType: "json",
  54. error: function(e) {
  55.  
  56. },
  57. success: function(res) {
  58.  
  59. var data = res['data'];
  60. var data_size = data.length;
  61. var str_html = '';
  62.  
  63. $('#txt_contracts_value').text(data.contacts);
  64.  
  65. Object.keys(data.summary).forEach(function(key, val){
  66. str_html += '<div>';
  67. str_html += ' <span>' + replaceTitle(key) + '</span>';
  68. str_html += ' <small class="pull-right">' + findPercent(data['summary'][key], data.contacts) + '%</small>';
  69. str_html += '</div>';
  70. str_html += '<div id="wrap_' + key + '" class="progress progress-small info_tooltip" data-toggle="tooltip" data-placement="top" title="' + tooltipAutomationDisplay(data['summary'][key], data.contacts) + '">';
  71. str_html += ' <div style="width: ' + findPercent(data['summary'][key], data.contacts) + '%;" class="progress-bar"></div>';
  72. str_html += '</div>';
  73. });
  74.  
  75. $('#data-summary').html(str_html);
  76.  
  77. $('.info_tooltip').tooltip({
  78. container: "body"
  79. });
  80. }
  81. });
  82. }
Add Comment
Please, Sign In to add comment