<%= javascript_include_tag 'index', :plugin => "redmine_wktime" %>
<%= javascript_include_tag 'accountproject', :plugin => "redmine_wktime" %>
<script type="text/javascript">
	productModifyUrl="<%= "#{url_for(:controller => "wklogmaterial", :action => 'modifyProductDD')}" %>";
</script>
<%= form_tag({:controller => controller_name, :action => 'update'}, :method => :post, :id => 'query_form') do %>
	<%	if @inventoryItem.blank?
			if @parentEntry.blank?
				newLbl = controller.newItemLabel
				editLbl = controller.editItemLabel
			else
				newLbl = controller.newcomponentLbl
				editLbl = controller.editcomponentLbl
			end
		else
			newLbl = controller.newcomponentLbl
			editLbl = @inventoryItem.parent_id.blank? ? controller.editItemLabel : controller.editcomponentLbl
		end
	%>
	<h2><b><%= @productItem.blank? ?  newLbl : editLbl %></b></h2>

	<div id="product_item_form">
		<%=h hidden_field_tag('product_item_id', @productItem.blank? ? "" :@productItem.id) %>
		<%=h hidden_field_tag('inventory_item_id', @inventoryItem.blank? ? "" :@inventoryItem.id) %>
		<%=h hidden_field_tag('product_type', controller.getItemType) %>
		<%= call_hook(:view_product_item, :inventoryItem => @inventoryItem) %>
			<%= render :partial => 'wkproductitem/edit_product_item', locals: {invntItem: @inventoryItem} %>
		<div style="clear:both;"></div>
		<fieldset id="date-range" class="collapsible">
			<legend onclick="toggleFieldset(this);" class="icon icon-<%= @inventoryItem.blank? ? "collapsed" : "expanded" %>"><%= l(:label_additional_info) %></legend>
			<div class="splitcontent" style="display:<%= @inventoryItem.blank? ? 'none' : 'flex' %>;">
				<% if controller.showAssetProperties %>
					<%= render :partial => 'wkasset/asset_property', locals: {invntItem: @inventoryItem, isTransfer: false}%>
				<% end %>
				<%= render :partial => 'wkproductitem/edit_inventory', locals: {invntItem: @inventoryItem, isTransfer: false}%>
			</div>
		</fieldset>
	</div>
	<div style="clear:both;"></div>
	<div  align='center'>
		<%= submit_tag l(:button_save) ,:id => 'wkproductitem_save' %>
		<% if controller.getItemType == "A" && @inventoryItem && !@inventoryItem.asset_property.is_disposed %>
			<%= button_tag(l(:label_dispose_asset), type: "button", onclick: "window.location.href='#{url_for(controller: "wkasset", action: "dispose_asset", inventory_item_id: params[:inventory_item_id])}'") %>
		<% end %>
	</div>
<% end %>

<% if @inventoryItem.present? %>
	</br>
	<div>
		<% if controller.showAssetProperties %>
			<%= render partial: "wkcrm/accordion_section", locals: { currentObj: @inventoryItem }%>
		<%else%>
			<%= render partial: "child_component", locals: { component: @assembledComponent} if @assembledComponent.present? %>
		<%end%>
		</div>
<% end %>