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/_form.html.erb

77 lines
4.0 KiB

<%= f.hidden_field :kind %>
<p><%= f.text_field :subject, :size => 80, :required => true %></p>
<p><%= f.text_area :description,
:cols => 60,
:rows => (@cost_object.description.blank? ? 10 : [[10, @cost_object.description.length / 50].max, 100].min),
:accesskey => accesskey(:edit),
:class => 'wiki-edit' %></p>
<p><%= f.text_field :fixed_date, :size => 10 %><%= calendar_for('cost_object_fixed_date') %></p>
<% if @cost_object.kind == "VariableCostObject" -%>
<script type="text/javascript">
//<![CDATA[
materialBudgetItemsForm = new Subform('<%= escape_javascript(render(:partial => "material_budget_item", :object => @cost_object.material_budget_items.build(:cost_type => CostType.default) )) %>',<%= @cost_object.material_budget_items.length %>,'material_budget_items_body');
<%# we have to assign the cost_object here as following methods depend on the item having an object -%>
<% item = @cost_object.labor_budget_items.build.tap do |i|
i.cost_object = @cost_object
end -%>
laborBudgetItemsForm = new Subform('<%= escape_javascript(render(:partial => "labor_budget_item", :object => item )) %>',<%= @cost_object.labor_budget_items.length %>,'labor_budget_items_body');
//]]>
</script>
<fieldset id="material_budget_items_fieldset">
<legend><%= VariableCostObject.human_attribute_name(:material_budget) %></legend>
<table class="list material_budget_items" id="material_budget_items">
<thead><tr>
<th class="cost_units"><%= MaterialBudgetItem.human_attribute_name(:units) %></th>
<th><%= MaterialBudgetItem.human_attribute_name(:cost_type) %></th>
<th><%= MaterialBudgetItem.human_attribute_name(:comment) %></th>
<% if User.current.allowed_to?(:view_cost_rates, @project)%><th class="currency" id="material_budget_items_price"><%= MaterialBudgetItem.human_attribute_name(:budget) %></th><%end%>
<th></th>
</tr></thead>
<tbody id="material_budget_items_body">
<%- @cost_object.material_budget_items.each_with_index do |material_budget_item, index| -%>
<%= render :partial => 'material_budget_item', :object => material_budget_item, :locals => {:index => index, :classes => cycle('odd', 'even')} %>
<%- end -%>
</tbody>
</table>
<div style="text-align: right"><%= link_to_function l(:button_add_budget_item), "materialBudgetItemsForm.add()", {:class => "icon icon-add"} %></div>
</fieldset>
<fieldset id="labor_budget_items_fieldset">
<legend><%= VariableCostObject.human_attribute_name(:labor_budget) %></legend>
<table class="list labor_budget_items" id="labor_budget_items">
<thead><tr>
<th class="cost_units"><%= LaborBudgetItem.human_attribute_name(:hours) %></th>
<th><%= LaborBudgetItem.human_attribute_name(:user) %></th>
<th><%= LaborBudgetItem.human_attribute_name(:comment) %></th>
<% if User.current.allowed_to?(:view_hourly_rates, @project) %>
<th class="currency" id="labor_budget_items_price"><%= LaborBudgetItem.human_attribute_name(:budget) %></th>
<% end %>
<th></th>
</tr></thead>
<tbody id="labor_budget_items_body">
<%- @cost_object.labor_budget_items.each_with_index do |labor_budget_item, index| -%>
<%= render :partial => 'labor_budget_item', :object => labor_budget_item, :locals => {:index => index, :classes => cycle('odd', 'even')} %>
<%- end -%>
</tbody>
</table>
<div style="text-align: right"><%= link_to_function l(:button_add_budget_item), "laborBudgetItemsForm.add()", {:class => "icon icon-add"} %></div>
</fieldset>
<%- end %>
<div style="clear: both;"> </div>
<% if @cost_object.new_record? %>
<p><label><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form' %></p>
<% end %>
<%= wikitoolbar_for 'cost_object_description' %>
<% content_for :header_tags do %>
<%= javascript_tag "initialize_editinplace('src=\"#{asset_path('webalys/cancel.png')}\" alt=\"#{l(:button_cancel_edit_budget)}\" title=\"#{l(:button_cancel_edit_budget)}\"' )" %>
<% end %>