
<%= form_tag({:controller => controller_name, :action => 'index'}, :method => :get, :id => 'query_form') do %>
	<%
		accountType = controller.getContactType == 'SC' ? 'S' : 'A'
		accArr = options_for_wktime_account(false, accountType, false)
	%>

	<%	accArr.unshift([l(:label_all_accounts),'AA'])  %>
	<%	accArr.unshift(["",''])  %>
	<%= hidden_field_tag "searchlist", controller_name %>
	<%=h hidden_field_tag('tab', controller_name) %>
	<%	conName = session[controller_name].try(:[], :contactname) %>
	<%	accId = session[controller_name].try(:[], :account_id) %>
	<%	locId = session[controller_name].try(:[], :location_id) %>
	<fieldset>
		<div style="float:right">
			<%= link_to controller.lblNewContact, url_for(:controller => controller_name, :action => 'edit'), :class => 'icon icon-add' %>
		</div>
		<table>
			<tr>
				<th><label for='name' style="float:left;"><%= l(:field_name)  %></label></th>
					<td><%= text_field_tag 'contactname', conName, :size => 30, :style=> "float: left;" %></td>
				<th><label style="float:left;padding-left: 10px;"><%= controller.getAccountLbl %></label></th>
					<td><%=h select_tag('account_id', options_for_select(accArr,  :selected => accId.nil? ? accArr : accId), :style=> "float: left;") %></td>
				<th><label for='location' style="float:left;padding-left: 10px;"><%= l(:field_location) %></label></th>
					<td><%=h select_tag("location_id", generic_options_for_select(WkLocation, nil, 'name', 'name', 'id', locId, true), :style=> "float: left;") %></td>
				<td><%= submit_tag l(:button_apply), :class => "small", :style=>"float:left;", :name => nil %></td>
				<td><%= link_to l(:button_clear), {tab: controller_name, clear: true}, class: 'icon icon-reload', :style=>"float:left; " %></td>
			</tr>
		</table>
	</fieldset>
	<div style="clear: both;"></div>
<% end %>

<% if @contact.present? %>
	<%= render :partial => 'wkcrmcontact/contact_list', locals: { contacts: @contact}%>
	<span class="pagination"><%= pagination_links_full @entry_pages, @entry_count %></span>
	<% other_formats_links do |f| %>
		<%= f.link_to_with_query_parameters 'CSV', {} %>
	<% end %>
<% else %>
	<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>