<% page_title t('titles.organisation'), t('titles.edit') %>

<div class="formContainer">

<h1><%= t('.title') %></h1>

<p class="requiredTitle"><%= t('layouts.forms.required_field') %></p>

<%= form_for(@organisation, url: organisation_path)  do |f| %>
<table class="editForm">
  <tr>
    <th class="requiredField"><%= f.label :o %></th>
    <td><%= f.text_field :o, required: 'required', autofocus: true %></td>
  </tr>

  <tr>
    <th><%= f.label :puavoEduOrgAbbreviation %></th>
    <td><%= f.text_field :puavoEduOrgAbbreviation %></td>
  </tr>

  <tr>
    <th><%= f.label :description %></th>
    <td><%= f.text_field :description %></td>
  </tr>

  <tr>
    <th><%= f.label :puavoOrganisationOID %></th>
    <td><%= f.text_field :puavoOrganisationOID %></td>
  </tr>

  <tr>
    <th><%= f.label :puavoNotes %></th>
    <td><%= f.text_area :puavoNotes, rows: 10, class: 'resize-v' %></td>
  </tr>

  <tr>
    <th><%= f.label :telephoneNumber %></th>
    <td><%= f.text_field :telephoneNumber %></td>
  </tr>

  <tr>
    <th><%= f.label :facsimileTelephoneNumber %></th>
    <td><%= f.text_field :facsimileTelephoneNumber %></td>
  </tr>

  <tr>
    <th><%= f.label :l %></th>
    <td><%= f.text_field :l %></td>
  </tr>

  <tr>
    <th><%= f.label :street %></th>
    <td><%= f.text_field :street %></td>
  </tr>

  <tr>
    <th><%= f.label :postOfficeBox %></th>
    <td><%= f.text_field :postOfficeBox %></td>
  </tr>

  <tr>
    <th><%= f.label :postalAddress %></th>
    <td><%= f.text_field :postalAddress %></td>
  </tr>

  <tr>
    <th><%= f.label :postalCode %></th>
    <td><%= f.text_field :postalCode %></td>
  </tr>

  <tr>
    <th><%= f.label :st %></th>
    <td><%= f.text_field :st %></td>
  </tr>

  <tr>
    <th><%= f.label :puavoLocale %></th>
    <td><%= f.select :puavoLocale, locales_for_select %></td>
  </tr>

  <tr>
    <th><%= f.label :puavoTimezone %></th>
    <td><%= f.select :puavoTimezone, timezones_for_select(f.object.puavoTimezone) %></td>
  </tr>

  <tr>
    <th><%= f.label :puavoKeyboardLayout %></th>
    <td><%= f.text_field :puavoKeyboardLayout %></td>
  </tr>

  <tr>
    <th><%= f.label :puavoKeyboardVariant %></th>
    <td><%= f.text_field :puavoKeyboardVariant %></td>
  </tr>

  <%= render(partial: 'shared/form_boolean_attribute', locals: { f: f, attribute: :puavoAutomaticImageUpdates }) %>

  <tr>
    <th><%= f.label :eduOrgHomePageURI %></th>
    <td><%= f.text_field :eduOrgHomePageURI %></td>
  </tr>

  <%= render(partial: 'shared/form_auto_power_off_settings', locals: { f: f }) %>

  <tr>
    <th><%= f.label :puavoDeviceImage %></th>
    <td>
      <%= f.text_field :puavoDeviceImage %>
      <p style="margin: 0;"><%= t('shared.img_extension_will_be_stripped') %></p>
      <% if @image_filenames_by_release %>
      <%= render partial: 'shared/known_recent_releases_selector' %>
      <% end %>
    </td>
  </tr>

  <tr>
    <th><%= f.label :puavoImageSeriesSourceURL, nil, for: "puavoImageSeriesSourceURL0" %></th>
    <td><%= multiple_text_field(f.object, "puavoImageSeriesSourceURL", t('shared.add_puavoImageSeriesSourceURL')) %></td>
  </tr>

  <!-- < %= render :partial => 'shared/form_allow_guest_and_personal_device', :locals => { :f => f } % > -->

  <%= render(partial: 'shared/form_puavoconf', locals: { f: f }) %>

  <tr>
    <th><%= f.label :puavoBillingInfo, nil, for: "puavoBillingInfo0" %></td>
    <td>
      <div id="organisation_puavoBillingInfo">
        <% if Array(f.object.puavoBillingInfo).empty? %>
        <input id='puavoBillingInfo0' name='ldap_organisation[puavoBillingInfo][]' type='text' />
        <% else %>
        <% Array(f.object.puavoBillingInfo).each_index do |index| %>
        <input id='puavoBillingInfo<%= index %>' name='ldap_organisation[puavoBillingInfo][]' type='text' value='<%= Array(f.object.puavoBillingInfo)[index] %>' />
        <% end %>
        <% end %>
      </div>
      <%= link_to "#", class: "clone_prev_input_element btn" do %>
        <i class="icon-plus"></i><%= t('.add_puavo_billing_info') %>
      <% end %>
    </td>
  </tr>

  <tr class="buttonRow">
    <td colspan="2">
      <%= f.submit t('link.update'), class: 'btn' %>
      <div class="cancel"><%= link_to t('link.cancel'), organisation_path, class: 'btn btn-danger' %></div>
    </td>
  </tr>
</table>

<% end %>

</div>

<%= render partial: 'shared/puavoconf_editor_templates' %>
<%= render partial: 'shared/puavoconf_editor', locals: { storage: 'ldap_organisation_puavoConf' } %>

<% if @image_filenames_by_release %>
<%= render partial: 'shared/known_recent_releases_selector', formats: :js, locals: { edit_field: 'ldap_organisation_puavoDeviceImage' } %>
<% end %>
