Module: OpportunitiesHelper
- Defined in:
- app/helpers/opportunities_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
-
#opportunity_campaign_select(options = {}) ⇒ Object
Generates a select list with the first 25 campaigns and prepends the currently selected campaign, if any.
-
#opportunity_revenue_message(opportunity, detailed = false) ⇒ Object
Generates the inline revenue message for the opportunity list table.
-
#opportunity_stage_checkbox(stage, count) ⇒ Object
Sidebar checkbox control for filtering opportunities by stage.
-
#opportunity_summary(opportunity) ⇒ Object
Opportunity summary for RSS/ATOM feeds.
Instance Method Details
#opportunity_campaign_select(options = {}) ⇒ Object
Generates a select list with the first 25 campaigns and prepends the currently selected campaign, if any.
39 40 41 42 43 44 45 46 47 48 |
# File 'app/helpers/opportunities_helper.rb', line 39 def opportunity_campaign_select( = {}) [:selected] ||= @opportunity.campaign_id.to_i selected_campaign = Campaign.find_by_id([:selected]) campaigns = ([selected_campaign] + Campaign.my(current_user).order(:name).limit(25)).compact.uniq collection_select :opportunity, :campaign_id, campaigns, :id, :name, { selected: [:selected], prompt: t(:select_a_campaign), include_blank: true }, style: 'width:330px;', class: 'select2', placeholder: t(:select_a_campaign), "data-url": auto_complete_campaigns_path(format: 'json') end |
#opportunity_revenue_message(opportunity, detailed = false) ⇒ Object
Generates the inline revenue message for the opportunity list table.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/helpers/opportunities_helper.rb', line 52 def (opportunity, detailed = false) msg = [] won_or_lost = %w[won lost].include?(opportunity.stage) msg << content_tag(:b, number_to_currency(opportunity.weighted_amount, precision: 0)) if opportunity.weighted_amount != 0 unless won_or_lost if detailed msg << number_to_currency(opportunity.amount.to_f, precision: 0) if opportunity.amount.to_f != 0 msg << t(:discount) + ' ' + number_to_currency(opportunity.discount, precision: 0) if opportunity.discount.to_f != 0 end msg << t(:probability) + ' ' + opportunity.probability.to_s + '%' if opportunity.probability.to_i != 0 end msg << (opportunity, won_or_lost) msg.join(' | ').html_safe end |
#opportunity_stage_checkbox(stage, count) ⇒ Object
Sidebar checkbox control for filtering opportunities by stage.
11 12 13 |
# File 'app/helpers/opportunities_helper.rb', line 11 def opportunity_stage_checkbox(stage, count) entity_filter_checkbox(:stage, stage, count) end |
#opportunity_summary(opportunity) ⇒ Object
Opportunity summary for RSS/ATOM feeds.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/helpers/opportunities_helper.rb', line 17 def opportunity_summary(opportunity) summary = [] amount = [] summary << (opportunity.stage ? t(opportunity.stage) : t(:other)) summary << number_to_currency(opportunity.weighted_amount, precision: 0) unless %w[won lost].include?(opportunity.stage) amount << number_to_currency(opportunity.amount.to_f, precision: 0) amount << (opportunity.discount ? t(:discount_number, number_to_currency(opportunity.discount, precision: 0)) : t(:no_discount)) amount << t(:probability_number, opportunity.probability.to_i.to_s + '%') summary << amount.join(' ') end summary << if opportunity.closes_on t(:closing_date, l(opportunity.closes_on, format: :mmddyy)) else t(:no_closing_date) end summary.compact.join(', ') end |