<% 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 "+ 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.name %> <% unless ad.mandatory? %>
not mandatory
<% end %>
<%= ad.short_description %> <% 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)} h"].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" %> <%= 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 %>

Compliance History

<% if @history.any? %> <% @history.each do |c| %> <% end %>
DateADHoursNext due (hrs)Notes
<%= c.date_complied %> <%= c.airworthiness_directive.name %><%= " (#{c.component})" if c.component %> <%= hours(c.aircraft_hours_at_compliance) %> <%= c.permanent? ? "Permanent" : (c.next_due_at_time.to_f > 0 ? hours(c.next_due_at_time) : "—") %> <%= c.compliance_notes %> <% 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 %>