Module: E9Crm::DealsHelper
- Defined in:
- app/helpers/e9_crm/deals_helper.rb
Instance Method Summary collapse
- #deal_category_select_options ⇒ Object
- #deal_contact_select ⇒ Object
- #deal_contact_select_options ⇒ Object
- #deal_contacts ⇒ Object
- #deal_contacts_array ⇒ Object
- #deal_date_select_options(options = {}) ⇒ Object
- #deal_offer_select_options ⇒ Object
- #deal_owner_select_options ⇒ Object
- #deal_status_select_options ⇒ Object
- #title_and_or_company(contact) ⇒ Object
Instance Method Details
#deal_category_select_options ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/helpers/e9_crm/deals_helper.rb', line 25 def @_deal_category_select_options ||= begin = MenuOption.('Deal Category') .unshift ['All Categories', nil] () end end |
#deal_contact_select ⇒ Object
12 13 14 |
# File 'app/helpers/e9_crm/deals_helper.rb', line 12 def deal_contact_select select_tag 'contacts_ids', end |
#deal_contact_select_options ⇒ Object
2 3 4 5 6 7 8 9 10 |
# File 'app/helpers/e9_crm/deals_helper.rb', line 2 def @_deal_contact_select_options ||= begin contacts = Contact.available_to_deal(resource) = contacts.map {|contact| [contact.name, contact.id] } .unshift ['Add Contact', nil] end end |
#deal_contacts ⇒ Object
79 80 81 82 83 84 |
# File 'app/helpers/e9_crm/deals_helper.rb', line 79 def deal_contacts @_eligible_responsible_contacts ||= begin roles = E9::Roles.list.map(&:role).select {|r| r > 'user' && r < 'e9_user' } User.includes(:contact).for_roles(roles).all.map(&:contact).compact.sort_by {|c| c.name.upcase } end end |
#deal_contacts_array ⇒ Object
86 87 88 |
# File 'app/helpers/e9_crm/deals_helper.rb', line 86 def deal_contacts_array deal_contacts.map {|c| [c.name, c.id] } end |
#deal_date_select_options(options = {}) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'app/helpers/e9_crm/deals_helper.rb', line 49 def ( = {}) @_first_deal_date ||= Deal.order(:created_at).first.try(:created_at) || Date.today date, cdate = @_first_deal_date, Date.today = [] if [:type] == :until prefix = 'Up to ' label = prefix + ' Now' elsif [:type] == :in_month prefix = 'Closed in ' label = 'Since Inception' else prefix = 'Since ' label = prefix + ' Inception' end begin << [date.strftime("#{prefix}%B %Y"), date.strftime('%Y/%m')] date += 1.month end while date.year <= cdate.year && date.month <= cdate.month .reverse! .unshift([label, nil]) () end |
#deal_offer_select_options ⇒ Object
41 42 43 44 45 46 47 |
# File 'app/helpers/e9_crm/deals_helper.rb', line 41 def @_deal_offer_select_options ||= begin = Offer.all.map {|c| [c.name, c.id] }.sort_by {|name, id| name.upcase } .unshift ['Any/No Offer', nil] () end end |
#deal_owner_select_options ⇒ Object
33 34 35 36 37 38 39 |
# File 'app/helpers/e9_crm/deals_helper.rb', line 33 def @_deal_owner_select_options ||= begin = deal_contacts_array .unshift ['All Responsible', nil] () end end |
#deal_status_select_options ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'app/helpers/e9_crm/deals_helper.rb', line 16 def @_deal_status_select_options ||= begin = Deal::Status::OPTIONS - %w(lead) .map! {|o| [o.titleize, o] } .unshift ['All Statuses', nil] () end end |
#title_and_or_company(contact) ⇒ Object
90 91 92 93 |
# File 'app/helpers/e9_crm/deals_helper.rb', line 90 def title_and_or_company(contact) [contact.title, contact.company_name]. map(&:presence).compact.join(' at ').html_safe end |