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....

142 lines
5.5 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 list">
<thead><tr>
<th><%= l(:caption_cost_unit_plural)%></th>
<th><%= l(:caption_cost_type) %></th>
<th><%= l(:caption_comment) %></th>
<th class="currency"><%= 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"><%= material_budget_item.costs_visible_by?(User.current) ? number_to_currency(material_budget_item.costs) : "" %></td>
</tr>
<% end %>
<% if User.current.allowed_to?(:view_cost_rates, @project) %>
<tr><td colspan="4" class="currency"><strong><%= number_to_currency(@cost_object.material_budget) %></strong></td></tr>
<% end %>
</tbody>
</table>
</div>
<div class="splitcontentright">
<h4><%= l(:caption_material_costs) %></h4>
<table class="material_budget_items list">
<thead><tr>
<th><%= l(:caption_issue)%></th>
<th><%= l(:caption_cost_unit_plural) %></th>
<th><%= l(:caption_cost_type) %></th>
<th class="currency"><%= l(:caption_costs) %></th>
</tr></thead>
<tbody>
<% @cost_object.cost_entries.visible(User.current, @project).all(:include => [:cost_type]).group_by(&:issue).each do |issue, cost_entries|
entries = 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
entries.each do |c|
%>
<tr>
<td class="subject"><%= link_to_issue issue %></td>
<td><%= link_to pluralize(c.units, c.cost_type.unit, c.cost_type.unit_plural), {:controller => "costlog", :action => "index", :cost_type_id => c.cost_type, :issue_id => issue} %></td>
<td><%= c.cost_type %></td>
<td class="currency"><%= c.costs_visible_by?(User.current) ? number_to_currency(c.real_costs) : "" %></td>
</tr>
<% end %>
<% end %>
<% if User.current.allowed_to?(:view_cost_rates, @project) %>
<tr><td colspan="4" class="currency"><strong><%= number_to_currency(@cost_object.spent_material) %></strong></td></tr>
<% end %>
</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 list">
<thead><tr>
<th><%= l(:field_hours)%></th>
<th><%= l(:label_user) %></th>
<th><%= l(:caption_comment) %></th>
<th class="currency"><%= 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>
<% if labor_budget_item.costs_visible_by?(User.current) %>
<td class="currency">
<%= number_to_currency(labor_budget_item.costs)%>
</td>
<% else %>
<td></td>
<% end %>
</tr>
<% end %>
<% if User.current.allowed_to?(:view_hourly_rates, @project) || User.current.allowed_to?(:view_own_hourly_rate, @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 list">
<thead><tr>
<th><%= l(:caption_issue)%></th>
<th><%= l(:field_hours)%></th>
<th><%= l(:label_user) %></th>
<th class="currency"><%= l(:caption_costs) %></th>
</tr></thead>
<tbody>
<% @cost_object.time_entries.visible(User.current, @project).all.group_by(&:issue).each do |issue, time_entries|
entries = 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)
result.hours = 0
results[entry.user.id.to_s] = result
end
result.overridden_costs += entry.real_costs
result.hours += entry.hours
results
end.values
entries.each do |t|
%>
<tr>
<td class="subject"><%= link_to_issue issue %></td>
<td class="hours"><%= link_to "#{t.hours}h", {:controller => "timelog", :action => "index", :issue_id => issue} %></td>
<td><%=h 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>