<h2>個別データ表示</h2>
<h3>依頼情報</h3>
<fieldset>
  <div class="table-sys-a1">
    <div class="item-body">
      <div class="item-tr">
        <div class="item-mid">依頼ＩＤ</div>
        <div class="input-mid"><%= h @requested_matter.request_matter.id %></div>
      </div>
      <div class="item-tr">
        <div class="item-mid">依頼者名</div>
        <div class="input-mid"><%= h @requested_matter.request_matter.name %></div>
      </div>
      <div class="item-tr">
        <div class="item-mid">依頼者者メールアドレス</div>
        <div class="input-mid"><%= h @requested_matter.request_matter.mail_address %></div>
      </div>
      <div class="item-tr">
        <div class="item-mid">メッセージ</div>
        <div class="input-mid">
        <%- if @requested_matter.request_matter.message.present? -%>
          <%- message_count = 0 -%>
          <%- for key_word in @requested_matter.request_matter.message.split(/\r\n|\r|\n/) -%>
          <div><%= key_word -%></div>
            <%- message_count += 1 -%>
          <%- end -%>
        <%- end -%>
        </div>
      </div>
      <div class="item-tr">
        <div class="item-mid">登録日</div>
        <div class="input-mid">
          <%= (Time.parse(@requested_matter.request_matter.created_at.to_s)).strftime("%Y年%m月%d日%H時%M分%S秒") %></div>
      </div>
      <div class="item-tr">
        <div class="item-mid">決裁種別</div>
        <div class="input-mid">
        <%- @request_moderate = @requested_matter.request_matter.request_moderate -%>
        <%- if @request_moderate == nil -%>
          決裁無し
        <%- else -%>
          <%- if @request_moderate.type_flag == 0 -%>
          通常決裁
          <%- else -%>
          簡易決裁
          <%- end -%>
        <%- end -%>
        </div>
      </div>

      <%- unless @request_moderate == nil -%>
      <div class="item-tr">
        <div class="item-mid">決裁結果</div>
        <div class="input-mid">
        <%- if @request_moderate.result == 1 -%>
          <font color="blue"><b>承認</b></font>
        <%- elsif @request_moderate.result == 2 -%>
          <font color="red">却下</font>
        <%- else -%>
          未決
        <%- end -%>
        </div>
      </div>
      <div class="item-tr">
        <div class="item-mid">決裁ルート</div>
        <div class="input-mid">
          <%- @request_moderaters = @request_moderate.request_moderaters -%>
          <%- number = 0 -%>
          <div class="table-i" style="border:0px;">
            <% for moderater in @request_moderaters %>
            <div class="input-l" style="border:0px; padding:5px 8px; height:20px;">
              <%- number += 1 -%>
              <%= number -%>.
              <%= moderater.moderater.user.name -%>
            </div>
            <div class="input-r" style="border:0px; padding:5px 8px; height:20px;">
            <%- if moderater.result == 1 -%>
              <font color="blue"><b>承認</b></font>
            <%- elsif moderater.result == 2 -%>
              <font color="red">却下</font>
            <%- else %>
              未決
            <%- end -%>
            </div>
          <%- end -%>
          </div>
        </div>
      </div>
      <%- end -%>
      <div class="item-tr">
        <div class="item-mid">依頼日</div>
        <div class="input-mid">
        <%- if @requested_matter.request_matter.sent_at.present? -%>
          <%= (Time.parse(@requested_matter.request_matter.sent_at.to_s)).strftime("%Y年%m月%d日%H時%M分%S秒") -%>
        <%- elsif @requested_matter.request_matter.moderate_flag == nil -%>
          <%- if @requested_matter.request_matter.created_at -%>
          <%= (Time.parse(@requested_matter.request_matter.created_at.to_s)).strftime("%Y年%m月%d日%H時%M分%S秒") -%>
          <%- end -%>
        <%- end -%>
        </div>
      </div>
      <div class="item-tr">
        <div class="item-mid">送信期限</div>
        <div class="input-mid">
        <%- if @requested_matter.request_matter.sent_at.present? -%>
          <%= (Time.parse(@requested_matter.request_matter.sent_at.to_s) +
              @params_app_env['REQUEST_PERIOD'].to_i).strftime("%Y年%m月%d日%H時%M分%S秒") -%>
        <%- elsif @requested_matter.request_matter.moderate_flag == nil -%>
          <%= (Time.parse(@requested_matter.request_matter.created_at.to_s) +
              @params_app_env['REQUEST_PERIOD'].to_i).strftime("%Y年%m月%d日%H時%M分%S秒") -%>
        <%- end -%>
        </div>
      </div>
    </div>
  </div>
</fieldset>

<h3>送信情報</h3>
<fieldset>
  <div class="table-sys-a1">
    <div class="item-body">
      <div class="item-tr">
        <div class="item-mid">依頼送信ＩＤ</div>
        <div class="input-mid"><%= h @requested_matter.id %></div>
      </div>
      <div class="item-tr">
        <div class="item-mid">送信者名</div>
        <div class="input-mid"><%= h @requested_matter.name %></div>
      </div>
      <div class="item-tr">
        <div class="item-mid">送信者メールアドレス</div>
        <div class="input-mid"><%= h @requested_matter.mail_address %></div>
      </div>
      <div class="item-tr">
        <div class="item-mid">パスワード通知</div>
        <div class="input-mid"><%= @password_notice %></div>
      </div>
      <div class="item-tr">
        <div class="item-mid">ダウンロードチェック</div>
        <div class="input-mid"><%= @download_check %></div>
      </div>
      <div class="item-tr">
        <div class="item-mid">ファイル保存期間</div>
        <div class="input-mid"><%= @file_life_period %></div>
      </div>
      <div class="item-tr">
        <div class="item-mid">メッセージ</div>
        <div class="input-mid">
        <%- if @requested_matter.message.present? -%>
          <%- message_count = 0 -%>
          <%- for key_word in @requested_matter.message.split(/\r\n|\r|\n/) -%>
            <%- unless message_count == 0 -%>
            <%- end -%>
            <div><%= key_word -%></div>
            <%- message_count += 1 -%>
          <%- end -%>
        <%- end -%>
        </div>
      </div>
      <div class="item-tr">
        <div class="item-mid">ステータス</div>
        <div class="input-mid"><%= @status %></div>
      </div>
      <div class="item-tr">
        <div class="item-mid">送信日</div>
        <div class="input-mid">
        <%- if @requested_matter.file_up_date -%>
          <%= (Time.parse(@requested_matter.file_up_date.to_s)).strftime("%Y年%m月%d日%H時%M分%S秒") -%>
        <%- end -%>
        </div>
      </div>
      <div class="item-tr">
        <div class="item-mid">受信期限</div>
        <div class="input-mid">
        <%- if @requested_matter.file_life_period -%>
          <%= (Time.parse(@requested_matter.file_up_date.to_s) +
              @requested_matter.file_life_period).strftime("%Y年%m月%d日%H時%M分%S秒") -%>
        <%- end -%>
        </div>
      </div>
    </div>
  </div>
</fieldset>

<h3>ファイル情報</h3>
<fieldset>
  <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>
    <td nowrap bgcolor=#e5f0fe>アップロード日</td>
    </tr>

  <% @count = -1 -%>
  <% @requested_attachments.each.with_index do | requested_attachment, count | -%>
    <% if requested_attachment.size.to_i > 1024 * 1024 -%>
      <% label_file_size = (requested_attachment.size.to_i / (1024 * 1024)).to_s + ' MB' -%>
    <% elsif requested_attachment.size.to_i > 1024 -%>
      <% label_file_size = (requested_attachment.size.to_i / 1024).to_s + ' KB' -%>
    <% else -%>
      <% label_file_size = requested_attachment.size.to_s + ' B' -%>
    <% end -%>
    <% if requested_attachment.download_flg == 0 -%><% download_flg = "未" -%>
    <% elsif requested_attachment.download_flg == 1 -%><% download_flg = "済" -%>
    <% else -%><% download_flg = "不明" -%>
    <% end -%>
    <tr bordercolor=gray>
    <td nowrap align=center><%= count + 1 %></td>
    <td nowrap><%= requested_attachment.id %></td>
    <td nowrap><% if File.exist?(@params_app_env['FILE_DIR'].to_s + "/r#{requested_attachment.id}") -%>
                 <%= link_to requested_attachment.name, {:controller => 'sys_data',
                                                         :action => 'get_requested_file',
                                                         :id => requested_attachment.id } %>
               <% else -%><%= requested_attachment.name -%><% end -%>
    </td>
    <td nowrap><%= label_file_size + " [" + requested_attachment.size.to_s + "]" %></td>
    <td nowrap><%= requested_attachment.content_type %></td>
    <td nowrap><%= download_flg %></td>
    <td nowrap><% if requested_attachment.virus_check == nil -%>(ウィルスチェック中)
               <%- else -%><%= requested_attachment.virus_check -%>
               <%- end -%></td>
    <td nowrap><%= (Time.parse(requested_attachment.created_at.to_s)).strftime("%Y年%m月%d日%H時%M分%S秒") %></td>
    </tr>
    <% @count += 1 -%>
  <% end -%>
  <% if @count < 0 -%>
    <tr><td colspan=8 algin=center>データがありません</td></tr>
  <% end -%>
  </table>
</fieldset>

<br>
<a href="#" onclick="history.back(); return false;">戻る</a><br>
<br>
