diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-04-09 17:45:39 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-04-09 17:45:39 +0000 |
commit | a3c89d4f697e958956e129b6bc5f564c9197a89c (patch) | |
tree | 7d08d8df3dcc7c822650fda850e3c28fcf3656a6 /app/helpers/timelog_helper.rb | |
parent | f025b16be747bf7ab7b1cae470eca28b77f7ada9 (diff) | |
download | redmine-a3c89d4f697e958956e129b6bc5f564c9197a89c.tar.gz redmine-a3c89d4f697e958956e129b6bc5f564c9197a89c.zip |
Custom fields (list and boolean) can be used as criteria in time report (#1012).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1340 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers/timelog_helper.rb')
-rw-r--r-- | app/helpers/timelog_helper.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/helpers/timelog_helper.rb b/app/helpers/timelog_helper.rb index e0459581d..db13556a1 100644 --- a/app/helpers/timelog_helper.rb +++ b/app/helpers/timelog_helper.rb @@ -77,6 +77,10 @@ module TimelogHelper export end + def format_criteria_value(criteria, value) + value.blank? ? l(:label_none) : ((k = @available_criterias[criteria][:klass]) ? k.find_by_id(value.to_i) : format_value(value, @available_criterias[criteria][:format])) + end + def report_to_csv(criterias, periods, hours) export = StringIO.new CSV::Writer.generate(export, l(:general_csv_separator)) do |csv| @@ -103,11 +107,11 @@ module TimelogHelper end def report_criteria_to_csv(csv, criterias, periods, hours, level=0) - hours.collect {|h| h[criterias[level]]}.uniq.each do |value| + hours.collect {|h| h[criterias[level]].to_s}.uniq.each do |value| hours_for_value = select_hours(hours, criterias[level], value) next if hours_for_value.empty? row = [''] * level - row << to_utf8(value.nil? ? l(:label_none) : @available_criterias[criterias[level]][:klass].find_by_id(value)) + row << to_utf8(format_criteria_value(criterias[level], value)) row += [''] * (criterias.length - level - 1) total = 0 periods.each do |period| |