diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-09-20 09:30:41 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-09-20 09:30:41 +0000 |
commit | 41cbd239c44eb8f702d04a8b0ba25dfc381483ad (patch) | |
tree | 3b6175b2d6f65bbe5e17f3370b9eb5c1cefe7629 /app/controllers/timelog_controller.rb | |
parent | b4c55ea4dee9bf160de809a86958ddd2240b6e91 (diff) | |
download | redmine-41cbd239c44eb8f702d04a8b0ba25dfc381483ad.tar.gz redmine-41cbd239c44eb8f702d04a8b0ba25dfc381483ad.zip |
Makes timelog report work at issue level (#2935).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2893 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/timelog_controller.rb')
-rw-r--r-- | app/controllers/timelog_controller.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb index 29ba49938..ca3774bc9 100644 --- a/app/controllers/timelog_controller.rb +++ b/app/controllers/timelog_controller.rb @@ -80,14 +80,22 @@ class TimelogController < ApplicationController unless @criterias.empty? sql_select = @criterias.collect{|criteria| @available_criterias[criteria][:sql] + " AS " + criteria}.join(', ') sql_group_by = @criterias.collect{|criteria| @available_criterias[criteria][:sql]}.join(', ') + sql_condition = '' + if @project.nil? + sql_condition = Project.allowed_to_condition(User.current, :view_time_entries) + elsif @issue.nil? + sql_condition = @project.project_condition(Setting.display_subprojects_issues?) + else + sql_condition = "#{TimeEntry.table_name}.issue_id = #{@issue.id}" + end + sql = "SELECT #{sql_select}, tyear, tmonth, tweek, spent_on, SUM(hours) AS hours" sql << " FROM #{TimeEntry.table_name}" sql << " LEFT JOIN #{Issue.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id" sql << " LEFT JOIN #{Project.table_name} ON #{TimeEntry.table_name}.project_id = #{Project.table_name}.id" sql << " WHERE" - sql << " (%s) AND" % @project.project_condition(Setting.display_subprojects_issues?) if @project - sql << " (%s) AND" % Project.allowed_to_condition(User.current, :view_time_entries) + sql << " (%s) AND" % sql_condition sql << " (spent_on BETWEEN '%s' AND '%s')" % [ActiveRecord::Base.connection.quoted_date(@from.to_time), ActiveRecord::Base.connection.quoted_date(@to.to_time)] sql << " GROUP BY #{sql_group_by}, tyear, tmonth, tweek, spent_on" |