<div class="row">
  <div class="col-md-12">
    <h1>
      <%= _('Editing profile for %{username}') % { username: @user.name(false) } %>
      <%= link_to(_('View all users'), admin_index_users_path, class: 'btn btn-default pull-right', role: 'button') %>
    </h1>
  </div>
</div>

<div class="row">
  <div class="col-md-7">
    <%= form_for(@user, namespace: :orgadmin, as: :user, url: org_admin_user_path(@user), html: {method: :put, id: 'org_admin_user_edit' }) do |f| %>
      <div class="form-group col-xs-12">
        <%= f.label(:email, _('Email'), class: 'control-label') %>
        <%= f.email_field(:email, class: "form-control", "disabled": true) %>
      </div>

      <div class="form-group col-xs-12">
        <%= f.label(:firstname, _('First name'), class: 'control-label') %>
        <%= f.text_field(:firstname, class: "form-control", "disabled": true) %>
      </div>

      <div class="form-group col-xs-12">
        <%= f.label(:surname, _('Last name'), class: 'control-label') %>
        <%= f.text_field(:surname, class: "form-control", "disabled": true) %>
      </div>

      <% if @departments.any? %>
      <div class="form-group col-xs-12">
        <% dept_id = @user.department.nil? ? -1 : @user.department.id  %>
        <%= f.label(:department_id, d_('dmpopidor', 'Structure'), class: 'control-label') %>
        <%= select_tag(:department_id,
            options_from_collection_for_select(@departments, "id", "name", dept_id),
            include_blank: true,
            disabled: current_user.org.active? == false,
            class: "form-control",
            name: 'user[department_id]') %>
      </div>
      <% end %>

      <% if Language.many? %>
        <div class="form-group col-xs-12">
          <% lang_id = @user.language.nil? ? Language.id_for(FastGettext.default_locale) : @user.language.id %>
          <%= f.label(:language_id, _('Language'), class: 'control-label') %>
          <%= select_tag(:org_admin_user_language_id,
              options_from_collection_for_select(Language.sorted_by_abbreviation, "id", "name", lang_id),
              disabled: true,
              class: "form-control", name: 'org_admin_user[language_id]') %>
        </div>
      <% end %>

      <div class="form-group col-xs-12">
        <!-- Hide save button if no departments for org -->
        <% if @departments.any? && @user.org.active? %>
          <%= f.button(_('Save'), class: 'btn btn-default', type: "submit", id: "personal_details_registration_form_submit") %>
        <% end %>
      </div>
    <% end %>
  </div>
</div>

<div class="row">
  <div class="col-md-12">
    <h2><%= _('Plans') % { username: @user.name(false) } %></h2>
    <!-- if the user has projects -->
  </div>
</div>
<div class="row">
  <div class="col-md-12">
    <%= paginable_renderise(
      partial: '/paginable/plans/org_admin_other_user',
      controller: 'paginable/plans',
      action: 'org_admin_other_user',
      scope: @plans,
      query_params: { sort_field: 'plans.updated_at', sort_direction: 'desc' }) %>
  </div>
</div>
