<div id="schoolsTitle"><h1><%= LdapOrganisation.current.o %></h1></div>

<table class="list">
  <tr class="thead">
    <th><%= t('activeldap.attributes.school.displayName') %></th>
    <th><%= t('activeldap.attributes.school.puavoNamePrefix') %></th>

    <th><%= t('activeldap.attributes.school.bootservers') %></th>

    <% if @have_school_codes %>
    <th><%= t('activeldap.attributes.school.puavoSchoolCode') %></th>
    <% end %>

    <% if @have_external_ids %>
    <th><%= t('activeldap.attributes.school.puavoExternalId') %></th>
    <% end %>

    <th><%= t('schools.index.members') %></th>

    <th><%= t('schools.index.devices') %></th>

    <th><%= t('.actions') %></th>
  </tr>

  <% @schools.each do |school| %>
  <tr>
    <td data-title="<%= t('activeldap.attributes.school.displayName')%>">
      <%= link_to school.displayName, school_path(school) %>
      <% unless school.displayName == 'Administration' %>
      <%= render :partial => "layouts/integrations", :locals => {
        :integrations_by_type => get_school_integrations_by_type(@organisation_name, school.id),
        :extraClass => "inlineIntegrations" }
      %>
      <% end %>
    </td>

    <td data-title="<%= t('activeldap.attributes.school.puavoNamePrefix')%>">
      <%= school.cn %>
    </td>

    <td>
      <% unless school.boot_servers.empty? %>
      <ul class="unstyledUL">
      <% school.boot_servers.each do |bs| %>
        <li><%= link_to bs.puavoHostname, server_path(bs) %></li>
      <% end %>
      </ul>
      <% end %>
    </td>

    <% if @have_school_codes %>
    <td data-title="<%= t('activeldap.attributes.school.puavoSchoolCode')%>">
      <%= school.puavoSchoolCode %>
    </td>
    <% end %>

    <% if @have_external_ids %>
    <td data-title="<%= t('activeldap.attributes.school.puavoExternalId')%>">
      <%= school.puavoExternalId %>
    </td>
    <% end %>

    <td><%= Array(school.memberUid || []).count %></td>

    <td><%= @device_counts.fetch(school.dn.to_s, 0) %></td>

    <td data-title="<%= t('actions')%>" class="table-actions">
      <%= link_to edit_school_path(school), class: "btn" do %>
        <i class="icon-pencil"></i><%= t('link.edit') %>
      <% end %>
    </td>
  </tr>
  <% end %>
</table>

<% if current_user.organisation_owner? %>
<% content_for :page_tools do %>
<%=
toolbar do |tb|
  tb.link t('link.new_school'),
          href: new_school_path,
          owners: true,
          icon: 'plus'
end %>
<% end %>
<% end %>
