% filtered_params = params.respond_to?(:to_unsafe_hash) ? params.to_unsafe_hash : params %>
<% if !@query.new_record? && @query.editable_by?(User.current) %>
<%= link_to l(:button_contacts_edit_query), edit_crm_query_path(@query, :object_type => "contact"), :class => 'icon icon-edit' %>
<%= link_to l(:button_contacts_delete_query), crm_query_path(@query, :object_type => "contact"), :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :class => 'icon icon-del' %>
<% end %>
<%= link_to_if_authorized l(:label_crm_contact_new), {:controller => 'contacts', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %>
<%= link_to_if_authorized l(:label_crm_import), {:controller => 'contact_imports', :action => 'new', :project_id => @project}, :class => 'icon icon-import', :id => 'import_from_csv' %>
<%= call_hook(:view_contacts_action_menu) %>
<% html_title(@query.new_record? ? l(:label_contact_plural) : @query.name) %>
<%= form_tag({ :controller => 'contacts', :action => 'index', :project_id => @project }, :method => :get, :id => 'query_form') do %>
<%= hidden_field_tag 'set_filter', '1' %>
<%= hidden_field_tag 'object_type', 'contact' %>
<%= link_to_function l(:button_apply), 'submit_query_form("query_form")', :class => 'icon icon-checked' %>
<%= link_to l(:button_clear), { :set_filter => 1, :project_id => @project }, :class => 'icon icon-reload' %>
<% if @query.new_record? && User.current.allowed_to?(:save_contacts_queries, @project, :global => true) %>
<%= link_to_function l(:button_save),
"$('#query_form').attr('action', '#{ @project ? new_project_crm_query_path(@project) : new_crm_query_path }'); submit_query_form('query_form')",
:class => 'icon icon-save' %>
<% end %>
<% end %>
<%= error_messages_for 'query' %>
<% if @query.valid? %>
<% if User.current.allowed_to?(:export_contacts, @project, :global => true) %>
<% other_formats_links do |f| %>
<%= f.link_to 'Atom', :url => filtered_params.merge(:key => User.current.rss_key) %>
<% if contacts_list_style == 'list' %>
<%= f.link_to 'CSV', :url => filtered_params, :onclick => "showModal('csv-export-options', '350px'); return false;" %>
<% else %>
<%= f.link_to 'CSV', :url => filtered_params %>
<% end %>
<%- if ContactsSetting.vcard? -%>
<%= f.link_to 'VCF', :url => filtered_params %>
<%- end -%>
<%- if ContactsSetting.spreadsheet? -%>
<%= f.link_to 'XLS', :url => filtered_params %>
<%- end -%>
<% end %>
<%= l(:label_export_options, :export_format => 'CSV') %>
<%= form_tag({:controller => 'contacts',
:action => 'index',
:project_id => @project,
:format => 'csv'},
:method => :get,
:id => 'csv-export-form') do %>
<% columns_name = 'c[]' %>
<% if Redmine::VERSION::STRING > '3.2.1' %>
<%= query_as_hidden_field_tags(@query) %>
<% if Redmine::VERSION::STRING < '3.4' %>
<%= hidden_field_tag 'sort', @sort_criteria.to_param, :id => nil %>
<% columns_name = 'csv[columns]' %>
<% end %>
<% elsif Redmine::VERSION::STRING < '3.2' %>
<% columns_name = 'columns' %>
<% end %>
<%= submit_tag l(:button_export),
:name => nil,
:onclick => "hideModal(this);" %>
<%= submit_tag l(:button_cancel),
:name => nil,
:onclick => "hideModal(this);",
:type => 'button' %>
<% end %>
<% end %>
<% end %>
<% content_for :sidebar do %>
<%= render :partial => 'common/sidebar' %>
<%= render :partial => 'tags_cloud', :object => @tags %>
<%= render_sidebar_crm_queries('contact') %>
<%= render :partial => 'notes/last_notes', :object => @last_notes %>
<%= render :partial => 'common/recently_viewed' %>
<%= call_hook(:view_contacts_sidebar_contacts_list_bottom) %>
<% end %>
<% content_for(:header_tags) do %>
<%= javascript_include_tag :contacts, :plugin => 'redmine_contacts' %>
<%= stylesheet_link_tag :contacts_sidebar, :plugin => 'redmine_contacts' %>
<%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => l(:label_contact_plural)) %>
<% end %>
<% if Redmine::VERSION.to_s >= '3.4' || RedmineContacts.unstable_branch? %>
<%= context_menu %>
<% else %>
<%= context_menu url_for( {:controller => "contacts", :action => "context_menu"} ) %>
<% end %>