netgescon-day0/resources/views/filament/pages/fornitore/pratiche-tecnorepair.blade.php

639 lines
45 KiB
PHP

<x-filament-panels::page>
<div class="space-y-5">
{{-- TOP TOOLBAR: FORNITORE CONTEXT & QUICK SYNC BUTTONS --}}
<div class="p-4 rounded-xl border border-slate-200 bg-white/90 shadow-sm backdrop-blur flex flex-wrap items-center justify-between gap-4">
<div class="flex items-center gap-3">
<div class="w-10 h-10 rounded-lg bg-sky-700 text-white flex items-center justify-center font-black text-lg shadow-sm">
TR
</div>
<div>
<h2 class="text-base font-bold text-slate-900 leading-tight">TecnoRepair Pro 4.5 Gestione Pratiche Riparazione</h2>
<p class="text-xs text-slate-500">
Fornitore operativo: <span class="font-semibold text-slate-800">{{ $this->fornitoreLabel ?? 'Nethome' }}</span>
</p>
</div>
</div>
<div class="flex flex-wrap items-center gap-2">
@if(count($this->fornitoriOptions) > 1)
<div class="flex items-center gap-2">
<label for="fornitoreSelect" class="text-xs font-semibold text-slate-600">Cambia fornitore:</label>
<select
id="fornitoreSelect"
wire:model.live="fornitoreId"
class="text-xs py-1.5 px-2.5 rounded-lg border border-slate-300 bg-white font-medium text-slate-700 shadow-xs focus:ring-2 focus:ring-sky-500"
>
@foreach($this->fornitoriOptions as $fid => $flabel)
<option value="{{ $fid }}">{{ $flabel }}</option>
@endforeach
</select>
</div>
@endif
<button
type="button"
wire:click="sincronizzaMdb"
wire:loading.attr="disabled"
class="px-3 py-1.5 rounded-lg bg-indigo-700 hover:bg-indigo-600 text-white font-bold text-xs shadow-xs transition flex items-center gap-1.5"
>
<span wire:loading.remove wire:target="sincronizzaMdb"> Sincronizza MDB TecnoRepair</span>
<span wire:loading wire:target="sincronizzaMdb"> Lettura MDB in corso...</span>
</button>
<button
type="button"
wire:click="sincronizzaContabilita"
wire:loading.attr="disabled"
class="px-3 py-1.5 rounded-lg bg-emerald-700 hover:bg-emerald-600 text-white font-bold text-xs shadow-xs transition flex items-center gap-1.5"
>
<span wire:loading.remove wire:target="sincronizzaContabilita">🔄 Aggiorna da Contabilità</span>
<span wire:loading wire:target="sincronizzaContabilita"> Aggiornamento...</span>
</button>
<a
href="/admin-filament/fornitore/seriali?fornitore={{ $this->fornitoreId }}"
class="px-3 py-1.5 rounded-lg bg-slate-100 hover:bg-slate-200 text-slate-800 border border-slate-300 font-bold text-xs shadow-xs transition"
>
🔍 Ricerca Seriali
</a>
<a
href="/admin-filament/fornitore/prodotti?fornitore={{ $this->fornitoreId }}"
class="px-3 py-1.5 rounded-lg bg-slate-100 hover:bg-slate-200 text-slate-800 border border-slate-300 font-bold text-xs shadow-xs transition"
>
📦 Catalogo & Ricambi
</a>
</div>
</div>
{{-- SUMMARY KPI CARDS --}}
<div class="grid grid-cols-2 sm:grid-cols-5 gap-3">
<div class="p-3.5 rounded-xl border border-slate-200 bg-white shadow-xs">
<div class="text-xs font-semibold text-slate-500 uppercase tracking-wider">Totale Schede</div>
<div class="mt-1 text-2xl font-black text-slate-900">{{ number_format($this->totals['totale'] ?? 0, 0, ',', '.') }}</div>
</div>
<div class="p-3.5 rounded-xl border border-sky-200 bg-sky-50 shadow-xs">
<div class="text-xs font-semibold text-sky-700 uppercase tracking-wider">In Lavorazione</div>
<div class="mt-1 text-2xl font-black text-sky-900">{{ number_format($this->totals['aperte'] ?? 0, 0, ',', '.') }}</div>
</div>
<div class="p-3.5 rounded-xl border border-emerald-200 bg-emerald-50 shadow-xs">
<div class="text-xs font-semibold text-emerald-700 uppercase tracking-wider">Riparate</div>
<div class="mt-1 text-2xl font-black text-emerald-900">{{ number_format($this->totals['riparate'] ?? 0, 0, ',', '.') }}</div>
</div>
<div class="p-3.5 rounded-xl border border-rose-200 bg-rose-50 shadow-xs">
<div class="text-xs font-semibold text-rose-700 uppercase tracking-wider">Rottamate / Ricambi</div>
<div class="mt-1 text-2xl font-black text-rose-900">{{ number_format($this->totals['rottamate'] ?? 0, 0, ',', '.') }}</div>
</div>
<div class="p-3.5 rounded-xl border border-amber-200 bg-amber-50 shadow-xs">
<div class="text-xs font-semibold text-amber-700 uppercase tracking-wider">Reso Fornitore / RMA</div>
<div class="mt-1 text-2xl font-black text-amber-900">{{ number_format($this->totals['rma_garanzia'] ?? 0, 0, ',', '.') }}</div>
</div>
</div>
{{-- FILTRI PER RICERCA SCHEDE (FEDELE AL DESKTOP TECNOREPAIR) --}}
<div class="p-4 rounded-xl border border-slate-200 bg-white shadow-xs space-y-3">
<div class="flex items-center justify-between border-b border-slate-100 pb-2">
<div class="text-xs font-bold uppercase tracking-wider text-slate-700 flex items-center gap-2">
<span>🎛️ FILTRI per Ricerca Schede</span>
<span class="text-[10px] px-2 py-0.5 rounded-full bg-slate-100 text-slate-600 font-normal">Standard TecnoRepair</span>
</div>
<button
type="button"
wire:click="resetFiltri"
class="text-xs text-sky-700 hover:text-sky-900 font-bold underline"
>
Reset Tutti i Filtri
</button>
</div>
<div class="grid grid-cols-1 md:grid-cols-4 gap-3">
<div>
<label class="block text-[11px] font-semibold text-slate-600 mb-1">Data Ingresso (Dal / Al)</label>
<div class="flex items-center gap-1">
<input
type="date"
wire:model.lazy="dataIngressoDal"
class="w-full text-xs py-1.5 px-2 rounded-lg border border-slate-300 text-slate-800 focus:ring-1 focus:ring-sky-500"
/>
<span class="text-slate-400 text-xs">-</span>
<input
type="date"
wire:model.lazy="dataIngressoAl"
class="w-full text-xs py-1.5 px-2 rounded-lg border border-slate-300 text-slate-800 focus:ring-1 focus:ring-sky-500"
/>
</div>
</div>
<div>
<label class="block text-[11px] font-semibold text-slate-600 mb-1">Matricola / IMEI / Seriale</label>
<input
type="text"
wire:model.live.debounce.400ms="searchMatricola"
placeholder="Es. 8CG9454YMN, PF508R8..."
class="w-full text-xs py-1.5 px-2.5 rounded-lg border border-slate-300 text-slate-800 focus:ring-1 focus:ring-sky-500"
/>
</div>
<div>
<label class="block text-[11px] font-semibold text-slate-600 mb-1">Num. Scheda</label>
<input
type="text"
wire:model.live.debounce.400ms="searchNumScheda"
placeholder="Es. 1839, 1843..."
class="w-full text-xs py-1.5 px-2.5 rounded-lg border border-slate-300 text-slate-800 focus:ring-1 focus:ring-sky-500"
/>
</div>
<div>
<label class="block text-[11px] font-semibold text-slate-600 mb-1">Stato Riparazione</label>
<select
wire:model.live="filterStato"
class="w-full text-xs py-1.5 px-2.5 rounded-lg border border-slate-300 text-slate-800 focus:ring-1 focus:ring-sky-500 font-medium"
>
<option value="0">0 - TUTTI - TUTTI</option>
<option value="4">4 - RIPARATO</option>
<option value="21">21 - INGRESSO ACCETTAZIONE</option>
<option value="2">2 - DISPOSITIVO IN RIPARAZIONE</option>
<option value="5">5 - ATTESA RICAMBIO</option>
<option value="6">6 - INVIATO NUOVO PREVENTIVO</option>
<option value="10">10 - DISPOSITIVO IRRIPARABILE</option>
<option value="23">23 - PC DA UTILIZZARE COME RICAMBI</option>
<option value="33">33 - MANDATO IN GARANZIA / RMA</option>
<option value="31">31 - ACQUISTO RICONDIZIONATO</option>
<option value="37">37 - SMALTITO PER ABBANDONO</option>
</select>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-3 pt-1 border-t border-slate-100">
<div>
<label class="block text-[11px] font-semibold text-slate-600 mb-1">Cliente / Committente</label>
<input
type="text"
wire:model.live.debounce.400ms="searchCliente"
placeholder="Cerca nominativo cliente..."
class="w-full text-xs py-1.5 px-2.5 rounded-lg border border-slate-300 text-slate-800 focus:ring-1 focus:ring-sky-500"
/>
</div>
<div class="flex items-center gap-4 pt-4">
<label class="inline-flex items-center gap-1.5 text-xs text-slate-700 cursor-pointer">
<input
type="checkbox"
wire:model.live="escludiRiconsegnati"
class="rounded border-slate-300 text-sky-600 focus:ring-sky-500"
/>
<span>Escludi Apparecchi Riconsegnati</span>
</label>
<label class="inline-flex items-center gap-1.5 text-xs text-slate-700 cursor-pointer">
<input
type="checkbox"
wire:model.live="soloRiconsegnati"
class="rounded border-slate-300 text-sky-600 focus:ring-sky-500"
/>
<span>Solo Riconsegnati</span>
</label>
</div>
<div class="flex items-center justify-end gap-2 pt-3">
<button
type="button"
wire:click="refreshData"
class="px-4 py-1.5 rounded-lg bg-sky-700 hover:bg-sky-600 text-white font-bold text-xs shadow-xs transition"
>
🔍 Applica Filtri
</button>
</div>
</div>
</div>
{{-- GRIGLIA ELENCO SCHEDE (COLORAZIONE FEDELE A TECNOREPAIR) --}}
<div class="rounded-xl border border-slate-200 bg-white shadow-xs overflow-hidden">
<div class="p-3 bg-slate-50 border-b border-slate-200 flex items-center justify-between text-xs font-bold text-slate-700">
<div>
Schede Elencate: <span class="text-sky-700">{{ count($this->rows) }}</span>
<span class="text-slate-400 font-normal">(visualizzate prime 120 per reattività)</span>
</div>
<div class="flex items-center gap-3 text-[11px] font-normal">
<span class="flex items-center gap-1"><span class="w-3 h-3 rounded bg-emerald-500 inline-block"></span> Riparato</span>
<span class="flex items-center gap-1"><span class="w-3 h-3 rounded bg-rose-500 inline-block"></span> Irreparabile / Rottamato</span>
<span class="flex items-center gap-1"><span class="w-3 h-3 rounded bg-sky-500 inline-block"></span> Accettazione</span>
<span class="flex items-center gap-1"><span class="w-3 h-3 rounded bg-amber-500 inline-block"></span> Attesa / Laboratorio</span>
</div>
</div>
<div class="overflow-x-auto max-h-[580px]">
<table class="w-full text-left text-xs border-collapse font-sans">
<thead class="sticky top-0 bg-slate-100 text-slate-700 font-bold border-b border-slate-200 text-[11px] uppercase tracking-wider z-10">
<tr>
<th class="py-2.5 px-2 border-r border-slate-200 w-14 text-center">Num</th>
<th class="py-2.5 px-2 border-r border-slate-200 w-24">Ingresso</th>
<th class="py-2.5 px-2 border-r border-slate-200 w-44">Cliente</th>
<th class="py-2.5 px-2 border-r border-slate-200 w-28">Telefono</th>
<th class="py-2.5 px-2 border-r border-slate-200 min-w-[200px]">Difetto Segnalato</th>
<th class="py-2.5 px-2 border-r border-slate-200 w-20">Marca</th>
<th class="py-2.5 px-2 border-r border-slate-200 w-32">Modello</th>
<th class="py-2.5 px-2 border-r border-slate-200 w-36">Seriale / IMEI</th>
<th class="py-2.5 px-2 border-r border-slate-200 w-28">Cod. Prod</th>
<th class="py-2.5 px-2 border-r border-slate-200 w-16 text-center">Ricons.</th>
<th class="py-2.5 px-2 border-r border-slate-200 w-40">Stato Riparazione</th>
<th class="py-2.5 px-2 border-r border-slate-200 w-28">Operatore</th>
<th class="py-2.5 px-2 text-center w-24">Azione</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100">
@forelse($this->rows as $r)
@php
$rowBg = match($r['row_color']) {
'green' => 'bg-emerald-50/80 hover:bg-emerald-100/90 text-emerald-950 font-medium',
'red' => 'bg-rose-50/80 hover:bg-rose-100/90 text-rose-950 font-medium',
'blue' => 'bg-sky-50/80 hover:bg-sky-100/90 text-sky-950',
'amber' => 'bg-amber-50/80 hover:bg-amber-100/90 text-amber-950',
default => 'bg-white hover:bg-slate-50 text-slate-800',
};
$borderLeft = match($r['row_color']) {
'green' => 'border-l-4 border-l-emerald-600',
'red' => 'border-l-4 border-l-rose-600',
'blue' => 'border-l-4 border-l-sky-600',
'amber' => 'border-l-4 border-l-amber-600',
default => 'border-l-4 border-l-transparent',
};
@endphp
<tr
class="{{ $rowBg }} {{ $borderLeft }} transition cursor-pointer"
wire:click="openScheda({{ $r['id'] }})"
>
<td class="py-2 px-2 border-r border-slate-200/60 font-black text-center text-slate-900">{{ $r['numero_scheda'] }}</td>
<td class="py-2 px-2 border-r border-slate-200/60">{{ $r['ingresso'] }}</td>
<td class="py-2 px-2 border-r border-slate-200/60 font-bold truncate max-w-[176px]" title="{{ $r['cliente'] }}">{{ $r['cliente'] }}</td>
<td class="py-2 px-2 border-r border-slate-200/60 font-mono text-[11px]">{{ $r['telefono'] }}</td>
<td class="py-2 px-2 border-r border-slate-200/60 truncate max-w-[260px]" title="{{ $r['difetto'] }}">{{ $r['difetto'] }}</td>
<td class="py-2 px-2 border-r border-slate-200/60 font-semibold uppercase">{{ $r['marca'] }}</td>
<td class="py-2 px-2 border-r border-slate-200/60 truncate max-w-[128px]" title="{{ $r['modello'] }}">{{ $r['modello'] }}</td>
<td class="py-2 px-2 border-r border-slate-200/60 font-mono text-[11px] font-bold text-sky-800">{{ $r['seriale'] }}</td>
<td class="py-2 px-2 border-r border-slate-200/60 font-mono text-[11px] text-slate-600">{{ $r['cod_prodotto'] }}</td>
<td class="py-2 px-2 border-r border-slate-200/60 text-center">
@if($r['riconsegnato'])
<span class="inline-block px-1.5 py-0.5 rounded bg-emerald-600 text-white font-bold text-[10px]">SI</span>
@else
<span class="text-slate-400 font-normal">-</span>
@endif
</td>
<td class="py-2 px-2 border-r border-slate-200/60 font-bold text-[11px]">
{{ $r['stato_rip'] }}
</td>
<td class="py-2 px-2 border-r border-slate-200/60 text-[11px] truncate max-w-[112px]">{{ $r['operatore'] }}</td>
<td class="py-2 px-2 text-center" onclick="event.stopPropagation()">
<button
type="button"
wire:click="openScheda({{ $r['id'] }})"
class="px-2 py-1 rounded bg-sky-700 hover:bg-sky-600 text-white font-bold text-[11px] shadow-xs"
>
Apri
</button>
</td>
</tr>
@empty
<tr>
<td colspan="13" class="py-8 text-center text-slate-500 bg-white">
Nessuna scheda trovata con i filtri correnti. Prova a cliccare "Reset Tutti i Filtri" o "Sincronizza MDB".
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
{{-- SCHEDA APPARECCHIO MODAL / DETTAGLIO INTERATTIVO (7 TABS TECNOREPAIR) --}}
@if($this->selectedSchedaId && $this->activeScheda)
<div class="fixed inset-0 z-50 overflow-y-auto bg-slate-900/60 backdrop-blur-xs flex items-center justify-center p-4">
<div class="relative w-full max-w-6xl rounded-2xl bg-white shadow-2xl border border-slate-300 overflow-hidden flex flex-col max-h-[92vh]">
{{-- MODAL HEADER --}}
<div class="p-4 bg-gradient-to-r from-slate-900 via-sky-950 to-slate-900 text-white flex items-center justify-between border-b border-sky-800">
<div class="flex items-center gap-3">
<span class="px-2.5 py-1 rounded-md bg-sky-500 text-slate-950 font-black text-sm">
SCHEDA #{{ $this->activeScheda['numero_scheda'] }}
</span>
<div>
<h3 class="text-base font-bold text-white">
{{ $this->activeScheda['marca'] }} {{ $this->activeScheda['modello'] }}
<span class="text-sky-300 font-mono text-xs">({{ $this->activeScheda['seriale'] }})</span>
</h3>
<p class="text-xs text-sky-200">
Cliente: <span class="font-bold text-white">{{ $this->activeScheda['cliente_nome'] }}</span> Ingresso: {{ $this->activeScheda['data_ingresso'] }}
</p>
</div>
</div>
<div class="flex items-center gap-2">
<span class="px-3 py-1 rounded-full text-xs font-bold border border-white/20 bg-white/10 text-white">
{{ $this->activeScheda['stato_rip'] }}
</span>
<button
type="button"
wire:click="closeScheda"
class="w-8 h-8 rounded-lg bg-white/10 hover:bg-white/20 text-white flex items-center justify-center font-bold text-sm transition"
>
</button>
</div>
</div>
{{-- TAB BAR --}}
<div class="bg-slate-100 border-b border-slate-200 px-4 pt-2 flex flex-wrap gap-1 text-xs font-bold">
@php
$tabsMap = [
'entrata' => '1. Apparecchio in Entrata',
'riparazione' => '2. Riparazione & Flussi ⚡',
'ricambi' => '3. Ricambi Utilizzati',
'preventivo' => '4. Preventivo - Costi - DDT',
'annotazioni' => '5. Annotazioni & Cortesia',
'comunicazioni' => '6. Comunicazioni',
'cq' => '7. Controllo Qualità (C.Q.)',
];
@endphp
@foreach($tabsMap as $tKey => $tLabel)
<button
type="button"
wire:click="setSchedaTab('{{ $tKey }}')"
class="px-3 py-2 rounded-t-lg transition border-t border-x {{ $this->schedaTab === $tKey ? 'bg-white text-sky-800 border-slate-300 -mb-px font-black shadow-xs' : 'bg-slate-200/70 hover:bg-slate-200 text-slate-600 border-transparent' }}"
>
{{ $tLabel }}
</button>
@endforeach
</div>
{{-- TAB CONTENTS --}}
<div class="p-5 overflow-y-auto flex-1 space-y-4">
{{-- TAB 1: APPARECCHIO IN ENTRATA --}}
@if($this->schedaTab === 'entrata')
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div class="p-4 rounded-xl border border-slate-200 bg-slate-50 space-y-2">
<div class="text-xs font-bold text-slate-700 uppercase tracking-wider border-b border-slate-200 pb-1">👤 Dati Cliente</div>
<div class="text-sm font-bold text-slate-900">{{ $this->activeScheda['cliente_nome'] }}</div>
<div class="text-xs text-slate-600"><strong>Tel:</strong> {{ $this->activeScheda['cliente_telefono'] }}</div>
<div class="text-xs text-slate-600"><strong>Email:</strong> {{ $this->activeScheda['cliente_email'] }}</div>
<div class="text-xs text-slate-600"><strong>Indirizzo:</strong> {{ $this->activeScheda['cliente_indirizzo'] }}, {{ $this->activeScheda['cliente_citta'] }}</div>
</div>
<div class="p-4 rounded-xl border border-slate-200 bg-slate-50 space-y-2">
<div class="text-xs font-bold text-slate-700 uppercase tracking-wider border-b border-slate-200 pb-1">💻 Dati Apparecchio</div>
<div class="text-xs text-slate-600"><strong>Tipo:</strong> {{ $this->activeScheda['tipo_apparecchio'] }}</div>
<div class="text-xs text-slate-600"><strong>Marca:</strong> {{ $this->activeScheda['marca'] }}</div>
<div class="text-xs text-slate-600"><strong>Modello:</strong> {{ $this->activeScheda['modello'] }}</div>
<div class="text-xs text-slate-600"><strong>Codice Prodotto:</strong> {{ $this->activeScheda['codice_prodotto'] }}</div>
<div class="text-xs text-sky-800 font-mono font-bold"><strong>Seriale 1:</strong> {{ $this->activeScheda['seriale'] }}</div>
@if($this->activeScheda['seriale_2'] !== '-')
<div class="text-xs text-slate-600 font-mono"><strong>Seriale 2:</strong> {{ $this->activeScheda['seriale_2'] }}</div>
@endif
</div>
<div class="p-4 rounded-xl border border-slate-200 bg-slate-50 space-y-2">
<div class="text-xs font-bold text-slate-700 uppercase tracking-wider border-b border-slate-200 pb-1">🔐 Sicurezza & Accesso</div>
<div class="text-xs text-slate-600"><strong>Codice PIN:</strong> <span class="font-mono font-bold text-slate-900">{{ $this->activeScheda['codice_pin'] }}</span></div>
<div class="text-xs text-slate-600"><strong>Codice Sblocco:</strong> <span class="font-mono font-bold text-slate-900">{{ $this->activeScheda['codice_sblocco'] }}</span></div>
<div class="text-xs text-slate-600"><strong>Tecnico Assegnato:</strong> {{ $this->activeScheda['tecnico'] }}</div>
<div class="text-xs text-slate-600"><strong>Accessori Consegnati:</strong> {{ $this->activeScheda['accessori'] }}</div>
</div>
</div>
<div class="p-4 rounded-xl border border-amber-200 bg-amber-50 space-y-1.5">
<div class="text-xs font-bold text-amber-900 uppercase tracking-wider">⚠️ Difetto Segnalato dal Cliente</div>
<p class="text-sm font-medium text-amber-950 whitespace-pre-line">{{ $this->activeScheda['difetto'] }}</p>
</div>
<div class="p-4 rounded-xl border border-slate-200 bg-white space-y-1.5">
<div class="text-xs font-bold text-slate-700 uppercase tracking-wider">🔍 Stato Generale Apparecchio</div>
<p class="text-xs text-slate-800 whitespace-pre-line">{{ $this->activeScheda['stato_generale'] }}</p>
</div>
@endif
{{-- TAB 2: RIPARAZIONE & FLUSSI AUTOMATIZZATI --}}
@if($this->schedaTab === 'riparazione')
<div class="space-y-4">
<div class="p-4 rounded-xl border border-indigo-200 bg-indigo-50/60 space-y-3">
<div class="text-xs font-black text-indigo-900 uppercase tracking-wider flex items-center gap-1.5">
<span> FLUSSI AUTOMATIZZATI DI CHIUSURA PRATICA</span>
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-3">
{{-- 1. FLUSSO RIPARATO --}}
<div class="p-3.5 rounded-xl border border-emerald-300 bg-white shadow-xs space-y-2.5">
<div class="flex items-center gap-2">
<span class="w-6 h-6 rounded-full bg-emerald-100 text-emerald-700 flex items-center justify-center font-bold text-xs">1</span>
<h4 class="font-bold text-xs text-emerald-900">Apparato Riparato</h4>
</div>
<p class="text-[11px] text-slate-600">
Imposta stato a <strong>RIPARATO (4)</strong>, data chiusura a oggi e prepara per riconsegna cliente.
</p>
<input
type="text"
wire:model="workflowNote"
placeholder="Nota chiusura o test..."
class="w-full text-xs py-1 px-2 rounded border border-slate-300 text-slate-800"
/>
<button
type="button"
wire:click="eseguiChiusuraRiparato"
class="w-full py-2 px-3 rounded-lg bg-emerald-600 hover:bg-emerald-500 text-white font-bold text-xs shadow-xs transition"
>
Segna come Riparato
</button>
</div>
{{-- 2. FLUSSO ROTTAMAZIONE / RICAMBI --}}
<div class="p-3.5 rounded-xl border border-rose-300 bg-white shadow-xs space-y-2.5">
<div class="flex items-center gap-2">
<span class="w-6 h-6 rounded-full bg-rose-100 text-rose-700 flex items-center justify-center font-bold text-xs">2</span>
<h4 class="font-bold text-xs text-rose-900">Rottamazione / Ricambi</h4>
</div>
<p class="text-[11px] text-slate-600">
Imposta stato a <strong>IRRIPARABILE</strong> o destina a pezzi di ricambio interni.
</p>
<input
type="text"
wire:model="workflowMotivoRottamazione"
placeholder="Motivo rottamazione..."
class="w-full text-xs py-1 px-2 rounded border border-slate-300 text-slate-800"
/>
<label class="inline-flex items-center gap-1.5 text-[11px] text-slate-700 cursor-pointer">
<input type="checkbox" wire:model="workflowComeRicambi" class="rounded border-slate-300 text-rose-600" />
<span>Destina a recupero ricambi (PZ-RICAM)</span>
</label>
<button
type="button"
wire:click="eseguiChiusuraRottamazione"
class="w-full py-2 px-3 rounded-lg bg-rose-600 hover:bg-rose-500 text-white font-bold text-xs shadow-xs transition"
>
♻️ Esegui Rottamazione
</button>
</div>
{{-- 3. FLUSSO RESO FORNITORE (RMA) --}}
<div class="p-3.5 rounded-xl border border-amber-300 bg-white shadow-xs space-y-2.5">
<div class="flex items-center gap-2">
<span class="w-6 h-6 rounded-full bg-amber-100 text-amber-700 flex items-center justify-center font-bold text-xs">3</span>
<h4 class="font-bold text-xs text-amber-900">Reso Fornitore (RMA)</h4>
</div>
<p class="text-[11px] text-slate-600">
Invia apparato in garanzia/RMA a fornitore (es. NCOM SRL) con tracking del seriale.
</p>
<input
type="text"
wire:model="workflowRmaCode"
placeholder="Codice RMA..."
class="w-full text-xs py-1 px-2 rounded border border-slate-300 text-slate-800 font-mono"
/>
<button
type="button"
wire:click="eseguiResoFornitoreRma"
class="w-full py-2 px-3 rounded-lg bg-amber-600 hover:bg-amber-500 text-white font-bold text-xs shadow-xs transition"
>
📦 Esegui Reso Fornitore RMA
</button>
</div>
</div>
</div>
<div class="p-4 rounded-xl border border-slate-200 bg-white space-y-2">
<div class="text-xs font-bold text-slate-700 uppercase tracking-wider">🛠️ Descrizione Lavorazione Effettuata</div>
<p class="text-xs text-slate-800 whitespace-pre-line leading-relaxed">{{ $this->activeScheda['descrizione_lavorazione'] }}</p>
</div>
</div>
@endif
{{-- TAB 3: RICAMBI UTILIZZATI --}}
@if($this->schedaTab === 'ricambi')
<div class="space-y-3">
<div class="text-xs font-bold text-slate-700 uppercase tracking-wider">📦 Componenti & Ricambi Collegati alla Scheda</div>
@if(!empty($this->activeScheda['ricambi']))
<div class="rounded-lg border border-slate-200 overflow-hidden">
<table class="w-full text-left text-xs">
<thead class="bg-slate-100 font-bold text-slate-700 border-b border-slate-200">
<tr>
<th class="py-2 px-3">Codice Ricambio</th>
<th class="py-2 px-3">Descrizione</th>
<th class="py-2 px-3 text-center">ID Riferimento</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100">
@foreach($this->activeScheda['ricambi'] as $item)
<tr>
<td class="py-2 px-3 font-mono font-bold text-sky-800">{{ $item['CodiceRicambio'] ?? '-' }}</td>
<td class="py-2 px-3">{{ $item['Descrizione'] ?? 'Ricambio collegato' }}</td>
<td class="py-2 px-3 text-center font-mono text-slate-500">{{ $item['ID'] ?? '-' }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@else
<div class="p-6 text-center text-slate-500 bg-slate-50 rounded-xl border border-dashed border-slate-200">
Nessun ricambio specifico registrato per questa pratica. Puoi cercarli nel <a href="/admin-filament/fornitore/prodotti" class="text-sky-700 font-bold underline">Catalogo Ricambi</a>.
</div>
@endif
</div>
@endif
{{-- TAB 4: PREVENTIVO - COSTI - DDT --}}
@if($this->schedaTab === 'preventivo')
<div class="grid grid-cols-1 md:grid-cols-4 gap-4">
<div class="p-3.5 rounded-xl border border-slate-200 bg-slate-50">
<div class="text-xs font-semibold text-slate-500">Costo Subito / Sostenuto</div>
<div class="mt-1 text-xl font-bold text-slate-900">{{ number_format($this->activeScheda['costo_subito'], 2, ',', '.') }} </div>
</div>
<div class="p-3.5 rounded-xl border border-slate-200 bg-slate-50">
<div class="text-xs font-semibold text-slate-500">Costo Addebitato Cliente</div>
<div class="mt-1 text-xl font-bold text-slate-900">{{ number_format($this->activeScheda['costo_addebitato'], 2, ',', '.') }} </div>
</div>
<div class="p-3.5 rounded-xl border border-slate-200 bg-slate-50">
<div class="text-xs font-semibold text-slate-500">Acconto Ricevuto</div>
<div class="mt-1 text-xl font-bold text-emerald-700">{{ number_format($this->activeScheda['acconto'], 2, ',', '.') }} </div>
</div>
<div class="p-3.5 rounded-xl border border-slate-200 bg-slate-50">
<div class="text-xs font-semibold text-slate-500">Preventivo Iniziale</div>
<div class="mt-1 text-xl font-bold text-sky-800">{{ number_format($this->activeScheda['preventivo'], 2, ',', '.') }} </div>
</div>
</div>
@endif
{{-- TAB 5: ANNOTAZIONI & ALLEGATI --}}
@if($this->schedaTab === 'annotazioni')
<div class="space-y-4">
<div class="text-xs font-bold text-slate-700 uppercase tracking-wider">📎 File Allegati & Fotografie</div>
@if(!empty($this->activeScheda['allegati']))
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3">
@foreach($this->activeScheda['allegati'] as $all)
<div class="p-3 rounded-lg border border-slate-200 bg-slate-50 flex items-center justify-between gap-2">
<span class="text-xs font-medium text-slate-800 truncate" title="{{ $all['nome'] }}">{{ $all['nome'] }}</span>
<span class="text-[10px] px-2 py-0.5 rounded bg-slate-200 text-slate-700 font-mono">allegato</span>
</div>
@endforeach
</div>
@else
<p class="text-xs text-slate-500 italic">Nessun file o foto allegata a questa pratica.</p>
@endif
</div>
@endif
{{-- TAB 6: COMUNICAZIONI --}}
@if($this->schedaTab === 'comunicazioni')
<div class="p-4 rounded-xl border border-slate-200 bg-slate-50 space-y-2">
<div class="text-xs font-bold text-slate-700 uppercase tracking-wider">💬 Storico Comunicazioni con il Cliente</div>
<div class="p-3 bg-white rounded-lg border border-slate-200 font-mono text-xs text-slate-800 whitespace-pre-line leading-relaxed">
{{ $this->activeScheda['comunicazioni'] ?: 'Nessuna comunicazione registrata.' }}
</div>
</div>
@endif
{{-- TAB 7: C.Q. CONTROLLO QUALITA --}}
@if($this->schedaTab === 'cq')
<div class="p-4 rounded-xl border border-slate-200 bg-slate-50 space-y-3">
<div class="text-xs font-bold text-slate-700 uppercase tracking-wider"> Checklist Standard Controllo Qualità</div>
<div class="space-y-2 text-xs text-slate-800">
<label class="flex items-center gap-2 cursor-pointer">
<input type="checkbox" checked disabled class="rounded border-slate-300 text-emerald-600" />
<span>Controllo alimentazione, tensione e batteria</span>
</label>
<label class="flex items-center gap-2 cursor-pointer">
<input type="checkbox" checked disabled class="rounded border-slate-300 text-emerald-600" />
<span>Verifica webcam, microfono e uscite audio</span>
</label>
<label class="flex items-center gap-2 cursor-pointer">
<input type="checkbox" checked disabled class="rounded border-slate-300 text-emerald-600" />
<span>Credenziali e password di sistema collaudate</span>
</label>
<label class="flex items-center gap-2 cursor-pointer">
<input type="checkbox" checked disabled class="rounded border-slate-300 text-emerald-600" />
<span>Installazione software e pacchetto applicativo</span>
</label>
<label class="flex items-center gap-2 cursor-pointer">
<input type="checkbox" checked disabled class="rounded border-slate-300 text-emerald-600" />
<span>Connettività Wi-Fi / Ethernet e porte I/O</span>
</label>
</div>
</div>
@endif
</div>
{{-- MODAL FOOTER --}}
<div class="p-3 bg-slate-100 border-t border-slate-200 flex items-center justify-between">
<span class="text-xs text-slate-500">
Pratica gestita da: <strong class="text-slate-800">{{ $this->activeScheda['tecnico'] }}</strong>
</span>
<button
type="button"
wire:click="closeScheda"
class="px-4 py-1.5 rounded-lg bg-slate-800 hover:bg-slate-700 text-white font-bold text-xs transition"
>
Chiudi Scheda
</button>
</div>
</div>
</div>
@endif
</div>
</x-filament-panels::page>