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/deliverables/_show_cost_based_deliverabl...

130 lines
4.8 KiB

<h3><%= l(:caption_materials) %></h3>
<div style="float: left; width: 100%">
<div class="splitcontentleft">
<h4><%= l(:caption_material_budget)%></h4>
<table class="deliverable_costs">
<thead><tr>
<th><%= l(:caption_cost_unit_plural)%></th>
<th><%= l(:caption_cost_type) %></th>
<th><%= l(:caption_comment) %></th>
<th><%= l(:caption_budget) %></th>
</tr></thead>
<tbody>
<% @deliverable.deliverable_costs.each do |deliverable_cost| %>
<tr>
<td class="units"><%=h pluralize(deliverable_cost.units, deliverable_cost.cost_type.unit, deliverable_cost.cost_type.unit_plural) %></td>
<td><%=h deliverable_cost.cost_type.name %></td>
<td class="comments"><%=h deliverable_cost.comments %></td>
<td class="currency"><%= number_to_currency(deliverable_cost.costs) %></td>
</tr>
<% end %>
<tr><td colspan="4" class="currency"><strong><%= number_to_currency(@deliverable.material_budget) %></strong></td></tr>
</tbody>
</table>
</div>
<div class="splitcontentright">
<h4><%= l(:caption_material_costs) %></h4>
<table class="deliverable_costs">
<thead><tr>
<th><%= l(:caption_issue)%></th>
<th><%= l(:caption_cost_unit_plural) %></th>
<th><%= l(:caption_cost_type) %></th>
<th><%= l(:caption_costs) %></th>
</tr></thead>
<tbody>
<% @deliverable.issues.each do |issue|
cost_entries = issue.cost_entries.inject(Hash.new) do |results, entry|
result = results[entry.cost_type.id.to_s]
unless result
result = CostEntry.new(:cost_type => entry.cost_type, :deliverable => @deliverable, :overridden_costs => 0.0, :units => 0)
results[entry.cost_type.id.to_s] = result
end
result.costs += entry.costs
result.units += entry.units
results
end.values
cost_entries.each do |c|
%>
<tr>
<td class="subject"><%= link_to_issue issue %>: <%= h(truncate(issue.subject, 50)) -%></td>
<td><%= link_to pluralize(c.units, c.cost_type.unit, c.cost_type.unit_plural), {:controller => "costlog", :action => "details", :cost_type_id => c.cost_type, :issue_id => issue} %></td>
<td><%= c.cost_type %></td>
<td class="currency"><%= number_to_currency(c.costs) %></td>
</tr>
<% end %>
<% end %>
<tr><td colspan="4" class="currency"><strong><%= number_to_currency(@deliverable.spent_material) %></strong></td></tr>
</tbody>
</table>
</div>
</div>
<h3 style="clear:left;"><%= l(:caption_labor) %></h3>
<div class="splitcontentleft">
<h4><%= l(:caption_labor_budget)%></h4>
<table class="deliverable_hours">
<thead><tr>
<th><%= l(:field_hours)%></th>
<th><%= l(:label_user) %></th>
<th><%= l(:caption_comment) %></th>
<th><%= l(:caption_budget) %></th>
</tr></thead>
<tbody>
<% @deliverable.deliverable_hours.each do |deliverable_hour| %>
<tr>
<td class="hours"><%= deliverable_hour.hours %>h</td>
<td><%=h deliverable_hour.user.name %></td>
<td class="comments"><%=h deliverable_hour.comments %></td>
<td class="currency"><%= number_to_currency(deliverable_hour.costs) %></td>
</tr>
<% end %>
<% if User.current.allowed_to?(:view_all_rates, @project) %>
<tr><td colspan="4" class="currency"><strong><%= number_to_currency(@deliverable.labor_budget) %></strong></td></tr>
<% end %>
</tbody>
</table>
</div>
<div class="splitcontentright">
<h4><%= l(:caption_labor_costs) %></h4>
<table class="deliverable_hours">
<thead><tr>
<th><%= l(:caption_issue)%></th>
<th><%= l(:field_hours)%></th>
<th><%= l(:label_user) %></th>
<th><%= l(:caption_costs) %></th>
</tr></thead>
<tbody>
<% @deliverable.issues.each do |issue|
time_entries = issue.time_entries.inject(Hash.new) do |results, entry|
result = results[entry.user.id.to_s]
unless result
result = TimeEntry.new(:user => entry.user, :costs => 0, :hours => 0)
results[entry.user.id.to_s] = result
end
result.costs += entry.costs
result.hours += entry.hours
results
end.values
time_entries.each do |t|
%>
<tr>
<td class="subject"><%= link_to_issue issue %>: <%= h(truncate(issue.subject, 50)) -%></td>
<td class="hours"><%= link_to "#{t.hours}h", {:controller => "timelog", :action => "details", :issue_id => issue} %></td>
<td><%= t.user.name %></td>
<td class="currency"><%= number_to_currency(t.costs) %></td>
</tr>
<% end %>
<% end %>
<tr><td colspan="4" class="currency"><strong><%= number_to_currency(@deliverable.spent_labor) %></strong></td></tr>
</tbody>
</table>
</div>
<div style="clear: both"></div>