%-
index ||= "INDEX"
new_or_existing = material_budget_item.new_record? ? 'new' : 'existing'
id_or_index = material_budget_item.new_record? ? index : material_budget_item.id
prefix = "cost_object[#{new_or_existing}_material_budget_item_attributes][]"
id_prefix = "cost_object_#{new_or_existing}_material_budget_item_attributes_#{id_or_index}"
name_prefix = "cost_object[#{new_or_existing}_material_budget_item_attributes][#{id_or_index}]"
classes ||= ""
@material_budget_item = material_budget_item
error_messages = error_messages_for 'material_budget_item'
-%>
<% unless error_messages.blank? %>
<%= cost_form.text_field :units, :index => id_or_index, :size => 3 %>
">
<%=h material_budget_item.cost_type.unit_plural if material_budget_item.cost_type %>
|
<%= cost_form.select :cost_type_id, cost_types_collection_for_select_options(material_budget_item.cost_type), {}, {:index => id_or_index} %>
<%= observe_field( "#{id_prefix}_cost_type_id", :url => {:action => :update_material_budget_item}, :with => "'cost_type_id=' + encodeURIComponent(value) + '&units=' + encodeURIComponent(document.getElementById('#{id_prefix}_units').value) + '&fixed_date=' + encodeURIComponent(document.getElementById('cost_object_fixed_date').value) + '&element_id=#{id_prefix}'") %>
<%= observe_field( "#{id_prefix}_units", :frequency => 1, :url => {:action => :update_material_budget_item}, :with => "'cost_type_id=' + encodeURIComponent(document.getElementById('#{id_prefix}_cost_type_id').value) + '&units=' + encodeURIComponent(value) + '&fixed_date=' + encodeURIComponent(document.getElementById('cost_object_fixed_date').value) + '&element_id=#{id_prefix}'") %>
|
" class="icon icon-edit" title="<%= l(:help_click_to_edit) %>">
<%= number_to_currency(material_budget_item.calculated_costs(@cost_object.fixed_date)) %>
<%= update_page_tag do |page|
page << "makeEditable('#{id_prefix}_costs', '#{name_prefix}[budget]');"
page << "edit($('#{id_prefix}_costs'), '#{name_prefix}[budget]', '#{number_to_currency(material_budget_item.budget)}');" if material_budget_item.budget
end %>
|
<%= link_to_function image_tag('delete.png'), "deleteMaterialBudgetItem('#{id_prefix}')" %>
|
<% end %>