<!-- shared/_form_wlan starts -->
<p class="genericWarning">
<%= t('.warning').html_safe %>
</p>

<h2><%= t('.wireless_access_point_setup') %></h2>

<table class="editForm">
  <tr>
    <th><%= f.label :puavoWlanChannel %></th>
    <td><%= f.select( :puavoWlanChannel,
                      [ [t('.default'), ""],
                        [t('.channel_random'), "random"] ] +
                      (1..13).map{ |i| [i.to_s,i.to_s] } )%></td>
  </tr>
</table>

<h2><%= t('.wireless_network_setup') %></h2>

<% (0..14).each do |index| %>
  <h3><strong><%= t('.wireless_network_title', :index => index + 1) %></strong></h3>

  <table class="editForm">
    <tr class="wlan_name_<%= index %>">
      <th><%= label_tag "wlan_name[#{ index }]", t('.wlan_name') %></th>
      <td>
        <%= text_field_tag "wlan_name[#{ index }]", f.object.wlan_name ? f.object.wlan_name[index] : "" %>
      </td>
    </tr>

    <tr class="wlan_description_<%= index %>">
      <th><%= label_tag "wlan_description[#{ index }]", t('.wlan_description') %></th>
      <td>
        <%= text_area_tag "wlan_description[#{ index }]", f.object.wlan_description ? f.object.wlan_description[index] : "", class: "resize-v" %>
      </td>
    </tr>

    <tr>
      <th><%= label_tag "wlan_type[#{ index }]", t('.wlan_type') %></th>
      <td>
        <%= select_tag( "wlan_type[#{ index }]",
                        options_for_select([ [t('.select_value_open'),    "open"],
                                             [t('.select_value_psk'),     "psk"],
                                             [t('.select_value_eappeap'), "eap-peap"],
                                             [t('.select_value_eaptls'),  "eap-tls"],
                                             [t('.select_value_eapttls'), "eap-ttls"] ], :selected => f.object.wlan_type ? f.object.wlan_type[index] : "" ) )%>
      </td>
    </tr>

    <tr class="wlan_identity_<%= index %>">
      <th><%= label_tag "wlan_identity[#{ index }]", t('.wlan_identity') %></th>
      <td>
        <%= text_field_tag "wlan_identity[#{ index }]", f.object.wlan_identity ? f.object.wlan_identity[index] : "" %>
      </td>
    </tr>

    <tr class="wlan_password_<%= index %>">
      <th><%= label_tag "wlan_password[#{ index }]", t('.wlan_password') %></th>
      <td>
        <%= text_field_tag "wlan_password[#{ index }]", f.object.wlan_password ? f.object.wlan_password[index] : "" %>
      </td>
    </tr>

    <tr class="wlan_certs_<%= index %>">
      <th><%= label_tag "wlan_ca_cert[#{ index }]", t('.wlan_ca_cert') %></th>
      <td>
        <%= file_field_tag "wlan_ca_cert[#{ index }]" %>
        <% if f.object.wlan_ca_cert && f.object.wlan_ca_cert[index] %>
          <%= t('.file_size') %>:
            <%= wlan_certfile_size(f.object.wlan_ca_cert[index]) %>
          /
          <%= t('.file_md5') %>:
            <%= wlan_certfile_md5(f.object.wlan_ca_cert[index]) %>
        <% end %>
      </td>
    </tr>

    <tr class="wlan_certs_<%= index %>">
      <th><%= label_tag "wlan_client_cert[#{ index }]", t('.wlan_client_cert') %></th>
      <td>
        <%= file_field_tag "wlan_client_cert[#{ index }]" %>
        <% if f.object.wlan_client_cert && f.object.wlan_client_cert[index] %>
          <%= t('.file_size') %>:
            <%= wlan_certfile_size(f.object.wlan_client_cert[index]) %>
          /
          <%= t('.file_md5') %>:
            <%= wlan_certfile_md5(f.object.wlan_client_cert[index]) %>
        <% end %>
      </td>
    </tr>

    <tr class="wlan_certs_<%= index %>">
      <th><%= label_tag "wlan_client_key[#{ index }]", t('.wlan_client_key') %></th>
      <td>
        <%= file_field_tag "wlan_client_key[#{ index }]" %>
        <% if f.object.wlan_client_key && f.object.wlan_client_key[index] %>
          <%= t('.file_size') %>:
            <%= wlan_certfile_size(f.object.wlan_client_key[index]) %>
          /
          <%= t('.file_md5') %>:
            <%= wlan_certfile_md5(f.object.wlan_client_key[index]) %>
        <% end %>
      </td>
    </tr>

    <tr class="wlan_certs_<%= index %>">
      <th><%= label_tag "wlan_client_key_password[#{ index }]", t('.wlan_client_key_password') %></th>
      <td>
        <%= text_field_tag "wlan_client_key_password[#{ index }]", f.object.wlan_client_key_password ? f.object.wlan_client_key_password[index] : "" %>
      </td>
    </tr>

    <tr class="wlan_phase2_auth_<%= index %>">
      <th><%= label_tag "wlan_phase2_auth[#{ index }]", t('.wlan_phase2_auth_mschapv2') %></th>
      <td>
        <%= check_box_tag "wlan_phase2_auth[#{ index }]", "enabled", f.object.wlan_phase2_auth ? f.object.wlan_phase2_auth[index] : false %>
      </td>
    </tr>

    <tr class="wlan_priority_<%= index %>">
      <th><%= label_tag "wlan_priority[#{ index }]", t('.wlan_priority') %></th>
      <td>
        <%= select_tag( "wlan_priority[#{ index }]",
                        options_for_select([ [t('.default'),    nil],
                                             [t('.select_value_strongprefer'),  "100"],
                                             [t('.select_value_weakprefer'),     "10"],
                                             [t('.select_value_weakavoid'),     "-10"],
                                             [t('.select_value_strongavoid'),  "-100"] ], :selected => f.object.wlan_priority ? f.object.wlan_priority[index] : "" ) )%>
      </td>
    </tr>

    <tr class="wlan_ap_<%= index %>">
      <th><%= label_tag "wlan_hidden[#{ index }]", t('.wlan_hidden') %></th>
      <td>
        <%= check_box_tag "wlan_hidden[#{ index }]", 'hidden', f.object.wlan_hidden ? f.object.wlan_hidden[index] : false %>
      </td>
    </tr>

    <tr class="wlan_ap_<%= index %>">
      <th><%= label_tag "wlan_ap[#{ index }]", t('.wlan_ap') %></th>
      <td>
        <%= check_box_tag "wlan_ap[#{ index }]", "enabled", f.object.wlan_ap ? f.object.wlan_ap[index] : false %>
      </td>
    </tr>
  </table>
  <br>
<% end %>

<table class="editForm">
  <tr class="buttonRow">
    <td><%= f.submit t('link.update'), class: 'btn' %></td>
  </tr>
</table>
<!-- shared/_form_wlan ends -->
