mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
- An entry can link a component (engine, propeller…) and records its total time and time since overhaul at the entry; picking the engine or prop log selects that component and fills its current times (editable). Squawk fixes carry the squawk's component - Components have an overhaul type (major, factory overhaul, factory new), shown as SMOH / SFOH / SNEW - Printouts: engine and propeller entries add the serial number, total time and SMOH/SFOH (blanks when no component is linked); airframe total time is labelled as such; full-page layouts draw a box around each entry - Archives carry the entry's component and times (the original format's components / component_hours), no longer dropped on import Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
25 lines
935 B
Ruby
25 lines
935 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, 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
|