<!-- shared/_form_linux_device_information starts -->
<h2><%= title(f.object) %></h2>
<table class="editForm">
  <tr>
    <th><%= f.label :puavoDeviceManufacturer %></th>
    <td><%= f.text_field :puavoDeviceManufacturer %></td>
  </tr>

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

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

  <tr>
    <th><%= f.label :macAddress, nil, for: "macAddress0" %></th>
    <td><%= multiple_text_field(f.object, "macAddress", t('shared.add_macAddress')) %></td>
  </tr>

  <% if f.object.classes.include?('puavoPrinter') || f.object.classes.include?('puavoOtherDevice') %>
  <tr>
    <th><%= f.label :ipHostNumber %></th>
    <td><%= f.text_field :ipHostNumber %></td>
  </tr>
  <% end %>

  <% unless f.object.classes.include?('puavoPrinter') || f.object.classes.include?('puavoOtherDevice') || f.object.classes.include?('puavoServer') %>
  <tr>
    <th><%= f.label :puavoDevicePrimaryUser %></th>
    <td><%= f.text_field :puavoDevicePrimaryUser, :value => get_uid_by_dn(f.object.puavoDevicePrimaryUser) %></td>
  </tr>
  <% end %>

  <% unless f.object.classes.include?('puavoServer') || f.object.classes.include?('puavoPrinter') ||  f.object.classes.include?('puavoOtherDevice') %>
  <tr>
    <th><%= f.label :puavoDeviceBootMode %></th>
    <td><%= f.select( :puavoDeviceBootMode,
            [ [t('shared.boot_mode_netboot'),"netboot"],
            [t('shared.boot_mode_dualboot'), "dualboot"] ] ) %></td>
  </tr>
  <% end %>

  <% unless f.object.classes.include?('puavoPrinter') || f.object.classes.include?('puavoOtherDevice') %>
  <tr>
    <th><%= f.label :puavoPrinterDeviceURI %></th>
    <td><%= f.text_field :puavoPrinterDeviceURI %></td>
  </tr>

  <% unless f.object.classes.include?('puavoServer') %>
  <tr>
    <th><%= f.label :puavoPrinterPPD %></th>
    <td><%= f.file_field :puavoPrinterPPD %></td>
  </tr>
  <% end %>

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

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

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

  <% if f.object.class == Device %>
  <%= render :partial => 'shared/form_allow_guest_and_personal_device', :locals => { :f => f } %>
  <% end %>

  <% if ["laptop", "wirelessaccesspoint"].include?(f.object.puavoDeviceType) %>
    <%= render( :partial => 'shared/form_boolean_attribute',
                :locals => {
                  :f => f,
                  :attribute => :puavoAutomaticImageUpdates } ) %>
  <% end %>

  <% if ["laptop"].include?(f.object.puavoDeviceType) %>
    <%= render( :partial => 'shared/form_boolean_attribute',
                :locals => {
                  :f => f,
                  :attribute => :puavoPersonallyAdministered } ) %>
  <% end %>

  <% end %>

  <tr>
    <th><%= f.label :description %></th>
    <td><%= f.text_area :description, cols: 40, rows: 6 %></td>
  </tr>

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

<% unless f.object.classes.include?('puavoServer') || f.object.classes.include?('puavoPrinter') || f.object.classes.include?('puavoOtherDevice') %>
<h2><%= t('shared.autopoweroff') %></h2>
<table  class="editForm" id="autopoweroff">

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

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

<h2><%= t('shared.location') %></h2>
<table class="editForm">
  <tr>
    <th><%= f.label :puavoLocationName %></th>
    <td><%= f.text_area :puavoLocationName, :rows => 5 %></td>
  </tr>

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

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

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

<% if (f.object.classes | ['puavoNetbootDevice', 'puavoLocalbootDevice', 'puavoServer']).count < (f.object.classes.count + 3) %>

<h2><%= t('shared.display_settings') %></h2>
<table class="editForm">
  <tr>
    <th><%= f.label :puavoDeviceMonitorsXML %></th>
    <td><%= f.text_area :puavoDeviceMonitorsXML, cols: 40, rows: 6 %></td>
  </tr>

  <tr>
    <th><%= f.label :puavoDeviceXrandr, nil, for: "xrandr0" %></th>
    <td>
      <div id="device_puavoDeviceXrandr">
        <% if f.object.puavoDeviceXrandr.nil? %>
        <input id='xrandr0' name='device[puavoDeviceXrandr][]'  type='text' />
        <% else %>
        <% Array(f.object.puavoDeviceXrandr).each_index do |index| %>
        <input id='xrandr<%= index %>' name='device[puavoDeviceXrandr][]'  type='text' value='<%= Array(f.object.puavoDeviceXrandr)[index] %>' />
        <% end %>
        <% end %>
      </div>
      <%= link_to "#", class: "clone_prev_input_element btn" do %>
      <i class="icon-plus"></i><%= t('shared.add_puavoDeviceXrandr') %>
      <% end %>
    </td>
  </tr>

</table>

<h2><%= t('shared.kernel_settings') %></h2>
<table class="editForm">
  <% if ["thinclient",
         "fatclient",
         "laptop",
         "ltspserver",
         "bootserver",
         "wirelessaccesspoint"].include?(f.object.puavoDeviceType) %>
  <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>
  <% end %>

  <% if f.object.puavoDeviceType == "thinclient" %>
  <tr>
    <th><%= f.label :puavoDeviceBootImage %></th>
    <td><%= f.text_field :puavoDeviceBootImage %></td>
  </tr>
  <% end %>

  <% if current_user.organisation_owner? %>
  <tr>
    <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 :puavoDeviceKernelVersion %></th>
    <td><%= f.text_field :puavoDeviceKernelVersion %></td>
  </tr>

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

<% if ["thinclient", "fatclient", "laptop"].include?(f.object.puavoDeviceType) %>

<h2><%= t('shared.printers_title') %></h2>

<% if @school_printers.empty? %>
<p><%= t('shared.no_printers_for_this_device') %></p>
<% else %>
<ul class="noBullets">
<% @school_printers.each do |printer| %>
  <li>
    <label>
      <%= hidden_field_tag "printers[#{ printer[:object].dn}]", false %>
      <%= check_box_tag "printers[#{ printer[:object].dn}]", true, printer[:has_printer], :disabled => printer[:input_disabled] %>
      <%= link_to( printer[:object].printerDescription, edit_printer_permission_path(@school, printer[:object]), id: "devicePrintersList-#{printer[:object].printerDescription}") %>
    </label>
  </li>
<% end %>
</ul>
<% end %>

<% end %>

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

<% end %>
<!-- shared/_form_linux_device_information ends -->
