Feature #14924 » percent_utilization_in_reports.diff
config/settings.yml (working copy) | ||
---|---|---|
230 | 230 |
default: |
231 | 231 |
- '6' |
232 | 232 |
- '7' |
233 |
standard_man_hours_a_day: |
|
234 |
format: int |
|
235 |
default: 8 |
config/locales/en.yml (working copy) | ||
---|---|---|
1092 | 1092 |
description_date_from: Enter start date |
1093 | 1093 |
description_date_to: Enter end date |
1094 | 1094 |
text_repository_identifier_info: 'Only lower case letters (a-z), numbers, dashes and underscores are allowed.<br />Once saved, the identifier cannot be changed.' |
1095 |
setting_standard_man_hours_a_day: Standard man hours a day |
|
1096 |
utilization: Utilization |
app/helpers/timelog_helper.rb (working copy) | ||
---|---|---|
101 | 101 |
end |
102 | 102 |
end |
103 | 103 | |
104 |
def calculate_availability(columns, hours, period) |
|
105 |
hours = hours.to_f |
|
106 |
std_hours = Setting.standard_man_hours_a_day.to_i |
|
107 |
business_days = case columns |
|
108 |
when "week" |
|
109 |
5 |
|
110 |
when "month" |
|
111 |
period = period.split('-') |
|
112 |
year, month = period[0].to_i, period[1].to_i |
|
113 |
start_date = Date.new(year, month) |
|
114 |
TimeEntry.business_days_between start_date, start_date.end_of_month |
|
115 |
when "day" |
|
116 |
1 |
|
117 |
when "year" |
|
118 |
year = period.to_i |
|
119 |
start_date = Date.new(year) |
|
120 |
TimeEntry.business_days_between start_date, start_date.end_of_year |
|
121 |
end |
|
122 |
availability = hours/(std_hours * business_days) |
|
123 |
"%.1f" % (availability * 100) |
|
124 |
end |
|
125 | ||
126 | ||
104 | 127 |
def report_to_csv(report) |
105 | 128 |
decimal_separator = l(:general_csv_decimal_separator) |
106 | 129 |
export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv| |
app/models/time_entry.rb (working copy) | ||
---|---|---|
116 | 116 |
def editable_by?(usr) |
117 | 117 |
(usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project) |
118 | 118 |
end |
119 | ||
120 |
def self.business_days_between(date1, date2) |
|
121 |
business_days = 0 |
|
122 |
date = date2 |
|
123 |
while date >= date1 |
|
124 |
business_days += 1 unless date.saturday? or date.sunday? |
|
125 |
date = date - 1 |
|
126 |
end |
|
127 |
business_days |
|
128 |
end |
|
129 | ||
119 | 130 |
end |
app/controllers/timelog_controller.rb (working copy) | ||
---|---|---|
82 | 82 | |
83 | 83 |
@report = Redmine::Helpers::TimeReport.new(@project, @issue, params[:criteria], params[:columns], scope) |
84 | 84 | |
85 |
@show_utilization = (params[:criteria].present? and params[:criteria].include? "utilization") |
|
86 | ||
85 | 87 |
respond_to do |format| |
86 | 88 |
format.html { render :layout => !request.xhr? } |
87 | 89 |
format.csv { send_data(report_to_csv(@report), :type => 'text/csv; header=present', :filename => 'timelog.csv') } |
app/views/timelog/report.html.erb (working copy) | ||
---|---|---|
12 | 12 |
<% @report.criteria.each do |criterion| %> |
13 | 13 |
<%= hidden_field_tag 'criteria[]', criterion, :id => nil %> |
14 | 14 |
<% end %> |
15 |
<%= (hidden_field_tag 'criteria[]', "utilization", :id => nil) if @show_utilization %> |
|
16 | ||
15 | 17 |
<%= render :partial => 'timelog/date_range' %> |
16 | 18 | |
17 | 19 |
<p><label for='columns'><%= l(:label_details) %></label>: <%= select_tag 'columns', options_for_select([[l(:label_year), 'year'], |
... | ... | |
19 | 21 |
[l(:label_week), 'week'], |
20 | 22 |
[l(:label_day_plural).titleize, 'day']], @report.columns), |
21 | 23 |
:onchange => "this.form.submit();" %> |
22 | ||
23 |
<label for='criterias'><%= l(:button_add) %></label>: <%= select_tag('criteria[]', options_for_select([[]] + (@report.available_criteria.keys - @report.criteria).collect{|k| [l_or_humanize(@report.available_criteria[k][:label]), k]}), |
|
24 |
<% select_opts = [[]] + (@report.available_criteria.keys - @report.criteria).collect{|k| [l_or_humanize(@report.available_criteria[k][:label]), k]} %> |
|
25 |
<% select_opts = select_opts + [[l(:utilization), "utilization"]] if (@report.criteria.count > 0 and !@show_utilization) %> |
|
26 |
<label for='criterias'><%= l(:button_add) %></label>: <%= select_tag('criteria[]', options_for_select(select_opts), |
|
24 | 27 |
:onchange => "this.form.submit();", |
25 | 28 |
:style => 'width: 200px', |
26 | 29 |
:id => nil, |
... | ... | |
56 | 59 |
<% total = 0 -%> |
57 | 60 |
<% @report.periods.each do |period| -%> |
58 | 61 |
<% sum = sum_hours(select_hours(@report.hours, @report.columns, period.to_s)); total += sum -%> |
59 |
<td class="hours"><%= html_hours("%.2f" % sum) if sum > 0 %></td> |
|
62 |
<td class="hours"><%= html_hours("%.2f" % sum) if sum > 0 %> |
|
63 |
<% if @show_utilization and sum > 0 %> |
|
64 |
<br/> |
|
65 |
(<%= calculate_availability(@report.columns, "%.2f" % sum, period.to_s) %>%) |
|
66 |
<% end %> |
|
67 |
</td> |
|
60 | 68 |
<% end -%> |
61 | 69 |
<td class="hours"><%= html_hours("%.2f" % total) if total > 0 %></td> |
62 | 70 |
</tr> |
app/views/timelog/_report_criteria.html.erb (working copy) | ||
---|---|---|
8 | 8 |
<% total = 0 -%> |
9 | 9 |
<% @report.periods.each do |period| -%> |
10 | 10 |
<% sum = sum_hours(select_hours(hours_for_value, @report.columns, period.to_s)); total += sum -%> |
11 |
<td class="hours"><%= html_hours("%.2f" % sum) if sum > 0 %></td> |
|
11 |
<td class="hours"><%= html_hours("%.2f" % sum) if sum > 0; %> |
|
12 |
<% if @show_utilization and sum > 0 %> |
|
13 |
<br/> |
|
14 |
(<%= calculate_availability(@report.columns, "%.2f" % sum, period.to_s) %>%) |
|
15 |
<% end %> |
|
16 |
</td> |
|
12 | 17 |
<% end -%> |
13 | 18 |
<td class="hours"><%= html_hours("%.2f" % total) if total > 0 %></td> |
14 | 19 |
</tr> |
app/views/settings/_general.html.erb (working copy) | ||
---|---|---|
33 | 33 |
<p><%= setting_text_field :repositories_encodings, :size => 60 %> |
34 | 34 |
<em class="info"><%= l(:text_comma_separated) %></em></p> |
35 | 35 | |
36 | ||
37 |
<p><%= setting_text_field :standard_man_hours_a_day, :size => 6 %></p> |
|
36 | 38 |
<%= call_hook(:view_settings_general_form) %> |
37 | 39 |
</div> |
38 | 40 |
- « Previous
- 1
- 2
- 3
- 4
- Next »