<script type="text/javascript">
var localDomains = "";
$(document).ready(function() {
  $.validationEngineLanguage.newLang(localDomains);
  $("form.app_env").each(function(index, element){
    $(element).validationEngine({
      success : function() { $(element).submit(); },
      failure : function() {}
    });
  });
});

</script>

<fieldset>
  <h2><%= $param_label['FILE_LIFE_PERIOD'] %></h2>
  <div class="table-sys-a1">
    <div class="item-body">
      <div class="item-tr">
        <div class="table-sys-a2">
          <div class="item-body">
          <%- file_life_periods = @app_envs.select{|app_env| app_env.key == 'FILE_LIFE_PERIOD'} -%>
          <%- @app_envs.each do | app_env | -%>
            <%- if app_env.key == 'FILE_LIFE_PERIOD' -%>
            <div class="item-tr">
              <div class="input-mid-2-l"><%= app_env.value %>（<%= app_env.note %>）</div>
              <div class="input-mid-2-r">
              <%= link_to '[編集]', {action: :edit1, id: app_env.id } -%>
              <%- if file_life_periods.size > 1 -%>
                <%= link_to '[削除]', {action: :destroy, id: app_env.id}, class: 'delete', data: { turbo: true, turbo_method: "delete", turbo_confirm: '削除します。よろしいですか?' } -%>
              <%- end -%>
              </div>
            </div>
            <%- end -%>
          <%- end -%>
          </div>
        </div>
        <div class="table-sys-a2">
          <div class="item-body">
          <%= form_with(model: @app_env, url: {action: :create},
                        id: 'app_env1', class: 'app_env', html: {name: "app_env1"}) do |f| -%>
            <div class="item-tr">
              <div class="item-mid"><%= $param_label['FILE_LIFE_PERIOD'] %>の登録</div>
              <div class="input-mid">
                <%= f.hidden_field :key, {value: "FILE_LIFE_PERIOD"} -%>
                <%= f.hidden_field :category, {value: @category} -%>
                <%= 
                    f.text_field :term, 
                    class: 'validate[required, custom[onlyNumber], funcCall[validateTermUnit]]', 
                    size: 5, 
                    data: {key: 'FILE_LIFE_PERIOD', category: @category} 
                   -%>
                <%= f.select :unit, options_for_select([["日", 1], ["時間", 0]], nil), {}, {id: 'period_unit'} -%>
                <%= f.submit "登　録" -%>
              </div> 
            </div>
          <% end %>
          </div>
        </div>
      </div>
    </div>
  </div>
</fieldset>

<br>

<fieldset>
  <h2><%= $param_label['FILE_LIFE_PERIOD_DEF'] %></h2>
  <div class="table-sys-a1">
    <div class="item-body">
    <%- 
    file_life_period_def = @selected_file_life_period.try(:id) 
    file_life_period_def_value = @selected_file_life_period.try(:note) || '未設定'
    -%>
    <%- c=0 -%>
    <%- @app_envs.each do | app_env | -%>
      <%- if app_env.key == 'FILE_LIFE_PERIOD_DEF' -%>
        <%= form_with(model: app_env, url: {action: :update, id: app_env.id},
                      id: 'app_env2', class: 'app_env', method: :put, html: {name: "app_env2"}) do |f| -%>
        <div class="item-tr">
          <div class="item-mid"><%= $param_label['FILE_LIFE_PERIOD_DEF'] %></div>
          <div class="input-mid">
            設定値：<%= file_life_period_def_value %>&nbsp;&nbsp;&nbsp;&nbsp;
            <%= f.hidden_field :key, {value: "FILE_LIFE_PERIOD_DEF"} -%>
            <%= f.hidden_field :category, {value: @category} -%>
            <%= 
            f.select :value, 
              options_from_collection_for_select(@file_life_periods, :id, :note, file_life_period_def)
            -%>
            <%= f.submit "更　新" -%>
          </div>
        </div>
        <%- end -%>
        <%- c += 1 -%>
      <%- end -%>
    <%- end -%>
    <%- if c == 0 -%>
      <%= form_with(model: @app_env, url: {action: :create},
                    id: 'app_env2', class: 'app_env', html: {name: "app_env2"}) do |f| -%>
        <div class="item-tr">
          <div class="item-mid"><%= $param_label['FILE_LIFE_PERIOD_DEF'] %></div>
          <div class="input-mid">
            設定値：<%= file_life_period_def_value %>&nbsp;&nbsp;&nbsp;&nbsp;
            <%= f.hidden_field :key, {value: "FILE_LIFE_PERIOD_DEF"} -%>
            <%= f.hidden_field :category, {value: @category} -%>
            <%= 
            f.select :value, 
              options_from_collection_for_select(@file_life_periods, :id, :note, file_life_period_def)
            -%>
            <%= f.submit "登　録" -%>
          </div>
        </div>
      <% end %>
    <% end -%>
    </div>
  </div>
</fieldset>

<br>

<fieldset>
  <h2><%= $param_label['RECEIVERS_LIMIT'] %>(単位：<%= $param_unit['RECEIVERS_LIMIT'] %>)</h2>
  <div class="table-sys-a1">
    <div class="item-body">
    <%- c=0 -%>
    <%- @app_envs.each do | app_env | -%>
      <%- if app_env.key == 'RECEIVERS_LIMIT' -%>
      <div class="item-tr">
        <div class="input-mid-2-l"><%= app_env.value %><%= $param_unit['RECEIVERS_LIMIT'] %></div>
        <div class="input-mid-2-r">
        <%= link_to '[編集]', {action: :edit1, id: app_env.id } -%>
        </div>
      </div>
        <%- c += 1 -%>
      <%- end -%>
    <%- end -%>
    <%- if c == 0 -%>
      <%= form_with(model: @app_env, url: {action: :create},
                    id: 'app_env3', class: 'app_env', html: {name: "app_env3"}) do |f| -%>
      <div class="item-tr">
        <div class="item-mid"><%= $param_label['RECEIVERS_LIMIT'] %>の登録</div>
        <div class="input-mid">
          <%= f.hidden_field :key, {value: "RECEIVERS_LIMIT"} -%>
          <%= f.hidden_field :category, {value: @category} -%>
          <%= 
          f.text_field :value, 
            class: 'validate[required, custom[onlyNumber], min[1], max[100]]', 
            size: 5, 
            data: {key: 'RECEIVERS_LIMIT', category: @category} 
          -%>
          <%= f.submit "登　録" -%>
        </div>
      </div>
      <%- end -%>
    <%- end -%>
    </div>
  </div>
</fieldset>

<br>

<fieldset>
  <h2><%= $param_label['FILE_SEND_LIMIT'] %>(単位：<%= $param_unit['FILE_SEND_LIMIT'] %>)</h2>
  <div class="table-sys-a1">
    <div class="item-body">
    <%- c=0 -%>
    <%- @app_envs.each do | app_env | -%>
      <% if app_env.key == 'FILE_SEND_LIMIT' -%>
      <div class="item-tr">
        <div class="input-mid-2-l"><%= app_env.value %><%= $param_unit['FILE_SEND_LIMIT'] %></div>
        <div class="input-mid-2-r">
          <%= link_to '[編集]', {action: :edit1, id: app_env.id } %>
        </div>
      </div>
        <% c += 1 -%>
      <% end -%>
    <% end -%>
    <% if c == 0 -%>
      <%= form_with(model: @app_env, url: {action: :create},
                    id: 'app_env4', class: 'app_env', html: {name: "app_env4"}) do |f| -%>
        <div class="item-tr">
          <div class="item-mid"><%= $param_label['FILE_SEND_LIMIT'] %>の登録</div>
          <div class="input-mid">
            <%= f.hidden_field :key, {value: 'FILE_SEND_LIMIT'} %>
            <%= f.hidden_field :category, {value: @category} %>
            <%= 
            f.text_field :value, 
              class: 'validate[required, custom[onlyNumber], min[1], max[100]]', 
              size: 5, 
              data: {key: 'FILE_SEND_LIMIT', category: @category} 
            %>
            <%= f.submit "登　録" %>
          </div> 
        </div> 
      <% end %>
    <% end -%>
    </div>
  </div>
</fieldset>

<br>

<fieldset>
  <h2><%= $param_label['FILE_SIZE_LIMIT'] %>(単位：<%= $param_unit['FILE_SIZE_LIMIT'] %>)</h2>
  <div class="table-sys-a1">
    <div class="item-body">
    <%- c=0 -%>
    <%- @app_envs.each do | app_env | -%>
      <%- if app_env.key == 'FILE_SIZE_LIMIT' -%>
      <div class="item-tr">
        <div class="input-mid-2-l"><%= app_env.value %><%= $param_unit['FILE_SIZE_LIMIT'] %></div>
        <div class="input-mid-2-r">
        <%= link_to '[編集]', {action: :edit1, id: app_env.id } -%>
        </div>
      </div>
        <%- c += 1 -%>
      <%- end -%>
    <%- end -%>
    <%- if c == 0 -%>
      <%= form_with(model: @app_env, url: {action: :create},
                    id: 'app_env5', class: 'app_env', html: {name: "app_env5"}) do |f| -%>
        <div class="item-tr">
          <div class="item-mid"><%= $param_label['FILE_SIZE_LIMIT'] %>の登録</div>
          <div class="input-mid">
            <%= f.hidden_field :key, {value: 'FILE_SIZE_LIMIT'} -%>
            <%= f.hidden_field :category, {value: @category} -%>
            <%= 
            f.text_field :value, 
              class: 'validate[required, custom[onlyNumber], min[1], max[102400]]', 
              size: 5, 
              data: {key: 'FILE_SIZE_LIMIT', category: @category} 
            -%>
            <%= f.submit "登　録" -%>
          </div> 
        </div> 
      <%- end -%>
    <%- end -%>
    </div>
  </div>
</fieldset>

<br>

<fieldset>
  <h2><%= $param_label['FILE_TOTAL_SIZE_LIMIT'] %>(単位：<%= $param_unit['FILE_TOTAL_SIZE_LIMIT'] %>)</h2>
  <div class="table-sys-a1">
    <div class="item-body">
    <%- c=0 -%>
    <%- @app_envs.each do | app_env | -%>
      <%- if app_env.key == 'FILE_TOTAL_SIZE_LIMIT' -%>
      <div class="item-tr">
        <div class="input-mid-2-l"><%= app_env.value %><%= $param_unit['FILE_TOTAL_SIZE_LIMIT'] %></div>
        <div class="input-mid-2-r">
        <%= link_to '[編集]', {action: :edit1, id: app_env.id } -%>
        </div>
      </div>
        <%- c += 1 -%>
      <%- end -%>
    <%- end -%>
    <%- if c == 0 -%>
      <%= form_with(model: @app_env, url: {action: :create},
                    id: 'app_env6', class: 'app_env', html: {name: "app_env6"}) do |f| -%>
        <div class="item-tr">
          <div class="item-mid"><%= $param_label['FILE_TOTAL_SIZE_LIMIT'] %>の登録</div>
          <div class="input-mid">
            <%= f.hidden_field :key, {value: 'FILE_TOTAL_SIZE_LIMIT'} -%>
            <%= f.hidden_field :category, {value: @category} -%>
            <%= 
            f.text_field :value, 
              class: 'validate[required, custom[onlyNumber], min[1], max[204800]]', 
              size: 5, 
              data: {key: 'FILE_TOTAL_SIZE_LIMIT', category: @category} 
            -%>
            <%= f.submit "登　録" -%>
          </div> 
        </div> 
      <%- end -%>
    <%- end -%>
    </div>
  </div>
</fieldset>

<br>

<fieldset>
  <h2><%= $param_label['MESSAGE_LIMIT'] %>(単位：<%= $param_unit['MESSAGE_LIMIT'] %>)</h2>
  <div class="table-sys-a1">
    <div class="item-body">
    <%- c=0 -%>
    <%- @app_envs.each do | app_env | -%>
      <%- if app_env.key == 'MESSAGE_LIMIT' -%>
      <div class="item-tr">
        <div class="input-mid-2-l"><%= app_env.value %><%= $param_unit['MESSAGE_LIMIT'] %></div>
        <div class="input-mid-2-r">
          <%= link_to '[編集]', {action: :edit1, id: app_env.id } -%>
        </div>
      </div>
        <%- c += 1 -%>
      <%- end -%>
    <%- end -%>
    <%- if c == 0 -%>
      <%= form_with(model: @app_env, url: {action: :create},
                    id: 'app_env7', class: 'app_env', html: {name: "app_env7"}) do |f| -%>
        <div class="item-tr">
          <div class="item-mid"><%= $param_label['MESSAGE_LIMIT'] %>の登録</div>
          <div class="input-mid">
            <%= f.hidden_field :key, {value: 'MESSAGE_LIMIT'} -%>
            <%= f.hidden_field :category, {value: @category} -%>
            <%= 
            f.text_field :value, 
              class: 'validate[required, custom[onlyNumber], min[1], max[3000]]', 
              size: 5, 
              data: {key: 'MESSAGE_LIMIT', category: @category} 
            -%>
            <%= f.submit "登　録" -%>
          </div> 
        </div>
      <%- end -%>
    <%- end -%>
    </div>
  </div>
</fieldset>

<br>

<fieldset>
  <h2><%= $param_label['PW_LENGTH_MIN'] %>(単位：<%= $param_unit['PW_LENGTH_MIN'] %>)</h2>
  <div class="table-sys-a1">
    <div class="item-body">
    <%- c=0 -%>
    <%- @app_envs.each do | app_env | -%>
      <%- if app_env.key == 'PW_LENGTH_MIN' -%>
      <div class="item-tr">
        <div class="input-mid-2-l"><%= app_env.value %><%= $param_unit['PW_LENGTH_MIN'] %></div>
        <div class="input-mid-2-r">
          <%= link_to '[編集]', {action: :edit1, id: app_env.id } -%>
        </div>
      </div>
        <% c += 1 -%>
      <% end -%>
    <% end -%>
    <% if c == 0 -%>
      <%= form_with(model: @app_env, url: {action: :create},
                    id: 'app_env8', class: 'app_env', html: {name: "app_env8"}) do |f| -%>
        <div class="item-tr">
          <div class="item-mid"><%= $param_label['PW_LENGTH_MIN'] %>の登録</div>
          <div class="input-mid">
            <%= f.hidden_field :key, {value: 'PW_LENGTH_MIN'} -%>
            <%= f.hidden_field :category, {value: @category} -%>
            <%= 
            f.text_field :value, 
              class: 'validate[required, custom[onlyNumber], min[1], max[64], funcCall[validatePWLengthMinMax]]', 
              size: 5, 
              data: {key: 'PW_LENGTH_MIN', category: @category} 
            -%>
            <%= f.submit "登　録" -%>
          </div> 
        </div>
      <%- end -%>
    <%- end -%>
    </div>
  </div>
</fieldset>

<br>

<fieldset>
  <h2><%= $param_label['PW_LENGTH_MAX'] %>(単位：<%= $param_unit['PW_LENGTH_MAX'] %>)</h2>
  <div class="table-sys-a1">
    <div class="item-body">
    <%- c=0 -%>
    <%- @app_envs.each do | app_env | -%>
      <%- if app_env.key == 'PW_LENGTH_MAX' -%>
      <div class="item-tr">
        <div class="input-mid-2-l"><%= app_env.value %><%= $param_unit['PW_LENGTH_MAX'] %></div>
        <div class="input-mid-2-r">
        <%= link_to '[編集]', {action: :edit1, id: app_env.id } -%>
        </div>
      </div>
        <%- c += 1 -%>
      <%- end -%>
    <%- end -%>
    <%- if c == 0 -%>
      <%= form_with(model: @app_env, url: {action: :create},
                    id: 'app_env9', class: 'app_env', html: {name: "app_env9"}) do |f| -%>
        <div class="item-tr">
          <div class="item-mid"><%= $param_label['PW_LENGTH_MAX'] %>の登録</div>
          <div class="input-mid">
            <%= f.hidden_field :key, {value: 'PW_LENGTH_MAX'} -%>
            <%= f.hidden_field :category, {value: @category} -%>
            <%= 
            f.text_field :value, 
              class: 'validate[required, custom[onlyNumber], min[1], max[64], funcCall[validatePWLengthMinMax]]', 
              size: 5, 
              data: {key: 'PW_LENGTH_MAX', category: @category} 
            -%>
            <%= f.submit "登　録" -%>
          </div> 
        </div>
      <%- end -%>
    <%- end -%>
    </div>
  </div>
</fieldset>

<br>

