Module: LeadsHelper

Defined in:
app/helpers/leads_helper.rb

Overview

Copyright © 2008-2013 Michael Dvorkin and contributors.

Fat Free CRM is freely distributable under the terms of MIT license. See MIT-LICENSE file or www.opensource.org/licenses/mit-license.php


Constant Summary collapse

RATING_STARS =
5

Instance Method Summary collapse

Instance Method Details

#confirm_reject(lead) ⇒ Object




31
32
33
34
35
36
37
38
39
# File 'app/helpers/leads_helper.rb', line 31

def confirm_reject(lead)
  question = %(<span class="warn">#{t(:reject_lead_confirm)}</span>).html_safe
  yes = link_to(t(:yes_button), reject_lead_path(lead), :method => :put)
  no = link_to_function(t(:no_button), "$('menu').update($('confirm').innerHTML)")
  update_page do |page|
    page << "$('confirm').update($('menu').innerHTML)"
    page[:menu].replace_html "#{question} #{yes} : #{no}"
  end
end

#get_lead_default_permissions_intro(access) ⇒ Object

Returns default permissions intro for leads.




49
50
51
52
53
54
55
# File 'app/helpers/leads_helper.rb', line 49

def get_lead_default_permissions_intro(access)
  case access
    when "Private" then t(:lead_permissions_intro_private, t(:opportunity_small))
    when "Public" then t(:lead_permissions_intro_public, t(:opportunity_small))
    when "Shared" then t(:lead_permissions_intro_shared, t(:opportunity_small))
  end
end

#lead_status_checkbox(status, count) ⇒ Object

Sidebar checkbox control for filtering leads by status.




43
44
45
# File 'app/helpers/leads_helper.rb', line 43

def lead_status_checkbox(status, count)
  entity_filter_checkbox(:status, status, count)
end

#lead_status_codes_for(lead) ⇒ Object

Do not offer :converted status choice if we are creating a new lead or editing existing lead that hasn’t been converted before.




70
71
72
73
74
75
76
# File 'app/helpers/leads_helper.rb', line 70

def lead_status_codes_for(lead)
  if lead.status != "converted" && (lead.new_record? || lead.contact.nil?)
    Setting.unroll(:lead_status).delete_if { |status| status.last == :converted }
  else
    Setting.unroll(:lead_status)
  end
end

#lead_summary(lead) ⇒ Object

Lead summary for RSS/ATOM feed.




80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'app/helpers/leads_helper.rb', line 80

def lead_summary(lead)
  summary = []
  summary << (lead.status ? t(lead.status) : t(:other))

  if lead.company? && lead.title?
    summary << t(:works_at, :job_title => lead.title, :company => lead.company)
  else
    summary << lead.company if lead.company?
    summary << lead.title if lead.title?
  end
  summary << "#{t(:referred_by_small)} #{lead.referred_by}" if lead.referred_by?
  summary << lead.email if lead.email.present?
  summary << "#{t(:phone_small)}: #{lead.phone}" if lead.phone.present?
  summary << "#{t(:mobile_small)}: #{lead.mobile}" if lead.mobile.present?
  summary.join(', ')
end



17
18
19
20
21
22
23
# File 'app/helpers/leads_helper.rb', line 17

def link_to_convert(lead)
  link_to(t(:convert), convert_lead_path(lead),
    :method => :get,
    :with   => "{ previous: crm.find_form('edit_lead') }",
    :remote => true
  )
end



26
27
28
# File 'app/helpers/leads_helper.rb', line 26

def link_to_reject(lead)
  link_to(t(:reject) + "!", reject_lead_path(lead), :method => :put, :remote => true)
end

#stars_for(lead) ⇒ Object




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

def stars_for(lead)
  star = '&#9733;'
  rating = lead.rating || 0
  (star * rating).html_safe + (:font, (star * (RATING_STARS - rating)).html_safe, :color => 'gainsboro')
end