Files
simple-aircraft-manager-rails/app/controllers/logbook_prints_controller.rb
T
rickyandClaude Opus 5.5 7caa213e7a Sub-components on logbook entries (e.g. the oil filter on the engine)
- Once a component is chosen, its sub-components are offered on the entry
  form (and the squawk Resolve page); ticked ones are saved with their
  total time and time since service, worked out from the airframe total
  time like the component's (editable; blank before it was installed)
- Entry page and printed PDFs list each sub-component with its serial
  number and times; parts without an overhaul type read "Since service"
- Archives carry them: the original format's list of components per entry
  (first = the entry's component, the rest = sub-components)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 12:54:49 -05:00

25 lines
943 B
Ruby

# Logbook entries as a PDF to print on labels or pages and put in the paper
# logbook (where they're signed by hand).
class LogbookPrintsController < ApplicationController
include AircraftScoped
before_action :set_entries
def new
@layout = params[:layout].presence || "avery_5164"
end
def show
pdf = LogbookEntryPdf.new(@aircraft, @entries, layout: params[:layout], start_at: params[:start_at])
log_event("logbook", "Logbook entries printed (#{@entries.size})")
send_data pdf.render, filename: pdf.filename, type: "application/pdf", disposition: "inline"
end
private
def set_entries
ids = Array(params[:ids]).map(&:to_i).first(200)
@entries = @aircraft.logbook_entries.where(id: ids).includes(:component, :parts, inspection_records: :inspection_type).order(:date, :id).to_a
redirect_to aircraft_logbook_entries_path(@aircraft), alert: "Choose the entries to print." if @entries.empty?
end
end