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/cost_objects/_show_variable_cost_object....

130 lines
4.9 KiB

<h3><%= l(:caption_materials) %></h3>
<div style="float: left; width: 100%">
<div class="splitcontentleft">
<h4><%= l(:caption_material_budget)%></h4>
<table class="material_budget_items">
<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>
<% @cost_object.material_budget_items.each do |material_budget_item| %>
<tr>
<td class="units"><%=h pluralize(material_budget_item.units, material_budget_item.cost_type.unit, material_budget_item.cost_type.unit_plural) %></td>
<td><%=h material_budget_item.cost_type.name %></td>
<td class="comments"><%=h material_budget_item.comments %></td>
<td class="currency"><%= number_to_currency(material_budget_item.costs) %></td>
</tr>
<% end %>
<tr><td colspan="4" class="currency"><strong><%= number_to_currency(@cost_object.material_budget) %></strong></td></tr>
</tbody>
</table>
</div>
<div class="splitcontentright">
<h4><%= l(:caption_material_costs) %></h4>
<table class="material_budget_items">
<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>
<% @cost_object.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, :cost_object => @cost_object, :overridden_costs => 0.0, :units => 0)
results[entry.cost_type.id.to_s] = result
end
result.overridden_costs += entry.real_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.real_costs) %></td>
</tr>
<% end %>
<% end %>
<tr><td colspan="4" class="currency"><strong><%= number_to_currency(@cost_object.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="labor_budget_items">
<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>
<% @cost_object.labor_budget_items.each do |labor_budget_item| %>
<tr>
<td class="hours"><%= labor_budget_item.hours %>h</td>
<td><%=h labor_budget_item.user.name %></td>
<td class="comments"><%=h labor_budget_item.comments %></td>
<td class="currency"><%= number_to_currency(labor_budget_item.costs) %></td>
</tr>
<% end %>
<% if User.current.allowed_to?(:view_all_rates, @project) %>
<tr><td colspan="4" class="currency"><strong><%= number_to_currency(@cost_object.labor_budget) %></strong></td></tr>
<% end %>
</tbody>
</table>
</div>
<div class="splitcontentright">
<h4><%= l(:caption_labor_costs) %></h4>
<table class="labor_budget_items">
<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>
<% @cost_object.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, :overridden_costs => 0, :hours => 0)
results[entry.user.id.to_s] = result
end
result.overridden_costs += entry.real_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.real_costs) %></td>
</tr>
<% end %>
<% end %>
<tr><td colspan="4" class="currency"><strong><%= number_to_currency(@cost_object.spent_labor) %></strong></td></tr>
</tbody>
</table>
</div>
<div style="clear: both"></div>