18
19
20
21
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
49
50
|
# File 'app/helpers/paid_up/plans_helper.rb', line 18
def plan_button(plan, text = nil, html_options = {})
data = {}
css_class = 'btn '
disabled_state = false
link = paid_up.new_plan_subscription_path(plan)
if user_signed_in?
text ||= :subscribe.l
if current_user.can_upgrade_to? plan
icon_class = 'arrow-up'
css_class += 'btn-success'
elsif current_user.can_downgrade_to? plan
icon_class = 'arrow-down'
css_class += 'btn-danger'
data[:confirm] = :are_you_sure.l
elsif current_user.is_subscribed_to? plan
icon_class = 'ok'
css_class += 'btn-disabled'
disabled_state = true
link = '#'
text = :already_subscribed.l
else icon_class = 'arrow-right'
css_class += 'btn-info'
end
else
text ||= :sign_up.l
icon_class = 'arrow-right'
css_class += 'btn-success'
end
html_options[:method] ||= :get
html_options[:disabled] ||= disabled_state
icon_button_to css_class, icon_class, text, link, html_options
end
|