summaryrefslogtreecommitdiff
path: root/app/helpers/version_reports_helper.rb
blob: ced3d071820ae05ce7a1d38d039a8b272043300d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
module VersionReportsHelper

  def display_issue(issue, *options)
    text = issue.subject
    text = text.sub(/\!\!\w*/,'')
    if options.include? :tracker
      text = "#{issue.tracker} ##{issue.id} " + text
    end
    link_to text, issue_path(issue)
  end

  def hours_to_money(hours)
    "$%i" % (hours*50)
  end

  def hour_budget(issue)
    v = issue.custom_field_values.detect {|value|
      value.custom_field.name == 'Hour Budget'
    }
    if v
      v.value.to_i
    end
  end

  def hour_budget_error(issue)
    return unless @show_time
    budget = hour_budget(issue)
    if issue.total_spent_hours != budget
      if issue.total_spent_hours < budget
        content_tag :div, :class => 'flash error' do
          "%s under budget!" % l_hours(budget - issue.total_spent_hours)
        end
      elsif issue.total_spent_hours > budget
        content_tag :div, :class => 'flash warning' do
          "%s over budget!" % l_hours(issue.total_spent_hours - budget)
        end
      end
    end
  end

end