<% content_for :js do %> <%= javascript_include_tag 'views/absence_justifications/form' %> <% end %> <%= simple_form_for @absence_justification, html: { class: "smart-form", id: 'absence_justification' } do |f| %> <%= f.error_notification %> <%= render 'base_errors', f: f %> <% readonly = @absence_justification.legacy || !['new', 'create'].include?(action_name) %> <% if @absence_justification.legacy %>
Não é possível editar uma justificativa de falta anterior ao ano de 2023.
<% end %>
<%= f.association :unity, as: :select2_unity, user: current_user %>
<% if current_user.current_role_is_admin_or_employee? %> <%= f.association :classroom, as: :select2_classroom, user: current_user, record: f.object %> <% else %> <%= f.association :classroom, as: :select2, elements: @classrooms, user: current_user, record: f.object, readonly: readonly %> <% end %>
<% if @absence_justification.legacy %>
<% if current_user.current_role_is_admin_or_employee? %> <%= f.association :disciplines, as: :select2_discipline, multiple: true, user: current_user, classroom_id: @absence_justification.classroom_id, admin_or_employee: current_user.current_role_is_admin_or_employee?, required: true, input_html: { value: f.object.discipline_ids.join(','), readonly: readonly, data: { without_json_parser: true } } %> <% else %> <%= f.association :disciplines, as: :select2, elements: @disciplines, multiple: true, user: current_user, classroom_id: @absence_justification.classroom_id, admin_or_employee: current_user.current_role_is_admin_or_employee?, required: true, input_html: { value: f.object.discipline_ids.join(','), readonly: readonly, data: { without_json_parser: true } } %> <% end %>
<% end %>
<%= f.input :absence_date, input_html: { readonly: readonly } %>
<%= f.input :absence_date_end, input_html: { readonly: readonly } %>
<% if @absence_justification.legacy %>
<%= f.association :students, as: :select2, elements: @students, multiple: true, required: true, input_html: { value: f.object.student_ids.join(','), readonly: readonly, data: { without_json_parser: true } } %>
<% end %>
<% unless @absence_justification.legacy %>
<%= f.input :period, as: :select2, elements: Periods.to_select_specific_values(false, %w[1 2 3]).to_json, readonly: @period != Periods::FULL %>
<%= f.association :students, as: :select2, elements: @students, multiple: true, required: true, input_html: { value: f.object.student_ids.join(','), readonly: readonly, data: { without_json_parser: true } } %>
<% if @frequency_by_discipline %>
<%= f.input :class_number, as: :select2, multiple: true, hint: "O não preenchimento do campo 'Aula' vincula a justificativa de falta com todas as aulas do período selecionado.", elements: number_of_classes_elements(@absence_justification.school_calendar.number_of_classes), input_html: { value: @absence_justification.class_number, readonly: readonly, data: { without_json_parser: true } } %>
<% end %>
<% end %>
<%= f.input :justification, input_html: { readonly: @absence_justification.legacy || action_name == 'show' } %>
Anexos
Somente arquivos nos formatos jpeg, jpg, png, gif, pdf, odt, doc, docx, ods, xls, xlsx, odp, ppt, pptx, odg, xml, csv. Tamanho máximo por arquivo: 3MB

<% if f.object.errors[:absence_justification_attachments].present? %>
<%= f.object.errors[:absence_justification_attachments].join "
" %>
<% end %> <%= f.simple_fields_for :absence_justification_attachments, f.object.absence_justification_attachments do |attachment| %> <% if attachment.object.persisted? %> <%= render 'absence_justification_attachment_show', f: attachment %> <% else %> <%= render 'absence_justification_attachment_fields', f: attachment %> <% end %> <% end %>
Anexo
<%= link_to_add_association t('.add_attachment'), f, :absence_justification_attachments, class: 'btn btn-success btn-sm', disabled: @absence_justification.legacy || action_name == 'show', :"data-association-insertion-method" => "append", :"data-association-insertion-node" => "#absence-justification-attachments" %>
<% if action_name == 'show' %>
Faltas justificadas <% if @absences_justified.empty? %> <% end %> <% @absences_justified.each do |absence_justified| %> <% end %>
Aluno Dia Aula Disciplina
Nenhuma falta foi justificada.
<%= absence_justified[:student_name] %> <%= absence_justified[:frequency_date] %> <%= absence_justified[:class_number] == 0 ? 'Todas' : absence_justified[:class_number] %> <%= absence_justified[:discipline_name] %>
<% end %> <%= hidden_field_tag :current_date, Time.now.strftime("%d/%m/%Y") %> <%= hidden_field_tag :teacher_id, current_teacher %>
<% end %>