<div style="position: relative;">
  <div style="padding: 15px 0; text-align: center; font-size: 18px; font-weight: bold; border: 1px solid #eee; border-bottom: unset;">
    学校数据统计（<%= I18n.t("school_daily_report.#{params[:contrast_column]}") %>变化统计情况）
  </div>
  <%= select_tag :contrast_column,
                 options_for_select(select_options, params[:contrast_column]),
                 class: 'form-control contrast-column-select' %>

  <% if statistics.present? %>
    <div style="position: absolute; left: 20px; bottom: 0; font-size: 12px;">
      说明：新增数=时段二-时段一；新增百分比=(新增数/时段一)*100%(保留小数点后五位)
    </div>
  <% end %>
</div>

<% if statistics.present? %>
  <table class="table table-hover text-center daily-school-statistic-list-table">
    <thead>
    <tr>
      <th width="36%" class="text-left">单位名称</th>
      <th width="22%">时段一<br><%= "（#{params[:begin_date]} 05:00至#{(Time.zone.parse(params[:end_date]) + 1.days).strftime('%Y-%m-%d')} 05:00）" %></th>
      <th width="22%">时段二<br><%= "（#{params[:other_begin_date]} 05:00至#{(Time.zone.parse(params[:other_end_date]) + 1.days).strftime('%Y-%m-%d')} 05:00）" %></th>
      <th width="20%" colspan="2">
        <%= sort_tag('变化情况', name: 'percentage', path: contrast_admins_school_statistics_path) %>
        <br>（  新  增  数   | 新增百分比）
      </th>
    </tr>
    </thead>
    <tbody>
    <% statistics.each do |statistic| %>
      <tr>
        <td class="text-left">
          <%= link_to statistic.school_name, "/colleges/#{statistic.school_id}/statistics",
                      target: '_blank', data: { toggle: 'tooltip', title: '点击查看学校统计概况' }  %>
        </td>
        <td><%= statistic['total'] %></td>
        <td><%= statistic['other_total'] %></td>
        <%
          increase = statistic['other_total'] - statistic['total']
          percentage = statistic['total'].zero? ? increase.to_f * 100 : (increase / statistic['total'].to_f) * 100
        %>
        <% if increase > 0 %>
          <td class="text-right pr-2 text-danger relative right-border">
            +<%= increase %>
          </td>
          <% if statistic['total'].zero? %>
            <td class="text-left pl-2">-</td>
          <% else %>
            <td class="text-left pl-2 text-danger">+<%= percentage.round(5) %>%</td>
          <% end %>
        <% elsif increase.zero? %>
          <td class="text-right pr-2 right-border relative" style="position: relative;">
            <%= increase %>
          </td>
          <td class="text-left pl-2"><%= percentage.round(5) %>%</td>
        <% else %>
          <td class="text-right pr-2 right-border relative text-success">
            <%= increase %>
          </td>
          <td class="text-left pl-2 text-success"><%= percentage.round(5) %>%</td>
        <% end %>
      </tr>
    <% end %>
    </tbody>
  </table>

  <%= render partial: 'admins/shared/paginate', locals: { objects: statistics } %>
<% else %>
  <div style="padding-top: 150px; height: 250px; text-align: center; color: grey; font-size: 14px;">
    暂无数据，请选择时间段对比
  </div>
<% end %>