@extends('layouts.app') @section('title', __('Review analysis')) @php $type = $types[$analysis->analysis_type] ?? null; $isAr = app()->getLocale() === 'ar'; // KPI rows stripped of any chart_hint legacy fields. $kpiRows = []; foreach (((array) $analysis->kpis) as $kpi) { if (! is_array($kpi)) continue; $kpiRows[] = [ 'label' => (string) ($kpi['label'] ?? ''), 'value' => (string) ($kpi['value'] ?? ''), 'unit' => (string) ($kpi['unit'] ?? ''), 'comment' => (string) ($kpi['comment'] ?? ''), 'trend' => (string) ($kpi['trend'] ?? ''), 'source_ref' => (string) ($kpi['source_ref'] ?? ''), ]; } // Charts arrive as [{title,type,categories,series,source_ref}] from the // analyzer or from a previous admin save. Series rows are either // {label,value,is_total?} or {label,values:[…]}. $chartRows = []; foreach (((array) $analysis->chart_config) as $c) { if (! is_array($c)) continue; $series = []; foreach ((array) ($c['series'] ?? []) as $s) { if (! is_array($s)) continue; if (isset($s['values']) && is_array($s['values'])) { $series[] = [ 'label' => (string) ($s['label'] ?? ''), 'values' => array_map(fn ($v) => (float) $v, $s['values']), 'is_total' => false, 'mode' => 'multi', ]; } else { $series[] = [ 'label' => (string) ($s['label'] ?? ''), 'value' => isset($s['value']) ? (float) $s['value'] : 0, 'is_total' => ! empty($s['is_total']), 'mode' => 'single', ]; } } $chartRows[] = [ 'title' => (string) ($c['title'] ?? ''), 'type' => (string) ($c['type'] ?? 'bar'), 'categories' => array_map(fn ($x) => (string) $x, (array) ($c['categories'] ?? [])), 'series' => $series, 'source_ref' => (string) ($c['source_ref'] ?? ''), ]; } @endphp @push('head') @endpush @section('content')
{{-- Header --}}
{{ __('Admin review') }} · #{{ $analysis->id }}

{{ $type['label'] ?? $analysis->analysis_type }}

{{ $submission->original_name }} · {{ optional($submission->uploader)->name ?? '—' }}

@if ($errors->any())
{{ $errors->first() }}
@endif
@csrf {{-- Left column --}}
{{-- Summary --}}

{{ __('Executive summary') }}

{{ __('4–7 sentences') }}
{{-- Explanation rich-text --}}

{{ __('Detailed explanation') }}

{{ __('HTML') }}
{!! old('explanation_html', $analysis->explanation_html) !!}
{{-- KPI grid: card-based, fluid, responsive --}}

{{ __('KPIs') }}

{{ __('indicators') }}

{{-- Empty state --}}

{{ __('No KPIs yet — add the first one.') }}

{{-- Chart editor: visual type-pickers + clean per-chart card --}}

{{ __('Charts') }}

· {{ __('Title, type and data — exactly what the client will see.') }}

{{-- Empty state --}}

{{ __('No charts yet — add the first one.') }}

{{ __('Tip: line/area/stacked-bar use Categories (periods) and per-period values. Donut/bar/waterfall use a single value per row.') }}

{{-- Action bar --}}
{{-- Right column: revisions + meta --}}
@endsection