<% a = @report.aircraft %> <% clock = a.time_basis_label.downcase %> <% content_for :title, t(".maintenance_status", tail_number: a.tail_number) %> <% 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" %> <% unless @standalone %>
<% back = @share ? shared_path(@share.token) : aircraft_path(a) %> <%= link_to t(".back"), back, class: "link text-sm" %>
<% end %>

<%= t(".maintenance_status_14_cfr_91") %>

<%= a.tail_number %> <%= [ a.make, a.model ].compact_blank.join(" ") %>

<%= t(".serial_number_html", serial_number: (a.serial_number.presence || "—")) %>

<%= t(".prepared") %>
<%= l(@report.generated_at.to_date, format: :long) %>
<%= t(".airframe_time_in_service") %>
<%= t(".hrs_html", time_in_service: (hours(@report.time_in_service)), clock: clock) %>
<%= t(".tach_hobbs") %>
<%= hours(a.tach_time) %> / <%= hours(a.hobbs_time) %>
<%= t(".status") %>
<%= airworthiness_badge(@report.airworthiness) %>
<%= t(".electronic_records_since") %>
<%= a.electronic_records_since || "—" %>

<%= t(".total_time_in_service_engines") %>

<% majors = @report.engines + @report.propellers %> <% if majors.any? %> <% majors.each do |c| %> <% end %>
<%= t(".item") %><%= t(".make_model") %><%= t(".serial") %><%= t(".total_time") %><%= t(".since_overhaul") %><%= t(".overhauled") %>
<%= c %><%= [ c.manufacturer, c.model ].compact_blank.join(" ") %><%= c.serial_number.presence || "—" %> <%= hours(c.hours_in_service) %><%= hours(c.hours_since_overhaul) %><%= c.overhaul_date || "—" %>
<% else %>

<%= t(".no_engines_or_propellers_recorded") %>

<% end %>

<%= t(".life_limited_parts") %>

<% if @report.life_limited.any? %> <% @report.life_limited.each do |c| %> <% end %>
<%= t(".part") %><%= t(".serial") %><%= t(".limit") %><%= t(".used") %><%= t(".remaining") %><%= t(".status") %>
<%= c %> <%= c.model %><%= c.serial_number.presence || "—" %> <%= [ (c.replacement_hours && "#{hours(c.replacement_hours)} hrs"), c.replacement_interval_label, (c.expires_on && "expires #{fmt_date(c.expires_on)}") ].compact.join(" / ") %> <%= t(".hrs_2_html", hours_since_overhaul: (hours(c.hours_since_overhaul))) %> <%= [ (c.hours_to_replacement && "#{hours(c.hours_to_replacement)} hrs"), (c.next_replacement_date && "by #{fmt_date(c.next_replacement_date)}") ].compact.join(", ") %> <%= life_badge(c.life_status) %>
<% else %>

<%= t(".none_recorded") %>

<% end %>

<%= t(".time_since_overhaul") %>

<% if @report.overhaul_items.any? %> <% @report.overhaul_items.each do |c| %> <% end %>
<%= t(".item") %><%= t(".serial") %><%= t(".overhaul_interval") %><%= t(".since_overhaul") %><%= t(".remaining") %><%= t(".tracked_as") %>
<%= c %> <%= c.model %><%= c.serial_number.presence || "—" %> <%= [ (c.tbo_hours && "#{hours(c.tbo_hours)} hrs"), c.tbo_interval_label ].compact.join(" / ") %> <%= t(".hrs_2_html", hours_since_overhaul: (hours(c.hours_since_overhaul))) %> <%= c.hours_to_tbo ? "#{hours(c.hours_to_tbo)} hrs" : "—" %> <%= c.on_condition? ? t(".on_condition_part_91") : (c.tbo_critical? ? t(".hard_limit") : t(".recommended")) %>
<% else %>

<%= t(".none_recorded") %>

<% end %>

<%= t(".inspection_status") %>

<% if @report.inspections.any? %> <% @report.inspections.each do |row| %> <% last = row.latest %> <% end %>
<%= t(".inspection") %><%= t(".interval") %><%= t(".last_done") %><%= t(".since") %><%= t(".next_due") %><%= t(".status") %>
<%= row.type.name %><% if row.type.satisfies %>
<%= t(".also_counts_as_html", satisfies: row.type.satisfies.name) %>
<% end %>
<%= row.type.interval_description %> <%= last ? "#{fmt_date(last.date)}#{" @ #{hours(last.hours_at_inspection)}" if last.hours_at_inspection}" : t(".never") %><%= " (#{last.inspection_type.name})" if last && last.inspection_type != row.type %> <%= last&.hours_at_inspection ? "#{hours(@report.time_in_service - last.hours_at_inspection)} hrs" : "—" %> <%= [ row.next_due_date&.to_s, row.next_due_hours && "#{hours(row.next_due_hours)} hrs" ].compact.join(" / ").presence || "—" %> <%= compliance_badge(row.status) %>
<% else %>

<%= t(".no_inspections_tracked") %>

<% end %>

<%= t(".airworthiness_directives") %>

<% if @report.ads.any? %> <% @report.ads.each do |row| %> <% c = row.latest %> <% end %>
<%= t(".ad") %><%= t(".revision_complied_with") %><%= t(".method_of_compliance") %><%= t(".complied") %><%= t(".recurring_next_due") %><%= t(".status") %>
<%= row.ad.name %>
<%= row.ad.short_description.to_s.truncate(70) %>
<%= c&.ad_revision.presence || "—" %> <%= c ? c.method_label : "—" %><% if c&.compliance_notes.present? %>
<%= c.compliance_notes.truncate(90) %>
<% end %>
<%= c ? "#{c.date_complied}#{" @ #{hours(c.aircraft_hours_at_compliance)}" if c.aircraft_hours_at_compliance}" : "—" %> <%= if c&.closed? then t(".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 || t(".recurring") else t(".one_time") end %> <%= compliance_badge(row.status) %>
<% else %>

<%= t(".no_ads_tracked") %>

<% end %>

<%= t(".major_repairs_and_alterations") %>

<% if (majors = @report.major_records.to_a).any? %> <% majors.each do |m| %> <% end %>
<%= t(".date") %><%= t(".type") %><%= t(".description") %><%= t(".stc") %><%= t(".form_337") %>
<%= fmt_date(m.date_performed) %><%= m.type_label %> <%= m.title %><%= " · #{m.component}" if m.component %> <%= [ m.stc_number, m.stc_holder ].compact_blank.join(", ").presence || "—" %> <%= m.form_337_document ? t(".on_file") : "—" %>
<% else %>

<%= t(".none_recorded") %>

<% end %>

<%= t(".weight_and_balance") %>

<% if (wb = a.current_weight_balance) %>

<%= t(".empty_weight_lb_cg_in_html", delimiter: (number_with_precision(wb.empty_weight, precision: 1, delimiter: ",")), precision: (number_with_precision(wb.empty_arm, precision: 2)), useful_load: (t(".useful_load_lb", delimiter: (number_with_precision(wb.useful_load, precision: 1, delimiter: ','))) if wb.useful_load), date: (fmt_date(wb.date)), present: (" (#{wb.reason})" if wb.reason.present?)) %>

<% else %>

<%= t(".none_recorded") %>

<% end %>

<%= t(".open_discrepancies") %>

<% if (squawks = @report.open_squawks.to_a).any? %> <% else %>

<%= t(".none_open") %>

<% end %>