Module: LeadsHelper

Defined in:
app/helpers/leads_helper.rb

Overview

Fat Free CRM Copyright © 2008-2011 by Michael Dvorkin

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <www.gnu.org/licenses/>.


Constant Summary collapse

RATING_STARS =
5

Instance Method Summary collapse

Instance Method Details

#confirm_reject(lead) ⇒ Object




43
44
45
46
47
48
49
50
51
# File 'app/helpers/leads_helper.rb', line 43

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.




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

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_checbox(status, count) ⇒ Object

Sidebar checkbox control for filtering leads by status.




55
56
57
58
59
60
61
62
63
64
# File 'app/helpers/leads_helper.rb', line 55

def lead_status_checbox(status, count)
  checked = (session[:leads_filter] ? session[:leads_filter].split(",").include?(status.to_s) : count.to_i > 0)
  onclick = remote_function(
    :url      => { :action => :filter },
    :with     => h(%Q/"status=" + $$("input[name='status[]']").findAll(function (el) { return el.checked }).pluck("value")/),
    :loading  => "$('loading').show()",
    :complete => "$('loading').hide()"
  )
  check_box_tag("status[]", status, checked, :id => status, :onclick => onclick)
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.




89
90
91
92
93
94
95
# File 'app/helpers/leads_helper.rb', line 89

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.




99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'app/helpers/leads_helper.rb', line 99

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



29
30
31
32
33
34
35
# File 'app/helpers/leads_helper.rb', line 29

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



38
39
40
# File 'app/helpers/leads_helper.rb', line 38

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

#stars_for(lead) ⇒ Object




22
23
24
25
26
# File 'app/helpers/leads_helper.rb', line 22

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