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

<%= form_for(@school, url: path, html: { method: method, multipart: true })  do |f| %>
<table class="editForm">
  <tr>
    <th class="requiredField"><%= f.label :displayName %></th>
    <td><%= f.text_field :displayName, :required => 'required', :autofocus => @is_new_school ? true : nil %></td>
  </tr>

  <tr>
    <th class="requiredField"><%= f.label :cn %></th>
    <td><%= f.text_field :cn, :required => 'required' %></td>
  </tr>

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

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

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

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

  <tr>
    <th><%= f.label :description %></th>
    <td><%= f.text_field :description %></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 :image %></th>
    <td><%= f.file_field(:image, accept: 'image/*') %></td>
  </tr>

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

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

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

  <% if current_user.organisation_owner? %>
  <tr class="ownersOnly">
    <th><%= f.label :puavoBillingInfo, nil, for: "puavoBillingInfo0" %></th>
    <td>
      <div id="school_puavoBillingInfo">
      <% if Array(f.object.puavoBillingInfo).empty? %>
        <input id='puavoBillingInfo0' name='school[puavoBillingInfo][]' type='text' />
      <% else %>
        <% Array(f.object.puavoBillingInfo).each_index do |index| %>
          <input id='puavoBillingInfo<%= index %>' name='school[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>
  <% end %>

  <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>

  <% if current_user.organisation_owner? %>
  <tr class="ownersOnly">
    <th><%= f.label :puavoImageSeriesSourceURL, nil, for: "puavoImageSeriesSourceURL0" %></th>
    <td>
      <%= default_value_by_parent(f.object, :puavoImageSeriesSourceURL) %>
      <%= multiple_text_field(f.object, "puavoImageSeriesSourceURL", t('shared.add_puavoImageSeriesSourceURL')) %>
    </td>
  </tr>
  <% end %>

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

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

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

</table>

<%= render :partial => 'shared/form_mountpoint', :locals => { :f => f } %>

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

<% end %>
