107 lines
4.9 KiB
PHP
107 lines
4.9 KiB
PHP
@php
|
|
$user = \Illuminate\Support\Facades\Auth::user();
|
|
|
|
$stabileLabel = static function (?\App\Models\Stabile $stabile): string {
|
|
if (! $stabile) {
|
|
return 'Seleziona stabile';
|
|
}
|
|
|
|
$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));
|
|
};
|
|
|
|
$stabili = collect();
|
|
$stabileAttivo = null;
|
|
|
|
if ($user instanceof \App\Models\User) {
|
|
$stabili = \App\Support\StabileContext::accessibleStabili($user);
|
|
$activeId = \App\Support\StabileContext::resolveActiveStabileId($user);
|
|
$stabileAttivo = $activeId ? $stabili->firstWhere('id', $activeId) : null;
|
|
}
|
|
|
|
$gestioni = \App\Support\GestioneContext::availableGestioni();
|
|
$gestioneAttiva = \App\Support\GestioneContext::resolveActiveGestione($user instanceof \App\Models\User ? $user : null);
|
|
|
|
$annoGestione = \App\Support\AnnoGestioneContext::resolveActiveAnno($user instanceof \App\Models\User ? $user : null);
|
|
|
|
$labelGestione = $gestioni[$gestioneAttiva] ?? (string) $gestioneAttiva;
|
|
|
|
$haRiscaldamento = (bool) ($stabileAttivo?->riscaldamento_centralizzato ?? false);
|
|
@endphp
|
|
|
|
<div class="flex min-w-0 items-center gap-2 ps-3">
|
|
<x-filament::dropdown placement="bottom-start">
|
|
<x-slot name="trigger">
|
|
<button type="button" class="flex items-center gap-2">
|
|
<span class="inline-flex items-center rounded-full border border-gray-200 bg-white px-2.5 py-1 text-xs font-medium text-gray-800">
|
|
{{ $stabileAttivo ? ($stabileLabel($stabileAttivo) . ' · ' . $stabileAttivo->denominazione) : 'Seleziona stabile' }}
|
|
</span>
|
|
<span class="inline-flex items-center rounded-full border border-gray-200 bg-white px-2.5 py-1 text-xs font-medium text-gray-800">
|
|
{{ $labelGestione }}
|
|
</span>
|
|
<span class="inline-flex items-center rounded-full border border-gray-200 bg-white px-2.5 py-1 text-xs font-medium text-gray-800">
|
|
{{ $annoGestione }}
|
|
</span>
|
|
<span class="inline-flex items-center rounded-full border border-gray-200 bg-white px-2.5 py-1 text-xs font-medium text-gray-800">
|
|
Risc: {{ $haRiscaldamento ? 'SI' : 'NO' }}
|
|
</span>
|
|
<x-filament::icon icon="heroicon-o-chevron-down" class="h-4 w-4 text-gray-500" />
|
|
</button>
|
|
</x-slot>
|
|
|
|
<div class="w-96 p-3 space-y-3">
|
|
@if($stabili->count() > 0)
|
|
<form method="POST" action="{{ route('admin-filament.stabile-attivo') }}" class="space-y-1">
|
|
@csrf
|
|
<div class="text-xs text-gray-500">Stabile</div>
|
|
<select name="stabile_id" class="fi-input block w-full" onchange="this.form.submit()">
|
|
@foreach($stabili as $stabile)
|
|
<option value="{{ $stabile->id }}" @selected($stabileAttivo?->id === $stabile->id)>
|
|
{{ $stabileLabel($stabile) }} — {{ $stabile->denominazione }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
</form>
|
|
@endif
|
|
|
|
<form method="POST" action="{{ route('admin-filament.gestione-attiva') }}" class="space-y-1">
|
|
@csrf
|
|
<div class="text-xs text-gray-500">Gestione</div>
|
|
<select name="gestione" class="fi-input block w-full" onchange="this.form.submit()">
|
|
@foreach($gestioni as $key => $label)
|
|
<option value="{{ $key }}" @selected($gestioneAttiva === $key)>{{ $label }}</option>
|
|
@endforeach
|
|
</select>
|
|
</form>
|
|
|
|
<form method="POST" action="{{ route('admin-filament.anno-gestione-attivo') }}" class="space-y-1">
|
|
@csrf
|
|
<div class="text-xs text-gray-500">Anno gestione</div>
|
|
<select name="anno" class="fi-input block w-full" onchange="this.form.submit()">
|
|
@for($y = (int) now()->year - 2; $y <= (int) now()->year + 1; $y++)
|
|
<option value="{{ $y }}" @selected($annoGestione === $y)>{{ $y }}</option>
|
|
@endfor
|
|
</select>
|
|
</form>
|
|
</div>
|
|
</x-filament::dropdown>
|
|
|
|
<livewire:filament.topbar-live-call />
|
|
|
|
<button
|
|
type="button"
|
|
class="fi-icon-btn fi-color-gray"
|
|
x-data="{}"
|
|
x-on:click="$dispatch('open-global-search-results')"
|
|
title="Cerca"
|
|
>
|
|
<x-filament::icon icon="heroicon-o-magnifying-glass" class="h-5 w-5" />
|
|
</button>
|
|
</div>
|