<% content_for :title, "Import Flights" %> <%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= form_with url: aircraft_flight_import_path(@aircraft), multipart: true, class: "card card-body space-y-4 lg:col-span-2" do |f| %>

Import flights from a spreadsheet

<%= f.label :file, "Spreadsheet (.xlsx or .csv)", class: "label" %> <%= f.file_field :file, accept: ".xlsx,.csv", required: true, class: "block text-sm text-slate-600 file:mr-3 file:rounded-md file:border-0 file:bg-slate-100 file:px-3 file:py-1.5 file:text-sm file:font-medium hover:file:bg-slate-200" %>
<%= f.label :starting_tach, "Tach before the first flight (optional)", class: "label" %> <%= f.number_field :starting_tach, step: 0.1, class: "input" %>

E.g. the tach at purchase. Without it, the first row's time comes from a Flight Time column, if you have one.

<%= f.label :starting_hobbs, "Hobbs before the first flight (optional)", class: "label" %> <%= f.number_field :starting_hobbs, step: 0.1, class: "input" %>
<%= f.submit "Upload & Preview", class: "btn-primary" %>

Nothing is saved until you confirm on the next page.

<% end %>

Expected layout

One row per flight, with the meter readings at the end of the flight. Columns are matched by header name, in any order:

Each flight's time is the difference from the row above. Rows are kept in file order.

Importing records history only. It doesn't add time to components.