Feature #9994 » timelog_report_links_patch.1.5.diff
| .gitignore | ||
|---|---|---|
|
/Gemfile.lock
|
||
|
/Gemfile.local
|
||
|
/nbproject/private/
|
||
| app/helpers/timelog_helper.rb | ||
|---|---|---|
|
export
|
||
|
end
|
||
|
def format_criteria_value(criteria_options, value)
|
||
|
def format_criteria_value(criteria_options, value, links = false)
|
||
|
if value.blank?
|
||
|
"[#{l(:label_none)}]"
|
||
|
elsif k = criteria_options[:klass]
|
||
|
obj = k.find_by_id(value.to_i)
|
||
|
if obj.is_a?(Issue)
|
||
|
obj.visible? ? "#{obj.tracker} ##{obj.id}: #{obj.subject}" : "##{obj.id}"
|
||
|
if links && (obj.respond_to?('visible?') && obj.visible? || obj.is_a?(User))
|
||
|
link_to(h(obj.to_s), obj)
|
||
|
else
|
||
|
obj
|
||
|
end
|
||
| ... | ... | |
|
format_value(value, criteria_options[:format])
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def criteria_date_range(period, value)
|
||
|
from, to = nil, nil
|
||
|
case period
|
||
|
when 'day'
|
||
|
from = to = value
|
||
|
when 'week'
|
||
|
from = Date.commercial(value.split('-')[0].to_f, value.split('-')[1].to_f, 1); to = from + 6
|
||
|
when 'month'
|
||
|
from = Date.civil(value.split('-')[0].to_f, value.split('-')[1].to_f, 1); to = (from >> 1) - 1
|
||
|
when 'year'
|
||
|
from = Date.civil(value.split('-')[0].to_f, 1, 1); to = Date.civil(value.split('-')[0].to_f, 12, 31)
|
||
|
end
|
||
|
from = params[:from].to_s.to_date if !params[:from].blank? && params[:from].to_s.to_date > from.to_date
|
||
|
to = params[:to].to_s.to_date if !params[:to].blank? && params[:to].to_s.to_date < to.to_date
|
||
|
return {:from => from, :to => to}
|
||
|
end
|
||
|
def report_to_csv(report)
|
||
|
decimal_separator = l(:general_csv_decimal_separator)
|
||
| app/views/timelog/_report_criteria.html.erb | ||
|---|---|---|
|
<% @report.hours.collect {|h| h[criterias[level]].to_s}.uniq.each do |value| %>
|
||
|
<% hours_for_value = select_hours(hours, criterias[level], value) -%>
|
||
|
<% hours_for_value = grand_total ? hours: select_hours(hours, criterias[level], value) -%>
|
||
|
<% next if hours_for_value.empty? -%>
|
||
|
<tr class="<%= cycle('odd', 'even') %> <%= criterias.length > level+1 ? 'subtotal' : 'last-level' %>">
|
||
|
<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 %>">
|
||
|
<%= ("<td></td>" * level).html_safe %>
|
||
|
<td><%= h(format_criteria_value(@report.available_criteria[criterias[level]], value)) %></td>
|
||
|
<td><%= grand_total ? l(:label_total) : h(format_criteria_value(@report.available_criteria[criterias[level]], value, true)) %></td>
|
||
|
<%= ("<td></td>" * (criterias.length - level - 1)).html_safe -%>
|
||
|
<% total = 0 -%>
|
||
|
<% total = 0; criteria_values = {} if level == 0 -%>
|
||
|
<% criteria_level_values = criteria_values.merge({criterias[level].to_sym => value}) -%>
|
||
|
<% @report.periods.each do |period| -%>
|
||
|
<% sum = sum_hours(select_hours(hours_for_value, @report.columns, period.to_s)); total += sum -%>
|
||
|
<td class="hours"><%= html_hours("%.2f" % sum) if sum > 0 %></td>
|
||
|
<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>
|
||
|
<% end -%>
|
||
|
<td class="hours"><%= html_hours("%.2f" % total) if total > 0 %></td>
|
||
|
<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>
|
||
|
</tr>
|
||
|
<% break if grand_total %>
|
||
|
<% if criterias.length > level+1 -%>
|
||
|
<%= render(:partial => 'report_criteria', :locals => {:criterias => criterias, :hours => hours_for_value, :level => (level + 1)}) %>
|
||
|
<%= 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}) %>
|
||
|
<% end -%>
|
||
|
<% end %>
|
||
| app/views/timelog/report.html.erb | ||
|---|---|---|
|
</tr>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
<%= render :partial => 'report_criteria', :locals => {:criterias => @report.criteria, :hours => @report.hours, :level => 0} %>
|
||
|
<tr class="total">
|
||
|
<td><%= l(:label_total) %></td>
|
||
|
<%= ('<td></td>' * (@report.criteria.size - 1)).html_safe %>
|
||
|
<% total = 0 -%>
|
||
|
<% @report.periods.each do |period| -%>
|
||
|
<% sum = sum_hours(select_hours(@report.hours, @report.columns, period.to_s)); total += sum -%>
|
||
|
<td class="hours"><%= html_hours("%.2f" % sum) if sum > 0 %></td>
|
||
|
<% end -%>
|
||
|
<td class="hours"><%= html_hours("%.2f" % total) if total > 0 %></td>
|
||
|
</tr>
|
||
|
<%= render :partial => 'report_criteria', :locals => {:criterias => @report.criteria, :hours => @report.hours, :level => 0, :grand_total => false} %>
|
||
|
<%= render :partial => 'report_criteria', :locals => {:criterias => @report.criteria, :hours => @report.hours, :level => 0, :grand_total => true} %>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
| lib/redmine/helpers/time_report.rb | ||
|---|---|---|
|
end
|
||
|
def load_available_criteria
|
||
|
@available_criteria = { 'project' => {:sql => "#{TimeEntry.table_name}.project_id",
|
||
|
@available_criteria = { 'project_id' => {:sql => "#{TimeEntry.table_name}.project_id",
|
||
|
:klass => Project,
|
||
|
:label => :label_project},
|
||
|
'status' => {:sql => "#{Issue.table_name}.status_id",
|
||
|
'status_id' => {:sql => "#{Issue.table_name}.status_id",
|
||
|
:klass => IssueStatus,
|
||
|
:label => :field_status},
|
||
|
'version' => {:sql => "#{Issue.table_name}.fixed_version_id",
|
||
|
'version_id' => {:sql => "#{Issue.table_name}.fixed_version_id",
|
||
|
:klass => Version,
|
||
|
:label => :label_version},
|
||
|
'category' => {:sql => "#{Issue.table_name}.category_id",
|
||
|
'category_id' => {:sql => "#{Issue.table_name}.category_id",
|
||
|
:klass => IssueCategory,
|
||
|
:label => :field_category},
|
||
|
'user' => {:sql => "#{TimeEntry.table_name}.user_id",
|
||
|
'user_id' => {:sql => "#{TimeEntry.table_name}.user_id",
|
||
|
:klass => User,
|
||
|
:label => :label_user},
|
||
|
'tracker' => {:sql => "#{Issue.table_name}.tracker_id",
|
||
|
'tracker_id' => {:sql => "#{Issue.table_name}.tracker_id",
|
||
|
:klass => Tracker,
|
||
|
:label => :label_tracker},
|
||
|
'activity' => {:sql => "#{TimeEntry.table_name}.activity_id",
|
||
|
'activity_id' => {:sql => "#{TimeEntry.table_name}.activity_id",
|
||
|
:klass => TimeEntryActivity,
|
||
|
:label => :label_activity},
|
||
|
'issue' => {:sql => "#{TimeEntry.table_name}.issue_id",
|
||
|
'issue_id' => {:sql => "#{TimeEntry.table_name}.issue_id",
|
||
|
:klass => Issue,
|
||
|
:label => :label_issue}
|
||
|
}
|
||
- « Previous
- 1
- …
- 5
- 6
- 7
- Next »