<%= javascript_include_tag "admin/admin_user" %>

<%= render :partial => "submenu" %>

<div id="main"><!-- メイン -->

<h2>メンバー管理</h2>
<br />
<div class="btn_t">
  <%= button_to '新規登録', new_admin_admin_user_path ,:class =>"btn_s"%>
</div>
<br />
<%= flash[:notice] %>
<%= flash[:error] %>
<table class="data2" cellspacing="1">
  <tr>
    <th>権限</th>
    <th>名前</th>
    <th>所属</th>
    <th>販売元</th>
    <th>稼働</th>
    <th>非稼働</th>
    <th>編集</th>
    <th>削除</th>
    <th>移動</th>
  </tr>
  <% unless @admin_users.empty? -%>
    <% @admin_users.each_with_index do | record, index | -%>
    <% @record = record -%>
  <tr>
    <td><%=h authority_name(record.authority_id) %></td>
    <td><%=h record.name %></td>
    <td><%=h record.belongs_to %></td>
    <td><%=h record.retailer.name %></td>
    <td class="t_center"><%= radio_button_tag "activity_#{index}", "true", checked=record.activity==1, {:onclick=>"fnUpdateActivity(#{record.id}, 'true')"} %></td>
    <td class="t_center"><%= radio_button_tag "activity_#{index}", "false", checked=record.activity==0, {:onclick=>"fnUpdateActivity(#{record.id}, 'false')"} %></td>
    <td class="t_center"><%= link_to "編集", edit_admin_admin_user_path(record) %></td>
    <td class="t_center">
      <% unless record.id == session[:admin_user].id %>
        <%= link_to "削除", admin_admin_user_path(record), :confirm => "本当に削除しますか？", :method => :delete %>
      <% end %>
    </td>
    <td class="t_center">
      <% if index > 0 -%>
        <%= link_to '上へ', { :action => 'up', :id => record.id } %>
      <% end -%>
      <% if index < @admin_users.size-1 -%>
        <%= link_to '下へ', { :action => "down", :id => record.id } %>
      <% end -%>
    </td>
  </tr>
    <% end -%>
  <% end -%>
</table>
</div><!-- メイン -->
