Module: Adherent::ApplicationHelper

Defined in:
app/helpers/adherent/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#icon_to(icon_file, options = {}, html_options = {}) ⇒ Object

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
13
14
# File 'app/helpers/adherent/application_helper.rb', line 5

def icon_to(icon_file, options={}, html_options={})
  raise ArgumentError unless icon_file
  title = alt = icon_file.split('.')[0].capitalize

  html_options[:title] ||=title
  html_options[:class] ||= 'icon_menu'
  # html_options[:tabindex]= "-1"
  img_path="adherent/icones/#{icon_file}"
  link_to image_tag(img_path, :alt=> alt), options, html_options
end

#icon_to_if(condition, icon_file, options = {}, html_options = {}) ⇒ Object

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
23
24
25
# File 'app/helpers/adherent/application_helper.rb', line 16

def icon_to_if(condition, icon_file, options={}, html_options={})
  raise ArgumentError unless icon_file
  title = alt = icon_file.split('.')[0].capitalize

  html_options[:title] ||=title
  html_options[:class] ||= 'icon_menu'
  # html_options[:tabindex]= "-1"
  img_path="adherent/icones/#{icon_file}"
  link_to_if condition, image_tag(img_path, :alt=> alt), options, html_options
end

#icon_to_usersObject



37
38
39
# File 'app/helpers/adherent/application_helper.rb', line 37

def icon_to_users
  icon_to 'users.png', members_path, title:'Liste des membres' 
end

#imputation_with_actions(pay, r) ⇒ Object



51
52
53
54
55
56
57
58
59
60
# File 'app/helpers/adherent/application_helper.rb', line 51

def imputation_with_actions(pay, r)
  # on gère le cas où l'adhésion a disparu (car le membre a disparu)
  a = r.adhesion
  mem = a ? a.member : 'supprimée'
  html = ''
  html << "Adhésion #{mem} pour #{number_to_currency(r.amount, locale: :fr)}"
  html << "&nbsp;&nbsp;"
  html << "#{icon_to 'detail.png', payment_reglement_path(pay.id, r.id)}"
  html.html_safe
end

#list_imputations(payment) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'app/helpers/adherent/application_helper.rb', line 41

def list_imputations(payment)
  (:ul) do
    payment.reglements.map do |r|
      (:li) do
        imputation_with_actions(payment, r)
      end
    end.join.html_safe
  end
end

#non_impute(payment) ⇒ Object



62
63
64
# File 'app/helpers/adherent/application_helper.rb', line 62

def non_impute(payment)
  payment.amount - payment.reglements.to_a.sum(&:amount)
end

#two_decimals(montant) ⇒ Object



32
33
34
# File 'app/helpers/adherent/application_helper.rb', line 32

def two_decimals(montant)
  sprintf('%0.02f',montant) rescue  '0.00'
end

#virgule(montant) ⇒ Object

Pour transformer un montant selon le format numérique français avec deux décimales



28
29
30
# File 'app/helpers/adherent/application_helper.rb', line 28

def virgule(montant)
  ActionController::Base.helpers.number_with_precision(montant, precision:2) rescue '0,00'
end