Feature #9994 » timelog_report_links_patch.1.5.diff
| .gitignore | ||
|---|---|---|
| 32 | 32 |
/Gemfile.lock |
| 33 | 33 |
/Gemfile.local |
| 34 | 34 | |
| 35 |
/nbproject/private/ |
|
| app/helpers/timelog_helper.rb | ||
|---|---|---|
| 129 | 129 |
export |
| 130 | 130 |
end |
| 131 | 131 | |
| 132 |
def format_criteria_value(criteria_options, value) |
|
| 132 |
def format_criteria_value(criteria_options, value, links = false)
|
|
| 133 | 133 |
if value.blank? |
| 134 | 134 |
"[#{l(:label_none)}]"
|
| 135 | 135 |
elsif k = criteria_options[:klass] |
| 136 | 136 |
obj = k.find_by_id(value.to_i) |
| 137 |
if obj.is_a?(Issue)
|
|
| 138 |
obj.visible? ? "#{obj.tracker} ##{obj.id}: #{obj.subject}" : "##{obj.id}"
|
|
| 137 |
if links && (obj.respond_to?('visible?') && obj.visible? || obj.is_a?(User))
|
|
| 138 |
link_to(h(obj.to_s), obj)
|
|
| 139 | 139 |
else |
| 140 | 140 |
obj |
| 141 | 141 |
end |
| ... | ... | |
| 143 | 143 |
format_value(value, criteria_options[:format]) |
| 144 | 144 |
end |
| 145 | 145 |
end |
| 146 |
|
|
| 147 |
def criteria_date_range(period, value) |
|
| 148 |
from, to = nil, nil |
|
| 149 |
case period |
|
| 150 |
when 'day' |
|
| 151 |
from = to = value |
|
| 152 |
when 'week' |
|
| 153 |
from = Date.commercial(value.split('-')[0].to_f, value.split('-')[1].to_f, 1); to = from + 6
|
|
| 154 |
when 'month' |
|
| 155 |
from = Date.civil(value.split('-')[0].to_f, value.split('-')[1].to_f, 1); to = (from >> 1) - 1
|
|
| 156 |
when 'year' |
|
| 157 |
from = Date.civil(value.split('-')[0].to_f, 1, 1); to = Date.civil(value.split('-')[0].to_f, 12, 31)
|
|
| 158 |
end |
|
| 159 |
from = params[:from].to_s.to_date if !params[:from].blank? && params[:from].to_s.to_date > from.to_date |
|
| 160 |
to = params[:to].to_s.to_date if !params[:to].blank? && params[:to].to_s.to_date < to.to_date |
|
| 161 |
return {:from => from, :to => to}
|
|
| 162 |
end |
|
| 146 | 163 | |
| 147 | 164 |
def report_to_csv(report) |
| 148 | 165 |
decimal_separator = l(:general_csv_decimal_separator) |
| app/views/timelog/_report_criteria.html.erb | ||
|---|---|---|
| 1 | 1 |
<% @report.hours.collect {|h| h[criterias[level]].to_s}.uniq.each do |value| %>
|
| 2 |
<% hours_for_value = select_hours(hours, criterias[level], value) -%> |
|
| 2 |
<% hours_for_value = grand_total ? hours: select_hours(hours, criterias[level], value) -%>
|
|
| 3 | 3 |
<% next if hours_for_value.empty? -%> |
| 4 |
<tr class="<%= cycle('odd', 'even') %> <%= criterias.length > level+1 ? 'subtotal' : 'last-level' %>">
|
|
| 4 |
<tr class="<%= cycle('odd', 'even') %> <%= grand_total ? 'total' : criterias.length > level+1 ? 'subtotal' : 'last-level' %> <%= 'current-users-row' if criterias[level] == 'member' && User.current.try(:id) == value.to_i %>">
|
|
| 5 | 5 |
<%= ("<td></td>" * level).html_safe %>
|
| 6 |
<td><%= h(format_criteria_value(@report.available_criteria[criterias[level]], value)) %></td>
|
|
| 6 |
<td><%= grand_total ? l(:label_total) : h(format_criteria_value(@report.available_criteria[criterias[level]], value, true)) %></td>
|
|
| 7 | 7 |
<%= ("<td></td>" * (criterias.length - level - 1)).html_safe -%>
|
| 8 |
<% total = 0 -%> |
|
| 8 |
<% total = 0; criteria_values = {} if level == 0 -%>
|
|
| 9 |
<% criteria_level_values = criteria_values.merge({criterias[level].to_sym => value}) -%>
|
|
| 9 | 10 |
<% @report.periods.each do |period| -%> |
| 10 | 11 |
<% 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>
|
|
| 12 |
<td class="hours"><%= link_to html_hours("%.2f" % sum), {:controller => 'timelog', :action => 'index'}.merge(criteria_level_values).merge(criteria_date_range(@report.columns.to_s, period)) if sum > 0 %></td>
|
|
| 12 | 13 |
<% end -%> |
| 13 |
<td class="hours"><%= html_hours("%.2f" % total) if total > 0 %></td>
|
|
| 14 |
<td class="hours"><%= (link_to html_hours("%.2f" % total), {:controller => 'timelog', :action => 'index', :period => params[:period], :from => @from, :to => @to}.merge(criteria_level_values)) if total > 0 %></td>
|
|
| 14 | 15 |
</tr> |
| 16 |
<% break if grand_total %> |
|
| 15 | 17 |
<% if criterias.length > level+1 -%> |
| 16 |
<%= render(:partial => 'report_criteria', :locals => {:criterias => criterias, :hours => hours_for_value, :level => (level + 1)}) %>
|
|
| 18 |
<%= render(:partial => 'report_criteria', :locals => {:criterias => criterias, :criteria_values => criteria_level_values.merge({criterias[level].to_sym => value}), :hours => hours_for_value, :level => (level + 1), :grand_total => false}) %>
|
|
| 17 | 19 |
<% end -%> |
| 18 | 20 | |
| 19 | 21 |
<% end %> |
| app/views/timelog/report.html.erb | ||
|---|---|---|
| 49 | 49 |
</tr> |
| 50 | 50 |
</thead> |
| 51 | 51 |
<tbody> |
| 52 |
<%= render :partial => 'report_criteria', :locals => {:criterias => @report.criteria, :hours => @report.hours, :level => 0} %>
|
|
| 53 |
<tr class="total"> |
|
| 54 |
<td><%= l(:label_total) %></td> |
|
| 55 |
<%= ('<td></td>' * (@report.criteria.size - 1)).html_safe %>
|
|
| 56 |
<% total = 0 -%> |
|
| 57 |
<% @report.periods.each do |period| -%> |
|
| 58 |
<% 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>
|
|
| 60 |
<% end -%> |
|
| 61 |
<td class="hours"><%= html_hours("%.2f" % total) if total > 0 %></td>
|
|
| 62 |
</tr> |
|
| 52 |
<%= render :partial => 'report_criteria', :locals => {:criterias => @report.criteria, :hours => @report.hours, :level => 0, :grand_total => false} %>
|
|
| 53 |
<%= render :partial => 'report_criteria', :locals => {:criterias => @report.criteria, :hours => @report.hours, :level => 0, :grand_total => true} %>
|
|
| 63 | 54 |
</tbody> |
| 64 | 55 |
</table> |
| 65 | 56 |
</div> |
| lib/redmine/helpers/time_report.rb | ||
|---|---|---|
| 98 | 98 |
end |
| 99 | 99 | |
| 100 | 100 |
def load_available_criteria |
| 101 |
@available_criteria = { 'project' => {:sql => "#{TimeEntry.table_name}.project_id",
|
|
| 101 |
@available_criteria = { 'project_id' => {:sql => "#{TimeEntry.table_name}.project_id",
|
|
| 102 | 102 |
:klass => Project, |
| 103 | 103 |
:label => :label_project}, |
| 104 |
'status' => {:sql => "#{Issue.table_name}.status_id",
|
|
| 104 |
'status_id' => {:sql => "#{Issue.table_name}.status_id",
|
|
| 105 | 105 |
:klass => IssueStatus, |
| 106 | 106 |
:label => :field_status}, |
| 107 |
'version' => {:sql => "#{Issue.table_name}.fixed_version_id",
|
|
| 107 |
'version_id' => {:sql => "#{Issue.table_name}.fixed_version_id",
|
|
| 108 | 108 |
:klass => Version, |
| 109 | 109 |
:label => :label_version}, |
| 110 |
'category' => {:sql => "#{Issue.table_name}.category_id",
|
|
| 110 |
'category_id' => {:sql => "#{Issue.table_name}.category_id",
|
|
| 111 | 111 |
:klass => IssueCategory, |
| 112 | 112 |
:label => :field_category}, |
| 113 |
'user' => {:sql => "#{TimeEntry.table_name}.user_id",
|
|
| 113 |
'user_id' => {:sql => "#{TimeEntry.table_name}.user_id",
|
|
| 114 | 114 |
:klass => User, |
| 115 | 115 |
:label => :label_user}, |
| 116 |
'tracker' => {:sql => "#{Issue.table_name}.tracker_id",
|
|
| 116 |
'tracker_id' => {:sql => "#{Issue.table_name}.tracker_id",
|
|
| 117 | 117 |
:klass => Tracker, |
| 118 | 118 |
:label => :label_tracker}, |
| 119 |
'activity' => {:sql => "#{TimeEntry.table_name}.activity_id",
|
|
| 119 |
'activity_id' => {:sql => "#{TimeEntry.table_name}.activity_id",
|
|
| 120 | 120 |
:klass => TimeEntryActivity, |
| 121 | 121 |
:label => :label_activity}, |
| 122 |
'issue' => {:sql => "#{TimeEntry.table_name}.issue_id",
|
|
| 122 |
'issue_id' => {:sql => "#{TimeEntry.table_name}.issue_id",
|
|
| 123 | 123 |
:klass => Issue, |
| 124 | 124 |
:label => :label_issue} |
| 125 | 125 |
} |
- « Previous
- 1
- …
- 5
- 6
- 7
- Next »