reports_controller.rb
95 lines
| 3.2 KiB
| text/x-ruby
|
RubyLexer
|
r6186 | # Redmine - project management software | ||
|
r9453 | # Copyright (C) 2006-2012 Jean-Philippe Lang | ||
|
r330 | # | ||
# This program is free software; you can redistribute it and/or | ||||
# modify it under the terms of the GNU General Public License | ||||
# as published by the Free Software Foundation; either version 2 | ||||
# of the License, or (at your option) any later version. | ||||
|
r6687 | # | ||
|
r330 | # This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
# GNU General Public License for more details. | ||||
|
r6687 | # | ||
|
r330 | # You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
class ReportsController < ApplicationController | ||||
|
r1062 | menu_item :issues | ||
|
r3296 | before_filter :find_project, :authorize, :find_issue_statuses | ||
|
r330 | |||
def issue_report | ||||
|
r3282 | @trackers = @project.trackers | ||
@versions = @project.shared_versions.sort | ||||
|
r9696 | @priorities = IssuePriority.all.reverse | ||
|
r3282 | @categories = @project.issue_categories | ||
|
r6186 | @assignees = (Setting.issue_group_assignment? ? @project.principals : @project.users).sort | ||
@authors = @project.users.sort | ||||
|
r3578 | @subprojects = @project.descendants.visible | ||
|
r3290 | |||
@issues_by_tracker = Issue.by_tracker(@project) | ||||
@issues_by_version = Issue.by_version(@project) | ||||
@issues_by_priority = Issue.by_priority(@project) | ||||
@issues_by_category = Issue.by_category(@project) | ||||
@issues_by_assigned_to = Issue.by_assigned_to(@project) | ||||
@issues_by_author = Issue.by_author(@project) | ||||
@issues_by_subproject = Issue.by_subproject(@project) || [] | ||||
|
r3282 | render :template => "reports/issue_report" | ||
|
r6687 | end | ||
|
r3282 | |||
def issue_report_details | ||||
|
r330 | case params[:detail] | ||
when "tracker" | ||||
@field = "tracker_id" | ||||
|
r907 | @rows = @project.trackers | ||
|
r3290 | @data = Issue.by_tracker(@project) | ||
|
r330 | @report_title = l(:field_tracker) | ||
|
r540 | when "version" | ||
@field = "fixed_version_id" | ||||
|
r3073 | @rows = @project.shared_versions.sort | ||
|
r3290 | @data = Issue.by_version(@project) | ||
|
r540 | @report_title = l(:field_version) | ||
|
r330 | when "priority" | ||
@field = "priority_id" | ||||
|
r9696 | @rows = IssuePriority.all.reverse | ||
|
r3290 | @data = Issue.by_priority(@project) | ||
|
r330 | @report_title = l(:field_priority) | ||
when "category" | ||||
@field = "category_id" | ||||
@rows = @project.issue_categories | ||||
|
r3290 | @data = Issue.by_category(@project) | ||
|
r330 | @report_title = l(:field_category) | ||
|
r1038 | when "assigned_to" | ||
@field = "assigned_to_id" | ||||
|
r6186 | @rows = (Setting.issue_group_assignment? ? @project.principals : @project.users).sort | ||
|
r3290 | @data = Issue.by_assigned_to(@project) | ||
|
r1038 | @report_title = l(:field_assigned_to) | ||
|
r330 | when "author" | ||
@field = "author_id" | ||||
|
r6186 | @rows = @project.users.sort | ||
|
r3290 | @data = Issue.by_author(@project) | ||
|
r330 | @report_title = l(:field_author) | ||
|
r407 | when "subproject" | ||
@field = "project_id" | ||||
|
r3578 | @rows = @project.descendants.visible | ||
|
r3290 | @data = Issue.by_subproject(@project) || [] | ||
|
r407 | @report_title = l(:field_subproject) | ||
|
r330 | end | ||
|
r3282 | |||
|
r3287 | respond_to do |format| | ||
if @field | ||||
format.html {} | ||||
else | ||||
format.html { redirect_to :action => 'issue_report', :id => @project } | ||||
end | ||||
end | ||||
|
r3282 | end | ||
|
r540 | |||
|
r3296 | private | ||
def find_issue_statuses | ||||
|
r10687 | @statuses = IssueStatus.sorted.all | ||
|
r3296 | end | ||
|
r2 | end | ||