@php use App\Services\AnalysisComparisonService; $totals = $diff['totals']; $sections = $diff['sections']; $gapDays = $diff['gap_days']; $autoSum = $diff['auto_summary'] ?? ''; $anomalies = $diff['anomalies'] ?? []; $trends = $diff['trends'] ?? ['positive' => [], 'negative' => []]; $leftDate = $left->finished_at?->format('Y-m-d') ?? '—'; $rightDate = $right->finished_at?->format('Y-m-d') ?? '—'; $totalCompared = $totals['improved'] + $totals['declined'] + $totals['flat']; $totalAll = $totalCompared + $totals['missing']; $netScore = $totals['improved'] - $totals['declined']; $improvedPct = $totalCompared > 0 ? round($totals['improved'] / $totalCompared * 100) : 0; $declinedPct = $totalCompared > 0 ? round($totals['declined'] / $totalCompared * 100) : 0; $flatPct = max(0, 100 - $improvedPct - $declinedPct); $isBudget = $mode === AnalysisComparisonService::MODE_BUDGET; $isAnnual = $mode === AnalysisComparisonService::MODE_ANNUAL; // Column captions depend on the mode. [$leftCaption, $rightCaption] = $isBudget ? [__('Budget'), __('Actual')] : ($isAnnual ? [__('Last year'), __('This year')] : [__('Earlier'), __('Now')]); $headline = match (true) { $totalCompared === 0 => ['copy' => __('Nothing comparable yet'), 'tone' => 'neutral'], $netScore >= 3 => ['copy' => __('Most things got better'), 'tone' => 'good'], $netScore > 0 => ['copy' => __('Slightly better overall'), 'tone' => 'good'], $netScore === 0 => ['copy' => __('Mixed picture'), 'tone' => 'neutral'], $netScore < -3 => ['copy' => __('Most things got worse'), 'tone' => 'bad'], default => ['copy' => __('Slightly worse overall'), 'tone' => 'bad'], }; @endphp {{-- ── DATE STRIP / PERIOD CHIPS / PICKER ──────────────────────────── --}}
{{ $autoSum }}
@endif{{ __(':compared of :total indicators could be compared.', ['compared' => $totalCompared, 'total' => $totalAll]) }}
@if($totalCompared > 0)@if($narrative) {{ __('Updated :when.', ['when' => $narrative->updated_at?->diffForHumans()]) }} @else {{ __('Click Generate to produce a plain-language explanation.') }} @endif
{{ __('No explanation yet') }}
{{ __('Click Generate above to produce a plain-language explanation. Takes ~30 seconds.') }}
{{ __(':compared of :total indicators could be compared.', ['compared' => $totalCompared, 'total' => $totalAll]) }}