OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/app/views/hooks/_view_issues_show_details_b...

59 lines
1.9 KiB

<%-
def summarized_cost_entries(cost_entries)
last_cost_type = ""
result = cost_entries.sort_by(&:id).inject(Hash.new) do |result, entry|
if entry.cost_type.id.to_s == last_cost_type
result[last_cost_type][:units] += entry.units
else
last_cost_type = entry.cost_type.id.to_s
result[last_cost_type] = {}
result[last_cost_type][:units] = entry.units
result[last_cost_type][:unit] = entry.cost_type.unit
result[last_cost_type][:unit_plural] = entry.cost_type.unit_plural
end
result
end
return "-" if result.empty?
str_array = []
options = {:class => 'icon icon-box'}
result.each do |k, v|
str_array << link_to(pluralize(v[:units], v[:unit], v[:unit_plural]), {:controller => 'costlog', :action => 'details', :project_id => @issue.project, :issue_id => @issue, :cost_type_id => k}, options)
options = {} # options apply only for first element
end
str_array.join(", ")
end
-%>
<% if @project.module_enabled? :costs_module %>
<%# Only render this partial, if the plugin is enabled for the current project %>
<tr>
<td><b><%= l(:label_cost_object) %>:</b></td>
<td><% if @issue.cost_object.nil? %>-<%else%><%= link_to h(@issue.cost_object.subject), {:controller => "cost_objects", :action => "show", :id => @issue.cost_object} %><% end %></td>
<% if User.current.allowed_to?(:view_cost_entries, @project, :for => User.current) %>
<td><b><%= l(:label_spent_units) %>:</b></td>
<td>
<%= summarized_cost_entries(@cost_entries) %>
</td>
<% end %>
</tr>
<% unless @overall_costs.nil? %>
<%
if @material_costs.nil?
label = :field_labor_costs
elsif @labor_costs.nil?
label = :field_material_costs
else
label = :field_overall_costs
end %>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><b><%= l(label) %>:</b></td>
<td><%= number_to_currency(@overall_costs) %></td>
</tr>
<% end %>
<% end %>