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




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

def confirm_reject(lead)
  question = %(<span class="warn">#{t(:reject_lead_confirm)}</span>)
  yes = link_to(t(:yes_button), reject_lead_path(lead), method: :put)
  no = link_to_function(t(:no_button), "$('#menu').html($('#confirm').html());")
  text = "$('#confirm').html( $('#menu').html() );\n"
  text += "$('#menu').html('#{question} #{yes} : #{no}');"
  text.html_safe
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.




60
61
62
63
64
65
66
# File 'app/helpers/leads_helper.rb', line 60

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.




70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'app/helpers/leads_helper.rb', line 70

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



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

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



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

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

#stars_for(lead) ⇒ Object




12
13
14
15
16
# File 'app/helpers/leads_helper.rb', line 12

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