Commit 55f9a5a3 by Manon

add-column-timelog

parent 4185c2d8
/.project /.project
/vendor
/.idea /.idea
/.loadpath /.loadpath
/.powrc /.powrc
......
...@@ -66,7 +66,7 @@ class TimelogController < ApplicationController ...@@ -66,7 +66,7 @@ class TimelogController < ApplicationController
format.csv { format.csv {
# Export all entries # Export all entries
@entries = scope.to_a @entries = scope.to_a
send_data(query_to_csv(@entries, @query, params), :type => 'text/csv; header=present', :filename => 'timelog.csv') send_data(query_to_csv_timelog(@entries, @query, params), :type => 'text/csv; header=present', :filename => 'timelog.csv')
} }
end end
end end
......
...@@ -283,7 +283,7 @@ module QueriesHelper ...@@ -283,7 +283,7 @@ module QueriesHelper
end end
end end
end end
def query_to_csv(items, query, options={}) def query_to_csv(items, query, options={})
columns = query.columns columns = query.columns
...@@ -297,6 +297,22 @@ module QueriesHelper ...@@ -297,6 +297,22 @@ module QueriesHelper
end end
end end
def query_to_csv_timelog(items, query, options={})
time_entry = TimeEntry.includes(:project).find(1)
project = time_entry.project
parent_project_name = project.parent.name
columns = query.columns
Redmine::Export::CSV.generate(:encoding => params[:encoding]) do |csv|
# csv header fields
csv << ['Projet principal'] + columns.map {|c| c.caption.to_s}
# csv lines
items.each do |item|
csv << [parent_project_name] + columns.map {|c| csv_content(c, item)}
end
end
end
# Retrieve query from session or build a new query # Retrieve query from session or build a new query
def retrieve_query(klass=IssueQuery, use_session=true, options={}) def retrieve_query(klass=IssueQuery, use_session=true, options={})
session_key = klass.name.underscore.to_sym session_key = klass.name.underscore.to_sym
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment