48 lines
1.7 KiB
PHP
48 lines
1.7 KiB
PHP
@php
|
|
/** @var \Illuminate\Support\Collection<int, \App\Models\Stabile> $stabili */
|
|
/** @var \App\Models\Stabile|null $stabileAttivo */
|
|
$activeId = $stabileAttivo?->id;
|
|
|
|
$stabileHasRiscaldamento = static function (?\App\Models\Stabile $stabile): bool {
|
|
if (! $stabile) {
|
|
return false;
|
|
}
|
|
|
|
return method_exists($stabile, 'hasOperationalHeating')
|
|
? $stabile->hasOperationalHeating()
|
|
: false;
|
|
};
|
|
|
|
$stabileLabel = static function (?\App\Models\Stabile $stabile): string {
|
|
if (! $stabile) {
|
|
return '';
|
|
}
|
|
|
|
$primary = trim((string) ($stabile->codice_operatore ?: $stabile->codice_stabile));
|
|
$mnemo = trim((string) ($stabile->cod_stabile ?? ''));
|
|
|
|
if ($mnemo !== '' && $primary !== '' && $mnemo !== $primary) {
|
|
return $mnemo . ' · ' . $primary;
|
|
}
|
|
|
|
return $primary !== '' ? $primary : ($mnemo !== '' ? $mnemo : ('#' . (string) $stabile->id));
|
|
};
|
|
@endphp
|
|
|
|
<div class="flex items-center gap-3">
|
|
@if($stabileAttivo)
|
|
<div class="hidden md:flex flex-col leading-tight">
|
|
<div class="text-xs text-gray-500">Stabile attivo</div>
|
|
<div class="text-sm font-medium">
|
|
{{ $stabileLabel($stabileAttivo) }} — {{ $stabileAttivo->denominazione }}
|
|
</div>
|
|
<div class="text-xs text-gray-500">
|
|
Ordinari: {{ ($stabileAttivo->numero_rate_ordinarie ?? 0) > 0 ? 'Sì' : 'No' }} ·
|
|
Riscaldamento: {{ $stabileHasRiscaldamento($stabileAttivo) ? 'Sì' : 'No' }}
|
|
</div>
|
|
</div>
|
|
@endif
|
|
|
|
<div class="text-xs text-gray-500">Selettore stabile temporaneamente disattivato.</div>
|
|
</div>
|