1756 lines
142 KiB
PHP
Executable File
1756 lines
142 KiB
PHP
Executable File
<x-filament-panels::page>
|
||
<div class="w-full max-w-full space-y-4 px-2 lg:px-6">
|
||
{{-- BARRA NAVIGAZIONE UNIFICATA E COMPATTA --}}
|
||
<div class="mb-2 flex flex-wrap items-center justify-between gap-2 rounded-xl border border-slate-200 bg-white/80 p-2 shadow-xs backdrop-blur-xs">
|
||
<div class="flex flex-wrap items-center gap-1.5">
|
||
<a href="{{ \App\Filament\Pages\Gescon\StabiliArchivio::getUrl(panel: 'admin-filament') }}"
|
||
class="inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-slate-50 px-2.5 py-1.5 text-xs font-semibold text-slate-700 transition hover:bg-slate-100 hover:text-slate-900">
|
||
<span>🏢</span>
|
||
<span>Elenco Stabili</span>
|
||
</a>
|
||
<a href="{{ \App\Filament\Pages\Condomini\NominativiStabile::getUrl(panel: 'admin-filament') }}"
|
||
class="inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-slate-50 px-2.5 py-1.5 text-xs font-semibold text-slate-700 transition hover:bg-slate-100 hover:text-slate-900">
|
||
<span>👥</span>
|
||
<span>Elenco Nominativi</span>
|
||
</a>
|
||
<a href="{{ \App\Filament\Pages\UnitaImmobiliarePage::getUrl(panel: 'admin-filament') }}"
|
||
class="inline-flex items-center gap-1.5 rounded-lg border border-indigo-200 bg-indigo-50 px-2.5 py-1.5 text-xs font-semibold text-indigo-700 shadow-xs ring-2 ring-indigo-500/20">
|
||
<span>🏠</span>
|
||
<span>Unità Immobiliare</span>
|
||
</a>
|
||
<a href="{{ \App\Filament\Pages\Condomini\TabelleMillesimaliArchivio::getUrl(panel: 'admin-filament') }}"
|
||
class="inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-slate-50 px-2.5 py-1.5 text-xs font-semibold text-slate-700 transition hover:bg-slate-100 hover:text-slate-900">
|
||
<span>📐</span>
|
||
<span>Millesimi</span>
|
||
</a>
|
||
<a href="{{ \App\Filament\Pages\Condomini\CatastoHub::getUrl(panel: 'admin-filament') }}"
|
||
class="inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-slate-50 px-2.5 py-1.5 text-xs font-semibold text-slate-700 transition hover:bg-slate-100 hover:text-slate-900">
|
||
<span>🏛️</span>
|
||
<span>Catasto</span>
|
||
</a>
|
||
</div>
|
||
</div>
|
||
|
||
@php
|
||
$unitaOptions = $this->getUnitaOptions();
|
||
$prevUrl = $this->getPrevUnitaUrl();
|
||
$nextUrl = $this->getNextUnitaUrl();
|
||
$visibilityOptions = [
|
||
'attive' => 'Attive',
|
||
'tutte' => 'Tutte',
|
||
'archiviate' => 'Archiviate',
|
||
];
|
||
@endphp
|
||
|
||
{{-- CONTROLLI COMPATTI SELEZIONE UNITÀ & PULSANTI RUOLO CONDOMINO / INQUILINO --}}
|
||
<div class="mb-3 flex flex-wrap items-center justify-between gap-3 rounded-xl border border-slate-200 bg-white p-2.5 shadow-xs">
|
||
<div class="flex flex-wrap items-center gap-2.5">
|
||
<a href="{{ $this->getBackUrl() }}" class="inline-flex items-center gap-1 rounded-lg border border-slate-200 bg-slate-50 px-2.5 py-1 text-xs font-semibold text-slate-600 transition hover:bg-slate-100 hover:text-slate-900">
|
||
<span>←</span>
|
||
<span>Torna indietro</span>
|
||
</a>
|
||
<span class="text-slate-300">|</span>
|
||
|
||
<div class="flex items-center gap-1.5">
|
||
@if($prevUrl)
|
||
<a class="inline-flex items-center justify-center rounded-lg border border-slate-200 bg-slate-50 px-2.5 py-1 text-xs font-semibold text-slate-700 transition hover:bg-slate-100" href="{{ $prevUrl }}">← Prec.</a>
|
||
@else
|
||
<span class="inline-flex items-center justify-center rounded-lg border border-slate-200 bg-slate-50 px-2.5 py-1 text-xs font-semibold text-slate-400 opacity-50">← Prec.</span>
|
||
@endif
|
||
|
||
<div class="min-w-64 max-w-xl">
|
||
{{ $this->getSchema('unitaPicker') }}
|
||
</div>
|
||
|
||
@if($nextUrl)
|
||
<a class="inline-flex items-center justify-center rounded-lg border border-slate-200 bg-slate-50 px-2.5 py-1 text-xs font-semibold text-slate-700 transition hover:bg-slate-100" href="{{ $nextUrl }}">Succ. →</a>
|
||
@else
|
||
<span class="inline-flex items-center justify-center rounded-lg border border-slate-200 bg-slate-50 px-2.5 py-1 text-xs font-semibold text-slate-400 opacity-50">Succ. →</span>
|
||
@endif
|
||
</div>
|
||
|
||
{{-- SELETTORE ESPLICITO RUOLO CONDOMINO / INQUILINO --}}
|
||
<div class="flex items-center gap-1 rounded-lg border border-slate-200 bg-slate-100 p-1">
|
||
<button type="button" wire:click="setCondInquilActive('C')"
|
||
class="inline-flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-bold transition {{ ($condInquilActive ?? 'C') === 'C' ? 'bg-amber-600 text-white shadow-xs' : 'text-slate-600 hover:text-slate-900' }}">
|
||
<span>🏢</span>
|
||
<span>Condomino (Proprietari)</span>
|
||
</button>
|
||
<button type="button" wire:click="setCondInquilActive('I')"
|
||
class="inline-flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-bold transition {{ ($condInquilActive ?? 'C') === 'I' ? 'bg-indigo-600 text-white shadow-xs' : 'text-slate-600 hover:text-slate-900' }}">
|
||
<span>👤</span>
|
||
<span>Inquilino</span>
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="flex flex-wrap items-center gap-2">
|
||
<span class="text-xs font-medium text-slate-500">Vista:</span>
|
||
<button
|
||
type="button"
|
||
wire:click="toggleMostraStorico"
|
||
class="rounded-lg border px-2.5 py-1 text-xs font-semibold transition {{ $mostraStorico ? 'border-amber-300 bg-amber-50 text-amber-700 shadow-xs' : 'border-slate-200 bg-slate-50 text-slate-700 hover:bg-slate-100' }}">
|
||
{{ $mostraStorico ? 'Mostra storico (Attivo)' : 'Solo gestione selezionata' }}
|
||
</button>
|
||
<span class="text-xs font-medium text-slate-500 ml-1">Visibilità:</span>
|
||
@foreach($visibilityOptions as $key => $label)
|
||
<button
|
||
type="button"
|
||
wire:click="setUnitaVisibilita('{{ $key }}')"
|
||
class="rounded-lg border px-2.5 py-1 text-xs font-semibold transition {{ $this->unitaVisibilita === $key ? 'border-indigo-300 bg-indigo-50 text-indigo-700 shadow-xs' : 'border-slate-200 bg-slate-50 text-slate-700 hover:bg-slate-100' }}">
|
||
{{ $label }}
|
||
</button>
|
||
@endforeach
|
||
</div>
|
||
</div>
|
||
|
||
@if(!$unita)
|
||
<div class="rounded-xl border border-dashed border-gray-200 bg-white p-6 text-center text-gray-500">Nessuna unità immobiliare trovata.</div>
|
||
@else
|
||
|
||
{{-- Tabs + contenuto --}}
|
||
<x-filament::section class="p-0! overflow-hidden">
|
||
<div class="flex flex-wrap items-center gap-2 px-4 py-2 bg-white border-b">
|
||
@php
|
||
$tabs = [
|
||
'riepilogo' => ['icon' => 'heroicon-o-rectangle-group', 'label' => 'Riepilogo'],
|
||
'nominativi' => ['icon' => 'heroicon-o-user-group', 'label' => '👥 Nominativi & Subentri'],
|
||
'estratto_conto' => ['icon' => 'heroicon-o-calculator', 'label' => '🧾 Estratto Conto & Pagamenti'],
|
||
'millesimi' => ['icon' => 'heroicon-o-chart-pie', 'label' => 'Tabelle millesimali'],
|
||
'catasto' => ['icon' => 'heroicon-o-building-office-2', 'label' => 'Catasto'],
|
||
'comproprietari' => ['icon' => 'heroicon-o-users', 'label' => 'Comproprietari'],
|
||
'preferenze' => ['icon' => 'heroicon-o-envelope', 'label' => 'Comunicazioni'],
|
||
'acqua' => ['icon' => 'heroicon-o-beaker', 'label' => 'Acqua'],
|
||
];
|
||
@endphp
|
||
@foreach($tabs as $key => $cfg)
|
||
<button
|
||
type="button"
|
||
wire:click="setTab('{{ $key }}')"
|
||
class="inline-flex items-center gap-2 rounded-lg border px-3 py-2 text-sm font-semibold transition
|
||
{{ $tab === $key ? 'border-primary-300 bg-primary-50 text-primary-700 shadow-sm' : 'border-transparent bg-gray-50 text-gray-700 hover:border-gray-200' }}">
|
||
<x-filament::icon :icon="$cfg['icon']" class="h-4 w-4" />
|
||
<span>{{ $cfg['label'] }}</span>
|
||
</button>
|
||
@endforeach
|
||
</div>
|
||
|
||
<div class="p-4 space-y-4">
|
||
@if($tab === 'riepilogo')
|
||
{{-- Header compatto dell'Unità Immobiliare --}}
|
||
<x-filament::section class="p-4! mb-4">
|
||
@php
|
||
$isArchivedUnita = method_exists($unita, 'trashed') && $unita->trashed();
|
||
$labelUnita = (string) ($unita->denominazione ?? '');
|
||
if ($labelUnita !== '' && preg_match('/^\s*area\s+condominiale\s*$/i', $labelUnita)) {
|
||
$labelUnita = '';
|
||
}
|
||
$condominoDaCondomin = trim((string) ($this->getLegacyCondominoRiferimentoNome() ?? ''));
|
||
$proprietariAttivi = collect($relazioniPerTipo['proprietari'] ?? []);
|
||
$condominoRiferimento = $proprietariAttivi
|
||
->first(fn (array $relazione): bool => strtolower(trim((string) ($relazione['tipo_raw'] ?? ''))) !== 'comproprietario')
|
||
?? ($relazioniPerTipo['proprietari'][0] ?? null);
|
||
$condominoNome = $condominoDaCondomin !== ''
|
||
? $condominoDaCondomin
|
||
: (string) ($condominoRiferimento['nome'] ?? '');
|
||
$condominoCf = trim((string) ($this->getLegacyCondominoRiferimentoCodiceFiscale() ?? ''));
|
||
if ($condominoCf === '') {
|
||
$condominoCf = (string) ($condominoRiferimento['codice_fiscale'] ?? '');
|
||
}
|
||
$inquilinoNome = (string) ($relazioniPerTipo['inquilini'][0]['nome'] ?? '');
|
||
$comproprietariCount = $proprietariAttivi
|
||
->filter(fn (array $relazione): bool => strtolower(trim((string) ($relazione['tipo_raw'] ?? ''))) === 'comproprietario')
|
||
->count();
|
||
$hasInquilino = !empty($relazioniPerTipo['inquilini'][0]['nome'] ?? null);
|
||
@endphp
|
||
|
||
<div class="flex items-start justify-between gap-4 flex-wrap">
|
||
<div class="space-y-1">
|
||
<div class="flex flex-wrap items-center gap-3 text-lg font-semibold text-gray-900">
|
||
<x-filament::icon icon="heroicon-o-home-modern" class="h-5 w-5 text-primary-600" />
|
||
<span class="text-primary-700 font-bold">Unità immobiliare {{ $unita->codice_unita ?? $unita->codice_completo }}</span>
|
||
@if($isArchivedUnita)
|
||
<span class="rounded-full border border-amber-300 bg-amber-50 px-2 py-0.5 text-xs font-semibold text-amber-700">Archiviata</span>
|
||
@endif
|
||
</div>
|
||
|
||
<div class="flex items-center gap-2 text-sm text-gray-800 mt-2">
|
||
<span class="inline-flex items-center rounded bg-emerald-100 px-2 py-0.5 text-xs font-bold text-emerald-800">C</span>
|
||
<span class="font-semibold">Condomino:</span>
|
||
<span class="font-bold text-indigo-900">{{ $condominoNome !== '' ? trim(str_replace([' - ', ' 0 ', ' 0', '-'], [' ', ' ', ' ', ' '], $condominoNome)) : '—' }}</span>
|
||
</div>
|
||
|
||
@if($comproprietariCount > 0)
|
||
<div class="text-xs text-gray-500 pl-6">Comproprietari collegati: {{ $comproprietariCount }}</div>
|
||
@endif
|
||
|
||
<div class="flex items-center gap-2 text-sm text-gray-800 mt-1">
|
||
<span class="inline-flex items-center rounded bg-sky-100 px-2 py-0.5 text-xs font-bold text-sky-800">I</span>
|
||
<span class="font-semibold">Inquilino:</span>
|
||
<span class="font-bold text-slate-800">{{ $inquilinoNome !== '' ? trim(str_replace([' - ', ' 0 ', ' 0', '-'], [' ', ' ', ' ', ' '], $inquilinoNome)) : '—' }}</span>
|
||
</div>
|
||
|
||
<div class="text-xs text-gray-600 mt-1">📍 {{ trim(($unita->indirizzo ?? '').' Scala '.($unita->scala ?? '').' Int. '.($unita->interno ?? '').' '.($unita->comune ?? '')) }}</div>
|
||
|
||
<div class="mt-3 pt-2 border-t border-gray-100">
|
||
<a href="/admin-filament/condomini/catasto-hub?unita_id={{ $unita->id }}" class="inline-flex items-center gap-2 rounded-lg bg-indigo-700 hover:bg-indigo-800 text-white font-semibold px-3.5 py-1.5 text-xs shadow-xs transition">
|
||
<span>🏛️</span>
|
||
<span>[ Apri in HUB Catasto ]</span>
|
||
</a>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="grid gap-3 sm:grid-cols-2 min-w-80">
|
||
<div class="rounded-xl border border-slate-200 bg-slate-50 p-3.5">
|
||
<div class="text-xs font-semibold text-slate-500">🏢 Condomino di riferimento</div>
|
||
<div class="text-sm font-bold text-slate-900 mt-1">{{ $condominoNome !== '' ? $condominoNome : '—' }}</div>
|
||
<div class="text-xs font-mono text-slate-600 mt-0.5">CF: {{ $condominoCf !== '' ? $condominoCf : '—' }}</div>
|
||
</div>
|
||
<div class="rounded-xl border border-slate-200 bg-slate-50 p-3.5 {{ $hasInquilino ? '' : 'opacity-60' }}">
|
||
<div class="text-xs font-semibold text-slate-500">👤 Inquilino</div>
|
||
<div class="text-sm font-bold text-slate-900 mt-1">{{ $inquilinoNome !== '' ? $inquilinoNome : '—' }}</div>
|
||
<div class="text-xs font-mono text-slate-600 mt-0.5">CF: {{ $relazioniPerTipo['inquilini'][0]['codice_fiscale'] ?? '—' }}</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</x-filament::section>
|
||
|
||
<div class="grid gap-4 lg:grid-cols-3">
|
||
<x-filament::section class="lg:col-span-2">
|
||
<x-slot name="heading">Indicatori principali</x-slot>
|
||
<x-slot name="description">Superficie, millesimi, percentuale, valore</x-slot>
|
||
<div class="grid gap-3 sm:grid-cols-2 lg:grid-cols-4">
|
||
@foreach([
|
||
['Superficie', ($unita->superficie_commerciale ?? 0) . ' m²'],
|
||
['Millesimi', $unita->millesimi_proprieta ?? $unita->millesimi_generali ?? 0],
|
||
['Percentuale', ($unita->millesimi_proprieta ?? $unita->millesimi_generali) ? number_format((($unita->millesimi_proprieta ?? $unita->millesimi_generali)/1000)*100,2) . '%' : '0%'],
|
||
['Valore stimato', ($unita->valore_commerciale_stimato ?? 0) . ' €'],
|
||
] as [$label, $value])
|
||
<x-filament::section class="p-4!">
|
||
<div class="text-xs text-gray-500">{{ $label }}</div>
|
||
<div class="text-lg font-semibold text-gray-900">{{ $value }}</div>
|
||
</x-filament::section>
|
||
@endforeach
|
||
</div>
|
||
</x-filament::section>
|
||
|
||
<x-filament::section>
|
||
<x-slot name="heading">Identificazione</x-slot>
|
||
<x-slot name="description">Tipologia e stato</x-slot>
|
||
<div class="space-y-2">
|
||
@foreach([
|
||
['Tipologia', $unita->tipo_unita ?? 'ND'],
|
||
['Stato occupazione', $unita->stato_occupazione ?? 'ND'],
|
||
['Utilizzo', $unita->utilizzo_attuale ?? 'ND'],
|
||
['Codice stabile', $unita->stabile?->codice_operatore ?? $unita->stabile?->codice_stabile ?? 'ND'],
|
||
] as [$label, $value])
|
||
<x-filament::section class="p-3! bg-gray-50">
|
||
<div class="text-xs text-gray-500">{{ $label }}</div>
|
||
<div class="text-sm font-semibold text-gray-900">{{ $value }}</div>
|
||
</x-filament::section>
|
||
@endforeach
|
||
</div>
|
||
</x-filament::section>
|
||
</div>
|
||
|
||
|
||
|
||
<x-filament::section>
|
||
<x-slot name="heading">Persone collegate</x-slot>
|
||
<x-slot name="description">Proprietari, inquilini, altri</x-slot>
|
||
<div class="grid gap-3 md:grid-cols-2 lg:grid-cols-3">
|
||
@foreach([
|
||
'inquilini' => ['label' => 'Inquilini', 'color' => 'text-sky-700'],
|
||
'altri' => ['label' => 'Altri soggetti', 'color' => 'text-gray-700'],
|
||
] as $key => $cfg)
|
||
@php $relazioni = $relazioniPerTipo[$key] ?? []; @endphp
|
||
<x-filament::section class="bg-gray-50">
|
||
<div class="mb-2 text-sm font-semibold {{ $cfg['color'] }}">{{ $cfg['label'] }} ({{ count($relazioni) }})</div>
|
||
@if(empty($relazioni))
|
||
<div class="text-sm text-gray-500">Nessun soggetto.</div>
|
||
@else
|
||
<div class="space-y-2">
|
||
@foreach($relazioni as $relazione)
|
||
@php
|
||
$tipoRawRelazione = strtolower(trim((string) ($relazione['tipo_raw'] ?? '')));
|
||
$roleBadge = null;
|
||
if ($key === 'proprietari') {
|
||
$roleBadge = $tipoRawRelazione === 'comproprietario'
|
||
? 'Comproprietario'
|
||
: 'Condomino di riferimento';
|
||
}
|
||
@endphp
|
||
<x-filament::section class="p-3!">
|
||
<div class="flex items-start justify-between gap-2">
|
||
<div class="text-sm font-semibold text-gray-900">{{ $relazione['nome'] }}</div>
|
||
@if($roleBadge)
|
||
<span class="rounded-full border border-gray-200 bg-white px-2 py-0.5 text-[11px] font-semibold text-gray-600">{{ $roleBadge }}</span>
|
||
@endif
|
||
</div>
|
||
<div class="text-xs text-gray-500">CF: {{ $relazione['codice_fiscale'] ?? '—' }}</div>
|
||
<div class="text-xs text-gray-500">Quota: {{ $relazione['quota_label'] ?? '—' }}%</div>
|
||
@php
|
||
$dal = $relazione['data_inizio'] ?? null;
|
||
$al = $relazione['data_fine'] ?? null;
|
||
@endphp
|
||
<div class="text-xs text-gray-500">
|
||
Periodo:
|
||
@if($dal || $al)
|
||
@if($dal) Da {{ $dal }} @endif
|
||
@if($al) · fino a {{ $al }} @endif
|
||
@else
|
||
Da sempre
|
||
@endif
|
||
</div>
|
||
@if(!empty($relazione['ruolo_rate']))
|
||
<div class="text-xs text-gray-500">Ruolo rate: ({{ $relazione['ruolo_rate'] }})</div>
|
||
@endif
|
||
</x-filament::section>
|
||
@endforeach
|
||
</div>
|
||
@endif
|
||
</x-filament::section>
|
||
@endforeach
|
||
</div>
|
||
|
||
<div class="mt-6">
|
||
<div class="text-sm font-semibold text-gray-900 mb-2">Recapiti email per servizio</div>
|
||
@if(empty($recapitiServizio))
|
||
<div class="text-sm text-gray-500">Nessun recapito email disponibile.</div>
|
||
@else
|
||
<div class="grid gap-3 lg:grid-cols-2">
|
||
@foreach($recapitiServizio as $service)
|
||
<div class="rounded-xl border bg-gray-50 p-3">
|
||
<div class="text-sm font-semibold text-gray-900">{{ $service['label'] ?? 'Servizio' }}</div>
|
||
@if(empty($service['rows']))
|
||
<div class="mt-2 text-sm text-gray-500">Nessun recapito risolto.</div>
|
||
@else
|
||
<div class="mt-2 space-y-2">
|
||
@foreach($service['rows'] as $recipient)
|
||
<div class="rounded-lg border bg-white p-3">
|
||
<div class="text-sm font-semibold text-gray-900">{{ $recipient['email'] ?? '—' }}</div>
|
||
<div class="text-xs text-gray-500">{{ $recipient['persona'] ?: 'Recapito unità' }} · {{ $recipient['sourceLabel'] ?? 'Anagrafica persona' }}</div>
|
||
</div>
|
||
@endforeach
|
||
</div>
|
||
@endif
|
||
</div>
|
||
@endforeach
|
||
</div>
|
||
@endif
|
||
</div>
|
||
|
||
<div class="mt-6 border-t pt-4">
|
||
<div class="flex items-center gap-2 mb-3">
|
||
<x-filament::icon icon="heroicon-o-clock" class="h-5 w-5 text-amber-600" />
|
||
<span class="text-base font-bold text-gray-900">Timeline Subentri e Gestioni Anteriore</span>
|
||
</div>
|
||
<div class="text-xs text-gray-500 mb-3">Cronistoria titolari ed avvicendamenti storici per questa unità immobiliare tra le diverse gestioni</div>
|
||
|
||
@if(empty($nominativiStorici))
|
||
<div class="rounded-lg border border-dashed border-gray-200 p-4 text-center text-sm text-gray-500">Nessun avvicendamento o storico subentri registrato per questa unità.</div>
|
||
@else
|
||
<div class="space-y-3">
|
||
@foreach($nominativiStorici as $item)
|
||
<div class="rounded-xl border border-gray-200 bg-white p-4 shadow-xs transition hover:border-amber-300">
|
||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||
<div class="flex flex-wrap items-center gap-2">
|
||
<span class="rounded-md bg-amber-50 border border-amber-200 px-2.5 py-1 text-xs font-bold text-amber-800">
|
||
{{ $item['periodo'] ?? 'Da sempre' }}
|
||
</span>
|
||
<span class="text-base font-bold text-gray-900">
|
||
{{ $item['nominativo'] ?? $item['nome_completo'] ?? $item['nome'] ?? '—' }}
|
||
</span>
|
||
@if(!empty($item['ruolo']))
|
||
<span class="rounded-full bg-gray-100 px-2.5 py-0.5 text-xs font-semibold text-gray-700">
|
||
{{ $item['ruolo'] }}
|
||
</span>
|
||
@endif
|
||
@if(!empty($item['percentuale']))
|
||
<span class="rounded-full bg-blue-50 text-blue-700 border border-blue-200 px-2.5 py-0.5 text-xs font-semibold">
|
||
Quota: {{ $item['percentuale'] }}
|
||
</span>
|
||
@endif
|
||
</div>
|
||
@if(!empty($item['fonte']))
|
||
<div class="text-xs text-gray-500 font-medium">Fonte: {{ $item['fonte'] }}</div>
|
||
@endif
|
||
</div>
|
||
@if(!empty($item['detail']))
|
||
<div class="mt-2 text-xs font-medium text-gray-600 bg-gray-50 rounded-lg p-2.5">
|
||
{{ $item['detail'] }}
|
||
</div>
|
||
@endif
|
||
</div>
|
||
@endforeach
|
||
</div>
|
||
@endif
|
||
</div>
|
||
</x-filament::section>
|
||
@endif
|
||
|
||
@if($tab === 'nominativi')
|
||
<div class="space-y-4">
|
||
<div class="rounded-xl border border-indigo-100 bg-indigo-50/50 p-4">
|
||
<div class="flex items-center gap-2">
|
||
<span class="text-xl">👥</span>
|
||
<div>
|
||
<h3 class="text-base font-semibold text-gray-900">Timeline Subentri e Cronistoria Avvicendamenti</h3>
|
||
<p class="text-xs text-gray-600">Cronistoria titolari ed avvicendamenti storici per questa unità immobiliare tra le diverse gestioni annuali. Seleziona un nominativo per accedere all'estratto conto contabile analitico.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
@php
|
||
$timelineItems = $this->getTimelineSubentriCompletaProperty();
|
||
@endphp
|
||
|
||
@if(empty($timelineItems))
|
||
<div class="rounded-xl border border-dashed border-gray-200 bg-white p-8 text-center text-gray-500">
|
||
Nessuna cronistoria subentri registrata per questa unità immobiliare.
|
||
</div>
|
||
@else
|
||
<div class="relative border-l-2 border-indigo-200 ml-4 space-y-4 py-2">
|
||
@foreach($timelineItems as $item)
|
||
<div class="relative pl-6">
|
||
<span class="absolute -left-[9px] top-3 h-4 w-4 rounded-full border-2 border-indigo-600 bg-white"></span>
|
||
<div class="rounded-xl border border-gray-200 bg-white p-4 shadow-xs hover:border-indigo-300 hover:shadow-md transition flex flex-wrap items-center justify-between gap-4">
|
||
<div class="space-y-1">
|
||
<div class="flex items-center gap-2">
|
||
<span class="font-bold text-gray-900 text-base">{{ $item['nominativo'] }}</span>
|
||
<span class="inline-flex items-center rounded-md px-2 py-0.5 text-xs font-semibold {{ $item['ruolo'] === 'Inquilino' ? 'bg-amber-100 text-amber-800' : 'bg-indigo-100 text-indigo-800' }}">
|
||
{{ $item['ruolo'] }}
|
||
</span>
|
||
</div>
|
||
<div class="text-xs text-gray-500 flex flex-wrap items-center gap-3">
|
||
@if($item['codice_fiscale'])
|
||
<span>CF: <code class="font-mono">{{ $item['codice_fiscale'] }}</code></span>
|
||
@endif
|
||
<span>ID Condomino: <strong>#{{ $item['id_cond'] }}</strong></span>
|
||
<span>Gestioni: <strong class="text-indigo-700">{{ implode(' | ', $item['year_labels'] ?? $item['years']) }}</strong></span>
|
||
</div>
|
||
@if(!empty($item['dettaglio_subentro']))
|
||
<div class="text-xs text-amber-700 bg-amber-50 rounded border border-amber-200 px-2 py-1 inline-block mt-1">
|
||
ℹ️ {{ $item['dettaglio_subentro'] }}
|
||
</div>
|
||
@endif
|
||
</div>
|
||
|
||
<div>
|
||
<button type="button"
|
||
wire:click="selectNominativoKey('{{ $item['key'] }}')"
|
||
class="inline-flex items-center gap-1.5 rounded-lg bg-indigo-600 px-3 py-2 text-xs font-semibold text-white shadow-xs hover:bg-indigo-700 transition">
|
||
<span>🧾</span>
|
||
<span>Vedi Estratto Conto per Nominativo</span>
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
@endforeach
|
||
</div>
|
||
@endif
|
||
</div>
|
||
@endif
|
||
|
||
@if($tab === 'estratto_conto')
|
||
@php
|
||
$ecData = $this->getEstrattoContoNominativoDettaglioProperty();
|
||
$timelineItems = $this->getTimelineSubentriCompletaProperty();
|
||
$soggetto = $ecData['soggetto'] ?? null;
|
||
|
||
$rateCondominiHeader = $rateEmessePerCategoria['condomini'] ?? [];
|
||
$rateInquiliniHeader = $rateEmessePerCategoria['inquilini'] ?? [];
|
||
$sumHeader = function (array $items, string $field): float {
|
||
$s = 0.0;
|
||
foreach ($items as $it) {
|
||
$s += (float) ($it[$field] ?? 0);
|
||
}
|
||
return $s;
|
||
};
|
||
$totCAddebH = $sumHeader($rateCondominiHeader, 'totale_addebitato');
|
||
$totCPagH = $sumHeader($rateCondominiHeader, 'totale_pagato');
|
||
$totCResH = $sumHeader($rateCondominiHeader, 'residuo');
|
||
$totIAddebH = $sumHeader($rateInquiliniHeader, 'totale_addebitato');
|
||
$totIPagH = $sumHeader($rateInquiliniHeader, 'totale_pagato');
|
||
$totIResH = $sumHeader($rateInquiliniHeader, 'residuo');
|
||
$hasInquilino = !empty($relazioniPerTipo['inquilini'][0]['nome'] ?? null);
|
||
if (empty($rateCondominiHeader) && empty($rateInquiliniHeader) && !$hasInquilino) {
|
||
$totCAddebH = (float) collect($estrattoCompattoRateRows ?? [])->sum(fn (array $row): float => (float) ($row['dovuto'] ?? 0));
|
||
$totCPagH = (float) collect($estrattoCompattoIncassi ?? [])->sum(fn (array $row): float => (float) ($row['importo'] ?? 0));
|
||
$totCResH = round($totCAddebH - $totCPagH, 2);
|
||
}
|
||
@endphp
|
||
|
||
<div class="space-y-4">
|
||
{{-- Box Estratto Rapido Sintetico diviso per Condomino ed Inquilino --}}
|
||
<div class="rounded-xl border border-slate-200 bg-slate-50 p-4">
|
||
<div class="text-xs font-bold text-slate-600 uppercase tracking-wider mb-2">⚡ Estratto Conto Rapido Sintetico</div>
|
||
<div class="grid gap-3 sm:grid-cols-2">
|
||
<button type="button"
|
||
wire:click="setCondInquilActive('C')"
|
||
class="rounded-xl border p-3.5 text-left transition {{ ($condInquilActive ?? 'C') === 'C' ? 'border-amber-400 bg-amber-50/80 shadow-xs ring-2 ring-amber-500/20' : 'border-slate-200 bg-white hover:bg-slate-100' }}">
|
||
<div class="flex items-center justify-between">
|
||
<span class="text-xs font-bold text-amber-900">🏢 Condomino (Proprietari)</span>
|
||
<span class="rounded bg-amber-200 px-1.5 py-0.5 text-[10px] font-bold text-amber-900">C</span>
|
||
</div>
|
||
<div class="text-xs text-slate-700 mt-1 font-mono">
|
||
Addebito: <strong>€ {{ number_format($totCAddebH, 2, ',', '.') }}</strong> ·
|
||
Incasso: <strong class="text-emerald-700">€ {{ number_format($totCPagH, 2, ',', '.') }}</strong> ·
|
||
Residuo: <strong class="{{ $totCResH > 0 ? 'text-rose-600' : 'text-slate-600' }}">€ {{ number_format($totCResH, 2, ',', '.') }}</strong>
|
||
</div>
|
||
</button>
|
||
|
||
<button type="button"
|
||
wire:click="setCondInquilActive('I')"
|
||
class="rounded-xl border p-3.5 text-left transition {{ ($condInquilActive ?? 'C') === 'I' ? 'border-indigo-400 bg-indigo-50/80 shadow-xs ring-2 ring-indigo-500/20' : 'border-slate-200 bg-white hover:bg-slate-100' }} {{ $hasInquilino ? '' : 'opacity-60' }}"
|
||
@if(!$hasInquilino) disabled @endif>
|
||
<div class="flex items-center justify-between">
|
||
<span class="text-xs font-bold text-indigo-900">👤 Inquilino</span>
|
||
<span class="rounded bg-indigo-200 px-1.5 py-0.5 text-[10px] font-bold text-indigo-900">I</span>
|
||
</div>
|
||
<div class="text-xs text-slate-700 mt-1 font-mono">
|
||
Addebito: <strong>€ {{ number_format($totIAddebH, 2, ',', '.') }}</strong> ·
|
||
Incasso: <strong class="text-emerald-700">€ {{ number_format($totIPagH, 2, ',', '.') }}</strong> ·
|
||
Residuo: <strong class="{{ $totIResH > 0 ? 'text-rose-600' : 'text-slate-600' }}">€ {{ number_format($totIResH, 2, ',', '.') }}</strong>
|
||
</div>
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
{{-- Header selezione soggetto --}}
|
||
<div class="flex flex-wrap items-center justify-between gap-4 rounded-xl border border-slate-200 bg-slate-50 p-4">
|
||
<div>
|
||
<span class="text-xs font-medium text-slate-500">Seleziona Nominativo / Subentrante:</span>
|
||
<div class="flex flex-wrap items-center gap-2 mt-1">
|
||
@foreach($timelineItems as $tItem)
|
||
<button type="button"
|
||
wire:click="selectNominativoKey('{{ $tItem['key'] }}')"
|
||
class="inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-semibold transition border {{ ($soggetto['key'] ?? '') === $tItem['key'] ? 'bg-indigo-700 text-white border-indigo-700 shadow-md ring-2 ring-indigo-500/20' : 'bg-white text-slate-700 border-slate-200 hover:bg-slate-100' }}">
|
||
<span>{{ $tItem['nominativo'] }}</span>
|
||
<span class="opacity-75">({{ implode(', ', array_slice($tItem['year_labels'] ?? $tItem['years'], -1)) }})</span>
|
||
</button>
|
||
@endforeach
|
||
</div>
|
||
</div>
|
||
|
||
@if($soggetto)
|
||
<div class="text-right">
|
||
<span class="text-xs text-slate-500">ID Condomino: <strong>#{{ $soggetto['id_cond'] }}</strong></span>
|
||
<div class="text-sm font-bold text-indigo-900">{{ $soggetto['nominativo'] }}</div>
|
||
</div>
|
||
@endif
|
||
</div>
|
||
|
||
@if($soggetto)
|
||
{{-- KPI Summary --}}
|
||
<div class="grid grid-cols-1 gap-4 sm:grid-cols-4">
|
||
<div class="rounded-xl border border-slate-200 bg-white p-4 text-center">
|
||
<span class="text-xs font-medium text-slate-500">Totale Preventivo (€)</span>
|
||
<div class="text-lg font-bold text-slate-900">€ {{ number_format($ecData['totale_preventivo'], 2, ',', '.') }}</div>
|
||
</div>
|
||
<div class="rounded-xl border border-slate-200 bg-white p-4 text-center">
|
||
<span class="text-xs font-medium text-slate-500">Totale Consuntivo (€)</span>
|
||
<div class="text-lg font-bold text-slate-900">€ {{ number_format($ecData['totale_consuntivo'], 2, ',', '.') }}</div>
|
||
</div>
|
||
<div class="rounded-xl border border-emerald-200 bg-emerald-50/50 p-4 text-center">
|
||
<span class="text-xs font-medium text-emerald-700">Totale Incassato (€)</span>
|
||
<div class="text-lg font-bold text-emerald-800">€ {{ number_format($ecData['totale_incassato'], 2, ',', '.') }}</div>
|
||
</div>
|
||
<div class="rounded-xl border {{ $ecData['saldo_finale'] >= 0 ? 'border-emerald-300 bg-emerald-100/50 text-emerald-900' : 'border-rose-300 bg-rose-50 text-rose-900' }} p-4 text-center">
|
||
<span class="text-xs font-medium">Saldo Finale (€)</span>
|
||
<div class="text-lg font-bold">€ {{ number_format($ecData['saldo_finale'], 2, ',', '.') }}</div>
|
||
</div>
|
||
</div>
|
||
|
||
{{-- Tabella Addebiti e Ripartizioni --}}
|
||
<div class="rounded-xl border border-slate-200 bg-white overflow-hidden shadow-xs">
|
||
<div class="border-b border-slate-200 bg-slate-50 px-4 py-3 font-semibold text-slate-800 text-sm flex items-center justify-between">
|
||
<div class="flex items-center gap-2">
|
||
<span>📊 Spese e Millesimi Addebitati a <strong>{{ $soggetto['nominativo'] }}</strong></span>
|
||
<span class="rounded bg-indigo-100 px-2 py-0.5 text-xs text-indigo-800 font-normal">
|
||
{{ reset($ecData['addebiti'])['anno_gestione'] ?? 'Anno In Corso' }}
|
||
</span>
|
||
</div>
|
||
<span class="text-xs text-slate-500 font-normal">Suddivise per Gruppo (Ordinaria, Riscaldamento, Straordinaria)</span>
|
||
</div>
|
||
@if(empty($ecData['addebiti']))
|
||
<div class="p-6 text-center text-slate-500 text-xs">Nessun addebito preventivato o consuntivato per questo nominativo.</div>
|
||
@else
|
||
<div class="overflow-x-auto">
|
||
<table class="w-full text-left text-xs">
|
||
<thead class="bg-slate-100 text-slate-700 font-semibold border-b border-slate-200">
|
||
<tr>
|
||
<th class="px-4 py-2.5">Codice Tabella</th>
|
||
<th class="px-4 py-2.5">Descrizione Tabella</th>
|
||
<th class="px-4 py-2.5">Tipo Gestione</th>
|
||
<th class="px-4 py-2.5 text-right">Millesimi (mm)</th>
|
||
<th class="px-4 py-2.5 text-right">Preventivo (€)</th>
|
||
<th class="px-4 py-2.5 text-right">Consuntivo (€)</th>
|
||
<th class="px-4 py-2.5 text-right">Conguaglio (€)</th>
|
||
<th class="px-4 py-2.5 text-center">Voci Spesa</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody class="divide-y divide-slate-100">
|
||
@foreach($ecData['addebiti'] as $addIndex => $add)
|
||
<tr class="hover:bg-indigo-50/50 transition cursor-pointer" onclick="document.getElementById('voc-spe-row-{{ $addIndex }}') ? document.getElementById('voc-spe-row-{{ $addIndex }}').classList.toggle('hidden') : null">
|
||
<td class="px-4 py-2.5 font-mono font-bold text-indigo-700">{{ $add['cod_tabella'] }}</td>
|
||
<td class="px-4 py-2.5 font-semibold text-slate-900">{{ $add['descrizione_tab'] }}</td>
|
||
<td class="px-4 py-2.5">
|
||
<span class="inline-flex items-center rounded-md px-2 py-0.5 text-xs font-semibold {{ $add['tipo_label'] === 'Riscaldamento' ? 'bg-amber-100 text-amber-800' : ($add['tipo_label'] === 'Straordinaria' ? 'bg-rose-100 text-rose-800' : 'bg-slate-100 text-slate-800') }}">
|
||
{{ $add['tipo_label'] }}
|
||
</span>
|
||
</td>
|
||
<td class="px-4 py-2.5 text-right font-mono text-slate-600">{{ number_format($add['millesimi'], 2, ',', '.') }}</td>
|
||
<td class="px-4 py-2.5 text-right font-mono font-medium text-slate-800">€ {{ number_format($add['preventivo_euro'], 2, ',', '.') }}</td>
|
||
<td class="px-4 py-2.5 text-right font-mono font-medium text-slate-800">€ {{ number_format($add['consuntivo_euro'], 2, ',', '.') }}</td>
|
||
<td class="px-4 py-2.5 text-right font-mono font-bold {{ $add['conguaglio_euro'] > 0 ? 'text-amber-600' : ($add['conguaglio_euro'] < 0 ? 'text-emerald-600' : 'text-slate-500') }}">
|
||
€ {{ number_format($add['conguaglio_euro'], 2, ',', '.') }}
|
||
</td>
|
||
<td class="px-4 py-2.5 text-center">
|
||
@if(!empty($add['voci_spesa']))
|
||
<span class="inline-flex items-center gap-1 rounded bg-indigo-50 border border-indigo-200 px-2 py-0.5 text-xs font-semibold text-indigo-700">
|
||
<span>{{ count($add['voci_spesa']) }} voci</span>
|
||
<span>🔍</span>
|
||
</span>
|
||
@else
|
||
<span class="text-slate-400 text-xs">—</span>
|
||
@endif
|
||
</td>
|
||
</tr>
|
||
@if(!empty($add['voci_spesa']))
|
||
<tr id="voc-spe-row-{{ $addIndex }}" class="hidden bg-slate-50/80 border-b border-indigo-100">
|
||
<td colspan="8" class="p-3">
|
||
<div class="rounded-lg border border-indigo-100 bg-white p-3 shadow-xs">
|
||
<div class="text-xs font-bold text-indigo-900 mb-2 flex items-center gap-2">
|
||
<span>📋 Voci di Spesa collegate alla Tabella <strong>{{ $add['cod_tabella'] }}</strong></span>
|
||
<span class="text-slate-500 font-normal">({{ count($add['voci_spesa']) }} voci da voc_spe)</span>
|
||
</div>
|
||
<table class="w-full text-left text-xs border border-slate-200 rounded">
|
||
<thead class="bg-indigo-50 text-indigo-900 font-semibold">
|
||
<tr>
|
||
<th class="px-3 py-1.5">Cod. Voce</th>
|
||
<th class="px-3 py-1.5">Descrizione Voce</th>
|
||
<th class="px-3 py-1.5 text-center">% Prop.</th>
|
||
<th class="px-3 py-1.5 text-center">% Inq.</th>
|
||
<th class="px-3 py-1.5 text-right">Preventivo Voce (€)</th>
|
||
<th class="px-3 py-1.5 text-right">Consuntivo Voce (€)</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody class="divide-y divide-slate-100">
|
||
@foreach($add['voci_spesa'] as $voc)
|
||
<tr class="hover:bg-slate-50">
|
||
<td class="px-3 py-1.5 font-mono font-bold text-slate-700">{{ $voc['cod_voce'] }}</td>
|
||
<td class="px-3 py-1.5 text-slate-900 font-medium">{{ $voc['descrizione'] }}</td>
|
||
<td class="px-3 py-1.5 text-center font-mono text-slate-600">{{ number_format($voc['perc_proprietario'], 0) }}%</td>
|
||
<td class="px-3 py-1.5 text-center font-mono text-slate-600">{{ number_format($voc['perc_inquilino'], 0) }}%</td>
|
||
<td class="px-3 py-1.5 text-right font-mono text-slate-800">€ {{ number_format($voc['preventivo_euro'], 2, ',', '.') }}</td>
|
||
<td class="px-3 py-1.5 text-right font-mono text-slate-800">€ {{ number_format($voc['consuntivo_euro'], 2, ',', '.') }}</td>
|
||
</tr>
|
||
@endforeach
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
@endif
|
||
@endforeach
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
@endif
|
||
</div>
|
||
|
||
{{-- Tabella Rate Emesse (Dovuto vs Pagato + Data Pagamento e Movimento) --}}
|
||
<div class="rounded-xl border border-slate-200 bg-white overflow-hidden shadow-xs">
|
||
<div class="border-b border-slate-200 bg-slate-50 px-4 py-3 font-semibold text-slate-800 text-sm flex items-center justify-between">
|
||
<span>📑 Rate Emesse ed Avvisi di Pagamento</span>
|
||
<span class="text-xs text-slate-500 font-normal">Estratti da rate_emesse / emes_det per {{ $soggetto['nominativo'] }}</span>
|
||
</div>
|
||
@if(empty($ecData['rate_emesse']))
|
||
<div class="p-6 text-center text-slate-500 text-xs">Nessuna rata emessa per questo nominativo / ruolo.</div>
|
||
@else
|
||
<div class="overflow-x-auto">
|
||
<table class="w-full text-left text-xs">
|
||
<thead class="bg-slate-100 text-slate-700 font-semibold border-b border-slate-200">
|
||
<tr>
|
||
<th class="px-4 py-2.5">Data Emissione</th>
|
||
<th class="px-4 py-2.5">Data Scadenza</th>
|
||
<th class="px-4 py-2.5">Gestione</th>
|
||
<th class="px-4 py-2.5">Descrizione Rata</th>
|
||
<th class="px-4 py-2.5 text-right">Dovuto (€)</th>
|
||
<th class="px-4 py-2.5 text-right">Pagato (€)</th>
|
||
<th class="px-4 py-2.5">Data Pagamento</th>
|
||
<th class="px-4 py-2.5">Movimento / Cassa-Banca</th>
|
||
<th class="px-4 py-2.5 text-right">Residuo (€)</th>
|
||
<th class="px-4 py-2.5 text-center">Stato</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody class="divide-y divide-slate-100">
|
||
@foreach($ecData['rate_emesse'] as $rE)
|
||
<tr class="hover:bg-slate-50 transition">
|
||
<td class="px-4 py-2 font-mono text-slate-600">{{ $rE['data_emissione'] }}</td>
|
||
<td class="px-4 py-2 font-mono text-slate-800 font-semibold">{{ $rE['data_scadenza'] }}</td>
|
||
<td class="px-4 py-2">
|
||
<span class="inline-flex items-center rounded px-2 py-0.5 text-xs font-semibold bg-indigo-50 text-indigo-700">
|
||
{{ $rE['gestione'] }}
|
||
</span>
|
||
</td>
|
||
<td class="px-4 py-2 font-medium text-slate-900">{{ $rE['descrizione'] }}</td>
|
||
<td class="px-4 py-2 text-right font-mono font-medium text-slate-900">€ {{ number_format($rE['dovuto'], 2, ',', '.') }}</td>
|
||
<td class="px-4 py-2 text-right font-mono font-medium text-emerald-700">€ {{ number_format($rE['pagato'], 2, ',', '.') }}</td>
|
||
<td class="px-4 py-2 font-mono text-slate-700 font-medium">{{ $rE['data_pagamento'] ?? '—' }}</td>
|
||
<td class="px-4 py-2 text-slate-600 font-mono text-xs">
|
||
@if(($rE['movimento_bancario'] ?? '—') !== '—')
|
||
<span class="inline-flex items-center gap-1 rounded bg-slate-100 border border-slate-200 px-2 py-0.5 text-xs text-slate-800 font-mono">
|
||
<span>🏛️ {{ $rE['movimento_bancario'] }}</span>
|
||
</span>
|
||
@else
|
||
<span class="text-slate-400">—</span>
|
||
@endif
|
||
</td>
|
||
<td class="px-4 py-2 text-right font-mono font-bold {{ $rE['residuo'] > 0 ? 'text-rose-600' : 'text-slate-500' }}">
|
||
€ {{ number_format($rE['residuo'], 2, ',', '.') }}
|
||
</td>
|
||
<td class="px-4 py-2 text-center">
|
||
@if($rE['residuo'] <= 0 && $rE['dovuto'] > 0)
|
||
<span class="inline-flex items-center rounded-full bg-emerald-100 px-2 py-0.5 text-xs font-semibold text-emerald-800">
|
||
Saldata
|
||
</span>
|
||
@elseif($rE['pagato'] > 0)
|
||
<span class="inline-flex items-center rounded-full bg-amber-100 px-2 py-0.5 text-xs font-semibold text-amber-800">
|
||
Parziale
|
||
</span>
|
||
@else
|
||
<span class="inline-flex items-center rounded-full bg-rose-100 px-2 py-0.5 text-xs font-semibold text-rose-800">
|
||
Da Pagare
|
||
</span>
|
||
@endif
|
||
</td>
|
||
</tr>
|
||
@endforeach
|
||
</tbody>
|
||
<tfoot class="bg-slate-50 font-bold border-t border-slate-200">
|
||
<tr>
|
||
<td colspan="4" class="px-4 py-2.5 text-right text-slate-700">Totali Rate Emesse:</td>
|
||
<td class="px-4 py-2.5 text-right font-mono text-slate-900">€ {{ number_format($ecData['totale_dovuto_rate'], 2, ',', '.') }}</td>
|
||
<td class="px-4 py-2.5 text-right font-mono text-emerald-700">€ {{ number_format($ecData['totale_pagato_rate'], 2, ',', '.') }}</td>
|
||
<td colspan="2"></td>
|
||
<td class="px-4 py-2.5 text-right font-mono text-rose-700">€ {{ number_format($ecData['totale_residuo_rate'], 2, ',', '.') }}</td>
|
||
<td></td>
|
||
</tr>
|
||
</tfoot>
|
||
</table>
|
||
</div>
|
||
@endif
|
||
</div>
|
||
|
||
{{-- Tabella Incassi Registrati --}}
|
||
<div class="rounded-xl border border-slate-200 bg-white overflow-hidden shadow-xs">
|
||
<div class="border-b border-slate-200 bg-slate-50 px-4 py-3 font-semibold text-slate-800 text-sm flex items-center justify-between">
|
||
<span>💵 Incassi Effettuati e Ricevute</span>
|
||
<span class="text-xs text-slate-500 font-normal">Estratti da incassi / in_da_ec</span>
|
||
</div>
|
||
@if(empty($ecData['incassi']))
|
||
<div class="p-6 text-center text-slate-500 text-xs">Nessun incasso registrato per questo nominativo.</div>
|
||
@else
|
||
<div class="overflow-x-auto">
|
||
<table class="w-full text-left text-xs">
|
||
<thead class="bg-slate-100 text-slate-700 font-semibold border-b border-slate-200">
|
||
<tr>
|
||
<th class="px-4 py-2.5">Data Pagamento</th>
|
||
<th class="px-4 py-2.5">Cassa / Banca</th>
|
||
<th class="px-4 py-2.5">Anno Rif.</th>
|
||
<th class="px-4 py-2.5">Descrizione / Note</th>
|
||
<th class="px-4 py-2.5 text-right">Importo Incassato (€)</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody class="divide-y divide-slate-100">
|
||
@foreach($ecData['incassi'] as $inc)
|
||
<tr class="hover:bg-slate-50 transition">
|
||
<td class="px-4 py-2 font-mono text-slate-800">{{ $inc['data_pagamento'] }}</td>
|
||
<td class="px-4 py-2 font-semibold text-indigo-700">{{ $inc['cod_cassa'] }}</td>
|
||
<td class="px-4 py-2 font-mono text-slate-600">{{ $inc['anno_rif'] }}</td>
|
||
<td class="px-4 py-2 text-slate-600">{{ $inc['descrizione'] }}</td>
|
||
<td class="px-4 py-2 text-right font-mono font-bold text-emerald-700">€ {{ number_format($inc['importo_euro'], 2, ',', '.') }}</td>
|
||
</tr>
|
||
@endforeach
|
||
</tbody>
|
||
<tfoot class="bg-slate-50 font-bold border-t border-slate-200">
|
||
<tr>
|
||
<td colspan="4" class="px-4 py-2.5 text-right text-slate-700">Totale Incassato:</td>
|
||
<td class="px-4 py-2.5 text-right font-mono text-emerald-700">€ {{ number_format($ecData['totale_incassato'], 2, ',', '.') }}</td>
|
||
</tr>
|
||
</tfoot>
|
||
</table>
|
||
</div>
|
||
@endif
|
||
</div>
|
||
@endif
|
||
</div>
|
||
@endif
|
||
|
||
@if($tab === 'catasto')
|
||
<x-filament::section>
|
||
<x-slot name="heading">Dati catastali</x-slot>
|
||
<x-slot name="description">Risultanze catastali ed identificativi ufficiali consolidati</x-slot>
|
||
|
||
<div class="max-w-3xl mx-auto rounded-xl border border-gray-200 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-900/50 p-6 shadow-xs space-y-6">
|
||
<div class="grid grid-cols-2 gap-y-4 gap-x-6 text-sm">
|
||
<div class="flex justify-between border-b border-gray-100 dark:border-gray-800 pb-2">
|
||
<span class="text-gray-500 font-medium">Sezione Urbana:</span>
|
||
<span class="font-semibold text-gray-900 dark:text-white">{{ ($unita->sezione_urbana && !preg_match('/^[A-Z]\d{3}$/i', $unita->sezione_urbana)) ? $unita->sezione_urbana : '—' }}</span>
|
||
</div>
|
||
<div class="flex justify-between border-b border-gray-100 dark:border-gray-800 pb-2">
|
||
<span class="text-gray-500 font-medium">Foglio:</span>
|
||
<span class="font-semibold text-gray-900 dark:text-white">{{ $unita->foglio ?: ($unita->stabile?->foglio ?? $unita->stabile?->foglio_catasto ?? '—') }}</span>
|
||
</div>
|
||
<div class="flex justify-between border-b border-gray-100 dark:border-gray-800 pb-2">
|
||
<span class="text-gray-500 font-medium">Particella:</span>
|
||
<span class="font-semibold text-gray-900 dark:text-white">{{ $unita->particella ?: ($unita->stabile?->particella_catasto ?? $unita->stabile?->mappale ?? '—') }}</span>
|
||
</div>
|
||
<div class="flex justify-between border-b border-gray-100 dark:border-gray-800 pb-2">
|
||
<span class="text-gray-500 font-medium">Subalterno:</span>
|
||
<span class="font-semibold text-gray-900 dark:text-white">{{ $unita->subalterno ?? '—' }}</span>
|
||
</div>
|
||
<div class="flex justify-between border-b border-gray-100 dark:border-gray-800 pb-2">
|
||
<span class="text-gray-500 font-medium">Categoria:</span>
|
||
<span class="font-semibold text-gray-900 dark:text-white">{{ \App\Filament\Pages\Condomini\CatastoHub::formattaCategoriaCatastale($unita->categoria_catastale ?? '') ?: '—' }}</span>
|
||
</div>
|
||
<div class="flex justify-between border-b border-gray-100 dark:border-gray-800 pb-2">
|
||
<span class="text-gray-500 font-medium">Classe:</span>
|
||
<span class="font-semibold text-gray-900 dark:text-white">{{ $unita->classe ?? ($unita->legacyData['classe'] ?? '03') }}</span>
|
||
</div>
|
||
<div class="flex justify-between border-b border-gray-100 dark:border-gray-800 pb-2">
|
||
<span class="text-gray-500 font-medium">Consistenza:</span>
|
||
<span class="font-semibold text-gray-900 dark:text-white">
|
||
{{ ($unita->superficie && str_starts_with(\App\Filament\Pages\Condomini\CatastoHub::estraiCodiceCompatto($unita->categoria_catastale ?? ''), 'C')) ? ($unita->superficie . ' m²') : ($unita->numero_vani ? ($unita->numero_vani . ' vani') : ($unita->vani ? ($unita->vani . ' vani') : '—')) }}
|
||
</span>
|
||
</div>
|
||
<div class="flex justify-between border-b border-gray-100 dark:border-gray-800 pb-2">
|
||
<span class="text-gray-500 font-medium">Rendita Euro:</span>
|
||
<span class="font-semibold text-gray-900 dark:text-white">{{ $unita->rendita_catastale ? '€ ' . number_format($unita->rendita_catastale, 2, ',', '.') : '—' }}</span>
|
||
</div>
|
||
<div class="flex justify-between border-b border-gray-100 dark:border-gray-800 pb-2">
|
||
<span class="text-gray-500 font-medium">Piano AdE:</span>
|
||
<span class="font-semibold text-gray-900 dark:text-white">{{ $unita->piano ?? '—' }}</span>
|
||
</div>
|
||
<div class="flex justify-between border-b border-gray-100 dark:border-gray-800 pb-2">
|
||
<span class="text-gray-500 font-medium">idImmobile:</span>
|
||
<span class="font-mono text-xs font-semibold text-gray-600 dark:text-gray-400 max-w-44 truncate" title="{{ $unita->codice_univoco ?? '—' }}">{{ $unita->codice_univoco ?? '—' }}</span>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="flex justify-center pt-4 border-t border-gray-200 dark:border-gray-800">
|
||
<a href="/admin-filament/condomini/catasto-hub?unita_id={{ $unita->id }}" class="inline-flex items-center gap-2 rounded-lg bg-primary-600 hover:bg-primary-700 text-white font-semibold px-6 py-2.5 text-sm shadow-md transition">
|
||
<x-filament::icon icon="heroicon-o-arrow-top-right-on-square" class="h-4 w-4" />
|
||
<span>[ Apri in HUB Catasto ]</span>
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</x-filament::section>
|
||
@endif
|
||
|
||
@if($tab === 'comproprietari')
|
||
<x-filament::section>
|
||
<x-slot name="heading">Comproprietari ed Aventi Diritto</x-slot>
|
||
<x-slot name="description">Elenco analitico dei soggetti con titolo reale o quota di possesso sull'immobile</x-slot>
|
||
|
||
<div class="space-y-4">
|
||
@php $comproprietari = $relazioniPerTipo['proprietari'] ?? []; @endphp
|
||
@if(empty($comproprietari))
|
||
<div class="text-sm text-gray-500">Nessun proprietario registrato.</div>
|
||
@else
|
||
<div class="overflow-x-auto rounded-lg border border-gray-200">
|
||
<table class="w-full text-left text-sm text-gray-500">
|
||
<thead class="bg-gray-50 text-xs uppercase text-gray-700 font-semibold border-b">
|
||
<tr>
|
||
<th class="px-6 py-3">Soggetto / Nominativo</th>
|
||
<th class="px-6 py-3">Codice Fiscale</th>
|
||
<th class="px-6 py-3">Titolo / Diritto</th>
|
||
<th class="px-6 py-3 text-right">Quota Proprietà</th>
|
||
<th class="px-6 py-3">Periodo di Possesso</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody class="divide-y divide-gray-200 bg-white">
|
||
@foreach($comproprietari as $p)
|
||
<tr class="hover:bg-gray-50/50">
|
||
<td class="px-6 py-4 font-semibold text-gray-900">{{ $p['nome'] }}</td>
|
||
<td class="px-6 py-4 font-mono text-gray-600">{{ $p['codice_fiscale'] ?? '—' }}</td>
|
||
<td class="px-6 py-4">
|
||
<span class="rounded bg-primary-50 px-2.5 py-1 text-xs font-bold text-primary-700 uppercase tracking-wide">
|
||
{{ $p['tipo'] ?? 'Proprietà' }}
|
||
</span>
|
||
</td>
|
||
<td class="px-6 py-4 text-right font-extrabold text-gray-900">
|
||
{{ $p['quota_label'] ?? ($p['percentuale_label'] ?? '—') }}%
|
||
</td>
|
||
<td class="px-6 py-4 text-xs text-gray-600">
|
||
@if(($p['data_inizio'] ?? null) || ($p['data_fine'] ?? null))
|
||
@if($p['data_inizio'] ?? null) Da {{ $p['data_inizio'] }} @endif
|
||
@if($p['data_fine'] ?? null) Fino a {{ $p['data_fine'] }} @endif
|
||
@else
|
||
Da sempre
|
||
@endif
|
||
</td>
|
||
</tr>
|
||
@endforeach
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
@endif
|
||
</div>
|
||
</x-filament::section>
|
||
@endif
|
||
|
||
@if($tab === 'preferenze')
|
||
<x-filament::section>
|
||
<x-slot name="heading">Comunicazioni e Canali di Invio</x-slot>
|
||
<x-slot name="description">Preferenze di spedizione e canali digitali ufficiali per proprietari e comproprietari</x-slot>
|
||
|
||
<div class="space-y-6">
|
||
@if(empty($canaliComunicazione))
|
||
<div class="text-sm text-gray-500">Nessun proprietario o comproprietario registrato per questa unità.</div>
|
||
@else
|
||
<div class="overflow-x-auto rounded-lg border border-gray-200">
|
||
<table class="w-full text-left text-sm text-gray-500">
|
||
<thead class="bg-gray-50 text-xs uppercase text-gray-700 font-semibold border-b">
|
||
<tr>
|
||
<th class="px-6 py-3">Soggetto / Nominativo</th>
|
||
<th class="px-6 py-3">Convocazione Assemblea</th>
|
||
<th class="px-6 py-3">Invio Verbali</th>
|
||
<th class="px-6 py-3">Solleciti e Rate</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody class="divide-y divide-gray-200 bg-white">
|
||
@foreach($canaliComunicazione as $soggettoId => $p)
|
||
<tr class="hover:bg-gray-50/50">
|
||
<td class="px-6 py-4">
|
||
<div class="font-semibold text-gray-900">{{ $p['nominativo'] }}</div>
|
||
<div class="text-xs text-gray-500 font-mono mt-0.5">{{ $p['codice_fiscale'] ?? '—' }}</div>
|
||
</td>
|
||
<td class="px-6 py-4">
|
||
<select
|
||
wire:change="salvaCanaleComunicazione({{ $soggettoId }}, 'convocazione', $event.target.value)"
|
||
class="w-full text-xs rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 font-semibold text-gray-700">
|
||
@foreach(['PEC', 'Raccomandata AR', 'Posta Ordinaria', 'Mano'] as $opt)
|
||
<option value="{{ $opt }}" {{ $p['convocazione'] === $opt ? 'selected' : '' }}>{{ $opt }}</option>
|
||
@endforeach
|
||
</select>
|
||
</td>
|
||
<td class="px-6 py-4">
|
||
<select
|
||
wire:change="salvaCanaleComunicazione({{ $soggettoId }}, 'verbali', $event.target.value)"
|
||
class="w-full text-xs rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 font-semibold text-gray-700">
|
||
@foreach(['PEC', 'Raccomandata AR', 'Posta Ordinaria', 'Mano'] as $opt)
|
||
<option value="{{ $opt }}" {{ $p['verbali'] === $opt ? 'selected' : '' }}>{{ $opt }}</option>
|
||
@endforeach
|
||
</select>
|
||
</td>
|
||
<td class="px-6 py-4">
|
||
<select
|
||
wire:change="salvaCanaleComunicazione({{ $soggettoId }}, 'solleciti', $event.target.value)"
|
||
class="w-full text-xs rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 font-semibold text-gray-700">
|
||
@foreach(['Email Standard', 'PEC', 'Posta Ordinaria'] as $opt)
|
||
<option value="{{ $opt }}" {{ $p['solleciti'] === $opt ? 'selected' : '' }}>{{ $opt }}</option>
|
||
@endforeach
|
||
</select>
|
||
</td>
|
||
</tr>
|
||
@endforeach
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
@endif
|
||
</div>
|
||
</x-filament::section>
|
||
@endif
|
||
|
||
@if($tab === 'millesimi')
|
||
<x-filament::section>
|
||
<div class="flex items-center gap-2 text-sm font-semibold text-gray-900 mb-3">
|
||
<x-filament::icon icon="heroicon-o-chart-pie" class="h-5 w-5 text-primary-600" />
|
||
<span>Tabelle millesimali assegnate</span>
|
||
</div>
|
||
|
||
<div class="mb-4 flex flex-wrap gap-2">
|
||
@php
|
||
$gruppi = [
|
||
'ordinarie' => 'ORDINARIE',
|
||
'riscaldamento' => 'RISCALDAMENTO',
|
||
'straordinarie' => 'STRAORDINARIE',
|
||
];
|
||
@endphp
|
||
@foreach($gruppi as $key => $label)
|
||
<button
|
||
type="button"
|
||
wire:click="setMillesimiGruppo('{{ $key }}')"
|
||
class="inline-flex items-center rounded-lg border px-4 py-2 text-sm font-semibold transition
|
||
{{ ($millesimiGruppo ?? 'ordinarie') === $key ? 'border-primary-300 bg-primary-50 text-primary-700 shadow-sm' : 'border-gray-200 bg-white text-gray-700 hover:bg-gray-50' }}"
|
||
>
|
||
{{ $label }}
|
||
</button>
|
||
@endforeach
|
||
</div>
|
||
|
||
@if(empty($millesimiPerTabella))
|
||
<div class="text-sm text-gray-500">Nessuna tabella millesimale associata.</div>
|
||
@else
|
||
@php
|
||
$selectedGruppo = $millesimiGruppo ?? 'ordinarie';
|
||
$filteredMillesimi = array_values(array_filter($millesimiPerTabella, fn ($r) => ($r['gruppo'] ?? 'ordinarie') === $selectedGruppo));
|
||
@endphp
|
||
<div class="overflow-x-auto">
|
||
<table class="min-w-full text-sm">
|
||
<thead>
|
||
<tr class="border-b text-left text-gray-500">
|
||
<th class="py-2 pr-4">Tabella</th>
|
||
<th class="py-2 pr-4">Denominazione</th>
|
||
<th class="py-2 pr-4 text-right">Millesimi</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody class="divide-y">
|
||
@forelse($filteredMillesimi as $r)
|
||
@php
|
||
$tipo = $r['tipo'] ?? 'altro';
|
||
$tipoLabel = $tipo;
|
||
$tipoLabel = str_replace('_', ' ', (string) $tipoLabel);
|
||
$tipoLabel = ucwords($tipoLabel);
|
||
|
||
$prevTipo = $loop->first ? null : ($filteredMillesimi[$loop->index - 1]['tipo'] ?? 'altro');
|
||
@endphp
|
||
|
||
@if($loop->first || $tipo !== $prevTipo)
|
||
<tr class="bg-gray-50">
|
||
<td class="py-2 pr-4 font-semibold" colspan="3">{{ $tipoLabel }}</td>
|
||
</tr>
|
||
@endif
|
||
|
||
<tr>
|
||
<td class="py-2 pr-4 font-medium">{{ $r['codice'] }}</td>
|
||
<td class="py-2 pr-4">{{ $r['nome'] }}</td>
|
||
<td class="py-2 pr-4 text-right">{{ number_format($r['millesimi'], 4, ',', '.') }}</td>
|
||
</tr>
|
||
@empty
|
||
<tr>
|
||
<td class="py-4 text-center text-gray-500" colspan="3">Nessun millesimo presente</td>
|
||
</tr>
|
||
@endforelse
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
@endif
|
||
</x-filament::section>
|
||
@endif
|
||
|
||
@if($tab === 'persone')
|
||
<x-filament::section>
|
||
<div class="flex items-center gap-2 text-sm font-semibold text-gray-900 mb-3">
|
||
<x-filament::icon icon="heroicon-o-user-group" class="h-5 w-5 text-primary-600" />
|
||
<span>Persone collegate</span>
|
||
</div>
|
||
@php
|
||
$blocchiRelazioni = [
|
||
'proprietari' => ['label' => 'Proprietari / comproprietari', 'class' => 'text-primary-700'],
|
||
'inquilini' => ['label' => 'Inquilini / conduttori', 'class' => 'text-sky-700'],
|
||
'altri' => ['label' => 'Altri soggetti collegati', 'class' => 'text-gray-700'],
|
||
];
|
||
@endphp
|
||
<div class="space-y-3">
|
||
@foreach($blocchiRelazioni as $key => $cfg)
|
||
@php $relazioni = $relazioniPerTipo[$key] ?? []; @endphp
|
||
<div class="rounded-2xl border bg-gray-50 p-3">
|
||
<div class="mb-2 text-sm font-semibold {{ $cfg['class'] }}">{{ $cfg['label'] }} ({{ count($relazioni) }})</div>
|
||
@if(empty($relazioni))
|
||
<div class="text-sm text-gray-500">Nessun soggetto collegato.</div>
|
||
@else
|
||
<div class="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
|
||
@foreach($relazioni as $relazione)
|
||
<div class="rounded-xl border bg-white p-3 shadow-sm">
|
||
<div class="text-xs text-gray-500">{{ $relazione['tipo'] ?? 'Relazione' }}</div>
|
||
<div class="text-sm font-semibold text-gray-900">{{ $relazione['nome'] }}</div>
|
||
<div class="text-xs text-gray-500 mt-1">CF: {{ $relazione['codice_fiscale'] ?? '—' }}</div>
|
||
<div class="text-xs text-gray-500 mt-1">Quota: {{ $relazione['quota_label'] ?? '—' }}%</div>
|
||
@if(!empty($relazione['telefono']))
|
||
<div class="text-xs text-gray-500 mt-1">Telefono: {{ $relazione['telefono'] }}</div>
|
||
@endif
|
||
@if(!empty($relazione['email']))
|
||
<div class="text-xs text-gray-500 mt-1">Email: {{ $relazione['email'] }}</div>
|
||
@endif
|
||
@if(!empty($relazione['data_inizio']) || !empty($relazione['data_fine']))
|
||
<div class="text-xs text-gray-500 mt-1">
|
||
Periodo:
|
||
@if(!empty($relazione['data_inizio'])) Da {{ $relazione['data_inizio'] }} @endif
|
||
@if(!empty($relazione['data_fine'])) · fino a {{ $relazione['data_fine'] }} @endif
|
||
</div>
|
||
@endif
|
||
@if(!empty($relazione['rubrica_url']))
|
||
<div class="mt-2">
|
||
<a href="{{ $relazione['rubrica_url'] }}" class="inline-flex items-center rounded-md border border-indigo-200 bg-indigo-50 px-2 py-1 text-[11px] font-medium text-indigo-700 hover:bg-indigo-100">Apri scheda rubrica</a>
|
||
</div>
|
||
@endif
|
||
</div>
|
||
@endforeach
|
||
</div>
|
||
@endif
|
||
</div>
|
||
@endforeach
|
||
</div>
|
||
|
||
<div class="mt-6">
|
||
<div class="mb-2 text-sm font-semibold text-gray-900">Recapiti email per servizio</div>
|
||
@if(empty($recapitiServizio))
|
||
<div class="text-sm text-gray-500">Nessun recapito email disponibile.</div>
|
||
@else
|
||
<div class="grid gap-3 lg:grid-cols-2">
|
||
@foreach($recapitiServizio as $service)
|
||
<div class="rounded-2xl border bg-gray-50 p-3">
|
||
<div class="text-sm font-semibold text-gray-900">{{ $service['label'] ?? 'Servizio' }}</div>
|
||
@if(empty($service['rows']))
|
||
<div class="mt-2 text-sm text-gray-500">Nessun recapito risolto.</div>
|
||
@else
|
||
<div class="mt-2 space-y-2">
|
||
@foreach($service['rows'] as $recipient)
|
||
<div class="rounded-xl border bg-white p-3 shadow-sm">
|
||
<div class="text-sm font-semibold text-gray-900">{{ $recipient['email'] ?? '—' }}</div>
|
||
<div class="text-xs text-gray-500 mt-1">{{ $recipient['persona'] ?: 'Recapito unità' }}</div>
|
||
<div class="text-xs text-gray-500 mt-1">Origine: {{ $recipient['sourceLabel'] ?? 'Anagrafica persona' }}</div>
|
||
</div>
|
||
@endforeach
|
||
</div>
|
||
@endif
|
||
</div>
|
||
@endforeach
|
||
</div>
|
||
@endif
|
||
</div>
|
||
</x-filament::section>
|
||
@endif
|
||
|
||
@if($tab === 'acqua')
|
||
<div class="space-y-4">
|
||
<x-filament::section>
|
||
<x-slot name="heading">Storico letture acqua unità</x-slot>
|
||
<x-slot name="description">Andamento letture, consumi e richieste legate a questa utenza immobiliare.</x-slot>
|
||
|
||
<div class="grid gap-3 md:grid-cols-4">
|
||
<div class="rounded-lg border bg-gray-50 p-3">
|
||
<div class="text-xs text-gray-500">Letture registrate</div>
|
||
<div class="mt-2 text-xl font-semibold text-gray-900">{{ number_format((int) ($acquaStats['totale_letture'] ?? 0), 0, ',', '.') }}</div>
|
||
</div>
|
||
<div class="rounded-lg border bg-gray-50 p-3">
|
||
<div class="text-xs text-gray-500">Consumi storici</div>
|
||
<div class="mt-2 text-xl font-semibold text-gray-900">{{ number_format((float) ($acquaStats['totale_consumi_mc'] ?? 0), 3, ',', '.') }} mc</div>
|
||
</div>
|
||
<div class="rounded-lg border bg-gray-50 p-3">
|
||
<div class="text-xs text-gray-500">Ultima lettura</div>
|
||
<div class="mt-2 text-xl font-semibold text-gray-900">{{ isset($acquaStats['ultima_lettura']) && $acquaStats['ultima_lettura'] !== null ? number_format((float) $acquaStats['ultima_lettura'], 3, ',', '.') : '—' }}</div>
|
||
<div class="mt-1 text-[11px] text-gray-500">{{ $acquaStats['ultima_data'] ?? 'nessuna data' }}</div>
|
||
</div>
|
||
<div class="rounded-lg border bg-gray-50 p-3">
|
||
<div class="text-xs text-gray-500">Richieste aperte</div>
|
||
<div class="mt-2 text-xl font-semibold text-gray-900">{{ number_format((int) ($acquaStats['richieste_aperte'] ?? 0), 0, ',', '.') }}</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mt-4 grid gap-4 lg:grid-cols-[1.2fr_0.8fr]">
|
||
<div class="rounded-xl border bg-cyan-50 p-4">
|
||
<div class="text-sm font-semibold text-cyan-900">Utenza acqua collegata</div>
|
||
<div class="mt-2 grid gap-2 text-xs text-cyan-900 md:grid-cols-2">
|
||
<div>Servizio: <span class="font-semibold">{{ $acquaStats['servizio_label'] ?? 'non configurato' }}</span></div>
|
||
<div>Matricola: <span class="font-semibold">{{ $acquaStats['matricola'] ?? '—' }}</span></div>
|
||
<div>Seriale unità: <span class="font-semibold">{{ $unita->acqua_contatore_seriale ?? '—' }}</span></div>
|
||
<div>Gateway ID: <span class="font-semibold">{{ $unita->acqua_gateway_device_id ?? '—' }}</span></div>
|
||
<div>Codice utenza: <span class="font-semibold">{{ $acquaStats['utenza'] ?? '—' }}</span></div>
|
||
<div>Contratto: <span class="font-semibold">{{ $acquaStats['contratto'] ?? '—' }}</span></div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="rounded-xl border bg-white p-4">
|
||
<div class="text-sm font-semibold text-gray-900">Azioni rapide</div>
|
||
<div class="mt-3 flex flex-wrap gap-2">
|
||
@if(!empty($acquaQuickLinks['ticket_light']))
|
||
<a href="{{ $acquaQuickLinks['ticket_light'] }}" class="inline-flex items-center rounded-md border border-cyan-300 bg-cyan-50 px-3 py-1.5 text-xs font-medium text-cyan-800 hover:bg-cyan-100">Nuova lettura unità</a>
|
||
@endif
|
||
@if(!empty($acquaQuickLinks['archivio']))
|
||
<a href="{{ $acquaQuickLinks['archivio'] }}" class="inline-flex items-center rounded-md border border-gray-300 bg-gray-50 px-3 py-1.5 text-xs font-medium text-gray-700 hover:bg-gray-100">Archivio letture</a>
|
||
@endif
|
||
@if(!empty($acquaQuickLinks['hub_stabile']))
|
||
<a href="{{ $acquaQuickLinks['hub_stabile'] }}" class="inline-flex items-center rounded-md border border-gray-300 bg-gray-50 px-3 py-1.5 text-xs font-medium text-gray-700 hover:bg-gray-100">Campagna stabile</a>
|
||
@endif
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</x-filament::section>
|
||
|
||
<x-filament::section>
|
||
<x-slot name="heading">Dettaglio letture e consumi nel tempo</x-slot>
|
||
<x-slot name="description">Storico operativo della singola unità con canale di arrivo, riferimento e protocollo.</x-slot>
|
||
|
||
<div class="overflow-x-auto">
|
||
<table class="min-w-full text-sm">
|
||
<thead>
|
||
<tr class="border-b text-gray-500">
|
||
<th class="px-2 py-2 text-left">Data</th>
|
||
<th class="px-2 py-2 text-left">Periodo</th>
|
||
<th class="px-2 py-2 text-right">Lett. iniziale</th>
|
||
<th class="px-2 py-2 text-right">Lett. finale</th>
|
||
<th class="px-2 py-2 text-right">Consumo</th>
|
||
<th class="px-2 py-2 text-left">Canale / stato</th>
|
||
<th class="px-2 py-2 text-left">Riferimento</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
@forelse($acquaLettureStorico as $row)
|
||
<tr class="border-b border-gray-100">
|
||
<td class="px-2 py-2">{{ $row['data'] ?: '—' }}</td>
|
||
<td class="px-2 py-2">{{ $row['periodo'] ?: '—' }}</td>
|
||
<td class="px-2 py-2 text-right">{{ isset($row['lettura_inizio']) && $row['lettura_inizio'] !== null ? number_format((float) $row['lettura_inizio'], 3, ',', '.') : '—' }}</td>
|
||
<td class="px-2 py-2 text-right">{{ isset($row['lettura_fine']) && $row['lettura_fine'] !== null ? number_format((float) $row['lettura_fine'], 3, ',', '.') : '—' }}</td>
|
||
<td class="px-2 py-2 text-right">{{ isset($row['consumo_valore']) && $row['consumo_valore'] !== null ? number_format((float) $row['consumo_valore'], 3, ',', '.') . ' ' . ($row['consumo_unita'] ?? 'mc') : '—' }}</td>
|
||
<td class="px-2 py-2">
|
||
<div>{{ $row['canale'] ?: '—' }}</div>
|
||
<div class="text-[11px] text-gray-500">{{ $row['workflow'] ?: '—' }} @if(!empty($row['protocollo'])) · {{ $row['protocollo'] }} @endif</div>
|
||
</td>
|
||
<td class="px-2 py-2">
|
||
<div>{{ $row['riferimento'] ?: '—' }}</div>
|
||
@if(!empty($row['fattura_label']))
|
||
<div class="text-[11px] text-cyan-700">{{ $row['fattura_label'] }}</div>
|
||
@endif
|
||
</td>
|
||
</tr>
|
||
@empty
|
||
<tr>
|
||
<td colspan="7" class="px-2 py-6 text-center text-gray-500">Nessuna lettura acqua registrata per questa unità.</td>
|
||
</tr>
|
||
@endforelse
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
|
||
@php
|
||
$tabelleAcqua = collect($preventiviPerTabella)->filter(fn($t) => str_starts_with(strtoupper($t['codice'] ?? ''), 'AC'))->values();
|
||
$ripartiAcqua = collect($ripartizioniPerTabella)->filter(fn($t) => str_starts_with(strtoupper($t['tabella_codice'] ?? ''), 'AC'))->values();
|
||
@endphp
|
||
|
||
@if($tabelleAcqua->isNotEmpty())
|
||
<div class="mt-6">
|
||
<h3 class="text-sm font-bold text-gray-900 mb-3">Millesimi e Quote Acqua di Preventivo</h3>
|
||
<div class="space-y-4">
|
||
@foreach($tabelleAcqua as $tabella)
|
||
<div class="rounded-2xl border border-cyan-100 bg-cyan-50/20 p-4">
|
||
<div class="flex items-center justify-between mb-2">
|
||
<span class="inline-flex items-center rounded-full bg-cyan-50 px-2.5 py-0.5 text-xs font-semibold text-cyan-700">{{ $tabella['codice'] }} · {{ $tabella['nome'] }}</span>
|
||
<div class="text-right">
|
||
<div class="text-xs text-gray-500">Totale tabella</div>
|
||
<div class="text-lg font-semibold text-gray-900">{{ number_format($tabella['total_preventivo'], 2, ',', '.') }} €</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="overflow-x-auto bg-white rounded-xl border border-cyan-100 p-2">
|
||
<table class="min-w-full text-sm">
|
||
<thead>
|
||
<tr class="text-gray-500">
|
||
<th class="text-left py-1">Voce</th>
|
||
<th class="text-right py-1">Preventivo</th>
|
||
<th class="text-right py-1">Quota unità</th>
|
||
<th class="text-right py-1">Prop.</th>
|
||
<th class="text-right py-1">Inquilino</th>
|
||
<th class="text-right py-1">% Prop.</th>
|
||
<th class="text-right py-1">% Inq.</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody class="divide-y">
|
||
@foreach($tabella['voci'] as $voce)
|
||
<tr>
|
||
<td class="py-1 text-gray-800">{{ $voce['codice'] }} · {{ $voce['descrizione'] }}</td>
|
||
<td class="py-1 text-right text-gray-900">{{ number_format($voce['importo_preventivato'] ?? 0, 2, ',', '.') }} €</td>
|
||
<td class="py-1 text-right text-gray-900">{{ number_format($voce['quota_unita'] ?? 0, 2, ',', '.') }} €</td>
|
||
<td class="py-1 text-right text-gray-900">{{ number_format($voce['importo_proprietario'] ?? 0, 2, ',', '.') }} €</td>
|
||
<td class="py-1 text-right text-gray-900">{{ number_format($voce['importo_inquilino'] ?? 0, 2, ',', '.') }} €</td>
|
||
<td class="py-1 text-right text-gray-700">{{ number_format(100.00 - ($voce['percentuale_inquilino'] ?? 0), 2, ',', '.') }} %</td>
|
||
<td class="py-1 text-right text-gray-700">{{ number_format($voce['percentuale_inquilino'] ?? 0, 2, ',', '.') }} %</td>
|
||
</tr>
|
||
@endforeach
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
@endforeach
|
||
</div>
|
||
</div>
|
||
@endif
|
||
|
||
@if($ripartiAcqua->isNotEmpty())
|
||
<div class="mt-6">
|
||
<h3 class="text-sm font-bold text-gray-900 mb-3">Millesimi e Quote Acqua di Consuntivo</h3>
|
||
<div class="space-y-4">
|
||
@foreach($ripartiAcqua as $tabella)
|
||
<div class="rounded-2xl border border-cyan-100 bg-cyan-50/20 overflow-hidden">
|
||
<div class="flex items-center gap-2 bg-white px-3 py-2 border-b border-cyan-100">
|
||
<span class="inline-flex items-center rounded-full bg-cyan-50 px-2 py-0.5 text-xs font-semibold text-cyan-700">{{ $tabella['tabella_codice'] }}</span>
|
||
<span class="text-sm font-semibold text-gray-900">{{ $tabella['tabella_nome'] }}</span>
|
||
</div>
|
||
<div class="overflow-x-auto bg-white">
|
||
<table class="min-w-full text-sm">
|
||
<thead>
|
||
<tr class="text-gray-500 border-b">
|
||
<th class="text-left py-2 px-2">Voce</th>
|
||
<th class="text-center py-2 px-2">Gestione</th>
|
||
<th class="text-center py-2 px-2">Calcolo</th>
|
||
<th class="text-right py-2 px-2">% applicata</th>
|
||
<th class="text-right py-2 px-2">Quota finale</th>
|
||
<th class="text-right py-2 px-2">% prop</th>
|
||
<th class="text-right py-2 px-2">% inquilino</th>
|
||
<th class="text-right py-2 px-2">Prop.</th>
|
||
<th class="text-right py-2 px-2">Inq.</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody class="divide-y">
|
||
@foreach($tabella['righe'] as $r)
|
||
<tr>
|
||
<td class="py-2 px-2 text-gray-900 font-semibold">{{ $r['voce_codice'] ?? '—' }} {{ $r['voce_descrizione'] ?? '' }}</td>
|
||
<td class="py-2 px-2 text-center text-gray-700">{{ $r['tipo_gestione'] ?? '—' }}</td>
|
||
<td class="py-2 px-2 text-center text-gray-700">{{ $r['calcolo'] ?? '—' }}</td>
|
||
<td class="py-2 px-2 text-right text-gray-900">{{ number_format($r['percentuale_applicata'] ?? 0, 2, ',', '.') }}%</td>
|
||
<td class="py-2 px-2 text-right text-gray-900">{{ number_format($r['quota_finale'] ?? 0, 4, ',', '.') }}</td>
|
||
<td class="py-2 px-2 text-right text-gray-900">{{ number_format(100.00 - ($r['percentuale_inquilino'] ?? 0), 2, ',', '.') }}%</td>
|
||
<td class="py-2 px-2 text-right text-gray-900">{{ number_format($r['percentuale_inquilino'] ?? 0, 2, ',', '.') }}%</td>
|
||
<td class="py-2 px-2 text-right text-gray-900">{{ number_format($r['importo_proprietario'] ?? 0, 4, ',', '.') }}</td>
|
||
<td class="py-2 px-2 text-right text-gray-900">{{ number_format($r['importo_inquilino'] ?? 0, 4, ',', '.') }}</td>
|
||
</tr>
|
||
@endforeach
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
@endforeach
|
||
</div>
|
||
</div>
|
||
@endif
|
||
</x-filament::section>
|
||
</div>
|
||
@endif
|
||
|
||
|
||
@if($tab === 'economico')
|
||
<div class="grid gap-4">
|
||
{{-- Contenuti economici: preventivi/riparti (rate emesse spostate nel tab Estratto conto) --}}
|
||
|
||
@if(!empty($preventiviPerTabella))
|
||
<x-filament::section>
|
||
<div class="flex flex-wrap items-center justify-between gap-3 mb-3">
|
||
<div>
|
||
<div class="text-sm font-semibold text-gray-900">Preventivo per tabella</div>
|
||
<div class="text-xs text-gray-500">Quote unità e riparto proprietario/inquilino (dett_tab cond_inquil).</div>
|
||
</div>
|
||
@if(!empty($totaliPerGestione))
|
||
<div class="flex flex-wrap gap-2 text-sm text-gray-700">
|
||
<span class="rounded border px-3 py-1 bg-gray-50">O: {{ number_format($totaliPerGestione['O'] ?? 0, 2, ',', '.') }} €</span>
|
||
<span class="rounded border px-3 py-1 bg-gray-50">R: {{ number_format($totaliPerGestione['R'] ?? 0, 2, ',', '.') }} €</span>
|
||
<span class="rounded border px-3 py-1 bg-gray-50">S: {{ number_format($totaliPerGestione['S'] ?? 0, 2, ',', '.') }} €</span>
|
||
</div>
|
||
@endif
|
||
</div>
|
||
|
||
<div class="space-y-4">
|
||
@foreach($preventiviPerTabella as $tabella)
|
||
@if(str_starts_with(strtoupper($tabella['codice'] ?? ''), 'AC')) @continue @endif
|
||
<div class="rounded-2xl border bg-gray-50 p-4">
|
||
|
||
<div class="flex items-center justify-between mb-2">
|
||
<div>
|
||
<div class="text-xs text-gray-600">{{ $tabella['tabella_codice'] }} · tipo {{ $tabella['tipo'] }}</div>
|
||
<div class="text-sm font-semibold text-gray-900">{{ $tabella['tabella_nome'] }}</div>
|
||
</div>
|
||
<div class="text-right">
|
||
<div class="text-xs text-gray-500">Totale tabella</div>
|
||
<div class="text-lg font-semibold text-gray-900">{{ number_format($tabella['total_preventivo'], 2, ',', '.') }} €</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="overflow-x-auto">
|
||
<table class="min-w-full text-sm">
|
||
<thead>
|
||
<tr class="text-gray-500">
|
||
<th class="text-left py-1">Voce</th>
|
||
<th class="text-right py-1">Preventivo</th>
|
||
<th class="text-right py-1">Quota unità</th>
|
||
<th class="text-right py-1">Prop.</th>
|
||
<th class="text-right py-1">Inquilino</th>
|
||
<th class="text-right py-1">% Prop.</th>
|
||
<th class="text-right py-1">% Inq.</th>
|
||
</tr>
|
||
</thead>
|
||
|
||
<tbody class="divide-y">
|
||
@foreach($tabella['voci'] as $voce)
|
||
<tr>
|
||
<td class="py-1 text-gray-800">{{ $voce['codice'] }} · {{ $voce['descrizione'] }}</td>
|
||
<td class="py-1 text-right text-gray-900">{{ number_format($voce['importo_preventivato'] ?? 0, 2, ',', '.') }} €</td>
|
||
<td class="py-1 text-right text-gray-900">{{ number_format($voce['quota_unita'] ?? 0, 2, ',', '.') }} €</td>
|
||
<td class="py-1 text-right text-gray-900">{{ number_format($voce['importo_proprietario'] ?? 0, 2, ',', '.') }} €</td>
|
||
<td class="py-1 text-right text-gray-900">{{ number_format($voce['importo_inquilino'] ?? 0, 2, ',', '.') }} €</td>
|
||
<td class="py-1 text-right text-gray-700">{{ number_format($voce['percentuale_inquilino'] ?? 0, 2, ',', '.') }} %</td>
|
||
</tr>
|
||
@endforeach
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="mt-3 grid grid-cols-1 md:grid-cols-3 gap-3 text-sm">
|
||
<div class="rounded border bg-white p-3">
|
||
<div class="text-gray-500">Millesimi unità / tabella</div>
|
||
<div class="font-semibold text-gray-900">{{ number_format($tabella['unit_millesimi'], 3, ',', '.') }} / {{ number_format($tabella['tabella_millesimi'], 3, ',', '.') }}</div>
|
||
</div>
|
||
<div class="rounded border bg-white p-3">
|
||
<div class="text-gray-500">Quota unità</div>
|
||
<div class="font-semibold text-gray-900">{{ number_format($tabella['quota_unit'], 2, ',', '.') }} €</div>
|
||
</div>
|
||
<div class="rounded border bg-white p-3">
|
||
<div class="text-gray-500">Riparto proprietario / inquilino</div>
|
||
<div class="font-semibold text-gray-900">{{ number_format($tabella['importo_proprietario'], 2, ',', '.') }} € / {{ number_format($tabella['importo_inquilino'], 2, ',', '.') }} €</div>
|
||
<div class="text-xs text-gray-500">% inquilino: {{ number_format($tabella['percentuale_inquilino'] ?? 0, 2, ',', '.') }}</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
@endforeach
|
||
</div>
|
||
</x-filament::section>
|
||
@endif
|
||
|
||
<x-filament::section>
|
||
<div class="flex items-center gap-2 text-sm font-semibold text-gray-900 mb-3">
|
||
<x-filament::icon icon="heroicon-o-banknotes" class="h-5 w-5 text-emerald-600" />
|
||
<span>Voci di spesa per tabella (prop. / inq.)</span>
|
||
</div>
|
||
@if(empty($ripartizioniPerTabella))
|
||
<div class="text-sm text-gray-500">Nessuna ripartizione registrata per questa unità.</div>
|
||
@else
|
||
<div class="space-y-3">
|
||
@foreach($ripartizioniPerTabella as $tabella)
|
||
@if(str_starts_with(strtoupper($tabella['tabella_codice'] ?? ''), 'AC')) @continue @endif
|
||
<div class="rounded-2xl border bg-gray-50 overflow-hidden">
|
||
|
||
<div class="flex items-center gap-2 bg-white px-3 py-2 border-b">
|
||
<span class="inline-flex items-center rounded-full border border-primary-200 bg-primary-50 px-2 py-0.5 text-xs font-semibold text-primary-700">{{ $tabella['tabella_codice'] }}</span>
|
||
<span class="text-sm font-semibold text-gray-900">{{ $tabella['tabella_nome'] }}</span>
|
||
</div>
|
||
<div class="overflow-x-auto">
|
||
<table class="min-w-full text-sm">
|
||
<thead>
|
||
<tr class="text-gray-500 border-b">
|
||
<th class="text-left py-2 px-2">Voce</th>
|
||
<th class="text-center py-2 px-2">Gestione</th>
|
||
<th class="text-center py-2 px-2">Calcolo</th>
|
||
<th class="text-right py-2 px-2">% applicata</th>
|
||
<th class="text-right py-2 px-2">Quota finale</th>
|
||
<th class="text-right py-2 px-2">% prop</th>
|
||
<th class="text-right py-2 px-2">% inquilino</th>
|
||
<th class="text-right py-2 px-2">Prop.</th>
|
||
<th class="text-right py-2 px-2">Inq.</th>
|
||
</tr>
|
||
</thead>
|
||
|
||
<tbody class="divide-y">
|
||
@foreach($tabella['righe'] as $r)
|
||
<tr>
|
||
<td class="py-2 px-2 text-gray-900 font-semibold">{{ $r['voce_codice'] ?? '—' }} {{ $r['voce_descrizione'] ?? '' }}</td>
|
||
<td class="py-2 px-2 text-center text-gray-700">{{ $r['tipo_gestione'] ?? '—' }}</td>
|
||
<td class="py-2 px-2 text-center text-gray-700">{{ $r['calcolo'] ?? '—' }}</td>
|
||
<td class="py-2 px-2 text-right text-gray-900">{{ number_format($r['percentuale_applicata'] ?? 0, 2, ',', '.') }}%</td>
|
||
<td class="py-2 px-2 text-right text-gray-900">{{ number_format($r['quota_finale'] ?? 0, 4, ',', '.') }}</td>
|
||
<td class="py-2 px-2 text-right text-gray-900">{{ number_format(100.00 - ($r['percentuale_inquilino'] ?? 0), 2, ',', '.') }}%</td>
|
||
<td class="py-2 px-2 text-right text-gray-900">{{ number_format($r['percentuale_inquilino'] ?? 0, 2, ',', '.') }}%</td>
|
||
<td class="py-2 px-2 text-right text-gray-900">{{ number_format($r['importo_proprietario'] ?? 0, 4, ',', '.') }}</td>
|
||
<td class="py-2 px-2 text-right text-gray-900">{{ number_format($r['importo_inquilino'] ?? 0, 4, ',', '.') }}</td>
|
||
</tr>
|
||
|
||
@endforeach
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
@endforeach
|
||
</div>
|
||
@if($tab === 'estratto')
|
||
@php
|
||
$rateCondomini = $rateEmessePerCategoria['condomini'] ?? [];
|
||
$rateInquilini = $rateEmessePerCategoria['inquilini'] ?? [];
|
||
|
||
$sumBlk = function (array $items, string $field): float {
|
||
$s = 0.0;
|
||
foreach ($items as $it) {
|
||
$s += (float) ($it[$field] ?? 0);
|
||
}
|
||
return $s;
|
||
};
|
||
|
||
$totCAddeb = $sumBlk($rateCondomini, 'totale_addebitato');
|
||
$totCPag = $sumBlk($rateCondomini, 'totale_pagato');
|
||
$totCRes = $sumBlk($rateCondomini, 'residuo');
|
||
|
||
$totIAddeb = $sumBlk($rateInquilini, 'totale_addebitato');
|
||
$totIPag = $sumBlk($rateInquilini, 'totale_pagato');
|
||
$totIRes = $sumBlk($rateInquilini, 'residuo');
|
||
|
||
if (empty($rateCondomini) && empty($rateInquilini)) {
|
||
$totCAddeb = (float) collect($estrattoRateRowsProprietario ?? [])->sum('dovuto');
|
||
$totCPag = (float) collect($estrattoIncassiProprietario ?? [])->sum('importo');
|
||
$totCRes = $totCAddeb - $totCPag;
|
||
|
||
$totIAddeb = (float) collect($estrattoRateRowsInquilino ?? [])->sum('dovuto');
|
||
$totIPag = (float) collect($estrattoIncassiInquilino ?? [])->sum('importo');
|
||
$totIRes = $totIAddeb - $totIPag;
|
||
}
|
||
@endphp
|
||
|
||
<div class="space-y-6">
|
||
<!-- SEZIONE PROPRIETARIO (C) -->
|
||
<x-filament::section>
|
||
<div class="flex items-center justify-between border-b pb-2 mb-4">
|
||
<div class="flex items-center gap-2 text-sm font-semibold text-gray-900">
|
||
<x-filament::icon icon="heroicon-o-user" class="h-5 w-5 text-primary-600" />
|
||
<span>Estratto Conto PROPRIETARIO (Condòmino - C)</span>
|
||
</div>
|
||
<div class="text-right text-xs">
|
||
<span class="font-medium text-gray-500">Addebito:</span> <span class="font-bold text-gray-900">{{ number_format($totCAddeb, 2, ',', '.') }} €</span> ·
|
||
<span class="font-medium text-gray-500">Pagato:</span> <span class="font-bold text-emerald-600">{{ number_format($totCPag, 2, ',', '.') }} €</span> ·
|
||
<span class="font-medium text-gray-500">Residuo:</span> <span class="font-bold text-amber-600">{{ number_format($totCRes, 2, ',', '.') }} €</span>
|
||
</div>
|
||
</div>
|
||
|
||
@php
|
||
$movimentiC = [];
|
||
$seenC = [];
|
||
foreach ($estrattoRateRowsProprietario ?? [] as $r) {
|
||
$k = ($r['gestione']??'').'|'.($r['data_emissione']??'').'|'.($r['descrizione']??'').'|'.number_format((float)($r['dovuto']??0), 2, '.', '');
|
||
if(isset($seenC[$k])) continue;
|
||
$seenC[$k] = true;
|
||
$movimentiC[] = [
|
||
'tipo' => 'rata',
|
||
'data' => $r['data_emissione'] ?? null,
|
||
'descrizione' => $r['descrizione'] ?? '',
|
||
'ref' => !empty($r['avviso']) ? ('Avv. ' . $r['avviso']) : '',
|
||
'dovuto' => (float)$r['dovuto'],
|
||
'incasso' => (float)$r['pagato'],
|
||
'residuo' => (float)$r['residuo'],
|
||
'gestione' => $r['gestione'] ?? 'Ordinaria',
|
||
];
|
||
}
|
||
foreach ($estrattoIncassiProprietario ?? [] as $i) {
|
||
$k = ($i['data']??'').'|'.($i['descrizione']??'').'|'.number_format((float)($i['importo']??0), 2, '.', '');
|
||
if(isset($seenC[$k])) continue;
|
||
$seenC[$k] = true;
|
||
$movimentiC[] = [
|
||
'tipo' => 'incasso',
|
||
'data' => $i['data'] ?? null,
|
||
'descrizione' => $i['descrizione'] ?? '',
|
||
'ref' => !empty($i['n_ricevuta']) ? ('Ric. ' . $i['n_ricevuta']) : '',
|
||
'dovuto' => null,
|
||
'incasso' => (float)$i['importo'],
|
||
'residuo' => null,
|
||
'gestione' => $i['gestione'] ?? 'Ordinaria',
|
||
];
|
||
}
|
||
foreach ($estrattoConguagliIniziali ?? [] as $c) {
|
||
$importo = (float)($c['importo'] ?? 0);
|
||
if(abs($importo) < 0.0001) continue;
|
||
$movimentiC[] = [
|
||
'tipo' => 'conguaglio',
|
||
'data' => $c['data'] ?? null,
|
||
'descrizione' => $c['descrizione'] ?? '',
|
||
'ref' => trim(($c['gestione_label'] ?? '') . ' ' . ($c['tipo'] ?? '')),
|
||
'dovuto' => $importo,
|
||
'incasso' => null,
|
||
'residuo' => $importo,
|
||
'gestione' => $c['gestione_label'] ?? 'Ordinaria',
|
||
];
|
||
}
|
||
usort($movimentiC, function($a, $b){
|
||
$da = $a['data'] ? \Carbon\Carbon::createFromFormat('d/m/Y', $a['data'])->timestamp : 0;
|
||
$db = $b['data'] ? \Carbon\Carbon::createFromFormat('d/m/Y', $b['data'])->timestamp : 0;
|
||
return $da <=> $db;
|
||
});
|
||
@endphp
|
||
|
||
@if(empty($movimentiC))
|
||
<div class="text-xs text-gray-500 py-2">Nessuna rata o incasso registrato per il proprietario.</div>
|
||
@else
|
||
<div class="overflow-x-auto rounded-xl border">
|
||
<table class="min-w-full text-xs">
|
||
<thead class="bg-gray-50 border-b">
|
||
<tr>
|
||
<th class="text-left py-2 px-3 text-gray-600">Data</th>
|
||
<th class="text-left py-2 px-3 text-gray-600">Tipo</th>
|
||
<th class="text-left py-2 px-3 text-gray-600">Descrizione</th>
|
||
<th class="text-left py-2 px-3 text-gray-600">Rif.</th>
|
||
<th class="text-right py-2 px-3 text-gray-600">Dovuto</th>
|
||
<th class="text-right py-2 px-3 text-gray-600">Pagato</th>
|
||
<th class="text-right py-2 px-3 text-gray-600">Residuo</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody class="divide-y">
|
||
@foreach($movimentiC as $m)
|
||
<tr>
|
||
<td class="py-2 px-3">{{ $m['data'] ?? '—' }}</td>
|
||
<td class="py-2 px-3 font-semibold">{{ $m['tipo'] === 'rata' ? 'Rata' : ($m['tipo'] === 'conguaglio' ? 'Conguaglio' : 'Incasso') }}</td>
|
||
<td class="py-2 px-3 text-gray-900">{{ $m['descrizione'] }}</td>
|
||
<td class="py-2 px-3 text-gray-500">{{ $m['ref'] ?: '—' }}</td>
|
||
<td class="py-2 px-3 text-right tabular-nums">{{ $m['dovuto'] !== null ? number_format($m['dovuto'], 2, ',', '.') . ' €' : '—' }}</td>
|
||
<td class="py-2 px-3 text-right tabular-nums">{{ $m['incasso'] !== null ? number_format($m['incasso'], 2, ',', '.') . ' €' : '—' }}</td>
|
||
<td class="py-2 px-3 text-right tabular-nums font-semibold">{{ $m['residuo'] !== null ? number_format($m['residuo'], 2, ',', '.') . ' €' : '—' }}</td>
|
||
</tr>
|
||
@endforeach
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
@endif
|
||
|
||
@if(!empty($rateCondomini))
|
||
<div class="mt-4 border-t pt-3">
|
||
<div class="text-xs font-semibold text-gray-700 mb-2">Schede anagrafiche collegate:</div>
|
||
<div class="grid gap-2 sm:grid-cols-2 lg:grid-cols-3">
|
||
@foreach($rateCondomini as $rc)
|
||
@php
|
||
$sid = (int) ($rc['soggetto_id'] ?? 0);
|
||
$url = $sid > 0 ? \App\Filament\Pages\Contabilita\EstrattoContoSoggetto::getUrl(panel: 'admin-filament', parameters: ['record' => $sid]) . '?' . http_build_query(['vista' => 'unita', 'unita_id' => (int) ($this->unita?->id ?? 0)]) : null;
|
||
@endphp
|
||
<div class="p-2 border rounded-lg bg-gray-50/50 flex justify-between items-center text-xs">
|
||
<div>
|
||
<div class="font-bold text-gray-900">{{ $rc['nome'] }}</div>
|
||
<div class="text-[10px] text-gray-500">Addebito: {{ number_format($rc['totale_addebitato'], 2, ',', '.') }} €</div>
|
||
</div>
|
||
@if($url)
|
||
<a href="{{ $url }}" class="px-2 py-1 bg-white hover:bg-gray-100 border rounded text-[10px] font-semibold">Apri scheda</a>
|
||
@endif
|
||
</div>
|
||
@endforeach
|
||
</div>
|
||
</div>
|
||
@endif
|
||
</x-filament::section>
|
||
|
||
<!-- SEZIONE INQUILINO (I) -->
|
||
<x-filament::section>
|
||
<div class="flex items-center justify-between border-b pb-2 mb-4">
|
||
<div class="flex items-center gap-2 text-sm font-semibold text-gray-900">
|
||
<x-filament::icon icon="heroicon-o-users" class="h-5 w-5 text-emerald-600" />
|
||
<span>Estratto Conto CONDUTTORE (Inquilino - I)</span>
|
||
</div>
|
||
<div class="text-right text-xs">
|
||
<span class="font-medium text-gray-500">Addebito:</span> <span class="font-bold text-gray-900">{{ number_format($totIAddeb, 2, ',', '.') }} €</span> ·
|
||
<span class="font-medium text-gray-500">Pagato:</span> <span class="font-bold text-emerald-600">{{ number_format($totIPag, 2, ',', '.') }} €</span> ·
|
||
<span class="font-medium text-gray-500">Residuo:</span> <span class="font-bold text-amber-600">{{ number_format($totIRes, 2, ',', '.') }} €</span>
|
||
</div>
|
||
</div>
|
||
|
||
@php
|
||
$movimentiI = [];
|
||
$seenI = [];
|
||
foreach ($estrattoRateRowsInquilino ?? [] as $r) {
|
||
$k = ($r['gestione']??'').'|'.($r['data_emissione']??'').'|'.($r['descrizione']??'').'|'.number_format((float)($r['dovuto']??0), 2, '.', '');
|
||
if(isset($seenI[$k])) continue;
|
||
$seenI[$k] = true;
|
||
$movimentiI[] = [
|
||
'tipo' => 'rata',
|
||
'data' => $r['data_emissione'] ?? null,
|
||
'descrizione' => $r['descrizione'] ?? '',
|
||
'ref' => !empty($r['avviso']) ? ('Avv. ' . $r['avviso']) : '',
|
||
'dovuto' => (float)$r['dovuto'],
|
||
'incasso' => (float)$r['pagato'],
|
||
'residuo' => (float)$r['residuo'],
|
||
'gestione' => $r['gestione'] ?? 'Ordinaria',
|
||
];
|
||
}
|
||
foreach ($estrattoIncassiInquilino ?? [] as $i) {
|
||
$k = ($i['data']??'').'|'.($i['descrizione']??'').'|'.number_format((float)($i['importo']??0), 2, '.', '');
|
||
if(isset($seenI[$k])) continue;
|
||
$seenI[$k] = true;
|
||
$movimentiI[] = [
|
||
'tipo' => 'incasso',
|
||
'data' => $i['data'] ?? null,
|
||
'descrizione' => $i['descrizione'] ?? '',
|
||
'ref' => !empty($i['n_ricevuta']) ? ('Ric. ' . $i['n_ricevuta']) : '',
|
||
'dovuto' => null,
|
||
'incasso' => (float)$i['importo'],
|
||
'residuo' => null,
|
||
'gestione' => $i['gestione'] ?? 'Ordinaria',
|
||
];
|
||
}
|
||
usort($movimentiI, function($a, $b){
|
||
$da = $a['data'] ? \Carbon\Carbon::createFromFormat('d/m/Y', $a['data'])->timestamp : 0;
|
||
$db = $b['data'] ? \Carbon\Carbon::createFromFormat('d/m/Y', $b['data'])->timestamp : 0;
|
||
return $da <=> $db;
|
||
});
|
||
@endphp
|
||
|
||
@if(empty($movimentiI))
|
||
<div class="text-xs text-gray-500 py-2">Nessuna rata o incasso registrato per l'inquilino.</div>
|
||
@else
|
||
<div class="overflow-x-auto rounded-xl border">
|
||
<table class="min-w-full text-xs">
|
||
<thead class="bg-gray-50 border-b">
|
||
<tr>
|
||
<th class="text-left py-2 px-3 text-gray-600">Data</th>
|
||
<th class="text-left py-2 px-3 text-gray-600">Tipo</th>
|
||
<th class="text-left py-2 px-3 text-gray-600">Descrizione</th>
|
||
<th class="text-left py-2 px-3 text-gray-600">Rif.</th>
|
||
<th class="text-right py-2 px-3 text-gray-600">Dovuto</th>
|
||
<th class="text-right py-2 px-3 text-gray-600">Pagato</th>
|
||
<th class="text-right py-2 px-3 text-gray-600">Residuo</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody class="divide-y">
|
||
@foreach($movimentiI as $m)
|
||
<tr>
|
||
<td class="py-2 px-3">{{ $m['data'] ?? '—' }}</td>
|
||
<td class="py-2 px-3 font-semibold">{{ $m['tipo'] === 'rata' ? 'Rata' : 'Incasso' }}</td>
|
||
<td class="py-2 px-3 text-gray-900">{{ $m['descrizione'] }}</td>
|
||
<td class="py-2 px-3 text-gray-500">{{ $m['ref'] ?: '—' }}</td>
|
||
<td class="py-2 px-3 text-right tabular-nums">{{ $m['dovuto'] !== null ? number_format($m['dovuto'], 2, ',', '.') . ' €' : '—' }}</td>
|
||
<td class="py-2 px-3 text-right tabular-nums">{{ $m['incasso'] !== null ? number_format($m['incasso'], 2, ',', '.') . ' €' : '—' }}</td>
|
||
<td class="py-2 px-3 text-right tabular-nums font-semibold">{{ $m['residuo'] !== null ? number_format($m['residuo'], 2, ',', '.') . ' €' : '—' }}</td>
|
||
</tr>
|
||
@endforeach
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
@endif
|
||
|
||
@if(!empty($rateInquilini))
|
||
<div class="mt-4 border-t pt-3">
|
||
<div class="text-xs font-semibold text-gray-700 mb-2">Schede anagrafiche collegate:</div>
|
||
<div class="grid gap-2 sm:grid-cols-2 lg:grid-cols-3">
|
||
@foreach($rateInquilini as $ri)
|
||
@php
|
||
$sid = (int) ($ri['soggetto_id'] ?? 0);
|
||
$url = $sid > 0 ? \App\Filament\Pages\Contabilita\EstrattoContoSoggetto::getUrl(panel: 'admin-filament', parameters: ['record' => $sid]) . '?' . http_build_query(['vista' => 'unita', 'unita_id' => (int) ($this->unita?->id ?? 0)]) : null;
|
||
@endphp
|
||
<div class="p-2 border rounded-lg bg-gray-50/50 flex justify-between items-center text-xs">
|
||
<div>
|
||
<div class="font-bold text-gray-900">{{ $ri['nome'] }}</div>
|
||
<div class="text-[10px] text-gray-500">Addebito: {{ number_format($ri['totale_addebitato'], 2, ',', '.') }} €</div>
|
||
</div>
|
||
@if($url)
|
||
<a href="{{ $url }}" class="px-2 py-1 bg-white hover:bg-gray-100 border rounded text-[10px] font-semibold">Apri scheda</a>
|
||
@endif
|
||
</div>
|
||
@endforeach
|
||
</div>
|
||
</div>
|
||
@endif
|
||
</x-filament::section>
|
||
</div>
|
||
@endif </a>
|
||
</div>
|
||
</div>
|
||
@endif
|
||
</x-filament::section>
|
||
@endif
|
||
|
||
</div>
|
||
</x-filament::section>
|
||
@endif
|
||
</div>
|
||
</x-filament-panels::page>
|