<tr onclick="  row_id  = this.rowIndex ">
	<%
		productItem = entry.product_item
		isDisable = isUsedInventoryItem(entry)
		sqlCond = ""
		attributeSql = ""
		productType = ""
		uomID = ""
		unless productItem.blank?
			sqlCond = " product_id = " + productItem.product_id.to_s
			attributeSql = " group_id = " + productItem.product.attribute_group_id.to_s
			productType = productItem.product.product_type
			uomID = productItem.product.uom_id
		else
			firstProduct = WkProduct.order(:name).first
			productId = firstProduct.blank? ? 0 : firstProduct.id
			sqlCond = " product_id = " + productId.to_s
			unless firstProduct.blank?
				attributeSql = " group_id = " + firstProduct.attribute_group_id.to_s
				productType = firstProduct.product_type
				uomID = firstProduct.uom_id
			end
		end
		unless productType.blank?
			productTypeArr = [[getProductTypeHash(false)[productType], productType]]
		else
			productTypeArr = getProductTypeHash(false).invert
		end
		notesArr = getInvoiceItemsNotes(entry.supplier_invoice_id)
	%>
	<%= hidden_field_tag "availabelInvIds" %>
	<td class="lbl-txt-align" headers="item_id">
		<%=h hidden_field_tag("item_id_#{row_index}",   entry.id )  %>
		<%=h hidden_field_tag("is_editable_#{row_index}",   isDisable )  %>
	</td>
	<td class="lbl-txt-align" headers="item_index">
		<label id="item_index_<%= row_index.to_s %>"><%= row_index  %></label>
	</td>
	<td class="lbl-txt-align" headers="invoice_item_id">
		<%=h select_tag("invoice_item_id_#{row_index.to_s}", options_for_select(notesArr, :selected => entry.invoice_item_id), :disabled => isDisable, :style => "width: 100px;") %>
	</td>
	<td class="lbl-txt-align" headers="product_id">
		<%=h select_tag("product_id_#{row_index.to_s}", generic_options_for_select(WkProduct, nil, 'name', 'name', 'id', productItem.blank? ? nil :productItem.product_id, false), :onchange => "productChanged(this.id, 'product_item_id_#{row_index.to_s}', #{User.current.id}, false, false, null, null);productChanged(this.id, 'product_attribute_id_#{row_index.to_s}', #{User.current.id}, false, false, null, null);productChanged(this.id, 'product_type_#{row_index.to_s}', #{User.current.id}, false, false, null, null);setUOMValue(this.id)", :disabled => isDisable, :style => "width: 100px;") %>
	</td>
	<td class="lbl-txt-align" headers="product_type">
		<%=h select_tag("product_type_#{row_index.to_s}",options_for_select(productTypeArr, :selected => entry.blank? ? productTypeArr : entry.product_type ), :disabled => isDisable, :required => true, :style => "width: 100px;") %>
	</td>
	<td class="lbl-txt-align" headers="product_item_id">
		<%=h select_tag("product_item_id_#{row_index.to_s}", product_item_select(sqlCond, false, productItem.blank? ? nil :productItem.id), :disabled => isDisable, :required => true, :style => "width: 100px;", :required => true) %>
	</td>
	<td class="lbl-txt-align" headers="product_attribute_id">
		<%=h select_tag("product_attribute_id_#{row_index.to_s}", generic_options_for_select(WkProductAttribute, attributeSql, 'name', 'name', 'id',  entry.blank? ? nil :entry.product_attribute_id, true), :disabled => isDisable, :style => "width: 100px;") %>
	</td>
	<td headers="fixed_serial_number">
		<%= text_field_tag "serial_number_#{row_index}",  entry&.serial_number || '', disabled: isDisable, style: "width: 120px;margin-top: 18px;" %>
		<p style="text-align: center;color: grey;"><%= l(:label_fixed) %></p>
	</td>
  <td headers="running_serial_number" style="display:inline-block;margin-top: 18px;width: 150px;">
		<%= text_field_tag "running_sn_#{row_index}",  entry&.running_sn || '', disabled: isDisable, style: "width: 85%;" %>
		<span><%= image_tag("withoutcommant.png", plugin: "redmine_wktime", title: l(:label_assigned_serial_numbers), id: "running_sn_#{row_index}", style: "cursor: pointer;", onclick: "getReceiptAssignedSNs(this.id);") %></span>
		<p style="text-align: center;color: grey;"><%= l(:label_running) %></p>
  </td>
	<td class="lbl-txt-align" headers="notes">
		<%= text_field_tag "notes_#{row_index}",  entry.notes, :required => false, :disabled => isDisable, :style => "width: 150px;" %>
	</td>
	<td class="lbl-txt-align" headers="currency">
		<% wkexpense_helper = Object.new.extend(WkexpenseHelper) %>
		<%=h select_tag("currency_#{row_index}",options_for_select(wkexpense_helper.options_for_currency, :selected => entry.blank? ? Setting.plugin_redmine_wktime['wktime_currency'] : entry.currency), :disabled => isDisable, :style => "width: 100%;") %>

	</td>
	<td class="lbl-txt-align" headers="cost_price"><%= text_field_tag "cost_price_#{row_index}",   ("%.2f" % entry.cost_price unless entry.cost_price.blank?) ,:maxlength => 14, :size => "#{controller.textfield_size}",  :disabled => isDisable %>
	</td>
	<td class="lbl-txt-align" headers="selling_price"><%= text_field_tag "selling_price_#{row_index}",   ("%.2f" % entry.selling_price unless entry.selling_price.blank?) ,:maxlength => 14, :size => "#{controller.textfield_size}", :disabled => isDisable %>
	</td>
	<td class="lbl-txt-align" headers="over_head_price"><%= text_field_tag "over_head_price_#{row_index}",   ("%.2f" % entry.over_head_price unless entry.over_head_price.blank?) ,:maxlength => 14, :size => "#{controller.textfield_size}", :disabled => isDisable %>
	</td>
	<td class="lbl-txt-align" headers="total_quantity">
		<%= text_field_tag "total_quantity_#{row_index}", ("%.2f" % entry.total_quantity unless entry.total_quantity.blank?), :maxlength => 14, :size => "3", :disabled => isDisable, :required => true %>
	</td>
	<td class="lbl-txt-align" headers="uom_id">
		<%=h select_tag("uom_id_#{row_index.to_s}", generic_options_for_select(WkMesureUnit, nil, 'short_desc', 'short_desc', 'id', uomID, false), :disabled => isDisable, :style => "width: 80px;") %>
	</td>
	<td class="lbl-txt-align" headers="location_id">
		<%=h select_tag("location_id_#{row_index.to_s}", generic_options_for_select(WkLocation, nil, 'name', 'name', 'id', entry.location_id, false), :disabled => isDisable, :style => "width: 80px;", :required => true) %>
	</td>
	<td class="lbl-txt-align" headers="project_id">
		<%=h select_tag("project_id_#{row_index.to_s}", options_for_select(getProjects, :selected => entry.project_id), :disabled => isDisable, :style => "width: 80px;") %>
	</td>
	<td>
		<% unless isDisable || !controller.hasDeletePermission %>
			<%= link_to image_tag('delete.png'), "javascript:deleteRow('shipmentTable', 'totalrow');", :id => row_index,
				:data => {:confirm => l(:text_are_you_sure)},
				:title => l(:button_delete) %>
		<% end %>
	</td>
	<td class="lbl-txt-align">
		<% if params[:shipment_id].present? %>
			<%= link_to l(:label_details), {:controller => entry.product_type == 'I' ? 'wkproductitem' : 'wkasset', :action => 'edit', :inventory_item_id => entry.id, :product_item_id => entry.product_item_id } %>
		<% end %>
	</td>
	<%=h hidden_field_tag("org_currency_#{row_index}", entry.id ) %>
	<%=h hidden_field_tag("org_cost_price_#{row_index}", entry.id ) %>
	<%=h hidden_field_tag("org_over_head_price_#{row_index}", entry.id ) %>
	<%=h hidden_field_tag("org_selling_price_#{row_index}", entry.id ) %>
</tr>
<script>
	var sn_blank_error = "<%=l(:warn_sn_blank) %>";
	var sn_text_error = "<%=l(:warn_sn_text) %>";
</script>