Class: Crm::Report::ActivityPerformanceResultPresenter

Inherits:
BasePresenter
  • Object
show all
Defined in:
app/presenters/crm/report/activity_performance_result_presenter.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.tagsObject



8
9
10
11
# File 'app/presenters/crm/report/activity_performance_result_presenter.rb', line 8

def self.tags
  # (1..ActivityType::TOTAL_TIERS)
  ActivityType::TAGS_FOR_REPORTS
end

Instance Method Details

#closed_activities(tag = nil) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'app/presenters/crm/report/activity_performance_result_presenter.rb', line 55

def closed_activities(tag = nil)
  ca_count = tag.present? ? r.closed_by_tag[tag[1]] : r.total_closed_activities
  return h.(:span, '-') if ca_count == 0

  options = {
    query_params: {
      completion_datetime_gteq_time: date.beginning_of_day,
      completion_datetime_lteq_time: date.end_of_day,
      closed_by_id_in: [r.employee_id],
      activity_type_id: ['Any'],
      activity_result_type_id: ['AnyCompletion']
    },
    counter_class: 'badge bg-success',
    num_records: ca_count,
    set_limit: 100
  }
  if tag
    tag[0] == 'CALLBLOCK' ? options[:query_params][:tag2_in] = tag[0] : options[:query_params][:tag1_in] = tag[0]
  end
  link,counter = h.query_template_link(ActivitySearch, nil, options)
  link.html_safe
end

#closed_by_tag(tag) ⇒ Object



29
30
31
# File 'app/presenters/crm/report/activity_performance_result_presenter.rb', line 29

def closed_by_tag(tag)
  closed_activities(tag)
end

#dateObject



4
5
6
# File 'app/presenters/crm/report/activity_performance_result_presenter.rb', line 4

def date
  @options[:date]
end

#open_activities(tag = nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/presenters/crm/report/activity_performance_result_presenter.rb', line 33

def open_activities(tag = nil)
  oa_count = tag.present? ? r.open_by_tag[tag[1]] : r.total_open_activities
  return h.(:span, '-') if oa_count == 0

  options = {
    query_params: {
      open_on_date: date,
      assigned_resource_id: [r.employee_id],
      activity_type_id: ['Any']
    },
    counter_class: 'badge bg-warning',
    num_records: oa_count,
    set_limit: 100
  }
  # options[:query_params][:activity_type_priority_in] = [tier] if tier
  if tag
    tag[0] == 'CALLBLOCK' ? options[:query_params][:tag2_in] = tag[0] : options[:query_params][:tag1_in] = tag[0]
  end
  link,counter = h.query_template_link(ActivitySearch, nil, options)
  link.html_safe
end

#open_by_tag(tag) ⇒ Object



25
26
27
# File 'app/presenters/crm/report/activity_performance_result_presenter.rb', line 25

def open_by_tag(tag)
  open_activities(tag)
end

#tagsObject



13
14
15
# File 'app/presenters/crm/report/activity_performance_result_presenter.rb', line 13

def tags
  self.class.tags
end

#total_closed_activitiesObject



21
22
23
# File 'app/presenters/crm/report/activity_performance_result_presenter.rb', line 21

def total_closed_activities
  closed_activities
end

#total_open_activitiesObject



17
18
19
# File 'app/presenters/crm/report/activity_performance_result_presenter.rb', line 17

def total_open_activities
  open_activities
end