{{ __('Violations Report') }}

{{ __('Company') }}: {{ session('company_name') ?? __('N/A') }} | {{ __('Branch') }}: {{ session('branch_name') ?? __('N/A') }}

{{ __('Date') }}: {{ now()->format('Y-m-d H:i') }}

@if(request('only_summary'))
{{ __('Summary') }}:

{{ __('Total Violations') }}: {{ count($violations) }}

{{ __('Most Common') }} {{ __('Reason') }}: {{ $violations->groupBy('reason')->sortByDesc(fn($group) => count($group))->keys()->first() ?? __('N/A') }}

@php $groupedByEmployee = $violations->groupBy('employee_id')->sortByDesc(fn($g) => count($g)); $topGroup = $groupedByEmployee->first(); $topEmployee = $topGroup ? optional($topGroup->first()->employee)->name : __('N/A'); @endphp

{{ __('Most Frequent Employee') }}: {{ $topEmployee }}

{{ __('Most Common') }} {{ __('Penalty') }}: {{ $violations->groupBy('penalty')->sortByDesc(fn($group) => count($group))->keys()->first() ?? __('N/A') }}

@else
{{ __('Summary') }}:

{{ __('Total Violations') }}: {{ count($violations) }}

{{ __('Most Common') }} {{ __('Reason') }}: {{ $violations->groupBy('reason')->sortByDesc(fn($group) => count($group))->keys()->first() ?? __('N/A') }}

@php $groupedByEmployee = $violations->groupBy('employee_id')->sortByDesc(fn($g) => count($g)); $topGroup = $groupedByEmployee->first(); $topEmployee = $topGroup ? optional($topGroup->first()->employee)->name : __('N/A'); @endphp

{{ __('Most Frequent Employee') }}: {{ $topEmployee }}

{{ __('Most Common') }} {{ __('Penalty') }}: {{ $violations->groupBy('penalty')->sortByDesc(fn($group) => count($group))->keys()->first() ?? __('N/A') }}

@foreach($violations as $v) @endforeach
# {{ __('Employee') }} {{ __('Reason') }} {{ __('Date') }} {{ __('Repeat') }} {{ __('Penalty') }}
{{ $v->id }} {{ $v->employee->name ?? __('N/A') }} {{ $v->reason }} {{ $v->violation_date }} {{ $v->repeat_count }} {{ $v->penalty }}
@endif