Adds custom fields to the time entries csv export.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1690 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
898fac293b
commit
f54c2d812d
|
@ -53,6 +53,7 @@ module TimelogHelper
|
||||||
def entries_to_csv(entries)
|
def entries_to_csv(entries)
|
||||||
ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
|
ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
|
||||||
decimal_separator = l(:general_csv_decimal_separator)
|
decimal_separator = l(:general_csv_decimal_separator)
|
||||||
|
custom_fields = TimeEntryCustomField.find(:all)
|
||||||
export = StringIO.new
|
export = StringIO.new
|
||||||
CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
|
CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
|
||||||
# csv header fields
|
# csv header fields
|
||||||
|
@ -66,6 +67,9 @@ module TimelogHelper
|
||||||
l(:field_hours),
|
l(:field_hours),
|
||||||
l(:field_comments)
|
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 << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
|
||||||
# csv lines
|
# csv lines
|
||||||
entries.each do |entry|
|
entries.each do |entry|
|
||||||
|
@ -79,6 +83,8 @@ module TimelogHelper
|
||||||
entry.hours.to_s.gsub('.', decimal_separator),
|
entry.hours.to_s.gsub('.', decimal_separator),
|
||||||
entry.comments
|
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 }
|
csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue