Files
simple-aircraft-manager-rails/app/views/maintenance_reports/show.html.erb
T
rickyandClaude Opus 5.5 a4ec7a691e Record keeping: 43.9/43.11 sign-off fields, AD method, status report
- Logbook entries record the signer's kind of certificate and number and
  an inspection's result; maintenance and inspection entries list what
  43.9 / 43.11 needs that's missing (flagged, not enforced). Transcription
  reads the certificate details too
- AD compliance records the method (inspection, terminating action, AMOC,
  not applicable) and the AD revision complied with, filled in from the AD
  when blank; the method sets the permanent / N/A flags
- Maintenance status report (91.417(a)(2)): total times, life-limited
  parts, time since overhaul, inspection and AD status, major alterations,
  open discrepancies; print or save as PDF; on maintenance share links too
- Archives carry the new fields

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 10:14:21 -05:00

152 lines
10 KiB
ERB

<% a = @report.aircraft %>
<% clock = a.time_basis_label.downcase %>
<% content_for :title, "#{a.tail_number} Maintenance Status" %>
<% section = "mt-6 break-inside-avoid-page" %>
<% th = "border-b border-slate-300 py-1 pr-3 text-left text-[11px] font-semibold uppercase tracking-wide text-slate-500" %>
<% td = "border-b border-slate-100 py-1 pr-3 align-top" %>
<div class="mb-4 flex flex-wrap items-center justify-between gap-2 print:hidden">
<% back = @share ? shared_path(@share.token) : aircraft_path(a) %>
<%= link_to "← Back", back, class: "link text-sm" %>
<button type="button" class="btn-primary" data-print>Print or save as PDF</button>
</div>
<header class="flex flex-wrap items-end justify-between gap-4 border-b-2 border-slate-800 pb-3">
<div>
<p class="text-xs uppercase tracking-wide text-slate-500">Maintenance status · 14 CFR 91.417(a)(2)</p>
<h1 class="text-2xl font-bold"><%= a.tail_number %> <span class="text-lg font-normal text-slate-600"><%= [ a.make, a.model ].compact_blank.join(" ") %></span></h1>
<p class="text-sm text-slate-600">Serial number <%= a.serial_number.presence || "—" %></p>
</div>
<dl class="grid grid-cols-2 gap-x-6 text-sm">
<dt class="text-slate-500">Prepared</dt><dd><%= l(@report.generated_at.to_date, format: :long) %></dd>
<dt class="text-slate-500">Airframe time in service</dt><dd class="font-semibold"><%= hours(@report.time_in_service) %> hrs (<%= clock %>)</dd>
<dt class="text-slate-500">Tach / Hobbs</dt><dd><%= hours(a.tach_time) %> / <%= hours(a.hobbs_time) %></dd>
<dt class="text-slate-500">Status</dt><dd><%= airworthiness_badge(@report.airworthiness) %></dd>
</dl>
</header>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Total time in service: engines and propellers</h2>
<% majors = @report.engines + @report.propellers %>
<% if majors.any? %>
<table class="mt-2 w-full text-sm">
<thead><tr><th class="<%= th %>">Item</th><th class="<%= th %>">Make / model</th><th class="<%= th %>">Serial</th><th class="<%= th %> text-right">Total time</th><th class="<%= th %> text-right">Since overhaul</th><th class="<%= th %>">Overhauled</th></tr></thead>
<tbody>
<% majors.each do |c| %>
<tr><td class="<%= td %>"><%= c %></td><td class="<%= td %>"><%= [ c.manufacturer, c.model ].compact_blank.join(" ") %></td><td class="<%= td %>"><%= c.serial_number.presence || "—" %></td>
<td class="<%= td %> text-right tabular-nums"><%= hours(c.hours_in_service) %></td><td class="<%= td %> text-right tabular-nums"><%= hours(c.hours_since_overhaul) %></td><td class="<%= td %>"><%= c.overhaul_date || "—" %></td></tr>
<% end %>
</tbody>
</table>
<% else %><p class="mt-1 text-sm text-slate-500">No engines or propellers recorded as components.</p><% end %>
</section>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Life-limited parts</h2>
<% if @report.life_limited.any? %>
<table class="mt-2 w-full text-sm">
<thead><tr><th class="<%= th %>">Part</th><th class="<%= th %>">Serial</th><th class="<%= th %>">Limit</th><th class="<%= th %> text-right">Used</th><th class="<%= th %>">Remaining</th><th class="<%= th %>">Status</th></tr></thead>
<tbody>
<% @report.life_limited.each do |c| %>
<tr><td class="<%= td %>"><%= c %> <span class="text-slate-500"><%= c.model %></span></td><td class="<%= td %>"><%= c.serial_number.presence || "—" %></td>
<td class="<%= td %>"><%= [ (c.replacement_hours && "#{hours(c.replacement_hours)} hrs"), (c.replacement_days && "#{c.replacement_days} days") ].compact.join(" / ") %></td>
<td class="<%= td %> text-right tabular-nums"><%= hours(c.hours_since_overhaul) %> hrs</td>
<td class="<%= td %>"><%= [ (c.hours_to_replacement && "#{hours(c.hours_to_replacement)} hrs"), (c.next_replacement_date && "by #{c.next_replacement_date}") ].compact.join(", ") %></td>
<td class="<%= td %>"><%= life_badge(c.life_status) %></td></tr>
<% end %>
</tbody>
</table>
<% else %><p class="mt-1 text-sm text-slate-500">None recorded.</p><% end %>
</section>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Time since overhaul</h2>
<% if @report.overhaul_items.any? %>
<table class="mt-2 w-full text-sm">
<thead><tr><th class="<%= th %>">Item</th><th class="<%= th %>">Serial</th><th class="<%= th %>">Overhaul interval</th><th class="<%= th %> text-right">Since overhaul</th><th class="<%= th %>">Remaining</th><th class="<%= th %>">Tracked as</th></tr></thead>
<tbody>
<% @report.overhaul_items.each do |c| %>
<tr><td class="<%= td %>"><%= c %> <span class="text-slate-500"><%= c.model %></span></td><td class="<%= td %>"><%= c.serial_number.presence || "—" %></td>
<td class="<%= td %>"><%= [ (c.tbo_hours && "#{hours(c.tbo_hours)} hrs"), (c.tbo_days && "#{c.tbo_days} days") ].compact.join(" / ") %></td>
<td class="<%= td %> text-right tabular-nums"><%= hours(c.hours_since_overhaul) %> hrs</td>
<td class="<%= td %>"><%= c.on_condition? ? "On condition" : (c.hours_to_tbo ? "#{hours(c.hours_to_tbo)} hrs" : "—") %></td>
<td class="<%= td %> text-xs"><%= c.tbo_critical? ? "Hard limit" : "Recommended" %></td></tr>
<% end %>
</tbody>
</table>
<% else %><p class="mt-1 text-sm text-slate-500">None recorded.</p><% end %>
</section>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Inspection status</h2>
<% if @report.inspections.any? %>
<table class="mt-2 w-full text-sm">
<thead><tr><th class="<%= th %>">Inspection</th><th class="<%= th %>">Interval</th><th class="<%= th %>">Last done</th><th class="<%= th %> text-right">Since</th><th class="<%= th %>">Next due</th><th class="<%= th %>">Status</th></tr></thead>
<tbody>
<% @report.inspections.each do |row| %>
<% last = row.latest %>
<tr><td class="<%= td %>"><%= row.type.name %><% if row.type.satisfies %><div class="text-xs text-slate-500">Also counts as <%= row.type.satisfies.name %></div><% end %></td>
<td class="<%= td %> text-xs"><%= row.type.interval_description %></td>
<td class="<%= td %>"><%= last ? "#{last.date}#{" @ #{hours(last.hours_at_inspection)}" if last.hours_at_inspection}" : "Never" %><%= " (#{last.inspection_type.name})" if last && last.inspection_type != row.type %></td>
<td class="<%= td %> text-right tabular-nums"><%= last&.hours_at_inspection ? "#{hours(@report.time_in_service - last.hours_at_inspection)} hrs" : "—" %></td>
<td class="<%= td %>"><%= [ row.next_due_date&.to_s, row.next_due_hours && "#{hours(row.next_due_hours)} hrs" ].compact.join(" / ").presence || "—" %></td>
<td class="<%= td %>"><%= compliance_badge(row.status) %></td></tr>
<% end %>
</tbody>
</table>
<% else %><p class="mt-1 text-sm text-slate-500">No inspections tracked.</p><% end %>
</section>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Airworthiness directives</h2>
<% if @report.ads.any? %>
<table class="mt-2 w-full text-sm">
<thead><tr><th class="<%= th %>">AD</th><th class="<%= th %>">Revision complied with</th><th class="<%= th %>">Method of compliance</th><th class="<%= th %>">Complied</th><th class="<%= th %>">Recurring / next due</th><th class="<%= th %>">Status</th></tr></thead>
<tbody>
<% @report.ads.each do |row| %>
<% c = row.latest %>
<tr><td class="<%= td %>"><span class="font-medium"><%= row.ad.name %></span><div class="text-xs text-slate-500"><%= row.ad.short_description.to_s.truncate(70) %></div></td>
<td class="<%= td %> text-xs"><%= c&.ad_revision.presence || "—" %></td>
<td class="<%= td %> text-xs"><%= c ? c.method_label : "—" %><% if c&.compliance_notes.present? %><div class="text-slate-500"><%= c.compliance_notes.truncate(90) %></div><% end %></td>
<td class="<%= td %>"><%= c ? "#{c.date_complied}#{" @ #{hours(c.aircraft_hours_at_compliance)}" if c.aircraft_hours_at_compliance}" : "—" %></td>
<td class="<%= td %> text-xs"><%= if c&.closed? then "No further action"
elsif row.ad.recurring? then [ row.next_due_date&.to_s, row.next_due_hours && "#{hours(row.next_due_hours)} hrs" ].compact.join(" / ").presence || "Recurring"
else "One-time" end %></td>
<td class="<%= td %>"><%= compliance_badge(row.status) %></td></tr>
<% end %>
</tbody>
</table>
<% else %><p class="mt-1 text-sm text-slate-500">No ADs tracked.</p><% end %>
</section>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Major repairs and alterations</h2>
<% if (majors = @report.major_records.to_a).any? %>
<table class="mt-2 w-full text-sm">
<thead><tr><th class="<%= th %>">Date</th><th class="<%= th %>">Type</th><th class="<%= th %>">Description</th><th class="<%= th %>">STC</th><th class="<%= th %>">Form 337</th></tr></thead>
<tbody>
<% majors.each do |m| %>
<tr><td class="<%= td %>"><%= m.date_performed %></td><td class="<%= td %> text-xs"><%= m.type_label %></td>
<td class="<%= td %>"><%= m.title %><%= " · #{m.component}" if m.component %></td>
<td class="<%= td %> text-xs"><%= [ m.stc_number, m.stc_holder ].compact_blank.join(", ").presence || "—" %></td>
<td class="<%= td %> text-xs"><%= m.form_337_document ? "On file" : "—" %></td></tr>
<% end %>
</tbody>
</table>
<% else %><p class="mt-1 text-sm text-slate-500">None recorded.</p><% end %>
</section>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Open discrepancies</h2>
<% if (squawks = @report.open_squawks.to_a).any? %>
<ul class="mt-2 space-y-1 text-sm">
<% squawks.each do |s| %><li><%= squawk_priority_badge(s) %> <%= s.issue_reported %><%= " · #{s.component}" if s.component %> <span class="text-xs text-slate-500">(<%= s.created_at.to_date %>)</span></li><% end %>
</ul>
<% else %><p class="mt-1 text-sm text-slate-500">None open.</p><% end %>
</section>
<footer class="mt-8 border-t border-slate-300 pt-2 text-xs text-slate-500">
Prepared <%= l(@report.generated_at, format: :long) %> from the records kept in Simple Aircraft Manager. Times are in hours of <%= clock %> time.
This summary doesn't replace the aircraft's signed maintenance records. <%= Airworthiness::DISCLAIMER %>
</footer>