% content_for :title, "Print logbook entries" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= form_with url: aircraft_logbook_print_path(@aircraft, format: :pdf), method: :get, class: "card card-body max-w-2xl space-y-4",
data: { turbo: false }, html: { target: "_blank" } do %>
Print for the logbook
A PDF of <%= pluralize(@entries.size, "entry") %> to print on adhesive labels or paper and put in <%= @aircraft.tail_number %>'s logbook. Each one has a blank line to sign by hand: a printed entry isn't valid until it's signed.
<% @entries.each do |e| %><%= hidden_field_tag "ids[]", e.id, id: nil %><% end %>
<% @entries.each do |e| %>
<%= e.date %> · <%= LogbookEntry::LOG_TYPES[e.log_type] %> · <%= e.text.truncate(90) %>
<% if (missing = e.missing_record_items).any? %>(missing <%= missing.to_sentence %>) <% end %>
<% end %>
Paper
<% LogbookEntryPdf::LAYOUTS.each do |l| %>
<%= radio_button_tag :layout, l.key, @layout == l.key %> <%= l.label %>
<% end %>
<%= label_tag :start_at, "Start at label", class: "label" %>
<%= number_field_tag :start_at, 1, min: 1, max: 10, class: "input w-24" %>
On a partly used label sheet, the first free label, counting across then down.
Print at 100% (“Actual size”), not “Fit to page”, so labels line up. Try a plain sheet first and hold it against the labels.
<%= submit_tag "Open PDF", class: "btn-primary" %><%= link_to "Back", aircraft_logbook_entries_path(@aircraft), class: "btn-secondary" %>
<% end %>