@php // Accent colours for a target's metric icon chip. $iconChip = [ 'indigo' => 'bg-indigo-50 text-indigo-600', 'violet' => 'bg-violet-50 text-violet-600', 'sky' => 'bg-sky-50 text-sky-600', 'emerald' => 'bg-emerald-50 text-emerald-600', 'amber' => 'bg-amber-50 text-amber-600', 'blue' => 'bg-blue-50 text-blue-600', ]; // Status badge + progress-bar styling, keyed by derived status. $statusMeta = [ 'on_track' => ['label' => __('On Track'), 'badge' => 'bg-emerald-50 text-emerald-700', 'bar' => 'from-emerald-500 to-emerald-400'], 'at_risk' => ['label' => __('At Risk'), 'badge' => 'bg-amber-50 text-amber-700', 'bar' => 'from-amber-500 to-amber-400'], 'behind' => ['label' => __('Behind'), 'badge' => 'bg-rose-50 text-rose-700', 'bar' => 'from-rose-500 to-rose-400'], 'upcoming' => ['label' => __('Upcoming'), 'badge' => 'bg-slate-100 text-slate-600', 'bar' => 'from-slate-400 to-slate-300'], 'ended' => ['label' => __('Ended'), 'badge' => 'bg-slate-100 text-slate-500', 'bar' => 'from-slate-400 to-slate-300'], ]; $statusFilters = [ 'all' => __('All statuses'), 'on_track' => __('On Track'), 'at_risk' => __('At Risk'), 'behind' => __('Behind'), ]; $periodFilters = [ 'all' => __('All Periods'), 'daily' => __('Daily'), 'weekly' => __('Weekly'), 'monthly' => __('Monthly'), 'yearly' => __('Yearly'), ]; $tabs = [ 'all' => ['label' => __('All Targets'), 'count' => $tabCounts['all'] ?? 0], 'sales' => ['label' => __('Sales Team'), 'count' => $tabCounts['sales'] ?? 0], 'production' => ['label' => __('Production Team'), 'count' => $tabCounts['production'] ?? 0], 'admin' => ['label' => __('Admin Team'), 'count' => $tabCounts['admin'] ?? 0], 'finance' => ['label' => __('Finance'), 'count' => $tabCounts['finance'] ?? 0], ]; $sparkPaths = [ 'emerald' => 'M0,26 C18,24 30,10 48,14 C66,18 78,6 96,9 C114,12 126,2 144,5', 'amber' => 'M0,22 C18,18 30,24 48,16 C66,8 78,18 96,12 C114,6 126,16 144,10', 'rose' => 'M0,12 C18,16 30,8 48,18 C66,24 78,14 96,20 C114,26 126,16 144,22', ]; @endphp
{{-- Page header --}} {{-- Period scope filter --}}
@foreach ($periodFilters as $value => $label) @endforeach
{{-- Status filter ("Filters") --}}
@foreach ($statusFilters as $value => $label) @endforeach
@if ($canManage) {{ __('New Target') }} @endif
@if (! $hasTargets) {{-- Nothing configured yet --}}
@if ($canManage) {{ __('New Target') }} @endif
@else {{-- Summary cards --}}
{{-- Overall progress donut --}}

{{ __('Overall Progress') }}

{{ __('All targets average') }}

{{ $summary['avg'] }}%

{{ __('Live this period') }}

{{ $summary['total'] }} {{ __('Targets') }}
{{ __('On Track') }} {{ $summary['on_track'] }}
{{ __('At Risk') }} {{ $summary['at_risk'] }}
{{ __('Behind') }} {{ $summary['behind'] }}
{{-- On Track / At Risk / Behind stat cards --}} @foreach ([ ['key' => 'on_track', 'label' => __('On Track'), 'count' => $summary['on_track'], 'pct' => $summary['on_track_pct'], 'icon' => 'arrow-trending-up', 'spark' => 'emerald', 'chip' => 'bg-emerald-50 text-emerald-600', 'stroke' => '#10b981'], ['key' => 'at_risk', 'label' => __('At Risk'), 'count' => $summary['at_risk'], 'pct' => $summary['at_risk_pct'], 'icon' => 'arrow-trending-up', 'spark' => 'amber', 'chip' => 'bg-amber-50 text-amber-600', 'stroke' => '#f59e0b'], ['key' => 'behind', 'label' => __('Behind'), 'count' => $summary['behind'], 'pct' => $summary['behind_pct'], 'icon' => 'arrow-trending-down', 'spark' => 'rose', 'chip' => 'bg-rose-50 text-rose-600', 'stroke' => '#ef4444'], ] as $stat) @endforeach
{{-- Tab bar: team filter + search + view toggle --}}
@foreach ($tabs as $key => $tab) @endforeach
@if (empty($rows))

{{ __('No targets match your filters.') }}

@elseif ($view === 'list') {{-- List (table) view --}}
@foreach ($rows as $row) @php $sm = $statusMeta[$row['status']] ?? $statusMeta['ended']; @endphp {{-- Target --}} {{-- Owner / Team --}} {{-- Period --}} {{-- Progress --}} {{-- Status --}} {{-- Actions --}} @endforeach
{{ __('Target') }} {{ __('Owner / Team') }} {{ __('Period') }} {{ __('Progress') }} {{ __('Status') }} {{ __('Actions') }}

{{ $row['title'] }}

{{ $row['description'] }}

{{ $row['team_label'] }}
@if ($row['owner_photo']) {{ $row['owner_name'] }} @else {{ $row['owner_initials'] }} @endif

{{ $row['owner_name'] }}

{{ $row['team_label'] }}

{{ $row['window_label'] }}

{{ $row['period_label'] }}

{{ $row['progress_label'] }} {{ number_format($row['pct'], 0) }}%
{{ $sm['label'] }}
@if ($canManage) @endif @if ($canDelete) @endif
@else {{-- Grid (card) view --}}
@foreach ($rows as $row) @php $sm = $statusMeta[$row['status']] ?? $statusMeta['ended']; @endphp

{{ $row['title'] }}

{{ $row['team_label'] }} · {{ $row['window_label'] }}

{{ $sm['label'] }}

{{ number_format($row['pct'], 0) }}%

{{ $row['progress_label'] }}

@if ($row['owner_photo']) {{ $row['owner_name'] }} @else {{ $row['owner_initials'] }} @endif {{ $row['owner_name'] }}
@if ($canManage) @endif @if ($canDelete) @endif
@endforeach
@endif {{-- Bottom CTA banner --}}

{{ __('Stay on track and hit your goals!') }}

{{ __('Regularly review your targets and adjust strategies to stay on track.') }}

{{ __('View Reports') }}
@endif {{-- Business development targets (CRM S8): per officer, approved, revised with history --}}
{{-- Create / Edit Modal --}} {{ $editingId ? __('Edit Target') : __('New Target') }} @php $metricMonetary = ! empty($metricDefs[$metric]['monetary']); $metricPerUser = ! empty($metricDefs[$metric]['per_user']); @endphp
{{-- Per-user scope: only attributable metrics can be assigned --}}
@if ($metricPerUser)

{{ __('Assign to one team member, or target the whole team.') }}

@else
{{ __('Company-wide (team only)') }}
@endif
{{-- Type-specific goal inputs --}} @if ($type === 'fixed' || $type === 'percentage')
@if ($metricMonetary && $type === 'fixed')

{{ __('Progress is reported in the team base currency.') }}

@endif
@elseif ($type === 'growth')

{{ __('Goal = the previous period\'s actual × (1 + growth%). E.g. 10 means “beat last period by 10%”.') }}

@elseif ($type === 'formula')

{{ __('Use + − * / and parentheses with these variables:') }} {{ implode(', ', $formulaVars) }}

@endif
{{-- Schedule (§16): recurring (open-ended) vs runs until a set date. --}}
@if ($schedule_mode === 'until')
@endif
{{ __('Cancel') }} {{ __('Save') }}