@extends('pdf.layout') @php $titulos = ['usuario' => 'Eventos por usuario', 'tipo' => 'Eventos por tipo', 'elemento' => 'Eventos por elemento']; $claveDe = [ 'usuario' => fn ($e) => [(string) ($e->idEUser ?? '')], 'tipo' => fn ($e) => [(string) $e->codEvento], 'elemento' => fn ($e) => $e->elementos->map(fn ($ee) => $ee->idEL.'|'.$ee->idElemento)->all(), ][$agrupar]; $porGrupo = []; foreach ($eventos as $evento) { foreach ($claveDe($evento) as $clave) { $porGrupo[$clave][] = $evento; } } $tipo = fn ($e) => config("eventos.tipos.{$e->codEvento}.nombre", "Evento {$e->codEvento}"); $usuario = fn ($e) => $e->idEUser === null ? 'Sistema' : ($e->usuario?->nameE ?? $e->idEUser); $elementos = fn ($e) => $e->elementos->sortByDesc('principal')->pluck('nombreElemento')->filter()->implode(' · '); $origen = fn ($e) => collect([$e->origenEvento, $e->dispositivoEvento, $e->ipEvento])->filter()->implode(' · '); @endphp @section('titulo', $titulos[$agrupar]) @push('estilos') .filtros td { font-size: 9px; padding: 1px 4px; } .resumen { margin-top: 10px; } .grupo { margin-top: 14px; } .grupo .cab td { font-size: 11px; font-weight: bold; border-bottom: 1px solid #c3c6c8; padding-top: 6px; } .grupo td { font-size: 9px; } .nw { white-space: nowrap; } @endpush @section('contenido')
| {{ $nombre }} | {{ $valor }} |
| Sin filtros: todos los eventos. | |
| Eventos | {{ number_format($eventos->count(), 0, ',', '.') }} |
El reporte muestra solo los primeros {{ number_format($maximo, 0, ',', '.') }} eventos: acote las fechas o los filtros.
@endif| {{ ['usuario' => 'Usuario', 'tipo' => 'Tipo', 'elemento' => 'Elemento'][$agrupar] }} | Eventos | Primero | Último | |
|---|---|---|---|---|
| {{ $grupo['nombre'] }} | {{ $grupo['detalle'] }} | {{ number_format($grupo['total'], 0, ',', '.') }} | {{ \Illuminate\Support\Carbon::parse($grupo['primero'])->format('d/m/Y h:i A') }} | {{ \Illuminate\Support\Carbon::parse($grupo['ultimo'])->format('d/m/Y h:i A') }} |
| {{ $grupo['nombre'] }} {{ $grupo['detalle'] }} · {{ count($porGrupo[$grupo['clave']]) }} | ||||
| Fecha | @if ($agrupar !== 'usuario')Usuario | @endif @if ($agrupar !== 'tipo')Evento | @endifDetalle | Origen |
|---|---|---|---|---|
| {{ \Illuminate\Support\Carbon::parse($evento->fechaEvento)->format('d/m/Y h:i A') }} | @if ($agrupar !== 'usuario'){{ $usuario($evento) }} | @endif @if ($agrupar !== 'tipo'){{ $tipo($evento) }} | @endif{{ $evento->descEvento }} {{ $elementos($evento) }} |
{{ $origen($evento) }} |