Module: Models::RepSearchable::ClassMethods

Defined in:
app/concerns/models/rep_searchable.rb

Overview

ActiveSupport::Concern mixin: class methods.

Instance Method Summary collapse

Instance Method Details

#grouped_local_sales_reps_for_select(_include_unassigned_search: true) ⇒ Object



29
30
31
32
# File 'app/concerns/models/rep_searchable.rb', line 29

def grouped_local_sales_reps_for_select(_include_unassigned_search: true)
  active_reps = Employee.local_sales_reps.sorted.pluck(:full_name, :id)
  grouped_rep_for_select(active_reps: active_reps, label: 'Local Reps - Active')
end

#grouped_primary_sales_reps_for_select(_include_unassigned_search: true) ⇒ Object



19
20
21
22
# File 'app/concerns/models/rep_searchable.rb', line 19

def grouped_primary_sales_reps_for_select(_include_unassigned_search: true)
  active_reps = Employee.primary_sales_reps.active_employees.sorted.pluck(:full_name, :id)
  grouped_rep_for_select(active_reps: active_reps, label: 'Primary Reps - Active')
end

#grouped_rep_for_select(active_reps: [], label: 'Reps - Active', include_unassigned_search: true) ⇒ Object



10
11
12
13
14
15
16
17
# File 'app/concerns/models/rep_searchable.rb', line 10

def grouped_rep_for_select(active_reps: [], label: 'Reps - Active', include_unassigned_search: true)
  all_reps = Employee.select_options(active_only: false, exclude_ids: active_reps.filter_map(&:last))
  res = {}
  res['Special Search'] = [%w[Unassigned Unassigned]] if include_unassigned_search
  res[label] = active_reps if active_reps.present?
  res['All Reps Past and Present'] = all_reps
  res
end

#grouped_secondary_sales_reps_for_select(_include_unassigned_search: true) ⇒ Object



24
25
26
27
# File 'app/concerns/models/rep_searchable.rb', line 24

def grouped_secondary_sales_reps_for_select(_include_unassigned_search: true)
  active_reps = Employee.secondary_sales_reps.sorted.pluck(:full_name, :id)
  grouped_rep_for_select(active_reps: active_reps, label: 'Secondary Reps - Active')
end

#grouped_service_reps_for_select(_include_unassigned_search: true) ⇒ Object



34
35
36
37
# File 'app/concerns/models/rep_searchable.rb', line 34

def grouped_service_reps_for_select(_include_unassigned_search: true)
  active_reps = Employee.select_options(active_only: true)
  grouped_rep_for_select(active_reps: active_reps, label: 'Service Reps - Active')
end

#grouped_technical_reps_for_select(_include_unassigned_search: true) ⇒ Object



39
40
41
42
# File 'app/concerns/models/rep_searchable.rb', line 39

def grouped_technical_reps_for_select(_include_unassigned_search: true)
  active_reps = Employee.technical_support_rep_options_for_select
  grouped_rep_for_select(active_reps: active_reps, label: 'Technical Reps - Active')
end