<% can_manager = manager_permission? %>
<table class="table table-hover text-center customer-list-table">
  <thead class="thead-light">
  <tr>
    <% if can_manager %>
      <th width="15%" class="text-left">单位名称</th>
      <th width="10%">权限控制</th>
    <% else %>
      <th width="25%" class="text-left">单位名称</th>
    <% end %>
    <th width="6%">教师</th>
    <th width="6%">学生</th>
    <th width="6%">课堂</th>
    <th width="8%">发布实训</th>
    <th width="10%">实训报告</th>
    <th width="14%">最新课堂动态时间</th>
    <th width="10%">使用详情</th>
  </tr>
  </thead>
  <tbody>
  <% if customers.present? %>
    <%- manager_group_options = current_partner.partner_manager_groups.without_admin.map{ |g| [g.name, g.id] }.unshift(['选择权限组', '']) -%>

    <% customers.each do |customer| %>
      <tr class="customer-item-<%= customer.id %>">
        <% if can_manager %>
          <td class="text-left"><%= customer.school.name %></td>
          <td>
            <%= select_tag(:manager_group, options_for_select(manager_group_options, customer.partner_manager_group_id),
                           data: { id: customer.id, last: customer.partner_manager_group_id },
                           id: nil, class: 'form-control manager-group-select') %>
          </td>
        <% else %>
          <td class="text-left"><%= customer.school.name %></td>
        <% end %>
        <td><%= display_text customer.display_extra_data(:teacher_count) %></td>
        <td><%= display_text customer.display_extra_data(:student_count) %></td>
        <td><%= display_text customer.display_extra_data(:course_count) %></td>
        <td><%= display_text customer.display_extra_data(:shixun_count) %></td>
        <td><%= display_text customer.display_extra_data(:shixun_report_count) %></td>
        <td><%= display_text customer.display_extra_data(:course_time)&.strftime('%Y-%m-%d %H:%M') %></td>
        <td>
          <%= link_to('查看', statistics_college_path(customer.school), target: '_blank') %>
        </td>
      </tr>
    <% end %>
  <% else %>
    <%= render 'admins/shared/no_data_for_table' %>
  <% end %>
  </tbody>
</table>

<%= render partial: 'admins/shared/paginate', locals: { objects: customers } %>