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.6KB

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