<% page_title t('titles.organisation'), t('titles.owners') %>

<h1><%= t('.title') %></h1>

<%= start_box t('.current') %>
  <table id="currentOwners">
    <% Array(@current_owners).each do |o| %>
    <% u = o[:user] %>
    <% if u.puavoRemovalRequestTime %>
    <tr class="groupUserMarkedForDeletion">
    <% else %>
    <tr>
    <% end %>
      <td>
        <%= render(:partial => 'shared/owners_and_admins',
                   :locals => { :user => u, :schools => o[:schools] }) %>
      </td>
      <td>
        <% if @logged_in_user == u.dn.to_s %>
        <span class="noOwnerSelfRemove"><%= t('organisations.owners.cant_remove_yourself') %></span>
        <% else %>
        <%= link_to(t('link.remove') + ' ►',
                      remove_owner_organisations_path(u),
                      method: :put,
                      id: "remove_user_#{u.id}",
                      class: 'btn') %>
        <% end %>
      </td>
    </tr>
    <% end %>
  </table>
<%= end_box %>

<%= start_box t('.available') %>
  <table id="availableAdmins">
    <% if @available_owners.empty? %>
    <tr><td><%= t('.none_left') %></td></tr>
    <% else %>
    <% Array(@available_owners).each do |o| %>
    <% u = o[:user] %>
    <% if u.puavoRemovalRequestTime %>
    <tr class="groupUserMarkedForDeletion">
    <% else %>
    <tr>
    <% end %>
      <td>
        <%= render(:partial => 'shared/owners_and_admins',
                   :locals => { :user => u, :schools => o[:schools] }) %>
      </td>
      <td>
        <%= link_to('◄ ' + t('link.add'),
                    add_owner_organisations_path(u),
                    method: :put,
                    id: "add_user_#{u.id}",
                    class: 'btn') %>
      </td>
    </tr>
    <% end %>
    <% end %>
  </table>
<%= end_box %>

<hr>
