<%= form_with model: [aircraft, entry], class: "card card-body space-y-4 max-w-3xl", data: { controller: "entry-template signer component-times", component_times_aircraft_hours_value: aircraft.current_hours.to_f } do |f| %> <%= f.errors_summary %> <% if entry.supersedes %> <%= f.hidden_field :supersedes_id %>

<%= t(".correcting_the_signed_html", link: (link_to t(".entry", date: fmt_date(entry.supersedes.date)), aircraft_logbook_entry_path(aircraft, entry.supersedes), class: "link")) %> <%= t(".change_what_s_wrong_save") %>

<% end %> <% templates = entry.new_record? ? LogbookTemplate.ordered.to_a : [] %> <% if templates.any? %>
<%= label_tag :template, t(".template"), class: "label" %>

<%= t(".fill_in_the_blanks_the") %><% if current_user.admin? %> <%= link_to t(".edit_templates"), admin_logbook_templates_path, class: "link" %><% end %>

<% end %>
<%= f.field :date, as: :date %> <%= f.field :log_type, as: :select, label: t(".logbook"), collection: LogbookEntry::LOG_TYPES.invert, data: { component_times_target: "logType", entry_template_target: "logType", action: "component-times#logTypeChanged" } %> <%= f.field :entry_type, as: :select, label: t(".entry_type"), collection: LogbookEntry::ENTRY_TYPES.invert, data: { entry_template_target: "entryType" } %> <%= f.field :aircraft_hours_at_entry, as: :number, step: 0.1, label: t(".airframe_total_time"), data: { component_times_target: "airframe", action: "input->component-times#airframeChanged" } %>
<%= render "logbook_entries/component_fields", f: f, aircraft: aircraft %> <%= f.field :text, as: :textarea, label: t(".entry_text"), rows: 8, data: { entry_template_target: "text" } %>

<%= t(".a_maintenance_entry_needs_a") %>

<%= render "shared/sign_as" %> <% if entry.new_record? && (types = aircraft.applicable_inspection_types.order(:name)).any? %> <%# Recurring items this work completes (e.g. an oil change): recorded on the Inspections tab, dated to this entry. %> <% ticked = Array(params.dig(:logbook_entry, :inspection_type_ids)).map(&:to_s) %>
<%= t(".inspections_completed") %>
<% types.each do |t| %> <% end %>

<%= t(".ticked_ones_are_recorded_as") %>

<% end %>
<%= f.field :signoff_person, label: t(".signed_off_by"), placeholder: t(".name"), data: { signer_target: "name" } %> <%= f.field :signoff_certificate_type, as: :select, label: t(".kind_of_certificate"), include_blank: "—", collection: LogbookEntry::CERTIFICATE_TYPES.invert, data: { entry_template_target: "certificate", signer_target: "kind" } %> <%= f.field :signoff_certificate_number, label: t(".certificate_number"), placeholder: "e.g. 1234567", data: { signer_target: "number" } %>
<%= f.field :inspection_result, as: :select, label: t(".inspection_result"), include_blank: t(".not_an_inspection"), collection: LogbookEntry::INSPECTION_RESULTS.invert, hint: t(".for_inspection_entries_43_11") %> <%= f.field :signoff_location, label: t(".location_shop") %> <%= f.field :document_id, as: :select, label: t(".scanned_page_document"), collection: document_options(aircraft) %> <%= f.field :page_number, as: :number, label: t(".page_in_document") %>
<% if entry.persisted? && !entry.verified_was %> <%= f.field :verified, as: :checkbox, label: t(".i_ve_checked_this_against"), hint: t(".transcribed_by_claude_it_stays") %> <% end %>
<%= f.submit t(".save_entry") %><%= link_to t(".cancel"), aircraft_logbook_entries_path(aircraft), class: "btn-secondary" %>
<% end %> <% if entry.persisted? %>
<%= delete_button t(".delete_entry"), aircraft_logbook_entry_path(aircraft, entry) %>
<% end %>