netgescon-day0/resources/views/filament/pages/condomini/tabelle-millesimali-tab.blade.php

118 lines
6.2 KiB
PHP

<div class="space-y-6">
@php
$tabelle = $stabile
->tabelleMillesimali()
->orderByRaw('COALESCE(nord, 999999)')
->orderBy('ordinamento')
->orderBy('nome_tabella')
->get();
$voci = $stabile
->vociSpesa()
->with('tabellaMillesimaleDefault')
->orderBy('ordinamento')
->orderBy('descrizione')
->get();
@endphp
<div class="flex flex-wrap items-center justify-between gap-3">
<div>
<div class="text-lg font-semibold text-gray-900">Tabelle millesimali</div>
<div class="text-sm text-gray-500">Dati reali importati per lo stabile corrente.</div>
</div>
<div class="flex flex-wrap gap-2">
<a class="fi-btn fi-btn-color-gray fi-btn-size-sm" href="{{ \App\Filament\Pages\Condomini\TabelleMillesimaliProspetto::getUrl(panel: 'admin-filament') }}">
<span class="fi-btn-label">Apri prospetto millesimi</span>
</a>
</div>
</div>
<div class="rounded-xl border bg-white">
<div class="border-b px-4 py-3 text-sm font-semibold text-gray-700">Elenco tabelle ({{ $tabelle->count() }})</div>
<div class="overflow-x-auto">
<table class="min-w-full text-sm">
<thead class="bg-gray-50 text-xs uppercase text-gray-500">
<tr>
<th class="px-4 py-2 text-left">Codice</th>
<th class="px-4 py-2 text-left">Denominazione</th>
<th class="px-4 py-2 text-left">Tipo</th>
<th class="px-4 py-2 text-right">Totale millesimi</th>
<th class="px-4 py-2 text-right">NORD</th>
<th class="px-4 py-2 text-left">Stato</th>
</tr>
</thead>
<tbody class="divide-y">
@forelse($tabelle as $tabella)
@php
$nome = trim((string) ($tabella->denominazione ?? ''));
if ($nome === '') {
$nome = trim((string) ($tabella->nome_tabella ?? ''));
}
if ($nome === '') {
$nome = trim((string) ($tabella->codice_tabella ?? 'Tabella'));
}
$tipo = trim((string) ($tabella->tipo_tabella ?? $tabella->tipo ?? ''));
$stato = $tabella->stato_tabella ?? ($tabella->attiva ? 'attiva' : 'sospesa');
@endphp
<tr>
<td class="px-4 py-2 font-medium text-gray-900">{{ $tabella->codice_tabella ?? '—' }}</td>
<td class="px-4 py-2 text-gray-700">
<div class="font-medium">{{ $nome }}</div>
@if(!empty($tabella->descrizione))
<div class="text-xs text-gray-500">{{ $tabella->descrizione }}</div>
@endif
</td>
<td class="px-4 py-2 text-gray-700">
<span class="inline-flex rounded-full bg-blue-50 px-2 py-0.5 text-xs font-semibold text-blue-700">{{ strtoupper($tipo ?: '—') }}</span>
</td>
<td class="px-4 py-2 text-right text-gray-900">{{ number_format((float) ($tabella->totale_millesimi ?? 0), 4, ',', '.') }}</td>
<td class="px-4 py-2 text-right text-gray-700">{{ $tabella->nord ?? '—' }}</td>
<td class="px-4 py-2 text-gray-700">{{ strtoupper((string) $stato) }}</td>
</tr>
@empty
<tr>
<td colspan="6" class="px-4 py-6 text-center text-sm text-gray-500">Nessuna tabella millesimale trovata.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
<div class="rounded-xl border bg-white">
<div class="border-b px-4 py-3 text-sm font-semibold text-gray-700">Voci di spesa ({{ $voci->count() }})</div>
<div class="overflow-x-auto">
<table class="min-w-full text-sm">
<thead class="bg-gray-50 text-xs uppercase text-gray-500">
<tr>
<th class="px-4 py-2 text-left">Codice</th>
<th class="px-4 py-2 text-left">Descrizione</th>
<th class="px-4 py-2 text-left">Tabella</th>
<th class="px-4 py-2 text-right">Preventivo </th>
<th class="px-4 py-2 text-right">Consuntivo </th>
</tr>
</thead>
<tbody class="divide-y">
@forelse($voci as $voce)
@php
$tabella = $voce->tabellaMillesimaleDefault;
$tabellaLabel = $tabella?->codice_tabella ?? $tabella?->nome_tabella ?? $tabella?->denominazione ?? '—';
@endphp
<tr>
<td class="px-4 py-2 font-medium text-gray-900">{{ $voce->codice ?? '—' }}</td>
<td class="px-4 py-2 text-gray-700">{{ $voce->descrizione ?? '—' }}</td>
<td class="px-4 py-2 text-gray-700">{{ $tabellaLabel }}</td>
<td class="px-4 py-2 text-right text-gray-900">{{ number_format((float) ($voce->preventivo_euro ?? 0), 2, ',', '.') }}</td>
<td class="px-4 py-2 text-right text-gray-700">{{ number_format((float) ($voce->consuntivo_euro ?? 0), 2, ',', '.') }}</td>
</tr>
@empty
<tr>
<td colspan="5" class="px-4 py-6 text-center text-sm text-gray-500">Nessuna voce di spesa trovata.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>