Module: AccountsHelper
- Defined in:
- app/helpers/accounts_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
-
#account_category_checkbox(category, count) ⇒ Object
Sidebar checkbox control for filtering accounts by category.
-
#account_select(options = {}) ⇒ Object
Generates a select list with the first 25 accounts and prepends the currently selected account, if any.
-
#account_select_or_create(form) {|options| ... } ⇒ Object
Select an existing account or create a new one.
-
#account_summary(account) ⇒ Object
Quick account summary for RSS/ATOM feeds.
-
#account_with_title_and_department(contact) ⇒ Object
Output account with title and department - a helper so it is easy to override in plugins that allow for several accounts —————————————————————————-.
-
#account_with_url_for(contact) ⇒ Object
Output account url for a given contact - a helper so it is easy to override in plugins that allow for several accounts —————————————————————————-.
-
#brief_account_info(contact) ⇒ Object
“title, department at Account name” used in index_brief and index_long - a helper so it is easy to override in plugins that allow for several accounts —————————————————————————-.
Instance Method Details
#account_category_checkbox(category, count) ⇒ Object
Sidebar checkbox control for filtering accounts by category.
11 12 13 |
# File 'app/helpers/accounts_helper.rb', line 11 def account_category_checkbox(category, count) entity_filter_checkbox(:category, category, count) end |
#account_select(options = {}) ⇒ Object
Generates a select list with the first 25 accounts and prepends the currently selected account, if any.
28 29 30 31 32 33 34 35 36 |
# File 'app/helpers/accounts_helper.rb', line 28 def account_select( = {}) [:selected] = @account&.id || 0 accounts = ([@account.new_record? ? nil : @account] + Account.my(current_user).order(:name).limit(25)).compact.uniq collection_select :account, :id, accounts, :id, :name, { include_blank: true }, style: 'width:330px;', class: 'select2', placeholder: t(:select_an_account), "data-url": auto_complete_accounts_path(format: 'json') end |
#account_select_or_create(form) {|options| ... } ⇒ Object
Select an existing account or create a new one.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/helpers/accounts_helper.rb', line 40 def account_select_or_create(form, &_block) = {} yield if block_given? content_tag(:div, class: 'label') do t(:account).html_safe + content_tag(:span, id: 'account_create_title') do " (#{t :create_new} #{t :or} <a href='#' onclick='crm.show_select_account(); return false;'>#{t :select_existing}</a>):".html_safe end + content_tag(:span, id: 'account_select_title') do " (<a href='#' onclick='crm.show_create_account(); return false;'>#{t :create_new}</a> #{t :or} #{t :select_existing}):".html_safe end + content_tag(:span, ':', id: 'account_disabled_title') end + account_select() + form.text_field(:name, style: 'width:324px; display:none;') end |
#account_summary(account) ⇒ Object
Quick account summary for RSS/ATOM feeds.
17 18 19 20 21 22 23 |
# File 'app/helpers/accounts_helper.rb', line 17 def account_summary(account) [number_to_currency(account.opportunities.pipeline.map(&:weighted_amount).sum, precision: 0), t(:added_by, time_ago: time_ago_in_words(account.created_at), user: account.user_id_full_name), t('pluralize.contact', account.contacts_count), t('pluralize.opportunity', account.opportunities_count), t('pluralize.comment', account.comments.count)].join(', ') end |
#account_with_title_and_department(contact) ⇒ Object
Output account with title and department
-
a helper so it is easy to override in plugins that allow for several accounts
68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/helpers/accounts_helper.rb', line 68 def account_with_title_and_department(contact) text = if !contact.title.blank? && contact.account # works_at: "{{h(job_title)}} at {{h(company)}}" content_tag :div, t(:works_at, job_title: h(contact.title), company: h(account_with_url_for(contact))).html_safe elsif !contact.title.blank? content_tag :div, h(contact.title) elsif contact.account content_tag :div, account_with_url_for(contact) else "" end text += t(:department_small, h(contact.department)) unless contact.department.blank? text end |
#account_with_url_for(contact) ⇒ Object
Output account url for a given contact
-
a helper so it is easy to override in plugins that allow for several accounts
61 62 63 |
# File 'app/helpers/accounts_helper.rb', line 61 def account_with_url_for(contact) contact.account ? link_to(h(contact.account.name), account_path(contact.account)) : "" end |
#brief_account_info(contact) ⇒ Object
“title, department at Account name” used in index_brief and index_long
-
a helper so it is easy to override in plugins that allow for several accounts
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'app/helpers/accounts_helper.rb', line 86 def brief_account_info(contact) text = "" title = contact.title department = contact.department account = contact.account account_text = "" account_text = link_to_if(can?(:read, account), h(account.name), account_path(account)) if account.present? text += if title.present? && department.present? t(:account_with_title_department, title: h(title), department: h(department), account: account_text) elsif title.present? t(:account_with_title, title: h(title), account: account_text) elsif department.present? t(:account_with_title, title: h(department), account: account_text) elsif account_text.present? t(:works_at, job_title: "", company: account_text) else "" end text.html_safe end |