Module: E9Crm::CampaignsHelper
- Defined in:
- app/helpers/e9_crm/campaigns_helper.rb
Instance Method Summary collapse
- #campaign_active_select_options ⇒ Object
- #campaign_date_select_options ⇒ Object
- #campaign_group_select_options ⇒ Object
- #campaign_type_select_options(with_all_option = true) ⇒ Object
- #display_campaign_code(val) ⇒ Object
- #display_campaign_fee(val) ⇒ Object
- #display_campaign_group_by_id(val) ⇒ Object
- #display_campaign_type(val) ⇒ Object
-
#link_to_edit_campaign(record) ⇒ Object
Accommodate for “NoCampaign” campaign in link.
- #m(val) ⇒ Object
- #no_money ⇒ Object
Instance Method Details
#campaign_active_select_options ⇒ Object
52 53 54 55 56 57 58 |
# File 'app/helpers/e9_crm/campaigns_helper.rb', line 52 def = [ ['Active', true], ['Inactive', false] ] () end |
#campaign_date_select_options ⇒ Object
48 49 50 |
# File 'app/helpers/e9_crm/campaigns_helper.rb', line 48 def '' end |
#campaign_group_select_options ⇒ Object
42 43 44 45 46 |
# File 'app/helpers/e9_crm/campaigns_helper.rb', line 42 def = CampaignGroup.select('name, id').ordered.all.map {|c| [c.name, c.id] } .unshift(['All Groups', nil]) () 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 (with_all_option = true) = %w( advertising affiliate email sales ).map {|t| [t.titleize, t] } .unshift(['All Types', nil]) if with_all_option () 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 |
#link_to_edit_campaign(record) ⇒ Object
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_money ⇒ Object
6 7 8 |
# File 'app/helpers/e9_crm/campaigns_helper.rb', line 6 def no_money @_no_money ||= Money.new(0) end |