{{-- ══════════════════════════════════════════════════════ --}} {{-- HEADER --}} {{-- ══════════════════════════════════════════════════════ --}} {{-- ══════════════════════════════════════════════════════ --}} {{-- SECCIÓN 1: ALIMENTACIÓN --}} {{-- ══════════════════════════════════════════════════════ --}} @php $alim = $payload['alimentacion']; @endphp {{-- STATUS alimentación --}} @if($alim['todos_los_dias_completos']) @elseif($alim['dias_con_datos'] === 0) @else @endif {{-- ══════════════════════════════════════════════════════ --}} {{-- SECCIÓN 2: INVENTARIO DE ANIMALES --}} {{-- ══════════════════════════════════════════════════════ --}} @php $inv = $payload['inventario']; @endphp {{-- ══════════════════════════════════════════════════════ --}} {{-- SECCIÓN 3: MOVIMIENTOS DE ANIMALES --}} {{-- ══════════════════════════════════════════════════════ --}} @php $mov = $payload['movimientos']; @endphp {{-- FOOTER --}}

Sistema de Gestion Ganadera

Rancho La Fortuna

Resumen Semanal General

{{ $payload['semana_formateada'] }}  ·  Semana {{ $payload['numero_semana'] }}

Seccion 1

Alimentacion

✓   {{ $alim['dias_completos'] }}/{{ $alim['total_dias'] }} dias con todos los corrales alimentados
Sin registros de alimentacion en esta semana
⚠   {{ $alim['dias_completos'] }}/{{ $alim['total_dias'] }} dias completos @if(count($alim['dias_incompletos']) > 0)  ·  {{ count($alim['dias_incompletos']) }} dias con corrales faltantes @endif
{{-- KPIs totales semana --}} @if(count($alim['total_semana_por_unidad']) > 0) @foreach($alim['total_semana_por_unidad'] as $ts) @if(($ts['total_consumido'] ?? 0) > 0) @endif @endforeach
{{ number_format($ts['total_ofrecido'], 1) }}
{{ $ts['unidad'] }} ofrecidos
{{ number_format($ts['total_consumido'], 1) }}
{{ $ts['unidad'] }} consumidos
@endif {{-- Alimento ofrecido + Consumo por sector --}} {{-- Izquierda: alimentos --}} {{-- Derecha: consumo por sector --}} @if(count($alim['consumo_por_seccion']) > 0) @endif
@if(!empty($alim['totales_por_producto']))

Alimento ofrecido en la semana

@foreach($alim['totales_por_producto'] as $i => $prod) @php $bgProd = ($i % 2 === 0) ? '#ffffff' : '#f1f8e9'; @endphp @endforeach
Alimento Cantidad
{{ $prod['nombre'] }} {{ number_format($prod['ofrecido'], 1) }} {{ $prod['unidad'] }}
@endif

Consumo semanal por sector

@foreach($alim['total_semana_por_unidad'] as $ts) @endforeach @foreach($alim['consumo_por_seccion'] as $i => $sec) @php $bgSec = ($i % 2 === 0) ? '#ffffff' : '#f5f5f5'; $accentColor = match($sec['key']) { 'R1' => '#1565c0', 'R2' => '#6a1b9a', 'E' => '#bf360c', default => '#37474f' }; @endphp @foreach($alim['total_semana_por_unidad'] as $ts) @php $consumoSecU = collect($sec['por_unidad'])->firstWhere('unidad', $ts['unidad']); $valorSec = $consumoSecU['total_consumido'] ?? null; @endphp @endforeach @endforeach @foreach($alim['total_semana_por_unidad'] as $ts) @endforeach
Sector{{ $ts['unidad'] }}
{{ $sec['nombre'] }} @if($valorSec !== null && $valorSec > 0) {{ number_format($valorSec, 1) }} {{ $ts['unidad'] }} @else @endif
TOTAL @if($ts['total_consumido'] > 0) {{ number_format($ts['total_consumido'], 1) }} {{ $ts['unidad'] }} @else @endif
{{-- Detalle día a día --}} @if(count($alim['dias']) > 0)

Dia a dia

@foreach($alim['total_semana_por_unidad'] as $ts) @if($ts['unidad'] !== 'L') @endif @endforeach @foreach($alim['consumo_por_seccion'] as $sec) @php $accentSec = match($sec['key']) { 'R1' => '#1565c0', 'R2' => '#6a1b9a', 'E' => '#bf360c', default => '#37474f' }; @endphp @endforeach @foreach($alim['dias'] as $i => $dia) @php $bg = !$dia['tiene_datos'] ? '#fafafa' : ($dia['todos_alimentados'] ? ($i % 2 === 0 ? '#ffffff' : '#f5f5f5') : '#fff8e1'); @endphp @if(!$dia['tiene_datos']) @php $totalCols = count($alim['consumo_por_seccion']); foreach ($alim['total_semana_por_unidad'] as $ts) { $totalCols += ($ts['unidad'] === 'L') ? 1 : 3; } @endphp @else @foreach($alim['total_semana_por_unidad'] as $ts) @php $consumoU = collect($dia['consumo_por_unidad'])->firstWhere('unidad', $ts['unidad']); $ofrecidoU = $consumoU['ofrecido'] ?? null; $valorU = $consumoU['consumido'] ?? null; $rechazoU = $consumoU['rechazo'] ?? null; @endphp @if($ts['unidad'] !== 'L') @endif @endforeach @foreach($alim['consumo_por_seccion'] as $sec) @php $secDia = collect($dia['consumo_por_seccion'])->firstWhere('key', $sec['key']); $primerU = $alim['total_semana_por_unidad'][0]['unidad'] ?? 'kg'; $consumoSD = $secDia ? collect($secDia['por_unidad'])->firstWhere('unidad', $primerU) : null; $valorSD = $consumoSD['consumido'] ?? null; $accentSec = match($sec['key']) { 'R1' => '#1565c0', 'R2' => '#6a1b9a', 'E' => '#bf360c', default => '#37474f' }; @endphp @endforeach @endif @endforeach {{-- Total semana --}} @foreach($alim['total_semana_por_unidad'] as $ts) @if($ts['unidad'] !== 'L') @endif @endforeach @foreach($alim['consumo_por_seccion'] as $sec) @php $primerU = $alim['total_semana_por_unidad'][0]['unidad'] ?? 'kg'; $totalSec = collect($sec['por_unidad'])->firstWhere('unidad', $primerU); $valSec = $totalSec['total_consumido'] ?? null; $accentSec = match($sec['key']) { 'R1' => '#1565c0', 'R2' => '#6a1b9a', 'E' => '#bf360c', default => '#37474f' }; @endphp @endforeach
Dia Anim. CorralesOfrecido ({{ $ts['unidad'] }})Consumido ({{ $ts['unidad'] }}) Rechazo{{ $sec['key'] }}
{{ $dia['fecha_corta'] }}
{{ $dia['dia_semana'] }} @if(!$dia['tiene_datos'])
Sin datos @elseif(!$dia['todos_alimentados'])
⚠ {{ $dia['total_corrales_faltantes'] }} falt. @endif
@if($dia['tiene_datos']) {{ $dia['total_animales'] }} @else @endif @if($dia['tiene_datos']) {{ $dia['total_corrales_alimentados'] }}/{{ $dia['total_corrales_con_animales'] }} @else @endif Sin registro @if($ofrecidoU !== null && $ofrecidoU > 0) {{ number_format($ofrecidoU, 1) }} {{ $ts['unidad'] }} @else @endif @if($valorU !== null) {{ number_format($valorU, 1) }} {{ $ts['unidad'] }} @else @endif @if($rechazoU === null) @else @php $colorRec = ($rechazoU == 0 || $rechazoU > $alim['rechazo_maximo']) ? '#c62828' : ($rechazoU > $alim['rechazo_minimo'] ? '#2e7d32' : '#a07800'); @endphp {{ $rechazoU }}% @endif @if($valorSD !== null) {{ number_format($valorSD, 1) }} @else @endif
TOTAL SEMANA @if($ts['total_ofrecido'] > 0){{ number_format($ts['total_ofrecido'], 1) }} {{ $ts['unidad'] }}@else@endif @if($ts['total_consumido'] > 0){{ number_format($ts['total_consumido'], 1) }} {{ $ts['unidad'] }}@else@endif @if($valSec !== null && $valSec > 0){{ number_format($valSec, 1) }} {{ $primerU }}@else@endif
@endif {{-- Días incompletos --}} @if(count($alim['dias_incompletos']) > 0)

Dias con corrales faltantes

@foreach($alim['dias_incompletos'] as $incompleto)
{{ $incompleto['fecha_corta'] }}  —  {{ $incompleto['alimentados'] }} alimentados, {{ $incompleto['faltantes'] }} sin registro
@endforeach @endif

Seccion 2

Inventario de Animales

Animales activos al {{ \Carbon\Carbon::parse($inv['fecha_corte'])->format('d/m/Y') }}

{{-- KPIs inventario --}}
{{ $inv['total_activos'] }}
Total Activos
{{ $inv['total_hembras'] }}
Hembras
{{ $inv['total_machos'] }}
Machos
{{ $inv['total_crias'] }}
Crias (≤12m)
{{ $inv['total_sin_fecha'] }}
Sin F. Nacimiento
{{-- Layout: columna izquierda = primera especie, columna derecha = resto apiladas --}} @php $especieIzq = $inv['especies'][0] ?? null; $especiesDer = array_slice($inv['especies'], 1); @endphp {{-- ── COLUMNA IZQUIERDA: primera especie ── --}} {{-- ── COLUMNA DERECHA: demás especies apiladas ── --}}
@if($especieIzq) @php $totEsp = $especieIzq['totales']; $grandTotalEsp = $especieIzq['total_animales']; @endphp @foreach($especieIzq['secciones'] as $seccion) @foreach($seccion['corrales'] as $j => $corralRow) @php $bgC = ($j%2===0)?'#ffffff':'#f1f8e9'; $tot = $corralRow['hembras']+$corralRow['machos']+$corralRow['crias']+$corralRow['sin_fecha']; @endphp @endforeach @endforeach
INVENTARIO GENERAL {{ strtoupper($especieIzq['especie']) }}
► {{ strtoupper($seccion['nombre']) }}
Corral Hembras Machos Crias Sin F. Nac. Total
{{ $corralRow['corral'] }} {{ $corralRow['hembras'] }} {{ $corralRow['machos'] }} {{ $corralRow['crias'] }} @if($corralRow['sin_fecha'] > 0) {{ $corralRow['sin_fecha'] }} @else @endif {{ $tot }}
TOTALES {{ $totEsp['hembras'] }} {{ $totEsp['machos'] }} {{ $totEsp['crias'] }} {{ $totEsp['sin_fecha'] }} {{ $grandTotalEsp }}
@endif
@foreach($especiesDer as $espData) @php $totEsp = $espData['totales']; $grandTotalEsp = $espData['total_animales']; @endphp @if(!$loop->first)
@endif @foreach($espData['secciones'] as $seccion) @foreach($seccion['corrales'] as $j => $corralRow) @php $bgC = ($j%2===0)?'#ffffff':'#f1f8e9'; $tot = $corralRow['hembras']+$corralRow['machos']+$corralRow['crias']+$corralRow['sin_fecha']; @endphp @endforeach @endforeach
INVENTARIO GENERAL {{ strtoupper($espData['especie']) }}
► {{ strtoupper($seccion['nombre']) }}
Corral Hembras Machos Crias Sin F. Nac. Total
{{ $corralRow['corral'] }} {{ $corralRow['hembras'] }} {{ $corralRow['machos'] }} {{ $corralRow['crias'] }} @if($corralRow['sin_fecha'] > 0) {{ $corralRow['sin_fecha'] }} @else @endif {{ $tot }}
TOTALES {{ $totEsp['hembras'] }} {{ $totEsp['machos'] }} {{ $totEsp['crias'] }} {{ $totEsp['sin_fecha'] }} {{ $grandTotalEsp }}
@endforeach

Seccion 3

Movimientos de Animales

Del {{ \Carbon\Carbon::parse($mov['fecha_inicio'])->format('d/m/Y') }} al {{ \Carbon\Carbon::parse($mov['fecha_fin'])->format('d/m/Y') }}  ·  {{ $mov['total'] }} movimiento{{ $mov['total'] !== 1 ? 's' : '' }}

@if($mov['total'] === 0)
No hubo movimientos de animales durante esta semana.
@else @foreach($mov['movimientos'] as $i => $m) @php $bgMov = ($i % 2 === 0) ? '#ffffff' : '#f0f4f8'; @endphp @endforeach
Arete Color Sexo F. Nacimiento Especie Corral Origen Corral Destino Fecha Motivo
{{ $m['arete'] ?? '—' }} @if(!empty($m['color_arete'])) @else @endif @if($m['sexo'] === 'macho') M @elseif($m['sexo'] === 'hembra') H @else ? @endif {{ $m['fecha_nacimiento'] }} {{ $m['especie'] }} {{ $m['corral_origen'] }} {{ $m['corral_destino'] }} {{ $m['fecha'] }} {{ $m['motivo'] }}
@endif
Rancho La Fortuna  ·  Sistema de Gestion Ganadera  ·  Generado el {{ now()->format('d/m/Y H:i') }}