app/views/schools/school_targets/progress/current.html.erb
<div class="d-flex justify-content-between align-items-center">
<h1>
<%= t('schools.school_targets.progress.current.title', fuel_type: @fuel_type.to_s.humanize(capitalize: false)) %>
</h1>
<div>
<% if @school_target.school.has_expired_target_for_fuel_type?(@fuel_type) %>
<%= link_to t('schools.school_targets.progress.current.view_last_years_target_report'),
{ school_target_id: @school_target.school.expired_target },
class: 'btn btn-outline-dark font-weight-bold' %>
<% end %>
<%= link_to t('schools.school_targets.progress.current.review_targets'),
school_school_target_path(@school, @school_target),
class: 'btn btn-outline-dark rounded-pill font-weight-bold' %>
<%= link_to_help_for_feature :school_targets, css: 'btn btn-outline-dark rounded-pill font-weight-bold' %>
</div>
</div>
<% if @recent_data %>
<% if @latest_progress %>
<% if @latest_progress == 0.0 %>
<p>
<%= t('schools.school_targets.progress.current.unfortunately_as_much_as_last_year',
fuel_type: human_fuel_type(@fuel_type)) %>
</p>
<% elsif @latest_progress > 0.0 %>
<p>
<%= t('schools.school_targets.progress.current.unfortunately_more_than_last_year',
fuel_type: human_fuel_type(@fuel_type),
relative_percent: format_target(@latest_progress, :relative_percent)).html_safe %>.
</p>
<% else %>
<p>
<%= t('schools.school_targets.progress.current.well_done_less_than_last_year',
fuel_type: human_fuel_type(@fuel_type),
relative_percent: format_target(@latest_progress, :relative_percent)).html_safe %>.
</p>
<% end %>
<% end %>
<% else %>
<div class="row alert info-bar text-light bg-negative">
<div class="col">
<span class="align-middle">
<%= t('schools.school_targets.progress.current.we_have_not_received_data',
fuel_type: human_fuel_type(@fuel_type)) %>.
</span>
</div>
</div>
<% end %>
<p>
<%= t('schools.school_targets.progress.current.your_school_has_set_a_target_to_reduce_html',
fuel_type: human_fuel_type(@fuel_type, include_storage_heaters: true),
school_target_attributes: @school_target.attributes[@fuel_type.to_s],
start_date: nice_dates(@school_target.start_date),
target_date: nice_dates(@school_target.target_date)) %>.
</p>
<% if @progress %>
<h3><%= t('schools.school_targets.progress.current.month_by_month_progress') %></h3>
<table class="table table-bordered table-hover table-sm">
<thead class="thead-dark">
<tr>
<th>
<%= t('schools.school_targets.progress.current.month') %>
</th>
<% @reporting_months.each do |month| %>
<th class="text-right">
<%= month.strftime('%b') %>
</th>
<% end %>
</tr>
</thead>
<tbody>
<%= render 'row', title: t('schools.school_targets.progress.current.target_consumption_kwh'), progress: @progress,
data: @progress.monthly_targets_kwh, keys: @reporting_months, partial_months: {},
percentage_synthetic: @progress.percentage_synthetic, units: :kwh, final_row: false %>
<%= render 'row', title: t('schools.school_targets.progress.current.actual_consumption_kwh'), progress: @progress,
data: @progress.monthly_usage_kwh, keys: @reporting_months,
partial_months: @progress.partial_months, percentage_synthetic: {}, units: :kwh, final_row: false %>
<%= render 'row', title: t('schools.school_targets.progress.current.overall_change_since_last_year'),
progress: @progress, data: @progress.monthly_performance,
keys: @reporting_months, partial_months: @progress.partial_months,
percentage_synthetic: {}, units: :relative_percent, final_row: true %>
</tbody>
</table>
<h3><%= t('schools.school_targets.progress.current.cumulative_progress') %></h3>
<table class="table table-bordered table-hover table-sm">
<thead class="thead-dark">
<tr>
<th>
<%= t('schools.school_targets.progress.current.month') %>
</th>
<% @reporting_months.each do |month| %>
<th class="text-right">
<%= month.strftime('%b') %>
</th>
<% end %>
</tr>
</thead>
<tbody>
<%= render 'row', title: t('schools.school_targets.progress.current.target_consumption_kwh'),
data: @progress.cumulative_targets_kwh, keys: @reporting_months, partial_months: {},
percentage_synthetic: @progress.percentage_synthetic, units: :kwh, final_row: false %>
<%= render 'row', title: t('schools.school_targets.progress.current.actual_consumption_kwh'),
data: @progress.cumulative_usage_kwh, keys: @reporting_months,
partial_months: @progress.partial_months, percentage_synthetic: {}, units: :kwh, final_row: false %>
<%= render 'row', title: t('schools.school_targets.progress.current.overall_performance_since_last_year'),
data: @progress.cumulative_performance, keys: @reporting_months,
partial_months: @progress.partial_months, percentage_synthetic: {}, units: :relative_percent,
final_row: true %>
</tbody>
</table>
<%= render 'footnotes', fuel_type: @fuel_type, school_target: @school_target,
show_storage_heater_notes: @show_storage_heater_notes, progress: @progress %>
<h3><%= t('schools.school_targets.progress.current.progress_charts') %></h3>
<%= render 'charts', school: @school, fuel_type: @fuel_type == :storage_heaters ? :storage_heater : @fuel_type,
progress: @progress %>
<% if current_user.present? && current_user.analytics? %>
<h2><%= t('schools.school_targets.progress.current.debug') %></h2>
<pre class="debug">
<%= JSON.pretty_generate(@debug_content) %>
</pre>
<% end %>
<% else %>
<div class="alert alert-danger">
<h4><%= t('schools.school_targets.progress.current.error_message') %></h4>
<p><%= t('schools.school_targets.progress.current.we_have_been_notified_about_this_error_2') %>.</p>
</div>
<% if current_user.present? && current_user.analytics? %>
<div class="alert alert-secondary">
<h4><%= t('schools.school_targets.progress.current.debug') %></h4>
<p><strong><%= t('schools.school_targets.progress.current.error') %></strong>: <%= @debug_error.presence %></p>
<p><strong><%= t('schools.school_targets.progress.current.problem') %></strong>: <%= @debug_problem.presence %></p>
</div>
<% end %>
<% end %>