<% is_processed = params[:status].to_s != 'pending' %>
<table class="table table-hover text-center professional-authentication-list-table">
  <thead class="thead-light">
  <tr>
    <th width="4%">序号</th>
    <th width="8%">头像</th>
    <th width="18%">创建者</th>
    <th width="14%">学校</th>
    <th width="24%">试卷</th>
    <th width="16%">提交时间</th>
    <% if !is_processed %>
      <th width="16%">操作</th>
    <% else %>
      <th width="16%">审批结果</th>
    <% end %>
  </tr>
  </thead>
  <tbody>
  <% if applies.present? %>
    <% applies.each_with_index do |apply, index| %>
      <% user = apply.user %>
      <% exam = ExaminationBank.find apply.container_id %>
      <tr class="examination-authentication-item examination-authentication-<%= apply.id %>">
        <td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
        <td>
          <%= link_to "/users/#{user.login}", class: 'examination-authentication-avatar', target: '_blank', data: { toggle: 'tooltip', title: '个人主页' } do %>
            <img src="/images/<%= url_to_avatar(user) %>" class="rounded-circle" width="40" height="40" />
          <% end %>
        </td>
        <td><%= user.real_name %></td>
        <td><%= raw [user.school_name.presence, user.department_name.presence].compact.join('<br/>') %></td>
        <td>
          <%= link_to exam.name, "/paperlibrary/see/#{exam.id}", target: "_blank" %>
        </td>

        <td><%= apply.updated_at.strftime('%Y-%m-%d %H:%M') %></td>

        <td class="action-container">
          <% if !is_processed %>
            <%= agree_link '同意', agree_admins_examination_authentication_path(apply, element: ".examination-authentication-#{apply.id}"), 'data-confirm': '确认同意该审批？', 'data-disable-with': "提交中..." %>
            <%= agree_link '拒绝', refuse_admins_examination_authentication_path(apply, element: ".examination-authentication-#{apply.id}"), 'data-confirm': '确认拒绝该审批？', 'data-disable-with': "拒绝中..." %>
          <% else %>
            <%= apply.status_text %>
          <% end %>
        </td>
      </tr>
    <% end %>
  <% else %>
    <%= render 'admins/shared/no_data_for_table' %>
  <% end %>
  </tbody>
</table>

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