@php $teamForecasts = $teamForecasts ?? []; $charts = $teamForecasts['charts'] ?? []; $periodLabel = $teamForecasts['period_label'] ?? ($tv['period_label'] ?? now()->format('F Y')); $forecastPanels = [ ['key' => 'total_sales_revenue', 'label' => 'Total Sales Revenue', 'canvasId' => 'tv-forecast-revenue'], ['key' => 'units_sold', 'label' => 'Units Sold', 'canvasId' => 'tv-forecast-units'], ['key' => 'gross_profit', 'label' => 'Gross Profit', 'canvasId' => 'tv-forecast-gp'], ]; $formatForecastSummary = function (array $chart, string $field): string { $summary = is_array($chart['summary'] ?? null) ? $chart['summary'] : []; $value = (float) ($summary[$field] ?? 0); $valueType = (string) ($chart['value_type'] ?? 'count'); if ($valueType === 'money') { return format_rand($value); } return number_format($value, 0, '.', ','); }; @endphp

Team Forecast

Target, actual, and projected run-rate ยท {{ $periodLabel }}

@foreach ($forecastPanels as $panel) @php $chart = $charts[$panel['key']] ?? []; $hasTarget = ($chart['has_target'] ?? false) === true; @endphp

{{ $panel['label'] }}

Month target

{{ $hasTarget ? $formatForecastSummary($chart, 'target') : 'โ€”' }}

Actual today

{{ $hasTarget ? $formatForecastSummary($chart, 'actual_to_date') : 'โ€”' }}

Forecast end

{{ $hasTarget ? $formatForecastSummary($chart, 'projected_end') : 'โ€”' }}

No team target configured for this metric.
@endforeach