<% content_for :title, "Oil Analysis #{fmt_date(@analysis.sample_date)}" %> <%= render "shared/aircraft_header", aircraft: @aircraft %>

Sample <%= fmt_date(@analysis.sample_date) %>

<%= oil_status_badge(@analysis) %>
Engine
<%= @analysis.component ? link_to(@analysis.component, aircraft_component_path(@aircraft, @analysis.component), class: "link") : "—" %>
Engine hrs (TSN/TSO)
<%= @analysis.engine_hours ? hours(@analysis.engine_hours) : "—" %>
Oil hrs
<%= @analysis.oil_hours ? hours(@analysis.oil_hours) : "—" %>
Filter hrs
<%= @analysis.filter_hours ? hours(@analysis.filter_hours) : "—" %>
Oil added
<%= @analysis.oil_added ? "#{number_with_precision(@analysis.oil_added, precision: 2, strip_insignificant_zeros: true)} qt" : "—" %>
Oil
<%= @analysis.oil_type || "—" %>
Lab
<%= @analysis.lab || "—" %>
Sample #
<%= @analysis.sample_number || "—" %>
Analyzed
<%= @analysis.analysis_date ? fmt_date(@analysis.analysis_date) : "—" %>
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? %>

Left out of trend charts.

<% end %> <% if @analysis.oil_properties.any? %>
Oil properties
<% OilAnalysis::PROPERTIES.each_key do |key| %> <% next unless @analysis.property(key) %>
<%= OilAnalysis::PROPERTIES[key][0] %>
<%= oil_property(@analysis, key) %>
<% end %>
<% end %> <% if @analysis.lab_comments.present? %>
Lab comments
<%= simple_format @analysis.lab_comments %>
<% end %> <% if @analysis.notes.present? %>
Notes
<%= simple_format @analysis.notes %>
<% end %> <% if owner? %>
<%= link_to "Edit", edit_aircraft_oil_analysis_path(@aircraft, @analysis), class: "btn-secondary btn-sm" %> <%= delete_button "Delete", aircraft_oil_analysis_path(@aircraft, @analysis), confirm: "Delete this oil analysis?" %>
<% end %>

Results (ppm)

<%= @previous ? "Compared with #{fmt_date(@previous.sample_date)}" : "First sample for this engine" %>
<% if @analysis.any_results? %>
<% if @previous %><% end %> <% OilAnalysis::ELEMENTS.each do |el, (label, source)| %> <% next unless @analysis.value(el) %> "> <% if @previous %> <% end %> <% end %>
ElementThis sampleLab averagePreviousChangeUsual source
<%= label %> "><%= ppm(@analysis.value(el)) %> <%= ppm(@analysis.average(el)) %><%= ppm(@previous.value(el)) %> <%= ppm_change(@analysis, @previous, el) %><%= source %>
<% else %> <%= empty_state "No results entered." %> <% end %>