<br/>

<% row_index = 1 %>
<% total = 0 %>
<%

%>
<script type="text/javascript">
	productModifyUrl="<%= "#{url_for(:controller => "wkshipment", :action => 'populateProductItemDD')}" %>";
</script>
<%=h hidden_field_tag("project_id",  'null' )  %>
<div class="wk-contextual">
<h2 style="float:left;"><%= l(:label_item) %></h2>
<%= link_to l(:button_add_row), "#", { :onclick => "javascript:invoiceAddRow('shipmentTable', 'totalrow');",  :class => 'icon icon-add' } %>
</div>
<div style="clear:both"></div>
<div class="autoscroll">
<table id="shipmentTable" class="list time-entries", style="width:100%;">
  <thead style="width:100%; word-wrap: break-word;">
    <tr>
			<th width="1%"></th>
			<th width="1%" >#</th>
			<th width="10%" ><%= l(:label_invoice_items) %></th>
			<th width="10%" ><%= l(:label_product) %></th>
			<th width="5%" ><%= l(:field_type) %></th>
			<th width="20%" ><%= l(:label_item) %></th>
			<!-- <th width="10%" ><%#= l(:label_brand) %></th>
			<th width="10%" ><%#= l(:label_model) %></th> -->
			<th width="7%" ><%= l(:label_attribute) %></th>
			<th width="25%" colspan="2"><%= l(:label_serial_number) %></th>
			<th width="10%" ><%= l(:field_notes) %></th>
			<th width="7%" ><%= l(:field_currency) %></th>
			<th width="7%" ><%= l(:label_cost_price) %></th>
			<th width="7%" ><%= l(:label_selling_price) %></th>
			<th width="7%" ><%= l(:label_over_head_price) %></th>
			<th width="3%" ><%= l(:field_quantity) %></th>
			<th width="5%" ><%= l(:label_s_uom) %></th>
			<th width="7%" ><%= l(:field_location) %></th>
			<th width="7%" ><%= l(:label_project) %></th>

			<th width="2%"></th>
			<th width="2%"></th>
    </tr>
  </thead>
   <tbody>
   <% if !@shipmentItem.blank? %>
       <% @shipmentItem.each do |entry| %>
			<%= render :partial => 'edit_shipment_row', locals: { row_index: row_index, entry: entry } %>
		    <% row_index = row_index + 1 %>
		<% end %>
	<% else %>
		<%= render :partial => 'edit_shipment_row', locals: { row_index: row_index, entry: entry } %>
		<% row_index = row_index + 1 %>
	<% end %>
   </tbody>
</table>

</div>
<div class="wk-contextual">
	<%= link_to l(:button_add_row), "#", { :onclick => "javascript:invoiceAddRow('shipmentTable', 'totalrow');",  :class => 'icon icon-add' } %>
</div style="clear: both;">
<%=h hidden_field_tag("totalrow",  row_index-1 )  %>
<%=h hidden_field_tag("shipment_id",  @shipment.id )  %>
<% unless @shipmentItem.blank?  %>
<% unless @shipmentItem.blank? && @shipmentItem[0].blank? %>
<%=h hidden_field_tag("shipment_id",  @shipment.id )  %>
<% end %>
<% end %>
<%=h hidden_field_tag("deletedids",  "" )  %>
<% if params[:shipment_id].present? %>
	<div class="contextual total-hours">
		<% @shipmentItem.each{|item| total += (item.total_quantity * item.cost_price) + item.over_head_price } %>
		<%= l(:label_total) %>: &nbsp;<%= @shipmentItem&.first&.currency %> <%= "%.2f" % total%>
	</div>
<%end%>
<%= submit_tag l(:button_save), :onclick => "return submitReceiptForm();",  :hidden => false, :id => 'items_save', :disabled => false %>