@@ -1,168 +1,191 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class ReportsController < ApplicationController |
|
19 | 19 | layout 'base' |
|
20 | 20 | before_filter :find_project, :authorize |
|
21 | 21 | |
|
22 | 22 | def issue_report |
|
23 | 23 | @statuses = IssueStatus.find(:all, :order => 'position') |
|
24 | 24 | |
|
25 | 25 | case params[:detail] |
|
26 | 26 | when "tracker" |
|
27 | 27 | @field = "tracker_id" |
|
28 | 28 | @rows = Tracker.find :all, :order => 'position' |
|
29 | 29 | @data = issues_by_tracker |
|
30 | 30 | @report_title = l(:field_tracker) |
|
31 | 31 | render :template => "reports/issue_report_details" |
|
32 | 32 | when "priority" |
|
33 | 33 | @field = "priority_id" |
|
34 | 34 | @rows = Enumeration::get_values('IPRI') |
|
35 | 35 | @data = issues_by_priority |
|
36 | 36 | @report_title = l(:field_priority) |
|
37 | 37 | render :template => "reports/issue_report_details" |
|
38 | 38 | when "category" |
|
39 | 39 | @field = "category_id" |
|
40 | 40 | @rows = @project.issue_categories |
|
41 | 41 | @data = issues_by_category |
|
42 | 42 | @report_title = l(:field_category) |
|
43 | 43 | render :template => "reports/issue_report_details" |
|
44 | 44 | when "author" |
|
45 | 45 | @field = "author_id" |
|
46 | 46 | @rows = @project.members.collect { |m| m.user } |
|
47 | 47 | @data = issues_by_author |
|
48 | 48 | @report_title = l(:field_author) |
|
49 | 49 | render :template => "reports/issue_report_details" |
|
50 | when "subproject" | |
|
51 | @field = "project_id" | |
|
52 | @rows = @project.children | |
|
53 | @data = issues_by_subproject | |
|
54 | @report_title = l(:field_subproject) | |
|
55 | render :template => "reports/issue_report_details" | |
|
50 | 56 | else |
|
51 | 57 | @queries = @project.queries.find :all, :conditions => ["is_public=? or user_id=?", true, (logged_in_user ? logged_in_user.id : 0)] |
|
52 | 58 | @trackers = Tracker.find(:all, :order => 'position') |
|
53 | 59 | @priorities = Enumeration::get_values('IPRI') |
|
54 | 60 | @categories = @project.issue_categories |
|
55 | 61 | @authors = @project.members.collect { |m| m.user } |
|
62 | @subprojects = @project.children | |
|
56 | 63 | issues_by_tracker |
|
57 | 64 | issues_by_priority |
|
58 | 65 | issues_by_category |
|
59 | 66 | issues_by_author |
|
67 | issues_by_subproject | |
|
60 | 68 | @total_hours = @project.time_entries.sum(:hours) |
|
61 | 69 | render :template => "reports/issue_report" |
|
62 | 70 | end |
|
63 | 71 | end |
|
64 | 72 | |
|
65 | 73 | def delays |
|
66 | 74 | @trackers = Tracker.find(:all) |
|
67 | 75 | if request.get? |
|
68 | 76 | @selected_tracker_ids = @trackers.collect {|t| t.id.to_s } |
|
69 | 77 | else |
|
70 | 78 | @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array |
|
71 | 79 | end |
|
72 | 80 | @selected_tracker_ids ||= [] |
|
73 | 81 | @raw = |
|
74 | 82 | ActiveRecord::Base.connection.select_all("SELECT datediff( a.created_on, b.created_on ) as delay, count(a.id) as total |
|
75 | 83 | FROM issue_histories a, issue_histories b, issues i |
|
76 | 84 | WHERE a.status_id =5 |
|
77 | 85 | AND a.issue_id = b.issue_id |
|
78 | 86 | AND a.issue_id = i.id |
|
79 | 87 | AND i.tracker_id in (#{@selected_tracker_ids.join(',')}) |
|
80 | 88 | AND b.id = ( |
|
81 | 89 | SELECT min( c.id ) |
|
82 | 90 | FROM issue_histories c |
|
83 | 91 | WHERE b.issue_id = c.issue_id ) |
|
84 | 92 | GROUP BY delay") unless @selected_tracker_ids.empty? |
|
85 | 93 | @raw ||=[] |
|
86 | 94 | |
|
87 | 95 | @x_from = 0 |
|
88 | 96 | @x_to = 0 |
|
89 | 97 | @y_from = 0 |
|
90 | 98 | @y_to = 0 |
|
91 | 99 | @sum_total = 0 |
|
92 | 100 | @sum_delay = 0 |
|
93 | 101 | @raw.each do |r| |
|
94 | 102 | @x_to = [r['delay'].to_i, @x_to].max |
|
95 | 103 | @y_to = [r['total'].to_i, @y_to].max |
|
96 | 104 | @sum_total = @sum_total + r['total'].to_i |
|
97 | 105 | @sum_delay = @sum_delay + r['total'].to_i * r['delay'].to_i |
|
98 | 106 | end |
|
99 | 107 | end |
|
100 | 108 | |
|
101 | 109 | private |
|
102 | 110 | # Find project of id params[:id] |
|
103 | 111 | def find_project |
|
104 | 112 | @project = Project.find(params[:id]) |
|
105 | 113 | rescue ActiveRecord::RecordNotFound |
|
106 | 114 | render_404 |
|
107 | 115 | end |
|
108 | 116 | |
|
109 | 117 | def issues_by_tracker |
|
110 | 118 | @issues_by_tracker ||= |
|
111 | 119 | ActiveRecord::Base.connection.select_all("select s.id as status_id, |
|
112 | 120 | s.is_closed as closed, |
|
113 | 121 | t.id as tracker_id, |
|
114 | 122 | count(i.id) as total |
|
115 | 123 | from |
|
116 | 124 | #{Issue.table_name} i, #{IssueStatus.table_name} s, #{Tracker.table_name} t |
|
117 | 125 | where |
|
118 | 126 | i.status_id=s.id |
|
119 | 127 | and i.tracker_id=t.id |
|
120 | 128 | and i.project_id=#{@project.id} |
|
121 | 129 | group by s.id, s.is_closed, t.id") |
|
122 | 130 | end |
|
123 | 131 | |
|
124 | 132 | def issues_by_priority |
|
125 | 133 | @issues_by_priority ||= |
|
126 | 134 | ActiveRecord::Base.connection.select_all("select s.id as status_id, |
|
127 | 135 | s.is_closed as closed, |
|
128 | 136 | p.id as priority_id, |
|
129 | 137 | count(i.id) as total |
|
130 | 138 | from |
|
131 | 139 | #{Issue.table_name} i, #{IssueStatus.table_name} s, #{Enumeration.table_name} p |
|
132 | 140 | where |
|
133 | 141 | i.status_id=s.id |
|
134 | 142 | and i.priority_id=p.id |
|
135 | 143 | and i.project_id=#{@project.id} |
|
136 | 144 | group by s.id, s.is_closed, p.id") |
|
137 | 145 | end |
|
138 | 146 | |
|
139 | 147 | def issues_by_category |
|
140 | 148 | @issues_by_category ||= |
|
141 | 149 | ActiveRecord::Base.connection.select_all("select s.id as status_id, |
|
142 | 150 | s.is_closed as closed, |
|
143 | 151 | c.id as category_id, |
|
144 | 152 | count(i.id) as total |
|
145 | 153 | from |
|
146 | 154 | #{Issue.table_name} i, #{IssueStatus.table_name} s, #{IssueCategory.table_name} c |
|
147 | 155 | where |
|
148 | 156 | i.status_id=s.id |
|
149 | 157 | and i.category_id=c.id |
|
150 | 158 | and i.project_id=#{@project.id} |
|
151 | 159 | group by s.id, s.is_closed, c.id") |
|
152 | 160 | end |
|
153 | 161 | |
|
154 | 162 | def issues_by_author |
|
155 | 163 | @issues_by_author ||= |
|
156 | 164 | ActiveRecord::Base.connection.select_all("select s.id as status_id, |
|
157 | 165 | s.is_closed as closed, |
|
158 | 166 | a.id as author_id, |
|
159 | 167 | count(i.id) as total |
|
160 | 168 | from |
|
161 | 169 | #{Issue.table_name} i, #{IssueStatus.table_name} s, #{User.table_name} a |
|
162 | 170 | where |
|
163 | 171 | i.status_id=s.id |
|
164 | 172 | and i.author_id=a.id |
|
165 | 173 | and i.project_id=#{@project.id} |
|
166 | 174 | group by s.id, s.is_closed, a.id") |
|
167 | 175 | end |
|
176 | ||
|
177 | def issues_by_subproject | |
|
178 | @issues_by_subproject ||= | |
|
179 | ActiveRecord::Base.connection.select_all("select s.id as status_id, | |
|
180 | s.is_closed as closed, | |
|
181 | i.project_id as project_id, | |
|
182 | count(i.id) as total | |
|
183 | from | |
|
184 | #{Issue.table_name} i, #{IssueStatus.table_name} s | |
|
185 | where | |
|
186 | i.status_id=s.id | |
|
187 | and i.project_id IN (#{@project.children.collect{|p| p.id}.join(',')}) | |
|
188 | group by s.id, s.is_closed, i.project_id") if @project.children.any? | |
|
189 | @issues_by_subproject ||= [] | |
|
190 | end | |
|
168 | 191 | end |
@@ -1,48 +1,48 | |||
|
1 | 1 | <% if @statuses.empty? or rows.empty? %> |
|
2 | 2 | <p><i><%=l(:label_no_data)%></i></p> |
|
3 | 3 | <% else %> |
|
4 | 4 | <% col_width = 70 / (@statuses.length+3) %> |
|
5 | 5 | <table class="list"> |
|
6 | 6 | <thead><tr> |
|
7 | 7 | <th style="width:25%"></th> |
|
8 | 8 | <% for status in @statuses %> |
|
9 | 9 | <th style="text-align:left;width:<%= col_width %>%"><div class="square" style="background:#<%= status.html_color %>;"></div> <small><%= status.name %></small></th> |
|
10 | 10 | <% end %> |
|
11 | 11 | <th align="center" style="width:<%= col_width %>%"><strong><%=l(:label_open_issues_plural)%></strong></th> |
|
12 | 12 | <th align="center" style="width:<%= col_width %>%"><strong><%=l(:label_closed_issues_plural)%></strong></th> |
|
13 | 13 | <th align="center" style="width:<%= col_width %>%"><strong><%=l(:label_total)%></strong></th> |
|
14 | 14 | </tr></thead> |
|
15 | 15 | <tbody> |
|
16 | 16 | <% for row in rows %> |
|
17 | 17 | <tr class="<%= cycle("odd", "even") %>"> |
|
18 | <td><%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => @project, | |
|
18 | <td><%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)), | |
|
19 | 19 | :set_filter => 1, |
|
20 | 20 | "#{field_name}" => row.id %></td> |
|
21 | 21 | <% for status in @statuses %> |
|
22 | 22 | <td align="center"><%= link_to (aggregate data, { field_name => row.id, "status_id" => status.id }), |
|
23 | :controller => 'projects', :action => 'list_issues', :id => @project, | |
|
23 | :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)), | |
|
24 | 24 | :set_filter => 1, |
|
25 | 25 | "status_id" => status.id, |
|
26 | 26 | "#{field_name}" => row.id %></td> |
|
27 | 27 | <% end %> |
|
28 | 28 | <td align="center"><%= link_to (aggregate data, { field_name => row.id, "closed" => 0 }), |
|
29 | :controller => 'projects', :action => 'list_issues', :id => @project, | |
|
29 | :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)), | |
|
30 | 30 | :set_filter => 1, |
|
31 | 31 | "#{field_name}" => row.id, |
|
32 | 32 | "status_id" => "o" %></td> |
|
33 | 33 | <td align="center"><%= link_to (aggregate data, { field_name => row.id, "closed" => 1 }), |
|
34 | :controller => 'projects', :action => 'list_issues', :id => @project, | |
|
34 | :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)), | |
|
35 | 35 | :set_filter => 1, |
|
36 | 36 | "#{field_name}" => row.id, |
|
37 | 37 | "status_id" => "c" %></td> |
|
38 | 38 | <td align="center"><%= link_to (aggregate data, { field_name => row.id }), |
|
39 | :controller => 'projects', :action => 'list_issues', :id => @project, | |
|
39 | :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)), | |
|
40 | 40 | :set_filter => 1, |
|
41 | 41 | "#{field_name}" => row.id, |
|
42 | 42 | "status_id" => "*" %></td> |
|
43 | 43 | </tr> |
|
44 | 44 | <% end %> |
|
45 | 45 | </tbody> |
|
46 | 46 | </table> |
|
47 | 47 | <% end |
|
48 | 48 | reset_cycle %> No newline at end of file |
@@ -1,37 +1,37 | |||
|
1 | 1 | <% if @statuses.empty? or rows.empty? %> |
|
2 | 2 | <p><i><%=l(:label_no_data)%></i></p> |
|
3 | 3 | <% else %> |
|
4 | 4 | <table class="list"> |
|
5 | 5 | <thead><tr> |
|
6 | 6 | <th style="width:25%"></th> |
|
7 | 7 | <th align="center" style="width:25%"><%=l(:label_open_issues_plural)%></th> |
|
8 | 8 | <th align="center" style="width:25%"><%=l(:label_closed_issues_plural)%></th> |
|
9 | 9 | <th align="center" style="width:25%"><%=l(:label_total)%></th> |
|
10 | 10 | </tr></thead> |
|
11 | 11 | <tbody> |
|
12 | 12 | <% for row in rows %> |
|
13 | 13 | <tr class="<%= cycle("odd", "even") %>"> |
|
14 | <td><%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => @project, | |
|
14 | <td><%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)), | |
|
15 | 15 | :set_filter => 1, |
|
16 | 16 | "#{field_name}" => row.id %></td> |
|
17 | 17 | <td align="center"><%= link_to (aggregate data, { field_name => row.id, "closed" => 0 }), |
|
18 | :controller => 'projects', :action => 'list_issues', :id => @project, | |
|
18 | :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)), | |
|
19 | 19 | :set_filter => 1, |
|
20 | 20 | "#{field_name}" => row.id, |
|
21 | 21 | "status_id" => "o" %></td> |
|
22 | 22 | <td align="center"><%= link_to (aggregate data, { field_name => row.id, "closed" => 1 }), |
|
23 | :controller => 'projects', :action => 'list_issues', :id => @project, | |
|
23 | :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)), | |
|
24 | 24 | :set_filter => 1, |
|
25 | 25 | "#{field_name}" => row.id, |
|
26 | 26 | "status_id" => "c" %></td> |
|
27 | 27 | <td align="center"><%= link_to (aggregate data, { field_name => row.id }), |
|
28 | :controller => 'projects', :action => 'list_issues', :id => @project, | |
|
28 | :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)), | |
|
29 | 29 | :set_filter => 1, |
|
30 | 30 | "#{field_name}" => row.id, |
|
31 | 31 | "status_id" => "*" %></td> |
|
32 | 32 | </tr> |
|
33 | 33 | <% end %> |
|
34 | 34 | </tbody> |
|
35 | 35 | </table> |
|
36 | 36 | <% end |
|
37 | 37 | reset_cycle %> No newline at end of file |
@@ -1,43 +1,48 | |||
|
1 | 1 | <h2><%=l(:label_report_plural)%></h2> |
|
2 | 2 | |
|
3 | 3 | <div class="splitcontentleft"> |
|
4 | 4 | <div class="contextual"> |
|
5 | 5 | <%= link_to_if_authorized l(:label_query_new), {:controller => 'projects', :action => 'add_query', :id => @project}, :class => 'icon icon-add' %> |
|
6 | 6 | </div> |
|
7 | 7 | <h3><%= l(:label_query_plural) %></h3> |
|
8 | 8 | |
|
9 | 9 | <% if @queries.empty? %><p><i><%=l(:label_no_data)%></i></p><% end %> |
|
10 | 10 | <ul> |
|
11 | 11 | <% @queries.each do |query| %> |
|
12 | 12 | <li><%= link_to query.name, :controller => 'projects', :action => 'list_issues', :id => @project, :query_id => query %></li> |
|
13 | 13 | <% end %> |
|
14 | 14 | </ul> |
|
15 | 15 | </div> |
|
16 | 16 | <div class="splitcontentright"> |
|
17 | 17 | <% if @total_hours %> |
|
18 | 18 | <h3 class="textright"><%= l(:label_spent_time) %>: |
|
19 | 19 | <%= link_to(lwr(:label_f_hour, @total_hours), {:controller => 'timelog', :action => 'details', :project_id => @project}, :class => 'icon icon-time') %> |
|
20 | 20 | </h3> |
|
21 | 21 | <% end %> |
|
22 | 22 | </div> |
|
23 | 23 | |
|
24 | 24 | <div class="clear"></div> |
|
25 | 25 | |
|
26 | 26 | <div class="splitcontentleft"> |
|
27 | 27 | <h3><%=l(:field_tracker)%> <%= link_to image_tag('zoom_in.png'), :detail => 'tracker' %></h3> |
|
28 | 28 | <%= render :partial => 'simple', :locals => { :data => @issues_by_tracker, :field_name => "tracker_id", :rows => @trackers } %> |
|
29 | 29 | <br /> |
|
30 | 30 | <h3><%=l(:field_author)%> <%= link_to image_tag('zoom_in.png'), :detail => 'author' %></h3> |
|
31 | 31 | <%= render :partial => 'simple', :locals => { :data => @issues_by_author, :field_name => "author_id", :rows => @authors } %> |
|
32 | 32 | <br /> |
|
33 | 33 | </div> |
|
34 | 34 | |
|
35 | 35 | <div class="splitcontentright"> |
|
36 | 36 | <h3><%=l(:field_priority)%> <%= link_to image_tag('zoom_in.png'), :detail => 'priority' %></h3> |
|
37 | 37 | <%= render :partial => 'simple', :locals => { :data => @issues_by_priority, :field_name => "priority_id", :rows => @priorities } %> |
|
38 | 38 | <br /> |
|
39 | <% if @project.children.any? %> | |
|
40 | <h3><%=l(:field_subproject)%> <%= link_to image_tag('zoom_in.png'), :detail => 'subproject' %></h3> | |
|
41 | <%= render :partial => 'simple', :locals => { :data => @issues_by_subproject, :field_name => "project_id", :rows => @subprojects } %> | |
|
42 | <br /> | |
|
43 | <% end %> | |
|
39 | 44 | <h3><%=l(:field_category)%> <%= link_to image_tag('zoom_in.png'), :detail => 'category' %></h3> |
|
40 | 45 | <%= render :partial => 'simple', :locals => { :data => @issues_by_category, :field_name => "category_id", :rows => @categories } %> |
|
41 | 46 | <br /> |
|
42 | 47 | </div> |
|
43 | 48 |
General Comments 0
You need to be logged in to leave comments.
Login now