summaryrefslogtreecommitdiffstats
path: root/app/helpers/timelog_helper.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-07-22 19:02:40 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-07-22 19:02:40 +0000
commitf54c2d812d4d9d06827d3f5e08650f1dfd46f09e (patch)
treeafb6c90dbeb07d91a71a600c6d0bfd680b975fa6 /app/helpers/timelog_helper.rb
parent898fac293b3d8042de3c1747776fac90d3ed40fa (diff)
downloadredmine-f54c2d812d4d9d06827d3f5e08650f1dfd46f09e.tar.gz
redmine-f54c2d812d4d9d06827d3f5e08650f1dfd46f09e.zip
Adds custom fields to the time entries csv export.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1690 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers/timelog_helper.rb')
-rw-r--r--app/helpers/timelog_helper.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/app/helpers/timelog_helper.rb b/app/helpers/timelog_helper.rb
index 2c1ae5285..2c1225a7c 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