@include('pdf.partials.styles-unified')

REPORTE DE DESPACHOS | {{ $empresa->name }}

Total de Despachos: {{ $records->count() }}

Total Aves: {{ number_format($totals->total_cantidad_pollos ?? 0, 0) }}

Peso Neto Total: {{ number_format($totals->total_peso_neto ?? 0, 2) }} kg

@if (isset($fuera_de_horario) && $fuera_de_horario !== null)

Filtro Horario: {{ $fuera_de_horario == 1 ? 'Fuera de Horario' : 'Horario' }}

@endif

Generado: {{ now()->format('d/m/Y H:i:s') }}

Por: {{ auth()->user()->name ?? 'Sistema' }}

@php $contador = 1; $totalCantidadPollos = 0; $totalPesoBruto = 0; $totalTara = 0; $totalPesoNeto = 0; $totalJabas = 0; @endphp @forelse($records as $item) @php // Acumulando totales $totalJabas += $item->cantidad_jabas; $totalCantidadPollos += $item->cantidad_pollos; $totalPesoBruto += $item->peso_total_bruto; $totalTara += $item->tara; $totalPesoNeto += $item->peso_total_neto; @endphp @empty @endforelse
Cliente F. Despacho Serie Producto Jabas Total Aves Promedio P. Bruto P. Tara P. Neto F. Horario
{{ $contador++ }} {{ $item->cliente_razon_social }} {{ \Carbon\Carbon::parse($item->fecha_despacho)->format('d/m/Y') }} {{ $item->serie_orden }} @if ($item->detalles && $item->detalles->count() > 0) @foreach ($item->detalles->take(3) as $detalle) {{ $detalle->tipo_pollo }}@if (!$loop->last) , @endif @endforeach @if ($item->detalles->count() > 3) ... (+{{ $item->detalles->count() - 3 }} más) @endif @else Sin productos @endif {{ number_format($item->cantidad_jabas, 0) }} {{ number_format($item->cantidad_pollos, 0) }} {{ $item->cantidad_pollos != 0 ? number_format($item->peso_total_neto / $item->cantidad_pollos, 2) : 'N/A' }} {{ number_format($item->peso_total_bruto, 2) }} {{ number_format($item->tara, 2) }} {{ number_format($item->peso_total_neto, 2) }} @if ($item->fuera_de_horario) @else No @endif
No hay despachos registrados
TOTALES: {{ number_format($totalJabas, 0) }} {{ number_format($totalCantidadPollos, 0) }} - {{ number_format($totalPesoBruto, 2) }} {{ number_format($totalTara, 2) }} {{ number_format($totalPesoNeto, 2) }}
@if (isset($mixed_orders) && $mixed_orders->count() > 0 && is_null($selected_tipo_pollo_id))

ÓRDENES MIXTAS ({{ $mixed_orders->count() }})

@foreach ($mixed_orders as $orden) @endforeach
Cliente Serie Fecha Despacho Tipos de Pollo Total Aves Peso Neto
{{ $orden->cliente->razon_social ?? 'N/A' }} {{ $orden->serie_orden }} {{ \Carbon\Carbon::parse($orden->fecha_despacho)->format('d-m-Y') }} @foreach ($orden->detalles as $detalle) @php $tipoPollo = \App\Models\TipoPollo::find($detalle->tipo_pollo_id); @endphp {{ $tipoPollo ? $tipoPollo->descripcion : 'Desconocido' }} ({{ $detalle->cantidad_pollos }}) @if (!$loop->last) , @endif @endforeach {{ number_format($orden->cantidad_pollos, 0) }} {{ number_format($orden->peso_total_neto, 2) }}
Total Órdenes Mixtas {{ number_format($mixed_orders->sum('cantidad_pollos'), 0) }} {{ number_format($mixed_orders->sum('peso_total_neto'), 2) }}
@endif @if (isset($totals_by_tipo) && $totals_by_tipo->count() > 0 && is_null($selected_tipo_pollo_id))

RESUMEN POR TIPO DE POLLO

@php $sumaPorTipos = 0; @endphp @foreach ($totals_by_tipo as $tipo) @php $tipoPollo = \App\Models\TipoPollo::find($tipo->tipo_pollo_id); $sumaPorTipos += $tipo->total_cantidad_pollos; @endphp @endforeach
Tipo de Pollo Total Aves
{{ $tipoPollo ? $tipoPollo->descripcion : 'Desconocido' }} {{ number_format($tipo->total_cantidad_pollos, 0) }}
Suma por Tipos {{ number_format($sumaPorTipos, 0) }}
Total General {{ number_format($totals->total_cantidad_pollos, 0) }}
@if ($sumaPorTipos == $totals->total_cantidad_pollos) Totales coinciden @else Diferencia (descuentos aplicados): {{ $totals->total_cantidad_pollos - $sumaPorTipos }} @endif
@endif