<%
  define_admin_breadcrumbs do
    add_admin_breadcrumb('身份审核列表', admins_identity_verifications_path)
    add_admin_breadcrumb('用户身份审核详情')
  end
%>

<div class="box identity_verification-edit-container">
  <div class="identity_verification-info mb-4 row">
    <%= link_to "/#{@identity_verification.user.login}", class: 'user-info-avatar col-md-1', target: '_blank', data: { toggle: 'tooltip', title: '个人中心' } do %>
      <img src="/<%= url_to_avatar(@user) %>" class="rounded-circle" width="80" height="80" />
    <% end %>
    <div class="d-flex flex-column justify-content-between col-md-3 user-info-content">
      <div class="user-info-name flex"><%= @user.real_name %> | <%= @user.id %> | <%= @user.login %></div>

      <div class="d-flex flex-row user-info-auth">
        <% if @user.authentication? %>
          <i class="fa fa-user text-success" data-toggle="tooltip" data-placement="bottom" title="已实名认证"></i>
        <% elsif @user.process_real_name_apply.present? %>
          <i class="fa fa-user text-danger" data-toggle="tooltip" data-placement="bottom" title="实名认证中"></i>
        <% else %>
          <i class="fa fa-user text-muted" data-toggle="tooltip" data-placement="bottom" title="未实名认证"></i>
        <% end %>

        <% if @user.professional_certification %>
          <i class="fa fa-list-alt text-success" data-toggle="tooltip" data-placement="bottom" title="已职业认证"></i>
        <% elsif @user.process_professional_apply.present? %>
          <i class="fa fa-list-alt text-danger" data-toggle="tooltip" data-placement="bottom" title="职业认证中"></i>
        <% else %>
          <i class="fa fa-list-alt text-muted" data-toggle="tooltip" data-placement="bottom" title="未职业认证"></i>
        <% end %>

        <% if @user.phone.present? %>
          <i class="fa fa-mobile text-success" data-toggle="tooltip" data-placement="bottom" title="已绑定手机"></i>
        <% else %>
          <i class="fa fa-mobile text-muted" data-toggle="tooltip" data-placement="bottom" title="未绑定手机"></i>
        <% end %>

        <% if @user.mail.present? %>
          <i class="fa fa-envelope text-success" data-toggle="tooltip" data-placement="bottom" title="已绑定邮箱"></i>
        <% else %>
          <i class="fa fa-envelope text-muted" data-toggle="tooltip" data-placement="bottom" title="未绑定邮箱"></i>
        <% end %>
      </div>
      <div class="user-info-last-login">最近登录：<%= @user.last_login_on&.strftime('%Y-%m-%d %H:%M') %></div>
    </div>
  </div>

  <%= simple_form_for(@identity_verification, url: admins_identity_verification_path(@identity_verification)) do |f| %>

    <div class="mt-4">
    <h6>审核信息</h6>
      <label>当前身份审核状态为 <b><%=@identity_verification.state %></b></label>

      <div class="form-row">
        <%= f.input :name, label: '姓名', wrapper_html: { class: 'col-md-3' }, input_html: { readonly: true, class: 'col-md-11' , value: @identity_verification.name } %>
      </div>
      <div class="form-row">
        <%= f.input :number, label: '身份证号', wrapper_html: { class: 'col-md-3' }, input_html: { readonly: true, class: 'col-md-11' , value: @identity_verification.number } %>
      </div>
      <label>身份证正面: </label>
      <div class="form-row">
        <td>
          <% if @identity_verification.card_front_attachment.present? %>
            <%= image_tag("/api/attachments/#{@identity_verification.card_front}", width: 100, height: 100, class: 'preview-image auth-image', data: { toggle: 'tooltip', title: '点击预览' }) %>
          <%else%>
            <p> 图片无法展示，图片已丢失</p>
          <%end%>
        </td>
      </div>
      <label>身份证背面: </label>
      <div class="form-row">
        <td>
          <% if @identity_verification.card_back_attachment.present? %>
            <%= image_tag("/api/attachments/#{@identity_verification.card_back}", width: 100, height: 100, class: 'preview-image auth-image', data: { toggle: 'tooltip', title: '点击预览' }) %>
          <%else%>
            <p> 图片无法展示，图片已丢失</p>
          <%end%>
        </td>
      </div>
      <label>手持身份证正面: </label>
      <div class="form-row">
        <td>
          <% if @identity_verification.hold_card_front_attachment.present? %>
            <%= image_tag("/api/attachments/#{@identity_verification.hold_card_front}", width: 100, height: 100, class: 'preview-image auth-image', data: { toggle: 'tooltip', title: '点击预览' }) %>
          <%else%>
            <p> 图片无法展示，图片已丢失</p>
          <%end%>
        </td>
      </div>
      <label>手持身份证背面: </label>
      <div class="form-row">
        <td>
          <% if @identity_verification.hold_card_back_attachment.present? %>
            <%= image_tag("/api/attachments/#{@identity_verification.hold_card_back}", width: 100, height: 100, class: 'preview-image auth-image', data: { toggle: 'tooltip', title: '点击预览' }) %>
          <%else%>
            <p> 图片无法展示，图片已丢失</p>
          <%end%>
        </td>
      </div>

      <% unless @identity_verification.state == "已通过"  %>
        <div class="form-row">
          <%= radio_button_tag("identity_verification[state]","已通过", required: 'required') %>通过　　
          <%= radio_button_tag("identity_verification[state]","已拒绝", required: 'required') %>拒绝
        </div>
        </br>
        <div class="form-row">
          <%= f.input :description, as: :text,label: '拒绝理由：（拒绝时请填写拒绝理由，不可以为空）', wrapper_html: { class: 'col-md-12' }, input_html: { maxlength: 100, size: 40, class: 'col-md-11' , value: @identity_verification.description } %>
        </div>
        <div class="form-row mt-4">
          <%= f.button :submit, value: '保存', class: 'btn-primary mr-3 px-4' %>
          <%= link_to '取消', admins_identity_verifications_path, class: 'btn btn-secondary px-4' %>
        </div>
      <% end %>
      </b>
    </div>
  <% end %>
</div>
