<%= form_with(url: {action: :get_csv_of_receive_log}) do %>
  <%= select_tag 'month_for_out', options_for_select(@select_month) %> のログを
  <%= submit_tag "　CSV保存　" %>
<% end %>

<br>

<%= form_with(url: {action: :receive_log}, method: :get) do %>
  <%= select_tag :type, options_for_select([["受信者", 0], ["受信者メールアドレス", 1]], @type.to_i ) %>
  <%= text_field_tag :keyward, @keyward %>
  <%= submit_tag "　検索　" %>
<% end %>
<br>

データ数：<%= @total_data %>　
[
<%= render '/layouts/original_paginate', controller: :sys_log, action: :receive_log, page: @page, total_page: @total_page, w_in: 4, w_out: 2 %> ]
<br>

<% count = 0 -%>

<table border=1 cellspacing=0 cellpadding=3>
  <tr bordercolor=gray>
  <td nowrap bgcolor=#e5f0fe><br></td>
  <td nowrap bgcolor=#e5f0fe>ＤＬ日</td>
  <td nowrap bgcolor=#e5f0fe>区分</td>
  <td nowrap bgcolor=#e5f0fe>受信者</td>
  <td nowrap bgcolor=#e5f0fe>受信者メールアドレス</td>
  <td nowrap bgcolor=#e5f0fe>ファイル名</td>
  <td nowrap bgcolor=#e5f0fe>ファイルサイズ</td>
  </tr>
  <%# if @receives_files -%>
    <%# @receives_files.each.with_index do | receives_file, count | -%>
  <% if @rs -%>
    <% @rs.each do | data | -%>
      <% count = count + 1 -%>
      <% cr_id = count -%>
      <% if @s_data <= cr_id and cr_id <= @e_data -%>
        <% if data.file_size.to_i > 1024 * 1024 -%>
          <% label_file_size = (data.file_size.to_i / (1024 * 1024)).to_s + ' MB' -%>
        <% elsif data.file_size.to_i > 1024 -%>
          <% label_file_size = (data.file_size.to_i / 1024).to_s + ' KB' -%>
        <% else -%>
          <% label_file_size = data.file_size.to_s + ' B' -%>
        <% end -%>

        <tr bordercolor=gray>
        <td nowrap><%= count %></td>
        <!--td nowrap><%#= (Time.parse(receives_file.dl_at.to_s)).strftime("%Y/%m/%d %H:%M:%S") %></td>
        <td nowrap><%#= receives_file.flg %></td>
        <td nowrap><%#= receives_file.receiver_name %></td>
        <td nowrap><%#= receives_file.receiver_mail_address %></td>
        <td nowrap><%#= receives_file.file_name %></td-->
        <td nowrap><%= (Time.parse(data.dl_at.to_s)).strftime("%Y/%m/%d %H:%M:%S") %></td>
        <td nowrap><%= data.flg %></td>
        <td nowrap><%= data.receiver_name %></td>
        <td nowrap><%= data.receiver_mail_address %></td>
        <td nowrap><%= data.file_name %></td>
        <td nowrap><%= label_file_size %></td>
        </tr>
      <% end -%>
    <% end -%>
  <% else -%>
    <tr>
      <td colspan=7 algin=center>データがありません</td>
    </tr>
  <% end -%>
  <% if count == 0 -%>
    <tr><td colspan=7 algin=center>データがありません</td></tr>
  <% end -%>
</table>

