<%= render 'shared/base_error_alert', f: f %>
<% content_for :js do %>
  <%= javascript_include_tag 'views/avaliation_exemptions/form' %>
<% end %>

<fieldset>

  <div class="row">
    <%= f.input :school_calendar_year, as: :hidden, input_html: { value: @school_calendar_year } %>

    <div class="col col-sm-4">
      <%= f.association :unity, as: :select2_unity, user: current_user %>
    </div>

    <div class="col col-sm-4">
      <%= f.input :course_id, as: :select2_course, user: current_user,
                  classroom_id: @avaliation_exemption.classroom_id %>
    </div>

    <div class="col col-sm-4">
      <% if current_user.current_role_is_admin_or_employee? %>
        <%= f.input :grade_id, as: :select2_grade, user: current_user,
                  classroom_id: @avaliation_exemption.classroom_id %>
      <% else %>
       <%= f.input :grade_id, as: :select2, elements: @grades, user: current_user, record: f.object,
                  classroom_id: @avaliation_exemption.classroom_id, readonly: action_name != 'new' %>
      <% end %>
    </div>
  </div>

  <div class="row">
    <div class="col col-sm-4">
      <% if current_user.current_role_is_admin_or_employee? %>
        <%= f.input :classroom_id, as: :select2_classroom, user: current_user, record: f.object %>
      <% else %>
        <%= f.input :classroom_id, as: :select2, elements: @classrooms, user:
                    current_user, record: f.object, readonly: action_name != 'new'  %>
      <% end %>
    </div>

    <div class="col col-sm-4">
      <% if current_user.current_role_is_admin_or_employee? %>
        <%= f.input :discipline_id, as: :select2_discipline, user: current_user, record: f.object,
                    classroom_id: @avaliation_exemption.classroom_id %>
      <% else %>
         <%= f.input :discipline_id, as: :select2, elements: @disciplines, user: current_user, record: f.object,
                      classroom_id: @avaliation_exemption.classroom_id, readonly: action_name != 'new'  %>
      <% end %>
    </div>

    <div class="col col-sm-4 <%= 'hidden' if !@school_calendar_classroom_steps.empty? %>">
      <%= f.input :school_calendar_step, as: :select2, elements: @school_calendar_steps, readonly: f.object.persisted?, required: true %>
    </div>
    <div class="col col-sm-4 <%= 'hidden' if @school_calendar_classroom_steps.empty? %>">
      <%= f.input :school_calendar_classroom_step, as: :select2, elements: @school_calendar_classroom_steps, readonly: f.object.persisted?, required: true %>
    </div>
  </div>

  <div class="row">
    <div class="col col-sm-4">
      <%= f.input :avaliation_id, as: :select2, elements: @avaliations, readonly: f.object.persisted? %>
      <%= f.input :avaliation_date, as: :hidden, input_html: { value: f.object.persisted? ? @avaliation_exemption.avaliation.test_date : '' } %>
    </div>

    <div class="col col-sm-4">
      <%= f.input :student_id, as: :select2, elements: @students, readonly: f.object.persisted? %>
    </div>
  </div>

  <div class="row">
    <div class="col col-sm-12">
      <%= f.input :reason, as: :text %>
    </div>
  </div>

</fieldset>
