{{-- Alerts --}} @if (session()->has('message'))
âś… {{ session('message') }}
@endif @if (session()->has('error'))
⚠️ {{ session('error') }}
@endif {{-- Stats --}}
{{ $availableCount }}
Rollos disponibles
{{ number_format($availableMeters, 0) }} m
Metros disponibles
{{ $enProcesoCount }}
En proceso
{{ $lotesActivos }}
Lotes abiertos
{{-- Tabs --}}
{{-- ── TAB: DISPONIBLES ──────────────────────────────────────────────────── --}} @if($tab === 'disponibles')
@if($search || $filterArticle || $filterQuality) @endif
{{-- Selection analysis banner --}} @if(!empty($selectedRolls) && !empty($selectionStats)) @php $ss = $selectionStats; $ROPE_T = 700; @endphp
{{ $ss['count'] }} rollo(s) seleccionado(s) {{ number_format($ss['meters'], 0) }} m {{-- Rope estimate --}} 🪢 {{ $ss['ropes'] }} cuerda(s) · ~{{ number_format($ss['mpr']) }}m c/u {{-- QC summary --}} QC: @if($ss['qc']['A']) {{ $ss['qc']['A'] }}A @endif @if($ss['qc']['B']) {{ $ss['qc']['B'] }}B @endif @if($ss['qc']['PEND']) {{ $ss['qc']['PEND'] }} PEND @endif @if($ss['qc']['R']) {{ $ss['qc']['R'] }} R @endif {{-- Earliest batch date --}} @if($ss['latest_corte']) 📅 Batch desde: {{ \Carbon\Carbon::parse($ss['latest_corte'])->format('d/m/Y') }} @endif
@if($ss['has_pend']) ⚠️ {{ $ss['qc']['PEND'] }} rollo(s) pendiente(s) de inspección @endif @if($ss['has_reject']) 🚫 {{ $ss['qc']['R'] }} rechazo(s) @endif
@elseif(!empty($selectedRolls))
{{ count($selectedRolls) }} rollo(s) seleccionado(s)
@endif
@if($available->isEmpty())
📦
No hay rollos disponibles
Todos los rollos están asignados, en proceso o despachados
@else @foreach ($available as $div) @php $inv = $div->greigeInventory; $clave = $div->cut; $isSeg = $div->etiqueta !== (string) $div->clave_id; $q = $div->calidad_final ?: 'PEND'; $corteFuture = $div->fecha_corte && $div->fecha_corte->isFuture(); @endphp @endforeach
Etiqueta Clave / Seq ArtĂ­culo Partida Fecha corte Telar Metros Peso kg Cal. Ubic.
{{ $div->etiqueta }} @if($isSeg) seg @endif {{ $div->clave_id }} @if($clave) #{{ $clave->roll_sequence }} @endif {{ $div->articulo_id }} {{ $div->partida_id ?? '—' }} @if($div->fecha_corte) {{ $div->fecha_corte->format('d/m/y') }} @if($corteFuture) ⏳ @endif @else — @endif {{ $clave?->loom_id ?? '—' }} {{ $inv ? number_format($inv->metros, 1) : ($clave ? number_format($clave->mts_telar, 1) : '—') }} {{ $inv?->peso_kg ? number_format($inv->peso_kg, 1) : '—' }} {{ $q }} {{ $inv?->ubicacion ?? '—' }}
Total {{ number_format($availableMeters, 0) }} m
@endif
@endif {{-- ── TAB: LOTES ────────────────────────────────────────────────────────── --}} @if($tab === 'lotes')

{{ $lotes->count() }} lote(s) registrado(s)

@if($lotes->isEmpty())
🗂️
No hay lotes creados
Cree un lote y asigne rollos a sus cuerdas desde la pestaña "Disponibles"
@else
@foreach ($lotes as $lote) @php $allRolls = $lote->ropes->flatMap(fn($r) => $r->rolls); $totalRollCount = $allRolls->count(); $pendRollCount = $allRolls->filter(fn($rr) => $rr->division?->calidad_final === 'PEND')->count(); $rejectCount = $allRolls->filter(fn($rr) => $rr->division?->calidad_final === 'R')->count(); $earliestBatch = $lote->earliestBatchDate; $batchDateFuture = $earliestBatch && $earliestBatch->isFuture(); @endphp
{{-- Lote header --}}
{{ $lote->codigo }} {{ $lote->estado }} @if($lote->color) {{ $lote->color->code }} — {{ $lote->color->name }} @else Sin color asignado @endif @if($lote->descripcion) {{ $lote->descripcion }} @endif {{-- Earliest batch date indicator --}} @if($earliestBatch) 📅 Batch desde: {{ $earliestBatch->format('d/m/Y') }} @if($batchDateFuture) ⏳ @endif @endif {{-- QC clearance --}} @if($pendRollCount > 0) ⚠️ {{ $pendRollCount }}/{{ $totalRollCount }} sin inspección @elseif($totalRollCount > 0) ✓ Todos inspeccionados @endif @if($rejectCount > 0) 🚫 {{ $rejectCount }} rechazado(s) @endif
{{ $lote->fecha?->format('d/m/Y') }} {{ $lote->ropes->count() }} cuerda(s) · {{ $lote->ropes->sum(fn($r) => $r->rolls->count()) }} rollos · {{ number_format($lote->ropes->sum('metros_total'), 0) }} m · {{ number_format($lote->ropes->sum('peso_kg_total'), 1) }} kg @if($lote->estado === 'ABIERTO') @else @endif
{{-- Ropes --}} @if($lote->ropes->isEmpty())
Sin cuerdas aún. Seleccione rollos en la pestaña "Disponibles" y asígnelos a este lote.
@else
@foreach ($lote->ropes as $rope)
🪢 Cuerda {{ $rope->rope_number }} {{ $rope->rolls->count() }} rollo(s) · {{ number_format($rope->metros_total, 0) }} m · {{ number_format($rope->peso_kg_total, 1) }} kg
@if($lote->estado === 'ABIERTO') @endif @foreach ($rope->rolls as $rr) @php $div = $rr->division; $clave = $div?->cut; $q = $div?->calidad_final ?: 'PEND'; $isSeg = $div && $div->etiqueta !== (string) $div->clave_id; $otherRopes = collect([1,2,3])->filter(fn($n) => $n !== $rope->rope_number); @endphp @if($lote->estado === 'ABIERTO') @endif @endforeach @if($lote->estado === 'ABIERTO') @endif
# Etiqueta Clave ArtĂ­culo Fecha corte Telar Metros Cal.Mover a
{{ $rr->join_order }} {{ $rr->etiqueta }} @if($isSeg) seg @endif {{ $div?->clave_id ?? '—' }} {{ $div?->articulo_id ?? '—' }} {{ $div?->fecha_corte?->format('d/m/y') ?? '—' }} {{ $clave?->loom_id ?? '—' }} {{ number_format($rr->metros, 1) }} {{ $q }}
@foreach($otherRopes as $n) @endforeach
Total cuerda {{ number_format($rope->metros_total, 1) }} m
@endforeach
@endif
@endforeach
@endif @endif {{-- ── TAB: PLANIFICACIÓN ────────────────────────────────────────────────── --}} @if($tab === 'planificacion')

📊 Planificación de carga por color

Los rollos se agrupan por artículo y partida. La fecha de corte más reciente marca cuándo puede iniciar el batch. Las barras de cuerda estiman la carga (objetivo: ~700 m/cuerda). Use "Seleccionar" para pasar los rollos a la pestaña Disponibles y asignarlos a un lote.

@if($planningData->isEmpty())
📊
No hay rollos disponibles para planificar
@else @foreach($planningData as $group)
{{-- Articulo header --}}
{{ $group['articulo_id'] }} {{ $group['total_rolls'] }} rollos · {{ number_format($group['total_meters']) }} m total @if($group['in_process'] > 0) {{ $group['in_process'] }} en proceso (ya en lote) @endif @if($group['multi_partida']) {{ $group['partidas']->count() }} partidas @endif
{{-- Per-partida cards --}} @foreach($group['partidas'] as $partida) @php $ROPE_T = 700; $fillPct = $partida['estimated_ropes'] > 0 ? min(100, (int) round($partida['meters_per_rope'] / $ROPE_T * 100)) : 0; $barColor = $fillPct >= 85 ? '#22c55e' : ($fillPct >= 50 ? '#f59e0b' : '#94a3b8'); $corteDate = $partida['latest_corte'] ? \Carbon\Carbon::parse($partida['latest_corte']) : null; $corteFuture = $corteDate && $corteDate->isFuture(); @endphp
@if($partida['partida_id']) Partida: {{ $partida['partida_id'] }} @else Sin partida @endif {{ $partida['roll_count'] }} rollos · {{ number_format($partida['meters']) }} m {{-- QC status --}} @if($partida['qc']['A']) {{ $partida['qc']['A'] }}A @endif @if($partida['qc']['B']) {{ $partida['qc']['B'] }}B @endif @if($partida['qc']['PEND']) {{ $partida['qc']['PEND'] }} PEND @endif @if($partida['qc']['R']) {{ $partida['qc']['R'] }} R @endif {{-- Inspection status --}} @if($partida['has_pend']) ⚠️ Pendiente inspección @elseif($partida['all_cleared']) ✓ Listo para batch @endif
{{-- Cut date constraint --}}
Batch no antes de: @if($corteDate) {{ $corteDate->format('d/m/Y') }} @if($corteFuture) · en {{ $corteDate->diffForHumans() }} @endif @else — @endif
{{-- Rope capacity visualization --}}

Capacidad estimada — {{ $partida['estimated_ropes'] }} cuerda(s) de ~{{ number_format($partida['meters_per_rope']) }} m c/u

@for($r = 1; $r <= 3; $r++) @php $used = $r <= $partida['estimated_ropes']; @endphp
C{{ $r }}
@if($used)
@endif
@if($used) {{ number_format($partida['meters_per_rope']) }}m @else — @endif
@endfor
{{-- Actions --}}
@endforeach {{-- Multi-partida comparison --}} @if($group['multi_partida']) @php $ROPE_T = 700; $combFill = $group['combined_ropes'] > 0 ? min(100, (int) round($group['combined_mpr'] / $ROPE_T * 100)) : 0; $combDate = $group['combined_start'] ? \Carbon\Carbon::parse($group['combined_start']) : null; @endphp

💡 Comparación de estrategias — Artículo {{ $group['articulo_id'] }}

{{-- Option A: together --}}

Opción A — Juntas (máxima carga)

{{ $group['total_rolls'] }} rollos · {{ number_format($group['total_meters']) }} m · {{ $group['combined_ropes'] }} cuerda(s) @if($combDate) · batch desde {{ $combDate->format('d/m/Y') }} @endif

@if($group['combined_ropes'] === 3)

✓ Carga completa de máquina

@else

⚠️ Carga parcial de máquina

@endif
{{-- Option B: separate --}}

Opción B — Por separado (entrega parcial anticipada)

@foreach($group['partidas'] as $p) @php $pDate = $p['latest_corte'] ? \Carbon\Carbon::parse($p['latest_corte']) : null; @endphp
{{ $p['partida_id'] ?? 'Sin partida' }} · {{ $p['roll_count'] }} rollos · {{ number_format($p['meters']) }} m · {{ $p['estimated_ropes'] }} cuerda(s) @if($pDate) · desde {{ $pDate->format('d/m/Y') }} @endif @if($p['has_pend']) ⚠️ @endif
@endforeach

Permite entregar cantidades parciales de mĂşltiples colores antes que esperar por carga completa.

@endif
@endforeach @endif @endif {{-- ─────────────────── MODAL: Crear Lote ─────────────────────────────── --}} @if($showCreateLoteModal) @endif {{-- ─────────────────── MODAL: Asignar a cuerda ──────────────────────── --}} @if($showAssignModal) @php $ss = $selectionStats; @endphp @endif