You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

reports_controller.rb 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2017 Jean-Philippe Lang
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. class ReportsController < ApplicationController
  18. menu_item :issues
  19. before_action :find_project, :authorize, :find_issue_statuses
  20. def issue_report
  21. @trackers = @project.rolled_up_trackers(false).visible
  22. @versions = @project.shared_versions.sorted
  23. @priorities = IssuePriority.all.reverse
  24. @categories = @project.issue_categories
  25. @assignees = (Setting.issue_group_assignment? ? @project.principals : @project.users).sorted
  26. @authors = @project.users.sorted
  27. @subprojects = @project.descendants.visible
  28. with_subprojects = Setting.display_subprojects_issues?
  29. @issues_by_tracker = Issue.by_tracker(@project, with_subprojects)
  30. @issues_by_version = Issue.by_version(@project, with_subprojects)
  31. @issues_by_priority = Issue.by_priority(@project, with_subprojects)
  32. @issues_by_category = Issue.by_category(@project, with_subprojects)
  33. @issues_by_assigned_to = Issue.by_assigned_to(@project, with_subprojects)
  34. @issues_by_author = Issue.by_author(@project, with_subprojects)
  35. @issues_by_subproject = Issue.by_subproject(@project) || []
  36. render :template => "reports/issue_report"
  37. end
  38. def issue_report_details
  39. with_subprojects = Setting.display_subprojects_issues?
  40. case params[:detail]
  41. when "tracker"
  42. @field = "tracker_id"
  43. @rows = @project.rolled_up_trackers(false).visible
  44. @data = Issue.by_tracker(@project, with_subprojects)
  45. @report_title = l(:field_tracker)
  46. when "version"
  47. @field = "fixed_version_id"
  48. @rows = @project.shared_versions.sorted
  49. @data = Issue.by_version(@project, with_subprojects)
  50. @report_title = l(:field_version)
  51. when "priority"
  52. @field = "priority_id"
  53. @rows = IssuePriority.all.reverse
  54. @data = Issue.by_priority(@project, with_subprojects)
  55. @report_title = l(:field_priority)
  56. when "category"
  57. @field = "category_id"
  58. @rows = @project.issue_categories
  59. @data = Issue.by_category(@project, with_subprojects)
  60. @report_title = l(:field_category)
  61. when "assigned_to"
  62. @field = "assigned_to_id"
  63. @rows = (Setting.issue_group_assignment? ? @project.principals : @project.users).sorted
  64. @data = Issue.by_assigned_to(@project, with_subprojects)
  65. @report_title = l(:field_assigned_to)
  66. when "author"
  67. @field = "author_id"
  68. @rows = @project.users.sorted
  69. @data = Issue.by_author(@project, with_subprojects)
  70. @report_title = l(:field_author)
  71. when "subproject"
  72. @field = "project_id"
  73. @rows = @project.descendants.visible
  74. @data = Issue.by_subproject(@project) || []
  75. @report_title = l(:field_subproject)
  76. else
  77. render_404
  78. end
  79. end
  80. private
  81. def find_issue_statuses
  82. @statuses = @project.rolled_up_statuses.sorted.to_a
  83. end
  84. end