added logic to display only selected types of entries (only cost_entries, only time_entries or both)

git-svn-id: https://dev.finn.de/svn/cockpit/trunk@209 7926756e-e54e-46e6-9721-ed318f58905e
pull/6827/head
hjust 15 years ago
parent c495ca0803
commit 7e6282a404
  1. 35
      app/controllers/cost_reports_controller.rb

@ -106,11 +106,7 @@ private
def get_entries(limit)
cost_statement = @query.statement(:cost_entries)
time_statement = @query.statement(:time_entries)
@entry_count = CostEntry.count(:conditions => cost_statement) +
TimeEntry.count(:conditions => time_statement)
@entry_pages = Paginator.new self, @entry_count, limit, params['page']
# at first get the entry ids to match the current query
unless sort_clause.nil?
(sort_column, sort_order) = sort_clause.split(" ")
@ -134,7 +130,34 @@ private
time_sort_column_sql += ","
end
end
if @query.display_time_entries && !@query.display_cost_entries
@entry_count = TimeEntry.count(cost_statement)
@entry_pages = Paginator.new self, @entry_count, limit, params['page']
@entries = TimeEntry.find :all, {:order => (sort_clause if time_sort_column),
:include => [:issue, :activity, :user],
:conditions => cost_statement,
:limit => limit,
:offset => @entry_pages.current.offset}
return
elsif @query.display_cost_entries && !@query.display_time_entries
@entry_count = CostEntry.count(cost_statement)
@entry_pages = Paginator.new self, @entry_count, limit, params['page']
@entries = CostEntry.find :all, {:order => (sort_clause if cost_sort_column),
:include => [:issue, :cost_type, :user],
:conditions => cost_statement,
:limit => limit,
:offset => @entry_pages.current.offset}
return
end
@entry_count = CostEntry.count(:conditions => cost_statement) +
TimeEntry.count(:conditions => time_statement)
@entry_pages = Paginator.new self, @entry_count, limit, params['page']
# TAKE extra care for SQL injection here!!!
sql = " SELECT id, #{cost_sort_column_sql} 'cost_entry' AS entry_type"
@ -169,7 +192,7 @@ private
:conditions => {:id => cost_entry_ids}}
time_entries = TimeEntry.find :all, {:order => (sort_clause if time_sort_column),
:include => [:issue, :user],
:include => [:issue, :activity, :user],
:conditions => {:id => time_entry_ids}}

Loading…
Cancel
Save