@php $fmtH = function ($v) { if ($v === null || $v === '') { return ''; } if ($v instanceof \DateTimeInterface) { return $v->format('H:i'); } return substr((string) $v, 0, 5); }; $catOA = function ($u) { $c = mb_strtolower((string) ($u->contrato_categoria ?? '')); if (str_contains($c, 'ayud')) { return 'A'; } return 'O'; }; $lugar = $parte->lugar; $filasMat = collect(); foreach ($parte->registrosTrabajo as $reg) { foreach ($reg->materialesUtilizados as $mu) { $filasMat->push([ 'cod' => $mu->material->codigo_sku ?? '', 'nom' => $mu->material->nombre ?? '', 'ud' => $mu->cantidad_utilizada, ]); } } foreach ($parte->materialesAdicionales as $ad) { $filasMat->push([ 'cod' => $ad->material->codigo_sku ?? '', 'nom' => $ad->material->nombre ?? '', 'ud' => $ad->cantidad, ]); } $filasMatMostrar = $filasMat ->filter(function ($f) { $cod = trim((string) ($f['cod'] ?? '')); $nom = trim((string) ($f['nom'] ?? '')); $ud = $f['ud'] ?? null; return $cod !== '' || $nom !== '' || ($ud !== '' && $ud !== null); }) ->take(20) ->values(); $trabajoTexto = $parte->registrosTrabajo ->map(fn ($r) => trim((string) $r->descripcion_trabajo)) ->filter() ->unique() ->implode("\n"); $numParteFmt = str_pad((string) $parte->id, 4, '0', STR_PAD_LEFT); $empresaLineaDir = $empresa ? trim(implode(', ', array_filter([ $empresa->direccion, trim(implode(' ', array_filter([$empresa->cp, $empresa->poblacion]))), $empresa->provincia, ]))) : ''; $empresaTels = ($empresa && $empresa->telefono) ? $empresa->telefono : ''; $a4HuecosOperariosExtra = 2; @endphp
{{ strtoupper($empresa->nombre_comercial) }}
@if($empresa->razon_social && strcasecmp($empresa->razon_social, $empresa->nombre_comercial) !== 0){{ $empresa->razon_social }}
@endif @elseEMPRESA
@endif| FECHA | {{ $parte->fecha?->format('d/m/Y') ?? '—' }} |
| REF. | {{ $numParteFmt }} |
| CONTROL | @php $estadoTxt = trim((string) ($parte->estado ?? '')); $controlTxt = $estadoTxt !== '' ? $estadoTxt : ''; if (!empty($parte->fecha_verificacion)) { $controlTxt = 'Verificado'; } @endphp @if($controlTxt !== '') {{ $controlTxt }} @else @endif |
PARTE DE TRABAJO
Nº {{ $numParteFmt }}
| CLIENTE | {{ $lugar->nombre ?? '—' }} | D.N.I./N.I.F. | |
| DIRECCIÓN | {{ $parte->direccion ?: ($lugar->direccion ?? '') }} | TELEF. | {{ $lugar->telefono ?? '' }} |
| LOCALIDAD | {{ $parte->poblacion ?: ($lugar->poblacion ?? '') }} | CLAVE | {{ $lugar->tipo ?? ($lugar->descripcion ?? '') }} |
Trabajo realizado
Observaciones
Materiales
| Cod. | Descripción | Ud. |
|---|---|---|
| {{ $fila['cod'] }} | {{ $fila['nom'] }} | {{ $fila['ud'] !== '' && $fila['ud'] !== null ? $fila['ud'] : '' }} |
| Sin materiales registrados. | ||
Horas de trabajo
| Operario | Cat. (O)/(A) |
Mañana | Tarde | Total horas |
||
|---|---|---|---|---|---|---|
| Empieza | Termina | Empieza | Termina | |||
| {{ $registro->user?->nombreCompleto() ?? '—' }} | {{ $catOA($registro->user) }} | {{ $fmtH($registro->entrada_manana) }} | {{ $fmtH($registro->salida_manana) }} | {{ $fmtH($registro->entrada_tarde) }} | {{ $fmtH($registro->salida_tarde) }} | {{ number_format((float) $registro->horas_laborales, 2, ',', '') }} |
| Sin registros de trabajo. | ||||||
| @endfor | ||||||
Firmas
|
|