Module: ContactsHelper

Defined in:
app/helpers/contacts_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


Instance Method Summary collapse

Instance Method Details

#contact_summary(contact) ⇒ Object

Contact summary for RSS/ATOM feeds.




11
12
13
14
15
16
17
18
19
20
# File 'app/helpers/contacts_helper.rb', line 11

def contact_summary(contact)
  summary = ['']
  summary << contact.title.titleize if contact.title?
  summary << contact.department if contact.department?
  summary.last += " #{t(:at)} #{contact..name}" if contact.&.name?
  summary << contact.email if contact.email.present?
  summary << "#{t(:phone_small)}: #{contact.phone}" if contact.phone.present?
  summary << "#{t(:mobile_small)}: #{contact.mobile}" if contact.mobile.present?
  summary.join(', ')
end

#vcard_for(contact) ⇒ Object



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
47
48
# File 'app/helpers/contacts_helper.rb', line 22

def vcard_for(contact)
  card = VCardigan.create
  card.name contact.last_name, contact.first_name
  card.fullname "#{contact.first_name} #{contact.last_name}"
  card.title contact.title if contact.title.present?
  if contact.respond_to?(:account) # Contact
    card.org contact..name, contact.department if contact..present?
  elsif contact.respond_to?(:company) # Lead
    card.org contact.company if contact.company.present?
  end
  card.email contact.email, type: %w[internet work] if contact.email.present?
  card.email contact.alt_email, type: %w[internet work] if contact.alt_email.present?
  card.tel contact.phone, type: 'work' if contact.phone?
  card.tel contact.mobile, type: %w[cell voice] if contact.mobile.present?
  card.note "Exported from Fat Free CRM"

  if contact.business_address
    card.adr contact.business_address.street1,
             contact.business_address.street2,
             contact.business_address.city,
             contact.business_address.state,
             contact.business_address.zipcode,
             contact.business_address.country, type: 'work'
  end

  card
end