fix #3645 for details excel export

git-svn-id: https://dev.finn.de/svn/cockpit/branches/deployment_merge@2118 7926756e-e54e-46e6-9721-ed318f58905e
pull/6827/head
t.felgentreff 14 years ago
parent 469e718a57
commit 3a78ba60b0
  1. 3
      lib/xls_report/cost_reports_controller_patch.rb
  2. 26
      lib/xls_report/xls_views/cost_entry_table.xls.rb

@ -39,8 +39,7 @@ if require_dependency 'cost_reports_controller'
options = { :query => @query, :project => @project, :cost_types => @cost_types }
if @query.group_bys.empty?
set_cost_types # honor the selected tab in detail table, because it's shorter
sb = CostEntryTable.generate(options.merge :cost_type => @cost_type, :unit_id => @unit_id)
sb = CostEntryTable.generate(options)
else
if @query.depth_of(:column) == 0 || @query.depth_of(:row) == 0
@query.depth_of(:column) == 0 ? @query.column(:singleton_value) : @query.row(:singleton_value)

@ -2,12 +2,31 @@ require_dependency 'xls_report/xls_views'
class CostEntryTable < XlsViews
def generate
spreadsheet = SpreadsheetBuilder.new(cost_type_label(@unit_id))
spreadsheet = SpreadsheetBuilder.new(l(:label_money))
default_query = @query.serialize
available_cost_type_tabs(options[:cost_types]).each_with_index do |ary, idx|
@query = CostQuery.deserialize(default_query)
@unit_id = ary.first
name = ary.last
if @unit_id != 0
@query.filter :cost_type_id, :operator => '=', :value => @unit_id.to_s
@cost_type = CostType.find(unit_id) if unit_id > 0
end
spreadsheet.worksheet(idx, name)
build_spreadsheet(spreadsheet)
end
spreadsheet
end
def build_spreadsheet(spreadsheet)
spreadsheet.add_title("#{@project.name + " >> " if @project}#{l(:cost_reports_title)} (#{format_date(Date.today)})")
list = [:spent_on, :user_id, :activity_id, :issue_id, :comments, :project_id]
headers = list.collect {|field| label_for(field) }
headers << (cost_type.try(:unit_plural) || l(:units))
headers << (cost_type.try(:unit_plural) || (@unit_id == -1 ? l(:caption_labor) : l(:units)))
headers << l(:field_costs)
spreadsheet.add_headers(headers)
@ -16,7 +35,8 @@ class CostEntryTable < XlsViews
query.each_direct_result do |result|
row = list.collect {|field| show_field field, result.fields[field.to_s] }
row << show_result(result, result.fields['cost_type_id'].to_i, true)
current_cost_type_id = result.fields['cost_type_id'].to_i
row << show_result(result, current_cost_type_id, current_cost_type_id != @unit_id)
row << show_result(result, 0) # currency
spreadsheet.add_row(row)
end

Loading…
Cancel
Save