Browse Source

Adds custom fields to the time entries csv export.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1690 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/0.8.0-RC1
Jean-Philippe Lang 16 years ago
parent
commit
f54c2d812d
1 changed files with 6 additions and 0 deletions
  1. 6
    0
      app/helpers/timelog_helper.rb

+ 6
- 0
app/helpers/timelog_helper.rb View File

@@ -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

Loading…
Cancel
Save