<h3 class="title"><%= l(:label_crm_add_contact_plural) %></h3>

<%= form_tag({:controller => 'contacts_issues',
              :action => 'create',
              :issue_id => @issue,
              :project_id => @project},
             :remote => true,
             :method => :post,
             :id => 'add-contact-form') do %>

  <p><%= label_tag 'contact_search', l(:label_crm_search_for_contact) %>:<%= text_field_tag 'contact_search', nil, :placeholder => l(:label_crm_contact_search) %></p>
  <%= javascript_tag "observeSearchfield('contact_search', 'contacts_for_issue', '#{escape_javascript url_for(:controller => 'contacts_issues',
    :action => 'autocomplete_for_contact', :project_id => @project, :issue_id => @issue, :cross_project_contacts => ContactsSetting.cross_project_contacts? ? '1' : '0')}')" %>

  <div id="contacts_for_issue">
    <%= contacts_check_box_tags 'contacts_issue[contact_ids][]', Contact.includes(:avatar).by_project(ContactsSetting.cross_project_contacts? ? nil : @project).visible.first(100) - @issue.contacts %>
  </div>

  <p class="buttons">
    <%= submit_tag l(:button_add), :name => nil, :onclick => "hideModal(this);" %>
    <%= submit_tag l(:button_cancel), :name => nil, :onclick => "hideModal(this);", :type => 'button' %>
  </p>
<% end %>

<% content_for :header_tags do %>
  <%= javascript_include_tag :contacts, :plugin => 'redmine_contacts'  %>
<% end %>
