<%= hidden_field_tag 'back_url', url_for(:controller => params[:controller], :action => params[:action]) %>
<script type="text/javascript">
	productModifyUrl="<%= "#{url_for(:controller => "wklogmaterial", :action => 'modifyProductDD')}" %>";
	productAssetUrl="<%= "#{url_for(:controller => "wkasset", :action => 'getProductAsset')}" %>";
</script>
<% wktime_helper = Object.new.extend(WktimeHelper) %>

<%= form_tag({:controller => controller_name, :action => 'index', :tab => controller_name}, :method => :get, :id => 'query_form') do %>
	<%= hidden_field_tag "searchlist", "#{controller_name}" %>
	<%=h hidden_field_tag('tab', controller_name) %>
	<script type="text/javascript">
		no_asset = '<%=l(:label_no_asset_current_product) %>';
		apply_warn = '<%=l(:warning_apply_depreciation) %>';
		assetUrl="<%= "#{url_for(:controller => "wklogmaterial", :action => 'modifyProductDD')}" %>";
	</script>
	<%
	logmaterial_helper = Object.new.extend(WklogmaterialHelper)
	productArr = logmaterial_helper.getProductArray(WkProduct, '', 'A', true)
	productId =session[controller_name].try(:[], :product_id)
	assetId =session[controller_name].try(:[], :inventory_item_id)
	assetItemArr = controller.getInventoryAssetItems(productId, 'A', true)
	%>
 	<fieldset>
		<legend><%= l(:label_filter_plural) %></legend>
		<div style="float:right">
			<%= link_to l(:label_new_depreciation), url_for(:controller => controller_name, :action => 'new'), :class => 'icon icon-add' %>
		</div>
		<table>
			<% if validateERPPermission("V_INV") || validateERPPermission("D_INV") %>
				<tr>
					<th align="right" ><%= l(:label_product) %></th>
					<td align="left">
						<%=h select_tag('product_id', options_for_select(productArr, :selected => (productId.blank? ? productArr : productId) ), :style => "width:155px;", :onchange => "productAssetChanged(this.id, 'inventory_item_id', #{User.current.id}, true); ") %>
					</td>
					<th align="right" style="padding-left: 10px;"><%= l(:label_asset) %></th>
					<td align="left">
						<%=h select_tag('inventory_item_id', options_for_select(assetItemArr, :selected => (assetId.blank? ? productArr : assetId) ), :style => "width:155px;") %>
					</td>
				</tr>
			<% end %>
		</table>
	<%= render :partial => 'wkassetdepreciation/date_range' %>
	</fieldset>
<% end %>