<% content_for :title, "#{@aircraft.tail_number} ADs" %> <%= render "shared/aircraft_header", aircraft: @aircraft %>

Airworthiness Directives & Bulletins

<% if owner? %>
<% if @attachable.any? %> <%= form_with url: attach_aircraft_airworthiness_directives_path(@aircraft), class: "flex gap-2" do |f| %> <%= f.select :airworthiness_directive_id, @attachable.map { ["#{_1.name} – #{_1.short_description.truncate(40)}", _1.id] }, {}, class: "input w-64" %> <%= f.submit "Link existing", class: "btn-secondary" %> <% end %> <% end %> <%= link_to "Import from FAA DRS", new_aircraft_ad_import_path(@aircraft), class: "btn-secondary" %> <%= link_to "+ New AD", new_aircraft_airworthiness_directive_path(@aircraft), class: "btn-primary" %>
<% end %>
<% if @rows.any? %>
<% @rows.each do |row| ad = row.ad %> <% end %>
AD / BulletinDescriptionRecurrenceLast compliedNext dueStatus
<%= ad.bulletin_label %><%= ad_link(ad) %> <% if ad.document %><%= link_to "📄", aircraft_document_path(@aircraft, ad.document), title: ad.document.name %><% end %> <% unless ad.mandatory? %>
not mandatory
<% end %>
<%= ad.short_description %> <% if ad.effective_date || ad.product_type.present? %>
<%= [(ad.effective_date && "Effective #{ad.effective_date}"), ad.product_type.presence].compact.join(" · ") %>
<% end %> <% if ad.superseded_by.present? %>
Superseded by <%= ad.superseded_by %>
<% end %> <% if ad.conditional? && ad.trigger_condition.present? %>
Trigger: <%= ad.trigger_condition %>
<% end %>
<%= ad.recurring? ? [ad.recurring_hours.to_f > 0 && "#{hours(ad.recurring_hours)} h", ad.recurring_months > 0 && "#{ad.recurring_months} mo"].select(&:itself).join(" / ") : "One-time" %> <%= row.latest ? "#{row.latest.date_complied}#{' (permanent)' if row.latest.permanent?}" : "—" %> <%= [row.next_due_date&.strftime("%b %Y"), row.next_due_hours && "#{hours(row.next_due_hours)} #{@aircraft.time_basis} (#{hours(row.next_due_hours - @aircraft.current_hours)} h left)"].compact.join(" / ").presence || "—" %> <%= compliance_badge(row.status) %> <% if owner? %> <%= link_to "Comply", new_aircraft_ad_compliance_path(@aircraft, ad_id: ad.id), class: "btn-secondary btn-sm" %> <% if row.status.in?(%w[no_compliance overdue due_soon conditional]) %><%= link_to "N/A", new_aircraft_ad_compliance_path(@aircraft, ad_id: ad.id, not_applicable: 1), class: "btn-secondary btn-sm", title: "Record that this AD doesn't apply to this aircraft" %><% end %> <%= link_to "Edit", edit_aircraft_airworthiness_directive_path(@aircraft, ad), class: "btn-secondary btn-sm" %> <% end %>
<% else %> <%= empty_state "No ADs tracked for this aircraft." %> <% end %>
<% last_drs = @aircraft.drs_imports.latest_first.first %> <% missing = DrsImport.missing_models(@aircraft) %>

AD baseline from FAA DRS

The full list comes from DRS imports; the weekly search below adds what's published after.

<% if owner? %><%= link_to "Import from FAA DRS", new_aircraft_ad_import_path(@aircraft), class: "btn-secondary btn-sm" %><% end %>
<% if last_drs %>

Last import <%= last_drs.created_at.to_date %> by <%= last_drs.user&.display_name || "—" %>: <%= last_drs.ad_count %> ADs<%= ", covering #{Array(last_drs.models_covered).to_sentence}" if Array(last_drs.models_covered).any? %>.

<% if last_drs.created_at < DrsImport::RENEW_AFTER.ago %>

Over a year old: import again to pick up revised ADs and anything the weekly search missed.

<% end %> <% else %>

No DRS import yet. Export the ADs for each model from drs.faa.gov and import them here.

<% end %> <% if missing.any? %>

Never imported for: <%= missing.join(", ") %>. Search DRS for each and import the file.

<% end %>

Newly published ADs that may apply

Searched weekly in the Federal Register for <%= AdWatch.new(@aircraft).terms.map(&:label).uniq.to_sentence.presence || "the aircraft and its installed components" %><%= " · last checked #{time_ago_in_words(@aircraft.ad_watch_checked_at)} ago" if @aircraft.ad_watch_checked_at %>.

<% if owner? %><%= button_to "Check now", check_aircraft_ad_alerts_path(@aircraft), class: "btn-secondary btn-sm", data: { turbo_submits_with: "Checking…" } %><% end %>
<% if @alerts.any? %> <% else %> <%= empty_state "Nothing new to review." %> <% end %> <% if owner? %> <%= form_with url: terms_aircraft_ad_alerts_path(@aircraft), method: :patch, class: "flex flex-wrap items-end gap-2 border-t border-slate-100 px-4 py-3" do %>
<%= label_tag :ad_watch_terms, "Additional search terms", class: "label" %> <%= text_field_tag :ad_watch_terms, @aircraft.ad_watch_terms, class: "input", placeholder: "e.g. an STC or part that isn't a component" %>
<%= submit_tag "Save", class: "btn-secondary" %>

Comma-separated, searched in addition to the automatic ones: the aircraft make and model, engine and propeller models (and families), and every installed component’s maker, type and model. A match on a component makes the tracked AD apply to that component. Matches are only possibly applicable: check each AD's applicability (and serial number ranges) before tracking it.

<% end %> <% end %>

Compliance History

<% if @history.any? %> <% @history.each do |c| %> <% ad = c.airworthiness_directive %> <% end %>
DateADHoursNext due (tach)Notes
<%= c.date_complied %> <%= ad_link(ad) %> <% if ad.document %><%= link_to "📄", aircraft_document_path(@aircraft, ad.document), title: ad.document.name %><% end %>
<%= ad.short_description %><%= " · #{c.component}" if c.component %>
<%= hours(c.aircraft_hours_at_compliance) %> <%= c.not_applicable? ? "N/A" : c.permanent? ? "Permanent" : (c.next_due_at_time.to_f > 0 ? hours(c.next_due_at_time) : "—") %>
<%= c.method_label %><%= " · #{c.ad_revision}" if c.ad_revision.present? %>
<%= c.compliance_notes %> <% if c.logbook_entry || c.inspection_record %>
<% if c.logbook_entry %><%= link_to "Logbook #{c.logbook_entry.date}", aircraft_logbook_entry_path(@aircraft, c.logbook_entry), class: "link" %><% end %> <% if c.inspection_record %><%= link_to "#{c.inspection_record.inspection_type.name} #{c.inspection_record.date}", aircraft_inspections_path(@aircraft), class: "link" %><% end %>
<% end %>
<% if owner? %><%= link_to "Edit", edit_aircraft_ad_compliance_path(@aircraft, c), class: "btn-secondary btn-sm" %><% end %>
<% else %> <%= empty_state "No compliance records." %> <% end %>