Sha256: 3d6662758135b9f0efb4c124d3be466dbb3db17325f74ae8e5d8bd59b52f841f

Contents?: true

Size: 1.55 KB

Versions: 13

Compression:

Stored size: 1.55 KB

Contents

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

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

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

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

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

  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

  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

  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

  def campaign_date_select_options
    ''
  end

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

  ##
  # Accommodate for "NoCampaign" campaign in link
  #
  def link_to_edit_campaign(record)
    link_to_edit_resource(record) unless record.is_a?(NoCampaign)
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
e9_crm-0.1.34 app/helpers/e9_crm/campaigns_helper.rb
e9_crm-0.1.33 app/helpers/e9_crm/campaigns_helper.rb
e9_crm-0.1.32 app/helpers/e9_crm/campaigns_helper.rb
e9_crm-0.1.31 app/helpers/e9_crm/campaigns_helper.rb
e9_crm-0.1.30 app/helpers/e9_crm/campaigns_helper.rb
e9_crm-0.1.29 app/helpers/e9_crm/campaigns_helper.rb
e9_crm-0.1.28 app/helpers/e9_crm/campaigns_helper.rb
e9_crm-0.1.27 app/helpers/e9_crm/campaigns_helper.rb
e9_crm-0.1.26 app/helpers/e9_crm/campaigns_helper.rb
e9_crm-0.1.25 app/helpers/e9_crm/campaigns_helper.rb
e9_crm-0.1.24 app/helpers/e9_crm/campaigns_helper.rb
e9_crm-0.1.23 app/helpers/e9_crm/campaigns_helper.rb
e9_crm-0.1.22 app/helpers/e9_crm/campaigns_helper.rb