Module: NewCustomersHelper

Defined in:
app/helpers/new_customers_helper.rb

Instance Method Summary collapse

Instance Method Details

#contact_display_with_highlight(contact) ⇒ Object



3
4
5
# File 'app/helpers/new_customers_helper.rb', line 3

def contact_display_with_highlight(contact)
  link_to highlight(contact.full_name, @new_customer.person_name_parts), contact_path(contact)
end

#customer_display_with_highlight(customer) ⇒ Object



7
8
9
# File 'app/helpers/new_customers_helper.rb', line 7

def customer_display_with_highlight(customer)
  link_to highlight(customer.full_name, @new_customer.company_name_parts), customer_path(customer)
end

#new_customer_attribute_hidden_fields(new_customer) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/new_customers_helper.rb', line 11

def new_customer_attribute_hidden_fields(new_customer)
  new_customer.attributes.map do |attr_key, value|
    if value.present?
      if value.is_a?Array
        value.map{|v| hidden_field_tag("new_customer[#{attr_key}][]", v)}
      else
        hidden_field_tag("new_customer[#{attr_key}]", value)
      end
    end
  end.flatten.compact.join.html_safe
end

#new_customer_attributes_paramsObject



23
24
25
26
27
28
29
30
31
# File 'app/helpers/new_customers_helper.rb', line 23

def new_customer_attributes_params
  attr_hash = { new_customer: {}}
  @new_customer.attributes.each do |attr_key, value|
    if value.present?
      attr_hash[:new_customer][attr_key] = value
    end
  end
  attr_hash.to_param
end


56
57
58
59
60
# File 'app/helpers/new_customers_helper.rb', line 56

def new_customer_link_to_duplicates_step
  button_to "2. Duplicates",
                { action: 'duplicates' },
                { class: 'btn btn-link', params: prefixed_new_customer_form_attributes }
end


68
69
70
71
72
# File 'app/helpers/new_customers_helper.rb', line 68

def new_customer_link_to_email_preferences_step
  button_to "4. Email Preferences",
                { action: 'email_preferences' },
                { class: 'btn btn-link', params: prefixed_new_customer_form_attributes }
end


50
51
52
53
54
# File 'app/helpers/new_customers_helper.rb', line 50

def new_customer_link_to_identify_step
  button_to "1. Identification",
                { action: 'identify' },
                { class: 'btn btn-link', params: prefixed_new_customer_form_attributes }
end


62
63
64
65
66
# File 'app/helpers/new_customers_helper.rb', line 62

def new_customer_link_to_setup_step
  button_to "3. Setup",
                { action: 'setup' },
                { class: 'btn btn-link', params: prefixed_new_customer_form_attributes }
end

#prefixed_new_customer_form_attributesObject



46
47
48
# File 'app/helpers/new_customers_helper.rb', line 46

def prefixed_new_customer_form_attributes
  @new_customer.attributes.inject({}) {|hsh, (k,v)| hsh["new_customer[#{k}]"] = v if v.present? ; hsh }
end

#rep_assign_method_collection_for_selectObject



33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/helpers/new_customers_helper.rb', line 33

def rep_assign_method_collection_for_select
  options = []
  options << [ Customer::NewCustomer::REP_ASSIGN_METHODS[:aa] , :aa ]
  if current_user.is_sales_rep? or current_user.is_admin?
    options << [ "Self Assign (#{current_user.full_name})", :sa ]
  end
  if can?(:assign_sales_rep, Customer)
    options << [ Customer::NewCustomer::REP_ASSIGN_METHODS[:ma], :ma ]
  end
  options << [ Customer::NewCustomer::REP_ASSIGN_METHODS[:dna], :dna ]
  options
end