<%= title l(:label_activity_plural) %>
<%= render partial: "wkcrm/render_crm_tabs" %>

<% actType = ["", ""] %>
<% actType << acttypeHash.to_a %>
<%  actTypehash = Hash[*actType.flatten].invert %>

<% relatedArr = ["", ""] %>
<% relatedArr << relatedHash.to_a %>
<%  relatedArrhash = Hash[*relatedArr.flatten].invert %>

<fieldset>
<%= form_tag({:controller => "wkcrmactivity", :action => 'index', :tab => "wkcrmactivity"}, :method => :get, :id => 'query_form') do %>
	<%= hidden_field_tag "searchlist", controller_name %>
	<%=h hidden_field_tag('tab', "wkcrmactivity") %>
	<%	actType =session[controller_name].try(:[], :activity_type)
		actRelated = session[controller_name].try(:[], :related_to)
		show_on_map = session[controller_name].try(:[], :show_on_map) %>
		<div style="float:right">
			<%= link_to controller.get_activity_label, url_for(:controller => controller_name, :action => 'edit'), :class => 'icon icon-add' %>
		</div>
		<table>
			<th align="left" ><%= l(:label_activity_type) %>:</th>
			<td  align="left"><%=h select_tag("activity_type", options_for_select(actTypehash, :selected => !actType.blank? ? actType : ""), :style => "width:190px;") %></td>
			<th align="left" style="padding-left:10px;"><%= l(:label_relates_to) %>:</th>
			<td align="left"><%=h select_tag("related_to", options_for_select(relatedArrhash, :selected => (!actRelated.blank? ? actRelated : "")), :style => "width:200px;") %></td>
		</table>
	<%= render :partial => 'wkcrmactivity/date_range' %>
  <%= link_to_function l(:button_apply), '$("#query_form").submit(); return false;', :class => 'icon icon-checked' %>
  <%= link_to l(:button_clear), {tab: controller_name, clear: true}, class: 'icon icon-reload' %>
  <% if isChecked('crm_save_geo_location') %>
    <label style="padding-left:5px">
      <%= check_box_tag('show_on_map', true, show_on_map || false, onclick: '$("#query_form").submit(); return false;') %>
      <%= l(:label_show_on_map) %>
    </label>
  <% end %>
<% end %>
</fieldset>

<% if @activity.present? %>
	<%= render partial: "activity_list", locals: { activities:  @activity } %>
	<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 %>