Module: E9Crm::CampaignsHelper

Defined in:
app/helpers/e9_crm/campaigns_helper.rb

Instance Method Summary collapse

Instance Method Details

#campaign_active_select_optionsObject



52
53
54
55
56
57
58
# File 'app/helpers/e9_crm/campaigns_helper.rb', line 52

def campaign_active_select_options
  options = [
    ['Active',     true],
    ['Inactive',   false]
  ]
  options_for_select(options)
end

#campaign_date_select_optionsObject



48
49
50
# File 'app/helpers/e9_crm/campaigns_helper.rb', line 48

def campaign_date_select_options
  ''
end

#campaign_group_select_optionsObject



42
43
44
45
46
# File 'app/helpers/e9_crm/campaigns_helper.rb', line 42

def campaign_group_select_options
  options = CampaignGroup.select('name, id').ordered.all.map {|c| [c.name, c.id] }
  options.unshift(['All Groups', nil])
  options_for_select(options)
end

#campaign_type_select_options(with_all_option = true) ⇒ Object



36
37
38
39
40
# File 'app/helpers/e9_crm/campaigns_helper.rb', line 36

def campaign_type_select_options(with_all_option = true)
  options = %w( advertising affiliate email sales ).map {|t| [t.titleize, t] }
  options.unshift(['All Types', nil]) if with_all_option
  options_for_select(options)
end

#display_campaign_code(val) ⇒ Object



16
17
18
# File 'app/helpers/e9_crm/campaigns_helper.rb', line 16

def display_campaign_code(val)
  val && "?#{E9Crm.query_param}=#{val}" || 'n/a'
end

#display_campaign_fee(val) ⇒ Object



2
3
4
# File 'app/helpers/e9_crm/campaigns_helper.rb', line 2

def display_campaign_fee(val)
  Money === val && val.format || 'n/a'
end

#display_campaign_group_by_id(val) ⇒ Object



28
29
30
31
32
33
34
# File 'app/helpers/e9_crm/campaigns_helper.rb', line 28

def display_campaign_group_by_id(val)
  @_campaign_groups ||= CampaignGroup.all
  @_campaign_group_by_id ||= {}
  @_campaign_group_by_id[val] ||= begin
    @_campaign_groups.find {|c| c.id == val }.try(:name) || 'No Group'
  end
end

#display_campaign_type(val) ⇒ Object



20
21
22
23
24
25
26
# File 'app/helpers/e9_crm/campaigns_helper.rb', line 20

def display_campaign_type(val)
  @_campaign_types ||= {}
  @_campaign_types[val] ||= begin
    retv = val[/(.*)Campaign/, 1]
    retv == 'No' ? 'No Campaign' : retv
  end
end

Accommodate for “NoCampaign” campaign in link



63
64
65
# File 'app/helpers/e9_crm/campaigns_helper.rb', line 63

def link_to_edit_campaign(record)
  link_to_edit_resource(record) unless record.is_a?(NoCampaign)
end

#m(val) ⇒ Object



10
11
12
13
14
# File 'app/helpers/e9_crm/campaigns_helper.rb', line 10

def m(val)
  val ||= no_money
  val = val.to_money
  val.format
end

#no_moneyObject



6
7
8
# File 'app/helpers/e9_crm/campaigns_helper.rb', line 6

def no_money
  @_no_money ||= Money.new(0)
end