Module: E9Crm::PageViewsHelper

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

Instance Method Summary collapse

Instance Method Details

#page_view_campaign_select_optionsObject



2
3
4
5
6
7
8
# File 'app/helpers/e9_crm/page_views_helper.rb', line 2

def page_view_campaign_select_options
  @_page_view_campaign_select_options ||= begin
    opts = Campaign.all.map {|campaign| [campaign.name, campaign.id] }
    opts.unshift ['Any', nil]
    options_for_select(opts)
  end
end

#page_view_date_select_options(options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/helpers/e9_crm/page_views_helper.rb', line 18

def page_view_date_select_options(options = {})
  @_first_date ||= PageView.order(:created_at).first.try(:created_at) || Date.today

  date, cdate = @_first_date, Date.today

  sel_options = []

  if options[:type] == :until
    prefix = 'Up to '
    label = prefix + ' Now'
  elsif options[:type] == :in_month
    prefix = 'Closed in '
    label = 'Since Inception'
  else
    prefix = 'Since '
    label = prefix + ' Inception'
  end

  begin
    sel_options << [date.strftime("#{prefix}%B %Y"), date.strftime('%Y/%m')]
    date += 1.month
  end while date.year <= cdate.year && date.month <= cdate.month

  sel_options.reverse!

  sel_options.unshift([label, nil])

  options_for_select(sel_options)
end

#page_view_new_visit_select_optionsObject



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

def page_view_new_visit_select_options
  options_for_select([
    ['Any', nil],
    ['New Visits', true],
    ['Repeat Visits', false]
  ])
end