@php use App\Services\ActivityTargets\ActivityTargetAssignment; $filters = $filters ?? [ 'metric_code' => null, 'period_type' => null, 'assignment_type' => null, 'is_active' => null, ]; $metrics = $metrics ?? []; $targetableMetrics = $targetableMetrics ?? $metrics; $metricLabels = $metricLabels ?? []; $metricValueTypes = $metricValueTypes ?? []; $filterQuery = $filterQuery ?? []; $metricOptions = [['value' => '', 'label' => 'Select a metric…']]; foreach ($targetableMetrics as $metricDef) { $metricOptions[] = ['value' => (string) $metricDef['code'], 'label' => (string) $metricDef['label']]; } $metricFilterMetricDefs = $metrics; $assignmentTypeOptions = [ ['value' => ActivityTargetAssignment::TYPE_DEALER, 'label' => 'Dealer-wide'], ['value' => ActivityTargetAssignment::TYPE_USER, 'label' => 'Specific user'], ['value' => ActivityTargetAssignment::TYPE_ROLE, 'label' => 'Role'], ]; $userOptions = [['value' => '', 'label' => 'Select a user…']]; foreach (($users ?? []) as $u) { $uName = trim(($u->name ?? '').' '.($u->surname ?? '')); $userOptions[] = ['value' => (string) $u->id, 'label' => $uName !== '' ? $uName : 'User #'.$u->id]; } $roleOptions = [['value' => '', 'label' => 'Select a role…']]; foreach (($assignableRoles ?? []) as $role) { $roleOptions[] = ['value' => (string) $role, 'label' => (string) $role]; } $periodTypeOptions = [ ['value' => 'daily', 'label' => 'Daily'], ['value' => 'weekly', 'label' => 'Weekly'], ['value' => 'monthly', 'label' => 'Monthly'], ]; $pageConfig = $pageConfig ?? []; $indexRoute = (string) ($pageConfig['indexRoute'] ?? 'sales-performance-targets.index'); $storeRoute = (string) ($pageConfig['storeRoute'] ?? 'sales-performance-targets.store'); $deactivateRouteName = (string) ($pageConfig['deactivateRouteName'] ?? 'sales-performance-targets.deactivate'); $emptyMessage = (string) ($pageConfig['emptyMessage'] ?? 'No sales performance targets match these filters.'); $config = $salesPerformanceConfig ?? []; $deactivateFormRef = (string) ($config['deactivateFormRef'] ?? 'salesPerformanceDeactivateForm'); $managerUserOnly = (bool) ($managerUserOnly ?? ($config['managerUserOnly'] ?? false)); $modalIdPrefix = (string) ($config['modalIdPrefix'] ?? ''); $summaryMetrics = [ ['label' => 'Total', 'key' => 'total'], ['label' => 'Active', 'key' => 'active', 'value_class' => 'text-emerald-700'], ['label' => 'Inactive', 'key' => 'inactive', 'value_class' => 'text-gray-600'], ]; @endphp
{{ number_format(count($targets ?? [])) }} target(s)
| Metric | Period | Target | Starts | Ends | Status | |
|---|---|---|---|---|---|---|
|
{{ $scopeGroup['label'] }}
{{ $scopeTargets->count() }} {{ $scopeTargets->count() === 1 ? 'target' : 'targets' }}
@if ($scopeActiveCount < $scopeTargets->count()) · {{ $scopeActiveCount }} active @endif
|
||||||
|
{{ $periodGroup['label'] }}
{{ $periodTargets->count() }}@if ($periodActiveCount < $periodTargets->count()) · {{ $periodActiveCount }} active @endif
|
||||||
| {{ $rowMetricLabel }} | {{ $target->period_type }} | {{ $rowTargetDisplay }} | {{ $target->starts_at?->format('Y-m-d') ?? '—' }} | {{ $target->ends_at?->format('Y-m-d') ?? '—' }} | @if ($target->is_active) Active @else Inactive @endif | |
| {{ $emptyMessage }} | ||||||