<div id="flash-messages">
  <p class="alert alert-info calculation-type-info hidden" id="substitution-calculation-type-info">
    <i class="fa-fw fa fa-info"></i>
    <%= t('.substitution_calculation_type_html') %>
  </p>
  <p class="alert alert-info calculation-type-info hidden" id="sum-calculation-type-info">
    <i class="fa-fw fa fa-info"></i>
      <%= t('.sum_calculation_type_html') %>
  </p>
  <p class="alert alert-info calculation-type-info hidden" id="substitution_if_greater-calculation-type-info">
    <i class="fa-fw fa fa-info"></i>
      <%= t('.substitution_if_greater_calculation_type_html') %>
  </p>
  <p class="alert alert-info calculation-type-info hidden" id="integral-calculation-type-info">
    <i class="fa-fw fa fa-info"></i>
      <%= t('.integral_calculation_type_html') %>
  </p>
</div>

<div class="widget-body no-padding">

  <%= simple_form_for @complementary_exam_setting, html: { class: "smart-form" } do |f| %>
    <% if f.object.errors[:base].present? %>
      <div class="alert alert-danger fade in">
        <i class="fa-fw fa fa-times"></i>
          <%= f.object.errors[:base].first %>
      </div>
    <% end %>

    <fieldset>
      <div class="row">
        <div class="col col-sm-3">
          <%= f.input :description %>
        </div>
        <div class="col col-sm-3">
          <%= f.input :initials %>
        </div>

        <div class="col col-sm-3">
          <%= f.input :calculation_type, as: :select2, elements: CalculationTypes.to_select.to_json %>
        </div>

        <div class="col col-sm-3">
          <%= f.input :affected_score, as: :select2, elements: AffectedScoreTypes.to_select.to_json %>
        </div>
      </div>

      <div class="row">
        <div class="col col-sm-3">
          <%= f.input :maximum_score %>
        </div>

        <div class="col col-sm-3">
          <%= f.input :number_of_decimal_places %>
        </div>

        <div class="col col-sm-3">
          <%= f.input :grade_ids, as: :select2, elements: grades_to_select2(grades), multiple: true,
          input_html: { value: f.object.grade_ids.join(','), data: { without_json_parser: true } } %>
        </div>

        <div class="col col-sm-3">
          <%= f.input :year, as: :integer, readonly: action_name != 'new' %>
        </div>
      </div>
    </fieldset>

    <footer>
      <%= link_to t('views.form.back'), complementary_exam_settings_path, class: "btn btn-default" %>

      <% if @complementary_exam_setting.persisted? %>
        <%= link_to t('views.form.history'), history_complementary_exam_setting_path(@complementary_exam_setting), class: 'btn btn-info' %>
      <% end %>

      <%= f.submit t('views.form.save'), class: 'btn btn-primary', data: { disable_with: 'Salvando...'} %>
    </footer>
  <% end %>
</div>

<% content_for :js do %>
  <%= javascript_include_tag 'views/complementary_exam_settings/form' %>
<% end %>
