Module: E9Crm::CampaignsHelper

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

Instance Method Summary collapse

Instance Method Details

#campaign_active_select_optionsObject



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

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

#campaign_date_select_optionsObject



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

def campaign_date_select_options
  ''
end

#campaign_group_select_optionsObject



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

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



25
26
27
28
29
# File 'app/helpers/e9_crm/campaigns_helper.rb', line 25

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_type(val = '') ⇒ Object



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

def display_campaign_type(val = '')
  retv = val[/(.*)Campaign/, 1]
  retv == 'No' ? 'No Campaign' : retv
end

Accommodate for “NoCampaign” campaign in link



52
53
54
# File 'app/helpers/e9_crm/campaigns_helper.rb', line 52

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