309 lines
18 KiB
PHP
Executable File
309 lines
18 KiB
PHP
Executable File
@extends('admin.layouts.netgescon')
|
|
|
|
@section('title', 'Gestione Relazioni Persona-Unità - NetGescon')
|
|
|
|
@section('header')
|
|
<div class="bg-white shadow">
|
|
<div class="px-4 sm:px-6 lg:max-w-6xl lg:mx-auto lg:px-8">
|
|
<div class="py-6 md:flex md:items-center md:justify-between lg:border-t lg:border-gray-200">
|
|
<div class="flex-1 min-w-0">
|
|
<div class="flex items-center">
|
|
<div>
|
|
<div class="flex items-center">
|
|
<h1 class="ml-3 text-2xl font-bold leading-7 text-gray-900 sm:leading-9 sm:truncate">
|
|
Gestione Relazioni Persona-Unità
|
|
</h1>
|
|
</div>
|
|
<dl class="mt-6 flex flex-col sm:ml-3 sm:mt-1 sm:flex-row sm:flex-wrap">
|
|
<dt class="sr-only">Totale relazioni</dt>
|
|
<dd class="flex items-center text-sm text-gray-500 font-medium capitalize sm:mr-6">
|
|
<i class="fas fa-users mr-1.5 text-gray-400"></i>
|
|
{{ $relazioni->total() }} relazioni totali
|
|
</dd>
|
|
</dl>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="mt-6 flex space-x-3 md:mt-0 md:ml-4">
|
|
<a href="{{ route('admin.persona-unita.create') }}"
|
|
class="inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
|
|
<i class="fas fa-plus mr-2"></i>
|
|
Nuova Relazione
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endsection
|
|
|
|
@section('content')
|
|
<div class="max-w-7xl mx-auto py-6 sm:px-6 lg:px-8">
|
|
|
|
<!-- Filtri -->
|
|
<div class="bg-white shadow rounded-lg mb-6">
|
|
<div class="px-4 py-5 sm:p-6">
|
|
<form method="GET" action="{{ route('admin.persona-unita.index') }}" class="space-y-4">
|
|
<div class="grid grid-cols-1 gap-4 sm:grid-cols-4">
|
|
<!-- Ricerca -->
|
|
<div>
|
|
<label for="search" class="block text-sm font-medium text-gray-700">
|
|
Cerca Persona
|
|
</label>
|
|
<input type="text" name="search" id="search" value="{{ request('search') }}"
|
|
placeholder="Nome, cognome o CF..."
|
|
class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md">
|
|
</div>
|
|
|
|
<!-- Tipo Relazione -->
|
|
<div>
|
|
<label for="tipo_relazione" class="block text-sm font-medium text-gray-700">
|
|
Tipo Relazione
|
|
</label>
|
|
<select name="tipo_relazione" id="tipo_relazione"
|
|
class="mt-1 block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
|
<option value="">Tutti i tipi</option>
|
|
@foreach($tipiRelazione as $tipo)
|
|
<option value="{{ $tipo->codice }}" {{ request('tipo_relazione') == $tipo->codice ? 'selected' : '' }}>
|
|
{{ $tipo->descrizione }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
|
|
<!-- Stabile -->
|
|
<div>
|
|
<label for="stabile_id" class="block text-sm font-medium text-gray-700">
|
|
Stabile
|
|
</label>
|
|
<select name="stabile_id" id="stabile_id"
|
|
class="mt-1 block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
|
<option value="">Tutti gli stabili</option>
|
|
@foreach($stabili as $stabile)
|
|
<option value="{{ $stabile->id }}" {{ request('stabile_id') == $stabile->id ? 'selected' : '' }}>
|
|
{{ $stabile->denominazione }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
|
|
<!-- Pulsanti -->
|
|
<div class="flex items-end space-x-2">
|
|
<button type="submit"
|
|
class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
|
|
<i class="fas fa-search mr-2"></i>
|
|
Filtra
|
|
</button>
|
|
<a href="{{ route('admin.persona-unita.index') }}"
|
|
class="inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
|
|
<i class="fas fa-times mr-2"></i>
|
|
Reset
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Checkbox Includi Inattive -->
|
|
<div class="flex items-center">
|
|
<input id="include_inactive" name="include_inactive" type="checkbox"
|
|
{{ request('include_inactive') ? 'checked' : '' }}
|
|
class="focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded">
|
|
<label for="include_inactive" class="ml-2 block text-sm text-gray-900">
|
|
Includi relazioni terminate
|
|
</label>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Tabella Relazioni -->
|
|
<div class="bg-white shadow overflow-hidden sm:rounded-md">
|
|
<div class="px-4 py-5 sm:px-6 border-b border-gray-200">
|
|
<h3 class="text-lg leading-6 font-medium text-gray-900">
|
|
Relazioni Attive
|
|
</h3>
|
|
<p class="mt-1 max-w-2xl text-sm text-gray-500">
|
|
Elenco completo delle relazioni tra persone e unità immobiliari
|
|
</p>
|
|
</div>
|
|
|
|
@if($relazioni->count() > 0)
|
|
<ul class="divide-y divide-gray-200">
|
|
@foreach($relazioni as $relazione)
|
|
<li class="px-4 py-4 sm:px-6 hover:bg-gray-50">
|
|
<div class="flex items-center justify-between">
|
|
<div class="flex items-center">
|
|
<div class="flex-shrink-0">
|
|
@switch($relazione->tipo_relazione)
|
|
@case('proprietario')
|
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
|
|
<i class="fas fa-home mr-1"></i>
|
|
Proprietario
|
|
</span>
|
|
@break
|
|
@case('inquilino')
|
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
|
|
<i class="fas fa-key mr-1"></i>
|
|
Inquilino
|
|
</span>
|
|
@break
|
|
@case('comproprietario')
|
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-100 text-yellow-800">
|
|
<i class="fas fa-users mr-1"></i>
|
|
Comproprietario
|
|
</span>
|
|
@break
|
|
@default
|
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800">
|
|
<i class="fas fa-user mr-1"></i>
|
|
{{ ucfirst($relazione->tipo_relazione) }}
|
|
</span>
|
|
@endswitch
|
|
</div>
|
|
|
|
@php
|
|
$ruoloRate = $relazione->ruolo_rate ?: \App\Models\PersonaUnitaRelazione::deriveRuoloRate($relazione->tipo_relazione);
|
|
@endphp
|
|
@if($ruoloRate)
|
|
<div class="ml-2">
|
|
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-semibold bg-gray-100 text-gray-800" title="Ruolo rate">
|
|
({{ $ruoloRate }})
|
|
</span>
|
|
</div>
|
|
@endif
|
|
|
|
<div class="ml-4">
|
|
<div class="flex items-center">
|
|
<p class="text-sm font-medium text-gray-900">
|
|
{{ $relazione->persona->cognome }} {{ $relazione->persona->nome }}
|
|
</p>
|
|
@if($relazione->persona->codice_fiscale)
|
|
<span class="ml-2 text-xs text-gray-500">
|
|
({{ $relazione->persona->codice_fiscale }})
|
|
</span>
|
|
@endif
|
|
</div>
|
|
@php
|
|
$unita = $relazione->unitaImmobiliare;
|
|
$stabile = $unita?->stabile;
|
|
@endphp
|
|
<div class="mt-1 flex items-center text-sm text-gray-500">
|
|
<i class="fas fa-building mr-1"></i>
|
|
<span>{{ $stabile->denominazione ?? 'N/A' }}</span>
|
|
<span class="mx-2">→</span>
|
|
<i class="fas fa-home mr-1"></i>
|
|
<span>{{ $unita->codice_unita ?? 'N/D' }}</span>
|
|
|
|
@if($relazione->quota_relazione)
|
|
<span class="ml-4 text-indigo-600">
|
|
Quota: {{ $relazione->quota_relazione }}%
|
|
</span>
|
|
@endif
|
|
</div>
|
|
<div class="mt-1 text-xs text-gray-400">
|
|
Dal {{ $relazione->data_inizio->format('d/m/Y') }}
|
|
@if($relazione->data_fine)
|
|
al {{ $relazione->data_fine->format('d/m/Y') }}
|
|
@endif
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex items-center space-x-2">
|
|
<!-- Status badges -->
|
|
<div class="flex space-x-1">
|
|
@if($relazione->riceve_comunicazioni)
|
|
<span class="inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800" title="Riceve Comunicazioni">
|
|
<i class="fas fa-envelope"></i>
|
|
</span>
|
|
@endif
|
|
@if($relazione->riceve_convocazioni)
|
|
<span class="inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-800" title="Riceve Convocazioni">
|
|
<i class="fas fa-calendar"></i>
|
|
</span>
|
|
@endif
|
|
@if($relazione->vota_assemblea)
|
|
<span class="inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-purple-100 text-purple-800" title="Vota in Assemblea">
|
|
<i class="fas fa-vote-yea"></i>
|
|
</span>
|
|
@endif
|
|
@if(!$relazione->attivo)
|
|
<span class="inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-red-100 text-red-800" title="Relazione Terminata">
|
|
<i class="fas fa-times"></i>
|
|
</span>
|
|
@endif
|
|
</div>
|
|
|
|
<!-- Actions -->
|
|
<div class="flex items-center space-x-1">
|
|
<a href="{{ route('admin.persona-unita.show', $relazione) }}"
|
|
class="text-indigo-600 hover:text-indigo-900 p-1" title="Visualizza">
|
|
<i class="fas fa-eye"></i>
|
|
</a>
|
|
<a href="{{ route('admin.persona-unita.edit', $relazione) }}"
|
|
class="text-yellow-600 hover:text-yellow-900 p-1" title="Modifica">
|
|
<i class="fas fa-edit"></i>
|
|
</a>
|
|
@if($relazione->attivo)
|
|
<form method="POST" action="{{ route('admin.persona-unita.destroy', $relazione) }}"
|
|
class="inline" onsubmit="return confirm('Sei sicuro di voler terminare questa relazione?')">
|
|
@csrf
|
|
@method('DELETE')
|
|
<button type="submit" class="text-red-600 hover:text-red-900 p-1" title="Termina Relazione">
|
|
<i class="fas fa-trash"></i>
|
|
</button>
|
|
</form>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</li>
|
|
@endforeach
|
|
</ul>
|
|
|
|
<!-- Paginazione -->
|
|
<div class="bg-white px-4 py-3 border-t border-gray-200 sm:px-6">
|
|
{{ $relazioni->withQueryString()->links() }}
|
|
</div>
|
|
@else
|
|
<div class="text-center py-12">
|
|
<i class="fas fa-users text-gray-400 text-4xl mb-4"></i>
|
|
<h3 class="text-lg font-medium text-gray-900 mb-2">Nessuna relazione trovata</h3>
|
|
<p class="text-gray-500 mb-4">
|
|
@if(request()->hasAny(['search', 'tipo_relazione', 'stabile_id']))
|
|
Nessuna relazione corrisponde ai filtri selezionati.
|
|
@else
|
|
Non ci sono relazioni persona-unità configurate.
|
|
@endif
|
|
</p>
|
|
<a href="{{ route('admin.persona-unita.create') }}"
|
|
class="inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
|
|
<i class="fas fa-plus mr-2"></i>
|
|
Crea Prima Relazione
|
|
</a>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
@endsection
|
|
|
|
@push('scripts')
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// Auto-submit filtri quando cambiano
|
|
const selectFilters = document.querySelectorAll('#tipo_relazione, #stabile_id');
|
|
const checkboxFilter = document.getElementById('include_inactive');
|
|
|
|
selectFilters.forEach(function(select) {
|
|
select.addEventListener('change', function() {
|
|
this.form.submit();
|
|
});
|
|
});
|
|
|
|
if (checkboxFilter) {
|
|
checkboxFilter.addEventListener('change', function() {
|
|
this.form.submit();
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
@endpush
|