Module: Crm::Reports::CustomerPerformanceReportHelper

Defined in:
app/helpers/crm/reports/customer_performance_report_helper.rb

Overview

View helper for the CRM customer performance report
(Crm::Reports::CustomerPerformanceController), rendering the grouping-label
link for each report row depending on the active grouping.

Instance Method Summary collapse

Instance Method Details

#customer_performance_group(hsh_group_key) ⇒ ActiveSupport::SafeBuffer?

Renders the grouping label for a report row as a link — to the customer
detail page for :customer_identity groupings, or to the drill-down report
filtered by the buying group, profile, or report grouping otherwise.

Parameters:

  • hsh_group_key (Hash)

    grouping key holding :grouping plus the
    label/ID values for that grouping (e.g. :customer_name, :customer_id)

Returns:

  • (ActiveSupport::SafeBuffer, nil)

    the label link, or nil for an unknown grouping



14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/helpers/crm/reports/customer_performance_report_helper.rb', line 14

def customer_performance_group(hsh_group_key)
  case hsh_group_key[:grouping]
  when :customer_identity
    link_to hsh_group_key[:customer_name], customer_path(hsh_group_key[:customer_id])
  when :buying_group_name
    link_to hsh_group_key[:buying_group_name], { command: { grouping: :customer_identity, buying_group_id: hsh_group_key[:buying_group_id] } }
  when :profile_name
    link_to hsh_group_key[:profile_name], { command: { grouping: :customer_identity, profile_id: hsh_group_key[:profile_id] } }
  when :report_grouping
    link_to hsh_group_key[:report_grouping], { command: { grouping: :customer_identity, report_grouping: hsh_group_key[:report_grouping] } }
  end
end