<% content_for :title, t(".oil_analysis", sample_date: fmt_date(@analysis.sample_date)) %> <%= render "shared/aircraft_header", aircraft: @aircraft %>

<%= t(".sample_html", sample_date: (fmt_date(@analysis.sample_date))) %>

<%= oil_status_badge(@analysis) %>
<%= t(".engine") %>
<%= @analysis.component ? link_to(@analysis.component, aircraft_component_path(@aircraft, @analysis.component), class: "link") : "—" %>
<%= t(".engine_hrs_tsn_tso") %>
<%= @analysis.engine_hours ? hours(@analysis.engine_hours) : "—" %>
<%= t(".oil_hrs") %>
<%= @analysis.oil_hours ? hours(@analysis.oil_hours) : "—" %>
<%= t(".filter_hrs") %>
<%= @analysis.filter_hours ? hours(@analysis.filter_hours) : "—" %>
<%= t(".oil_added") %>
<%= @analysis.oil_added ? "#{number_with_precision(@analysis.oil_added, precision: 2, strip_insignificant_zeros: true)} qt" : "—" %>
<%= t(".oil") %>
<%= @analysis.oil_type || "—" %>
<%= t(".lab") %>
<%= @analysis.lab || "—" %>
<%= t(".sample_2") %>
<%= @analysis.sample_number || "—" %>
<%= t(".analyzed") %>
<%= @analysis.analysis_date ? fmt_date(@analysis.analysis_date) : "—" %>
<%= t(".report") %>
<%= @analysis.report.attached? ? link_to(@analysis.report.filename, rails_blob_path(@analysis.report, disposition: :inline), class: "link", target: "_blank", rel: "noopener") : "—" %>
<% if @analysis.excluded_from_averages? %>

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

<% end %> <% if @analysis.oil_properties.any? %>
<%= t(".oil_properties") %>
<% OilAnalysis::PROPERTIES.each_key do |key| %> <% next unless @analysis.property(key) %>
<%= OilAnalysis::PROPERTIES[key] %>
<%= oil_property(@analysis, key) %>
<% end %>
<% end %> <% if @analysis.lab_comments.present? %>
<%= t(".lab_comments") %>
<%= simple_format @analysis.lab_comments %>
<% end %> <% if @analysis.notes.present? %>
<%= t(".notes") %>
<%= simple_format @analysis.notes %>
<% end %> <% if can?(:manage_oil_analyses) %>
<%= link_to t(".edit"), edit_aircraft_oil_analysis_path(@aircraft, @analysis), class: "btn-secondary btn-sm" %> <%= delete_button t(".delete"), aircraft_oil_analysis_path(@aircraft, @analysis), confirm: t(".delete_this_oil_analysis") %>
<% end %>

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

<%= @previous ? t(".compared_with", sample_date: (fmt_date(@previous.sample_date))) : t(".first_sample_for_this_engine") %>
<% if @analysis.any_results? %>
<% if @previous %><% end %> <% OilAnalysis::ELEMENTS.each do |el, label| %><% source = OilAnalysis::ELEMENT_SOURCES[el] %> <% next unless @analysis.value(el) %> "> <% if @previous %> <% end %> <% end %>
<%= t(".element") %><%= t(".this_sample") %><%= t(".lab_average") %><%= t(".previous") %><%= t(".change") %><%= t(".usual_source") %>
<%= label %> "><%= ppm(@analysis.value(el)) %> <%= ppm(@analysis.average(el)) %><%= ppm(@previous.value(el)) %> <%= ppm_change(@analysis, @previous, el) %><%= source %>
<% else %> <%= empty_state t(".no_results_entered") %> <% end %>