app/views/wbs_activities/_activities_ratio_per_profile.html.erb
<%= hidden_field_tag "wbs_activity_id", params[:id] %>
<table id="profiles_per_activity" class="table table-striped table-bordered table-condensed">
<tr>
<th colspan="2"><%= I18n.t(:wbs_activity) %></th>
<th colspan="<%= @wbs_organization_profiles.length %>"><%= I18n.t(:profiles) %></th>
<th rowspan="2"><%= I18n.t(:total_ratio_per_activity) %></th>
</tr>
<tr>
<th>Outline</th>
<th><%= I18n.t(:name) %></th>
<% if @wbs_organization_profiles.length > 0 %>
<% @wbs_organization_profiles.each do |profile| %>
<th><%= profile.name %></th>
<% end %>
<% else %>
<th><%= I18n.t(:no_profiles_for_wbs_activity_organization) %></th>
<% end %>
</tr>
<% gap = 1 %>
<% @wbs_activity_ratio_elements.each do |activity| %>
<%= hidden_field_tag 'wbs_activity_ratio_id', activity.wbs_activity_ratio_id %>
<%= hidden_field_tag 'wbs_activity_id', activity.wbs_activity_ratio.wbs_activity_id %>
<% total_percentage_activity = 0 %>
<tr>
<td><%= activity.wbs_activity_element.dotted_id %></td>
<td style="padding-left:<%=gap+(activity.wbs_activity_element.depth*2)%>em"><%= activity.wbs_activity_element.name %></td>
<% if @wbs_organization_profiles.length > 0 %>
<% @wbs_organization_profiles.each do |profile| %>
<% activity_profile = WbsActivityRatioProfile.where(wbs_activity_ratio_element_id: activity.id, organization_profile_id: profile.id).first %>
<% current_percentage = activity_profile.nil? ? nil : activity_profile.ratio_value %>
<% total_percentage_activity += (current_percentage.nil? ? 0 : current_percentage.to_f) %>
<% if activity.wbs_activity_element.has_children? %>
<td style="text-align: center"><%= hidden_field_tag "activity_profile_percentage[#{activity.id}][#{profile.id}]", nil, :class => 'input-mini profiles_per_activity', 'data-activity_id' => activity.id, "data-profile_id" => profile.id %> - </td>
<% else %>
<td style="text-align: center"><%= text_field_tag "activity_profile_percentage[#{activity.id}][#{profile.id}]", current_percentage, :class => 'input-mini profiles_per_activity', 'data-activity_id' => activity.id, "data-profile_id" => profile.id %></td>
<% end %>
<% end %>
<% else %>
<td></td>
<% end %>
<% if activity.wbs_activity_element.has_children? %>
<td style="text-align: center"> - </td>
<% else %>
<td id='<%= "total_ratio_activity_#{activity.id}" %>' style="text-align: center"><%= activity.wbs_activity_element.is_root? ? "-" : "#{total_percentage_activity} %" %></td>
<% end %>
</tr>
<% end %>
</table>
<% if can? :manage_modules_instances, ModuleProject %>
<%= submit_tag I18n.t('save'), :class => 'btn ' %>
<%= submit_tag I18n.t('apply'), :class => 'btn' %>
<% end %>