<script type="text/javascript">
	prevTab = 'tab-<%= "clcok" %>';
	clockInOutUrl = '<%=url_for(:controller => "wkattendance", :action => "clockindex", :tab => "clock")%>';
	grpUrl="<%= "#{url_for(:controller => "wkattendance", :action => 'getMembersbyGroup')}" %>";
</script>
<%
	wktime_helper = Object.new.extend(WktimeHelper)
	groupid =session[controller_name].try(:[], :group_id)
	userid =session[controller_name].try(:[], :user_id)
	showOnMap =session[controller_name].try(:[], :show_on_map)
%>

<%= form_tag({:controller => controller_name, :action => 'clockindex'}, :method => :get, :id => 'query_form') do %>
	<%= hidden_field_tag 'back_url', url_for(:controller => params[:controller], :action => params[:action]) %>
	<%=h hidden_field_tag('tab', "clock") %>
	<%= hidden_field_tag "searchlist", controller_name %>
	<%= hidden_field_tag :page, params[:page]%>
	<fieldset>
		<legend><%= l(:label_filter_plural) %></legend>
		<% if validateERPPermission('A_ATTEND') %>
			<div style="float:right">
				<%= link_to l(:"label_import_attendance"), url_for(:controller => "wkimportattendance", :action => 'new', :tab => controller.controller_name)%>
			</div>
			<label><%= l(:label_group_plural) %></label>&nbsp;
			<% if !@groups.blank? %>
				<%=h select_tag('group_id',
					options_for_select( [["",0]] + (@groups.collect {|p| [p.name, p.id ]}),
					:selected => !groupid.nil? ? groupid.to_i: 0), :onchange => "grpChanged(this, #{User.current.id}, true);", :style=> "width:300px;") %>&nbsp;
			<% end %>
			<label><%= l(:label_member) %></label>&nbsp;
			<%# show the blank value if more than one user is in the list %>
			<%=h select_tag('user_id',
				options_for_select( [[l(:all_users_for_select),"0"]] + @members,
				:selected => userid.nil? ? (@user.nil? ? User.current.id : @user.id) : userid),
				:style=> "width:200px;") %>
		<% end %>
		<%= render :partial => 'wkattendance/date_range' %>
		<%= link_to_function l(:button_apply), '$("#query_form").submit()', :class => 'icon icon-checked' %>&nbsp;
		<%= link_to l(:button_clear), {tab: 'clock', clear: true}, class: 'icon icon-reload' %>
		<% if wktime_helper.isChecked('att_save_geo_location') %>
			<label style="padding-left:5px">
				<%= check_box_tag('show_on_map', true, showOnMap, onclick: '$("#query_form").submit(); return false;') %>
				<%= l(:label_show_on_map) %>
			</label>
		<% end %>
	</fieldset>
<% end %>

<%= render :partial => 'wkattendance/clk_list'%>
<span class="pagination"><%= pagination_links_full @entry_pages, @entry_count %></span>
<% other_formats_links do |f| %>
	<%= f.link_to_with_query_parameters "CSV", {} %>
<% end %>