Class: Crm::Report::CustomerPerformanceResultsPresenter

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

Instance Method Summary collapse

Instance Method Details

#check_boxObject



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

def check_box
  return unless grouping == :customer_identity
  h.check_box_tag 'customer_ids[]', customer_id, false, { form: 'pin_customers' }
end


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/presenters/crm/report/customer_performance_results_presenter.rb', line 4

def group_link
  case grouping
  when :customer_identity
    h. :td, h.link_to(customer_name, h.customer_path(customer_id))
  when :state_code
    state = State.find_by(code: group_identifier)
    title = state.try(:name) || "Other"
    region = state.try(:region) || "Other"
    h.(:td, h.link_to(title, { action: :show, command: { grouping: :customer_identity, state_codes: [group_identifier] }})) +
    h.(:td, region)
  when :report_grouping
    h. :td, h.link_to(group_identifier, { action: :show, command: { grouping: :customer_identity, report_groupings: [group_identifier] }})
  when :profile_name
    h. :td, h.link_to(group_identifier, { action: :show, command: { grouping: :customer_identity, profile_ids: [profile_ids] }})
  when :buying_group_ids
    h. :td, h.link_to(group_identifier, { action: :show, command: { grouping: :customer_identity, buying_group_ids: [buying_group_id] }})
  when :primary_sales_rep_id
    primary_rep = Employee.find(group_identifier)
    h. :td, h.link_to(primary_rep.full_name, { action: :show, command: { grouping: :customer_identity, primary_sales_rep_ids: [group_identifier] }})
  else
    h. :td, group_identifier
  end
end


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

def sales_revenue_link(period_index)
  period_data = periods[period_index]
  options = {:show_zero => true, :counter_class => ''}
  options[:num_records] = period_data.sales_revenue
  options[:format] = :currency
  options[:query_params] = {}
  options[:query_params][:gl_date_gteq] =  period_data.period.first
  options[:query_params][:gl_date_lteq] =  period_data.period.last

  options[:query_params][:customer_id_eq] = customer_id if customer_id.present?
  options[:query_params][:buying_group_id_in] = buying_group_ids if buying_group_ids.present?
  options[:query_params][:profile_id_in] = profile_ids if profile_ids.present?
  options[:query_params][:company_id_in] = company_ids if company_ids.present?
  options[:query_params][:state_code_in] = state_codes if state_codes.present?
  options[:query_params][:report_grouping] = report_groupings if report_groupings.present?
  options[:query_params][:primary_sales_rep_id_includes] = primary_sales_rep_ids if primary_sales_rep_ids.present?
  h.query_template_link(InvoiceSearch, nil, options)[0]
end