{{-- ── Filters + navigation bar ────────────────────────────────────────── --}}
@if($planFilterArticle || $planFilterState || $planFilterType)
@endif
{{-- ══════════════════════════ PLAN TELARES GRID ════════════════════════ --}} @if($planGrid->isEmpty())
🏭
No hay telares en producción con los filtros actuales
@else
@foreach($planDays as $day) @php $ds = $day->toDateString(); $isToday = $ds === now()->toDateString(); $isFuture = $ds > now()->toDateString(); @endphp @endforeach @foreach($planGrid as $row) @php $loom = $row['loom']; $asgn = $row['assignment']; $beamR = $row['beam_remaining']; $beamO = $row['beam_original']; $beamPct = $beamO > 0 ? min(100, round((($beamO - $beamR) / $beamO) * 100)) : 0; $barC = $beamPct >= 90 ? '#ef4444' : ($beamPct >= 70 ? '#f59e0b' : '#10b981'); $hasInc = $row['has_incident']; @endphp {{-- Fixed info cell --}} {{-- Day cells --}} @foreach($planDays as $day) @php $ds = $day->toDateString(); $cell = $row['days'][$ds] ?? null; $rec = $cell['recorded_mts'] ?? null; $est = $cell['estimated_mts'] ?? null; $cuts = $cell['cuts'] ?? collect(); $expCuts = $cell['expected_cuts'] ?? []; $isTdy = $cell['is_today'] ?? false; $isFut = $cell['is_future'] ?? false; @endphp @endforeach @endforeach @foreach($planDays as $day) @php $ds = $day->toDateString(); $totalWoven = 0; $totalRolls = 0; $totalCutMts = 0; foreach($planGrid as $row) { $cell = $row['days'][$ds] ?? null; if ($cell) { $rec = $cell['recorded_mts'] ?? null; $est = $cell['estimated_mts'] ?? null; $totalWoven += ($rec !== null ? $rec : ($est ?? 0)); $cuts = $cell['cuts'] ?? collect(); $expCuts = $cell['expected_cuts'] ?? []; foreach($cuts as $cut) { if ($cut->tipo_clave !== 'SCRAP') { $totalRolls++; $totalCutMts += $cut->mts_telar; } } foreach($expCuts as $expCutMts) { $totalRolls++; $totalCutMts += $expCutMts; } } } @endphp @endforeach
Telar / Info
{{ $day->format('d') }}
{{ $day->isoFormat('ddd') }} @if($isToday) HOY@endif
{{-- Block 1: Identity & Avg --}}
{{-- Line 1: Loom + Status + Mts/Day --}}
{{ $loom->id }} @php $dotColor = $loom->running_state === 'RUNNING' ? 'bg-emerald-500' : ($loom->running_state === 'STOPPED' ? 'bg-red-500' : 'bg-slate-400'); if($loom->estado === 'UNASSIGNED') $dotColor = 'bg-slate-300'; @endphp @if($hasInc) @endif
@if($asgn)
~{{ number_format($row['avg_mts_day'], 0) }}m/d
@endif
{{-- Line 2: Article + Cut Size --}} @if($asgn)
{{ $asgn->articulo_id }}
✂️ {{ $row['article_cut_mts'] ? number_format($row['article_cut_mts'], 0) : '~'.$row['avg_mts_roll'] }}m
@else
{{ $loom->marca }} · {{ $loom->tipo }}
@endif
{{-- Block 2: Stats Grid --}} @if($asgn)
Orig:{{ number_format($beamO, 0) }} Tej:{{ number_format($beamO - $beamR, 0) }}
Rest:{{ number_format($beamR, 0) }} {{ $beamPct }}%
@endif
{{-- Actions Column --}}
@if($asgn) @if($hasInc) @else @endif @else @endif
@if($rec !== null)
{{ number_format($rec, 0) }}m
@endif @if($est !== null && $rec === null)
~{{ number_format($est, 0) }}m
@elseif($est !== null && $rec !== null && $isTdy)
+~{{ number_format($est - $rec, 0) }}
@endif
@foreach($cuts as $cut) @if($cut->tipo_clave !== 'SCRAP')
✂️ {{ $cut->clave_id }}
{{ number_format($cut->mts_telar,0) }}m
@else
🗑 {{ number_format($cut->mts_telar,0) }}m
@endif @endforeach @foreach($expCuts as $expMts) @php $isPartialRoll = $expMts < ($row['avg_mts_roll'] * 0.9); @endphp
✂️ ~{{ number_format($expMts,0) }}m
{{ $isPartialRoll ? '🔚 final' : 'proyectado' }}
@endforeach
TOTALES
{{ number_format($totalWoven, 0) }}m
@if($totalRolls > 0)
✂️ {{ $totalRolls }} ro.
{{ number_format($totalCutMts, 0) }}m
@endif
425m Registrado ~380m Estimado
✂️ 3240
800m
Corte real
✂️ ~800m
proy.
Proyectado
✂️ ~120m
🔚 final
Último rollo Incidencia abierta
@endif {{-- ── Incident table ─────────────────────────────────────────────── --}} @if($planIncidents->isNotEmpty())

⚠️ Incidencias

@foreach($planIncidents as $inc) @endforeach
Telar Fecha Hora Tipo Descripción Tiempo perdido Estado
{{ $inc->loom_id }} {{ $inc->fecha_inicio }} {{ $inc->hora_inicio ?? '—' }} {{ $inc->tipo }} {{ $inc->descripcion }} {{ number_format($inc->delay_horas_real ?: $inc->delay_horas, 1) }} h @if($inc->estado === 'ABIERTO') ABIERTO @else RESUELTO @endif @if($inc->estado === 'ABIERTO') @endif
@endif {{-- ══════════════ PLEGADORES DISPONIBLES ════════════════════════════════ --}}

🔄 Plegadores Disponibles

{{ $wipBeams->count() }} en cola WIP
@if($wipBeams->isEmpty())
No hay plegadores en cola WIP. Prepare nuevos plegadores desde Partidas.
@else
@foreach($wipBeams as $wb) @php $wbOriginal = $wb->longitud_m ?? 0; $wbAvail = $wb->available_meters ?? 0; $wbPct = $wbOriginal > 0 ? min(100, round((($wbOriginal - $wbAvail) / $wbOriginal) * 100)) : 0; $wbBarC = $wbPct >= 90 ? 'bg-red-500' : ($wbPct >= 70 ? 'bg-amber-500' : 'bg-emerald-500'); @endphp @endforeach
Plegador Artículo Partida M. Original M. Disponibles Consumo Estado Acciones
{{ $wb->id }} {{ $wb->partida?->articulo_id ?? '—' }} {{ $wb->partida_id }} {{ number_format($wbOriginal, 0) }} {{ number_format($wbAvail, 0) }} m
{{ $wbPct }}%
WIP
@endif
{{-- ══════════════════════════════ MODALS ════════════════════════════════ --}} @if($showAssignModal)

Nueva Asignación de Telar

@if($assignLoomId) @else @endif
@endif @if($showTurnoModal)

{{ $editTurnoId ? '✏️ Editar Turno' : '📋 Reporte de Turno' }}

Telar: {{ $turnoLoomId }} @if($editTurnoId) EDITANDO #{{ $editTurnoId }} @endif

@if($editTurnoId)
{{ $turnoTurno === 'M' ? 'Mañana (M)' : 'Tarde (T)' }}
@else @endif
@error('turnoMetros') {{ $message }} @enderror
@if($turnoDuplicado && !$editTurnoId)
⚠️ Ya existe un reporte de turno guardado para este telar, fecha y turno.
@endif @if(!$editTurnoId)
Paros del Turno
@if(count($turnoParos) > 0)
@foreach($turnoParos as $idx => $paro)
{{ $idx + 1 }}
@endforeach
@else

Sin paros registrados en este turno.

@endif
@endif {{-- !$editTurnoId (paros section) --}} @php $histShifts = \App\Models\TurnosReporte::where('loom_id', $turnoLoomId)->orderBy('fecha', 'desc')->orderBy('turno', 'desc')->limit(3)->get(); @endphp @if($histShifts->count() > 0)
Últimos Turnos @foreach($histShifts as $hs) @endforeach
FechaTurno OperarioMetrosRPM
{{ $hs->fecha->format('Y-m-d') }} {{ $hs->turno }} {{ $hs->operario ?: '—' }} {{ number_format($hs->metros_turno, 1) }}m {{ $hs->rpm ?: '—' }}
@endif
@endif @if($showCutModal)

✂️ Cortar Rollo (Clave)

Telar: {{ $cutLoomId }}

@php $activeAsg = \App\Models\LoomAssignment::where('loom_id', $cutLoomId)->where('estado', 'ACTIVA')->first(); $beamAvail = $activeAsg && $activeAsg->beam ? $activeAsg->beam->available_meters : 0; @endphp @if($activeAsg)

Plegador: {{ $activeAsg->plegador_id }}

Disponible en telar: {{ number_format($beamAvail, 1) }} m

@endif
@error('cutMetros') {{ $message }} @enderror
@endif @if($showProblemModal)

⚠️ Reportar Problema

Telar: {{ $probLoomId }}

@endif @if($showResolveModal)

✅ Resolver Incidencia

Telar: {{ $resolveLoomId }}

@php $actInc = \App\Models\LoomIncident::find($resolveIncidentId); @endphp @if($actInc)

Falla: {{ $actInc->descripcion }}

Tipo: {{ $actInc->tipo }}  ·  Reportó: {{ $actInc->reportado_por ?: '—' }}

@endif
@endif @if($showUnassignModal)

🔓 Desasignar Plegador

Telar: {{ $unassignLoomId }}

@php $unAs = \App\Models\LoomAssignment::where('loom_id', $unassignLoomId)->where('estado', 'ACTIVA')->first(); $unAvail = $unAs && $unAs->beam ? $unAs->beam->available_meters : 0; @endphp @if($unAs)

Plegador: {{ $unAs->plegador_id }}

Partida: {{ $unAs->partida_id }}

Metros disponibles: {{ number_format($unAvail, 0) }} m

@endif @if(!$showUnassignScrapForm)

¿Qué pasó con este plegador?

{{-- Option 1: Has yarn — return to WIP --}} {{-- Option 2: Finished naturally -- no scrap --}} {{-- Option 3: Scrap --}}
@else

⚠️ Los {{ number_format($unAvail, 0) }} m disponibles quedarán como merma de la partida {{ $unAs?->partida_id }}.

@error('unassignResponsable') {{ $message }} @enderror
@endif
@endif @if($showScrapWipModal)

🗑 Merma de Plegador (WIP)

Plegador: {{ $scrapWipBeamId }}

@php $wipPleg = \App\Models\Plegador::find($scrapWipBeamId); $wipMts = $wipPleg ? $wipPleg->available_meters : 0; @endphp

⚠️ Todos los metros de este plegador ({{ number_format($wipMts, 0) }} m) se registrarán como desperdicio.

@error('scrapWipResponsable') {{ $message }} @enderror
@endif @if($showCellModal)
@php $cellLoom = \App\Models\Loom::find($cellLoomId); $cellAsgn = \App\Models\LoomAssignment::where('loom_id', $cellLoomId)->where('estado', 'ACTIVA')->first(); $cellDay = \Carbon\Carbon::parse($cellDate); $cellIsToday = $cellDate === now()->toDateString(); $cellIsFuture = $cellDate > now()->toDateString(); $cellTurnos = \App\Models\TurnosReporte::where('loom_id', $cellLoomId) ->whereDate('fecha', $cellDate)->get()->keyBy('turno'); $cellCuts = \App\Models\Clave::where('loom_id', $cellLoomId) ->whereDate('fecha', $cellDate)->get(); $cellHasInc = \App\Models\LoomIncident::where('loom_id', $cellLoomId) ->where('estado', 'ABIERTO')->exists(); @endphp {{-- Header --}}
⚙️ {{ $cellLoomId }} @if($cellIsToday) HOY @elseif($cellIsFuture) FUTURO @endif @if($cellHasInc) @endif

{{ $cellDay->isoFormat('dddd D [de] MMMM [de] YYYY') }} @if($cellAsgn) · {{ $cellAsgn->articulo_id }} @endif

{{-- ── Production section ──────────────────────────────── --}}
📊 Producción (Metros)
@foreach(['M' => 'Mañana', 'T' => 'Tarde', 'N' => 'Nocturno'] as $tc => $tl) @php $ct = $cellTurnos[$tc] ?? null; $metros = $ct ? $ct->metros_turno : ''; @endphp
{{ $tc }} {{ $tl }}
✓ Guardado
@if($ct && $ct->operario) · {{ $ct->operario }} @endif
@endforeach
{{-- ── Tiempos de Paro section ─────────────────────────── --}}
⏱️ Tiempos de Paro / Lost Time
@php $cellParos = \App\Models\ParoLog::where('loom_id', $cellLoomId)->where('fecha', $cellDate)->get(); @endphp @if($cellParos->isNotEmpty())
@foreach($cellParos as $paro)
{{ $paro->motivo }} {{ number_format($paro->duracion_mins / 60, 2) }} hrs
@endforeach
@endif
@error('newParoHoras') {{ $message }} @enderror
{{-- ── Cuts section ────────────────────────────────────── --}}
✂️ Cortes
@if($cellCuts->isEmpty())

Sin cortes registrados en esta fecha para este telar.

@else
@foreach($cellCuts as $cc) @php $ccBg = match($cc->tipo_clave) { 'PRODUCTION' => 'bg-violet-50 border-violet-200', 'SAMPLE' => 'bg-amber-50 border-amber-200', 'SCRAP' => 'bg-red-50 border-red-200', default => 'bg-gray-50 border-gray-200', }; @endphp
{{ $cc->clave_id }} {{ number_format($cc->mts_telar, 1) }} m {{ $cc->tipo_clave }} @if($cc->turno)T{{ $cc->turno }}@endif @if($deleteCutId == $cc->clave_id)
¿Confirmar?
@else @endif
@endforeach
@endif
{{-- ── Machine state section ───────────────────────────── --}}
⚙️ Estado Telar
@if($cellHasInc) @else @endif
@if($cellLoom)
{{ $cellLoom->running_state ?? $cellLoom->estado }} @if($cellAsgn) Plegador: {{ $cellAsgn->plegador_id }} · {{ number_format($cellAsgn->beam?->available_meters ?? 0, 0) }} m disponibles @endif
@endif
{{-- Footer --}}
@endif {{-- ══════════════ REGISTRO DE CORTES ══════════════════════════════════ --}}

✂️ Registro de Cortes

Use los botones ✂️ Corte en el plan de arriba para registrar un nuevo corte

{{-- Last registered clave banner --}} @if ($lastClaveRegistered)
✅
Clave {{ $lastClaveRegistered->clave_id }} registrada
Telar {{ $lastClaveRegistered->loom_id }} · {{ number_format($lastClaveRegistered->mts_telar, 1) }} m · {{ $lastClaveRegistered->tipo_clave }} · Turno {{ $lastClaveRegistered->turno }} · {{ $lastClaveRegistered->fecha?->format('d/m/Y') }} @if($lastClaveRegistered->operario) · {{ $lastClaveRegistered->operario }} @endif
@if ($lastClaveRegistered->tipo_clave !== 'SCRAP') @endif
@endif
{{-- Cortes del día --}}
Cortes del día
{{ $todayCuts->count() }} · {{ number_format($todayMetersTotal, 0) }} m
@forelse ($todayCuts as $c) @php $tb = ['PRODUCTION'=>'bg-blue-100 text-blue-800','SAMPLE'=>'bg-amber-100 text-amber-800','TEST'=>'bg-amber-100 text-amber-800','SCRAP'=>'bg-red-100 text-red-800'][$c->tipo_clave] ?? 'bg-gray-100 text-gray-600'; @endphp @empty @endforelse @if($todayCuts->isNotEmpty()) @endif
Clave Telar Artículo #R Metros Tipo T Operario
{{ $c->clave_id }} {{ $c->loom_id }} {{ $c->articulo_id }} #{{ $c->roll_sequence }} {{ number_format($c->mts_telar, 1) }} {{ $c->tipo_clave }} {{ $c->turno }} {{ $c->operario ?: '—' }}
Sin cortes este día
Total {{ number_format($todayMetersTotal, 0) }} m
{{-- Historial --}}
Historial de Claves
@if($filterHistDateRange === 'custom')
@endif
@if($filterHistDateRange !== 'hoy' || $filterHistClave || $filterHistLoom || $filterHistArt || $filterHistQuality || $filterHistCustomFecha) @endif
@forelse ($historicalCuts as $c) @php $tb = ['PRODUCTION'=>'bg-blue-100 text-blue-800','SAMPLE'=>'bg-amber-100 text-amber-800','TEST'=>'bg-amber-100 text-amber-800','SCRAP'=>'bg-red-100 text-red-800'][$c->tipo_clave] ?? 'bg-gray-100 text-gray-600'; $kg = $c->article && $c->article->rendimiento_mts_kg > 0 ? $c->mts_telar / $c->article->rendimiento_mts_kg : 0; $div = $c->division; $calidad = $div ? $div->calidad_final : null; $insp = $div ? $div->activeInspection() : null; $calidadBadge = match($calidad) { 'A' => 'bg-green-100 text-green-800', 'B' => 'bg-yellow-100 text-yellow-800', 'RECHAZADO' => 'bg-red-100 text-red-800', default => 'bg-gray-100 text-gray-600' }; @endphp @empty @endforelse
Clave / T / Tipo Telar / Art. Color Cantidades Calidad Acciones
{{ $c->clave_id }}
Turno: {{ $c->turno }} | {{ $c->tipo_clave }}
{{ $c->loom_id }}
{{ $c->articulo_id }}
{{ $c->fecha?->format('d/m/Y') }}
@if($c->color_requested) {{ $c->color_requested }} @else Sin asignar @endif
{{ number_format($c->mts_telar, 1) }} m
@if($kg > 0)
{{ number_format($kg, 1) }} kg
@endif
@if($div)
{{ $calidad ?? 'PEND' }} @if($insp) {{ $insp->puntos_totales }} pts @endif
@else - @endif
@if($div) 🔍 Insp. @if(!$div->ingresoGreige) @else En WH @endif @endif
Sin resultados