From f54c2d812d4d9d06827d3f5e08650f1dfd46f09e Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Tue, 22 Jul 2008 19:02:40 +0000 Subject: [PATCH] Adds custom fields to the time entries csv export. git-svn-id: http://redmine.rubyforge.org/svn/trunk@1690 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/timelog_helper.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/helpers/timelog_helper.rb b/app/helpers/timelog_helper.rb index 2c1ae528..2c1225a7 100644 --- a/app/helpers/timelog_helper.rb +++ b/app/helpers/timelog_helper.rb @@ -53,6 +53,7 @@ module TimelogHelper def entries_to_csv(entries) ic = Iconv.new(l(:general_csv_encoding), 'UTF-8') decimal_separator = l(:general_csv_decimal_separator) + custom_fields = TimeEntryCustomField.find(:all) export = StringIO.new CSV::Writer.generate(export, l(:general_csv_separator)) do |csv| # csv header fields @@ -66,6 +67,9 @@ module TimelogHelper l(:field_hours), l(:field_comments) ] + # Export custom fields + headers += custom_fields.collect(&:name) + csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end } # csv lines entries.each do |entry| @@ -79,6 +83,8 @@ module TimelogHelper entry.hours.to_s.gsub('.', decimal_separator), entry.comments ] + fields += custom_fields.collect {|f| show_value(entry.custom_value_for(f)) } + csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end } end end