<%= form_tag({}, :data => {:cm_url => context_menu_contacts_path}) do %>
<%= hidden_field_tag 'back_url', url_for(params.respond_to?(:to_unsafe_hash) ? params.to_unsafe_hash : params) %>
<%= hidden_field_tag 'project_id', @project.id if @project %>
<div class="autoscroll">
    <table class="contacts index">
    <tbody>
    <% previous_group = false %>
    <% @contacts.each do |contact| %>
        <% if @query.grouped? && (group = @query.group_by_column.value(contact)) != previous_group %>
          <% reset_cycle %>
          <tr class="group open">
            <td colspan="<%= @query.columns.size + 2 %>">
              <span class="expander" onclick="toggleRowGroup(this);">&nbsp;</span>
              <%= group.blank? ? 'None' : column_content(@query.group_by_column, contact) %> <span class="count">(<%= @contact_count_by_group[group] %>)</span>
              <%= link_to_function("#{l(:button_collapse_all)}/#{l(:button_expand_all)}", "toggleAllRowGroups(this)", :class => 'toggle-all') %>
            </td>
          </tr>
          <% previous_group = group %>
        <% end %>

        <tr class="hascontextmenu  <%= cycle('odd', 'even') %> ">
            <td class="checkbox">
                <%= check_box_tag "selected_contacts[]", contact.id, false, :onclick => "toggleContact(event, this);" %>
            </td>
            <td class="avatar">
                    <%= link_to avatar_to(contact, :size => "32"), contact_path(contact, :project_id => @project), :id => "avatar" %>
            </td>
            <td class="name">
                <h1><%= link_to contact.name, contact_path(contact, :project_id => @project) %></h1>
                <p>
                    <%= link_to contact.website, contact.website_address, :class => 'external', :only_path => true unless !contact.is_company %>
                    <%= mail_to contact.emails.first unless contact.is_company%>
                    <div><%= contact.phones.first %></div>
                </p>
            </td>
            <td class="info">
                <div class="title_and_company" >
                    <%= contact.job_title %>
                    <% if !contact.is_company %>
                        <%= " #{l(:label_crm_at_company)} " unless (contact.job_title.blank? or contact.company.blank?) %>
                        <%= contact.company %>
                    <% end %>
                </div>
                <div class="tags">
                    <%= tag_links(contact.tag_list) %>
                    <%# tag_links(RedmineCrm::TagList.from(contact.cached_tag_list)) %>
                </div>
            </td>
        </tr>
    <% end %>
    </tbody>
    </table>
 </div>
 <% end %>
