315 lines
17 KiB
PHP
315 lines
17 KiB
PHP
<!-- Tab Unità Immobiliari -->
|
|
<div class="space-y-6">
|
|
<!-- Header con statistiche -->
|
|
<div class="grid grid-cols-1 md:grid-cols-4 gap-6">
|
|
<div class="bg-blue-50 rounded-lg p-4">
|
|
<div class="flex items-center">
|
|
<div class="p-2 bg-blue-100 rounded-lg">
|
|
<i class="fas fa-home text-blue-600"></i>
|
|
</div>
|
|
<div class="ml-3">
|
|
<p class="text-sm font-medium text-blue-600">Unità Totali</p>
|
|
<p class="text-2xl font-bold text-blue-900">{{ $stabile->unitaImmobiliari()->count() }}</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="bg-green-50 rounded-lg p-4">
|
|
<div class="flex items-center">
|
|
<div class="p-2 bg-green-100 rounded-lg">
|
|
<i class="fas fa-user-check text-green-600"></i>
|
|
</div>
|
|
<div class="ml-3">
|
|
<p class="text-sm font-medium text-green-600">Occupate</p>
|
|
<p class="text-2xl font-bold text-green-900">
|
|
{{ $stabile->unitaImmobiliari()->whereIn('stato_occupazione', ['occupata_proprietario', 'occupata_inquilino'])->count() }}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="bg-yellow-50 rounded-lg p-4">
|
|
<div class="flex items-center">
|
|
<div class="p-2 bg-yellow-100 rounded-lg">
|
|
<i class="fas fa-door-open text-yellow-600"></i>
|
|
</div>
|
|
<div class="ml-3">
|
|
<p class="text-sm font-medium text-yellow-600">Libere</p>
|
|
<p class="text-2xl font-bold text-yellow-900">
|
|
{{ $stabile->unitaImmobiliari()->where('stato_occupazione', 'libera')->count() }}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="bg-purple-50 rounded-lg p-4">
|
|
<div class="flex items-center">
|
|
<div class="p-2 bg-purple-100 rounded-lg">
|
|
<i class="fas fa-euro-sign text-purple-600"></i>
|
|
</div>
|
|
<div class="ml-3">
|
|
<p class="text-sm font-medium text-purple-600">In Vendita/Affitto</p>
|
|
<p class="text-2xl font-bold text-purple-900">
|
|
{{ $stabile->unitaImmobiliari()->whereIn('stato_occupazione', ['in_vendita', 'in_affitto'])->count() }}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Filtri e ricerca -->
|
|
<div class="bg-white rounded-lg border border-gray-200 p-4">
|
|
<div class="flex flex-wrap gap-4 items-center">
|
|
<div class="flex-1 min-w-64">
|
|
<input type="text"
|
|
id="search-unita"
|
|
placeholder="Cerca per codice, palazzina, scala..."
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500">
|
|
</div>
|
|
<div>
|
|
<select id="filter-palazzina" class="px-3 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500">
|
|
<option value="">Tutte le Palazzine</option>
|
|
@foreach($stabile->palazzine as $palazzina)
|
|
<option value="{{ $palazzina->codice_palazzina }}">Palazzina {{ $palazzina->codice_palazzina }}</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<select id="filter-tipo" class="px-3 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500">
|
|
<option value="">Tutti i Tipi</option>
|
|
<option value="abitazione">Abitazione</option>
|
|
<option value="studio_professionale">Studio Professionale</option>
|
|
<option value="attivita_commerciale">Attività Commerciale</option>
|
|
<option value="box_garage">Box/Garage</option>
|
|
<option value="cantina">Cantina</option>
|
|
<option value="altro">Altro</option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<select id="filter-stato" class="px-3 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500">
|
|
<option value="">Tutti gli Stati</option>
|
|
<option value="occupata_proprietario">Occupata Proprietario</option>
|
|
<option value="occupata_inquilino">Occupata Inquilino</option>
|
|
<option value="libera">Libera</option>
|
|
<option value="in_vendita">In Vendita</option>
|
|
<option value="in_affitto">In Affitto</option>
|
|
</select>
|
|
</div>
|
|
<button class="netgescon-btn netgescon-btn-primary" onclick="applicaFiltri()">
|
|
<i class="fas fa-filter mr-2"></i>
|
|
Filtra
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Azioni rapide -->
|
|
<div class="flex justify-between items-center">
|
|
<h3 class="text-lg font-semibold text-gray-900">Unità Immobiliari</h3>
|
|
<div class="flex space-x-3">
|
|
<a href="{{ route('admin.unita-immobiliari.create', ['stabile_id' => $stabile->id]) }}"
|
|
class="netgescon-btn netgescon-btn-primary">
|
|
<i class="fas fa-plus mr-2"></i>
|
|
Nuova Unità
|
|
</a>
|
|
<button class="netgescon-btn netgescon-btn-secondary" onclick="esportaUnita()">
|
|
<i class="fas fa-download mr-2"></i>
|
|
Esporta Excel
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Visualizzazione per Palazzina -->
|
|
@if($stabile->unitaImmobiliari()->count() > 0)
|
|
@php
|
|
$unitaPerPalazzina = $stabile->unitaImmobiliari()
|
|
->with('palazzinaObj')
|
|
->get()
|
|
->groupBy('palazzina');
|
|
@endphp
|
|
|
|
@foreach($unitaPerPalazzina as $codicePalazzina => $unita)
|
|
<div class="bg-white rounded-lg border border-gray-200">
|
|
<div class="bg-gray-50 px-6 py-4 border-b border-gray-200">
|
|
<div class="flex justify-between items-center">
|
|
<h4 class="text-lg font-semibold text-gray-900">
|
|
<i class="fas fa-building mr-2 text-blue-600"></i>
|
|
Palazzina {{ $codicePalazzina ?? 'Non Assegnata' }}
|
|
</h4>
|
|
<span class="bg-blue-100 text-blue-800 text-sm font-medium px-2.5 py-0.5 rounded">
|
|
{{ $unita->count() }} unità
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="p-6">
|
|
<!-- Griglia unità per scala -->
|
|
@php
|
|
$unitaPerScala = $unita->groupBy('scala');
|
|
@endphp
|
|
|
|
@foreach($unitaPerScala as $scala => $unitaScala)
|
|
<div class="mb-6 last:mb-0">
|
|
<h5 class="text-md font-medium text-gray-700 mb-3">
|
|
<i class="fas fa-stairs mr-2"></i>
|
|
Scala {{ $scala }}
|
|
</h5>
|
|
|
|
<!-- Organizza per piano -->
|
|
@php
|
|
$unitaPerPiano = $unitaScala->groupBy('piano')->sortKeysDesc();
|
|
@endphp
|
|
|
|
<div class="grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-4">
|
|
@foreach($unitaPerPiano as $piano => $unitaPiano)
|
|
<div class="border border-gray-200 rounded-lg">
|
|
<div class="bg-gray-100 px-3 py-2 border-b border-gray-200">
|
|
<span class="text-sm font-medium text-gray-700">
|
|
@if($piano == 0)
|
|
Piano Terra
|
|
@elseif($piano < 0)
|
|
Piano {{ $piano }} (Interrato)
|
|
@else
|
|
Piano {{ $piano }}
|
|
@endif
|
|
</span>
|
|
</div>
|
|
|
|
<div class="p-3 space-y-2">
|
|
@foreach($unitaPiano->sortBy('interno') as $unita)
|
|
<div class="flex items-center justify-between p-2 bg-gray-50 rounded">
|
|
<div class="flex items-center space-x-3">
|
|
<div class="w-8 h-8 bg-blue-100 rounded-full flex items-center justify-center">
|
|
<span class="text-xs font-bold text-blue-600">{{ $unita->interno }}</span>
|
|
</div>
|
|
<div>
|
|
<p class="text-sm font-medium text-gray-900">
|
|
{{ $unita->codice_unita }}
|
|
</p>
|
|
<p class="text-xs text-gray-500">
|
|
{{ ucfirst(str_replace('_', ' ', $unita->tipo_unita ?? 'abitazione')) }}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex items-center space-x-2">
|
|
<!-- Stato occupazione -->
|
|
@switch($unita->stato_occupazione)
|
|
@case('occupata_proprietario')
|
|
<span class="w-2 h-2 bg-green-500 rounded-full" title="Occupata Proprietario"></span>
|
|
@break
|
|
@case('occupata_inquilino')
|
|
<span class="w-2 h-2 bg-blue-500 rounded-full" title="Occupata Inquilino"></span>
|
|
@break
|
|
@case('libera')
|
|
<span class="w-2 h-2 bg-gray-500 rounded-full" title="Libera"></span>
|
|
@break
|
|
@case('in_vendita')
|
|
<span class="w-2 h-2 bg-orange-500 rounded-full" title="In Vendita"></span>
|
|
@break
|
|
@case('in_affitto')
|
|
<span class="w-2 h-2 bg-purple-500 rounded-full" title="In Affitto"></span>
|
|
@break
|
|
@default
|
|
<span class="w-2 h-2 bg-gray-300 rounded-full" title="Stato Sconosciuto"></span>
|
|
@endswitch
|
|
|
|
<!-- Azioni -->
|
|
<div class="flex space-x-1">
|
|
<a href="{{ route('admin.unita-immobiliari.show', $unita) }}"
|
|
class="text-blue-600 hover:text-blue-900 text-xs">
|
|
<i class="fas fa-eye"></i>
|
|
</a>
|
|
<a href="{{ route('admin.unita-immobiliari.edit', $unita) }}"
|
|
class="text-green-600 hover:text-green-900 text-xs">
|
|
<i class="fas fa-edit"></i>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
@endforeach
|
|
|
|
<!-- Legenda stati -->
|
|
<div class="bg-gray-50 rounded-lg p-4">
|
|
<h5 class="text-sm font-medium text-gray-700 mb-2">Legenda Stati Occupazione:</h5>
|
|
<div class="flex flex-wrap gap-4 text-xs">
|
|
<div class="flex items-center">
|
|
<span class="w-2 h-2 bg-green-500 rounded-full mr-2"></span>
|
|
Occupata Proprietario
|
|
</div>
|
|
<div class="flex items-center">
|
|
<span class="w-2 h-2 bg-blue-500 rounded-full mr-2"></span>
|
|
Occupata Inquilino
|
|
</div>
|
|
<div class="flex items-center">
|
|
<span class="w-2 h-2 bg-gray-500 rounded-full mr-2"></span>
|
|
Libera
|
|
</div>
|
|
<div class="flex items-center">
|
|
<span class="w-2 h-2 bg-orange-500 rounded-full mr-2"></span>
|
|
In Vendita
|
|
</div>
|
|
<div class="flex items-center">
|
|
<span class="w-2 h-2 bg-purple-500 rounded-full mr-2"></span>
|
|
In Affitto
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@else
|
|
<!-- Stato vuoto -->
|
|
<div class="text-center py-12">
|
|
<div class="mx-auto w-24 h-24 bg-gray-100 rounded-full flex items-center justify-center mb-4">
|
|
<i class="fas fa-home text-gray-400 text-3xl"></i>
|
|
</div>
|
|
<h3 class="text-lg font-medium text-gray-900 mb-2">Nessuna unità immobiliare</h3>
|
|
<p class="text-gray-500 mb-6">
|
|
Le unità immobiliari verranno generate automaticamente quando creerai le palazzine,
|
|
oppure puoi crearle manualmente.
|
|
</p>
|
|
<div class="flex justify-center space-x-3">
|
|
<a href="{{ route('admin.palazzine.create', ['stabile_id' => $stabile->id]) }}"
|
|
class="netgescon-btn netgescon-btn-primary">
|
|
<i class="fas fa-building mr-2"></i>
|
|
Crea Palazzina
|
|
</a>
|
|
<a href="{{ route('admin.unita-immobiliari.create', ['stabile_id' => $stabile->id]) }}"
|
|
class="netgescon-btn netgescon-btn-secondary">
|
|
<i class="fas fa-plus mr-2"></i>
|
|
Crea Unità Manualmente
|
|
</a>
|
|
</div>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
|
|
<script>
|
|
function applicaFiltri() {
|
|
const search = document.getElementById('search-unita').value.toLowerCase();
|
|
const palazzina = document.getElementById('filter-palazzina').value;
|
|
const tipo = document.getElementById('filter-tipo').value;
|
|
const stato = document.getElementById('filter-stato').value;
|
|
|
|
// Implementa logica di filtro
|
|
console.log('Filtri:', { search, palazzina, tipo, stato });
|
|
// TODO: Implementare filtro lato client o AJAX
|
|
}
|
|
|
|
function esportaUnita() {
|
|
// Implementa esportazione Excel
|
|
alert('Funzionalità di esportazione in sviluppo');
|
|
}
|
|
|
|
// Ricerca in tempo reale
|
|
document.getElementById('search-unita').addEventListener('input', function() {
|
|
// Implementa ricerca in tempo reale
|
|
});
|
|
</script>
|