271 lines
16 KiB
PHP
271 lines
16 KiB
PHP
<x-filament-panels::page>
|
|
@php
|
|
$baseQuery = request()->query();
|
|
unset($baseQuery['palazzina_id'], $baseQuery['unita_id']);
|
|
|
|
$buildUrl = function (array $params) use ($baseQuery): string {
|
|
$query = array_merge($baseQuery, $params);
|
|
return static::getUrl() . (empty($query) ? '' : ('?' . http_build_query($query)));
|
|
};
|
|
@endphp
|
|
|
|
<div class="mx-auto max-w-7xl space-y-4">
|
|
<x-filament::section class="p-4!">
|
|
@include('filament.components.page-breadcrumbs', [
|
|
'breadcrumbs' => [
|
|
['label' => 'Condomini', 'url' => route('admin.dashboards.condomini')],
|
|
['label' => 'Palazzine', 'url' => \App\Filament\Pages\Condomini\PalazzineArchivio::getUrl(panel: 'admin-filament')],
|
|
['label' => 'Interni'],
|
|
],
|
|
'backUrl' => $this->getBackUrl(),
|
|
'backLabel' => 'Torna indietro',
|
|
])
|
|
|
|
<div class="mt-3 flex items-start justify-between gap-4 flex-wrap">
|
|
<div class="space-y-1">
|
|
<div class="flex items-center gap-2 text-lg font-semibold text-gray-900">
|
|
<x-filament::icon icon="heroicon-o-building-office-2" class="h-5 w-5 text-primary-600" />
|
|
<span>Palazzine · Interni</span>
|
|
</div>
|
|
<div class="text-sm text-gray-700">Seleziona una palazzina e poi un interno per aprire la scheda unità e vedere le tabelle millesimali collegate.</div>
|
|
</div>
|
|
|
|
@if(!empty($palazzine))
|
|
<div class="min-w-70">
|
|
<div class="text-xs text-gray-500 mb-1">Palazzina</div>
|
|
<select
|
|
class="fi-input block w-full"
|
|
onchange="window.location = @js($buildUrl(['palazzina_id' => '__PAL__'])) . ''.replace('__PAL__', this.value)"
|
|
>
|
|
@foreach($palazzine as $p)
|
|
<option value="{{ $p['id'] }}" @selected((int) $palazzinaId === (int) $p['id'])>
|
|
{{ $p['codice'] }} — {{ $p['nome'] }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
@endif
|
|
</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">Selezione interno</x-slot>
|
|
<x-slot name="description">Scala / piano / interno</x-slot>
|
|
|
|
<div class="mb-3 flex items-end justify-between gap-3 flex-wrap">
|
|
<div class="text-xs text-gray-500">
|
|
Seleziona una o più unità con la checkbox e applica modifiche in blocco.
|
|
</div>
|
|
<div class="flex items-end gap-2">
|
|
<div>
|
|
<div class="text-xs text-gray-500 mb-1">Scala</div>
|
|
<input
|
|
type="text"
|
|
class="fi-input block w-20"
|
|
placeholder="A"
|
|
wire:model.defer="bulkScala"
|
|
/>
|
|
</div>
|
|
<button
|
|
type="button"
|
|
class="fi-btn fi-btn-color-primary fi-btn-size-sm"
|
|
wire:click="bulkSetScala"
|
|
>
|
|
Associa scala
|
|
</button>
|
|
|
|
<div class="hidden sm:block w-px bg-gray-200 h-7"></div>
|
|
|
|
<div>
|
|
<div class="text-xs text-gray-500 mb-1">Piano</div>
|
|
<input
|
|
type="number"
|
|
class="fi-input block w-24"
|
|
wire:model.defer="bulkPiano"
|
|
/>
|
|
</div>
|
|
<button
|
|
type="button"
|
|
class="fi-btn fi-btn-color-primary fi-btn-size-sm"
|
|
wire:click="bulkSetPiano"
|
|
>
|
|
Associa piano
|
|
</button>
|
|
|
|
<div class="hidden sm:block w-px bg-gray-200 h-7"></div>
|
|
|
|
<div class="min-w-56">
|
|
<div class="text-xs text-gray-500 mb-1">Tipologia</div>
|
|
<select class="fi-input block w-full" wire:model.defer="bulkTipologiaId">
|
|
<option value="">—</option>
|
|
@foreach($this->getTipologieOptions() as $id => $label)
|
|
<option value="{{ $id }}">{{ $label }}</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
|
|
<div>
|
|
<div class="text-xs text-gray-500 mb-1">Catasto</div>
|
|
<input
|
|
type="text"
|
|
class="fi-input block w-28"
|
|
placeholder="A/2"
|
|
wire:model.defer="bulkCategoriaCatastale"
|
|
/>
|
|
</div>
|
|
|
|
<button
|
|
type="button"
|
|
class="fi-btn fi-btn-color-primary fi-btn-size-sm"
|
|
wire:click="bulkSetTipologiaCatasto"
|
|
>
|
|
Applica tipologia
|
|
</button>
|
|
<div class="text-xs text-gray-500">Selezionate: {{ is_array($selectedUnitaIds ?? null) ? count($selectedUnitaIds) : 0 }}</div>
|
|
</div>
|
|
</div>
|
|
|
|
@if(empty($unitaPerScalaPiano))
|
|
<div class="rounded-xl border border-dashed border-gray-200 bg-white p-6 text-center text-gray-500">Nessuna unità per questa palazzina.</div>
|
|
@else
|
|
<div class="space-y-4">
|
|
@foreach($unitaPerScalaPiano as $scala => $piani)
|
|
<div class="rounded-2xl border bg-white">
|
|
<div class="flex items-center justify-between gap-3 border-b px-4 py-3">
|
|
<div class="text-sm font-semibold text-gray-900">Scala {{ $scala }}</div>
|
|
<div class="text-xs text-gray-500">Clicca un interno</div>
|
|
</div>
|
|
|
|
<div class="p-4 space-y-3">
|
|
@foreach($piani as $piano => $unita)
|
|
<div class="rounded-xl border bg-gray-50 p-3">
|
|
<div class="mb-2 flex items-center justify-between">
|
|
<div class="text-xs font-semibold text-gray-700">Piano {{ $piano }}</div>
|
|
<div class="text-xs text-gray-500">{{ count($unita) }} unità</div>
|
|
</div>
|
|
|
|
<div class="grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
|
@foreach($unita as $u)
|
|
@php $selected = (int) $unitaId === (int) $u['id']; @endphp
|
|
<div class="rounded-lg border p-2 transition overflow-hidden
|
|
{{ $selected ? 'border-primary-300 bg-primary-50 shadow-sm' : 'border-gray-200 bg-white hover:bg-gray-50' }}"
|
|
>
|
|
<div class="flex items-start justify-between gap-2">
|
|
<label class="inline-flex items-center gap-2">
|
|
<input
|
|
type="checkbox"
|
|
class="h-4 w-4 rounded border-gray-300"
|
|
wire:model="selectedUnitaIds"
|
|
value="{{ (int) $u['id'] }}"
|
|
/>
|
|
<a
|
|
href="{{ $buildUrl(['palazzina_id' => (int) $palazzinaId, 'unita_id' => (int) $u['id']]) }}"
|
|
class="text-sm font-semibold leading-5
|
|
{{ $selected ? 'text-primary-700' : 'text-gray-900' }}"
|
|
>
|
|
Int. {{ $u['interno'] }}
|
|
</a>
|
|
</label>
|
|
|
|
<div class="text-[11px] text-gray-500 whitespace-nowrap max-w-32 truncate text-right">
|
|
{{ $u['codice'] }}
|
|
</div>
|
|
</div>
|
|
|
|
@if(!empty($u['proprietario']) || !empty($u['inquilino']))
|
|
<div class="mt-1 space-y-0.5">
|
|
@if(!empty($u['proprietario']))
|
|
<div class="text-xs text-gray-700 truncate" title="{{ $u['proprietario'] }}">
|
|
{{ $u['proprietario'] }}
|
|
</div>
|
|
@endif
|
|
@if(!empty($u['inquilino']))
|
|
<div class="text-xs text-gray-500 truncate" title="{{ $u['inquilino'] }}">
|
|
Inq. {{ $u['inquilino'] }}
|
|
</div>
|
|
@endif
|
|
</div>
|
|
@endif
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
@endif
|
|
</x-filament::section>
|
|
|
|
<x-filament::section>
|
|
<x-slot name="heading">Dettaglio unità</x-slot>
|
|
<x-slot name="description">Tabelle millesimali associate</x-slot>
|
|
|
|
@if(!$unitaId)
|
|
<div class="text-sm text-gray-500">Seleziona un interno per vedere i dettagli.</div>
|
|
@else
|
|
<div class="space-y-3">
|
|
<div class="flex items-center justify-between gap-2">
|
|
<div class="text-sm font-semibold text-gray-900">Unità #{{ (int) $unitaId }}</div>
|
|
@if($this->getUnitaPageUrl())
|
|
<a
|
|
class="fi-btn fi-btn-color-primary fi-btn-size-sm"
|
|
href="{{ $this->getUnitaPageUrl() }}"
|
|
>
|
|
Apri scheda
|
|
</a>
|
|
@endif
|
|
</div>
|
|
|
|
@if(empty($millesimiPerTabella))
|
|
<div class="rounded-xl border border-dashed border-gray-200 bg-white p-4 text-center text-sm text-gray-500">Nessuna tabella millesimale associata.</div>
|
|
@else
|
|
<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">Tabella</th>
|
|
<th class="py-2 text-right">Millesimi</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y">
|
|
@php $lastTipo = null; @endphp
|
|
@foreach($millesimiPerTabella as $r)
|
|
@php
|
|
$tipo = $r['tipo'] ?? 'altro';
|
|
$tipoLabel = strtoupper(str_replace('_', ' ', (string) $tipo));
|
|
@endphp
|
|
@if($lastTipo !== $tipo)
|
|
<tr class="bg-gray-50">
|
|
<td colspan="2" class="py-2 text-xs font-semibold text-gray-600">{{ $tipoLabel }}</td>
|
|
</tr>
|
|
@php $lastTipo = $tipo; @endphp
|
|
@endif
|
|
@php
|
|
$prospettoUrl = \App\Filament\Pages\Condomini\TabelleMillesimaliProspetto::getUrl(panel: 'admin-filament')
|
|
. '?tabella_id=' . (int) $r['tabella_id']
|
|
. '&back=' . urlencode((string) request()->getRequestUri());
|
|
@endphp
|
|
<tr>
|
|
<td class="py-2">
|
|
<a href="{{ $prospettoUrl }}" 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 hover:bg-primary-100">
|
|
{{ $r['codice'] }}
|
|
</a>
|
|
<span class="ml-2 text-gray-900">{{ $r['nome'] }}</span>
|
|
</td>
|
|
<td class="py-2 text-right text-gray-900">{{ number_format($r['millesimi'], 3, ',', '.') }}</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
@endif
|
|
</x-filament::section>
|
|
</div>
|
|
</div>
|
|
</x-filament-panels::page>
|