250 lines
13 KiB
PHP
250 lines
13 KiB
PHP
@extends('layouts.app-universal-v2')
|
|
|
|
@section('title', 'Gestione Anagrafiche (Soggetti)')
|
|
|
|
@section('breadcrumb-internal')
|
|
<nav aria-label="breadcrumb">
|
|
<ol class="breadcrumb mb-0">
|
|
<li class="breadcrumb-item"><a href="{{ route('dashboard') }}"><i class="fas fa-home"></i> Dashboard</a></li>
|
|
<li class="breadcrumb-item"><i class="fas fa-users"></i> Gestione Soggetti</li>
|
|
<li class="breadcrumb-item active" aria-current="page">Anagrafiche</li>
|
|
</ol>
|
|
</nav>
|
|
@endsection
|
|
|
|
@section('content')
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card card-netgescon">
|
|
<div class="card-header d-flex justify-content-between align-items-center bg-light">
|
|
<h3 class="card-title mb-0">
|
|
<i class="fas fa-address-book text-primary me-2"></i>
|
|
Elenco Anagrafiche
|
|
</h3>
|
|
@if($userPermissions['soggetti'] !== 'limited')
|
|
<a href="{{ route('admin.soggetti.create') }}" class="btn btn-netgescon-primary">
|
|
<i class="fas fa-plus me-1"></i>Nuova Anagrafica
|
|
</a>
|
|
@endif
|
|
</div>
|
|
<div class="card-body">
|
|
{{-- Filtri di ricerca --}}
|
|
<div class="row mb-3">
|
|
<div class="col-md-4">
|
|
<div class="input-group">
|
|
<span class="input-group-text"><i class="fas fa-search"></i></span>
|
|
<input type="text" class="form-control" placeholder="Cerca per nome, ragione sociale..." id="search-input">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<select class="form-select" id="tipo-filter">
|
|
<option value="">Tutti i tipi</option>
|
|
<option value="persona_fisica">Persona Fisica</option>
|
|
<option value="persona_giuridica">Persona Giuridica</option>
|
|
</select>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<button class="btn btn-outline-primary" onclick="resetFilters()">
|
|
<i class="fas fa-eraser me-1"></i>Reset Filtri
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
{{-- Tabella responsive --}}
|
|
<div class="table-responsive">
|
|
<table class="table table-netgescon table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th><i class="fas fa-hashtag me-1"></i>ID</th>
|
|
<th><i class="fas fa-user me-1"></i>Nome / Ragione Sociale</th>
|
|
<th><i class="fas fa-tag me-1"></i>Tipo</th>
|
|
<th><i class="fas fa-envelope me-1"></i>Email</th>
|
|
<th><i class="fas fa-phone me-1"></i>Telefono</th>
|
|
<th class="text-center"><i class="fas fa-cogs me-1"></i>Azioni</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@forelse($soggetti as $soggetto)
|
|
<tr>
|
|
<td>
|
|
<span class="badge bg-secondary">{{ $soggetto->id_soggetto }}</span>
|
|
</td>
|
|
<td>
|
|
<div class="d-flex align-items-center">
|
|
<div class="avatar-sm me-2">
|
|
@if($soggetto->tipo === 'persona_fisica')
|
|
<i class="fas fa-user text-primary"></i>
|
|
@else
|
|
<i class="fas fa-building text-info"></i>
|
|
@endif
|
|
</div>
|
|
<div>
|
|
<strong>{{ $soggetto->ragione_sociale ?: ($soggetto->nome . ' ' . $soggetto->cognome) }}</strong>
|
|
@if($soggetto->codice_fiscale)
|
|
<br><small class="text-muted">CF: {{ $soggetto->codice_fiscale }}</small>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
@if($soggetto->tipo === 'persona_fisica')
|
|
<span class="badge bg-success">Persona Fisica</span>
|
|
@else
|
|
<span class="badge bg-info">Persona Giuridica</span>
|
|
@endif
|
|
</td>
|
|
<td>
|
|
@if($soggetto->email)
|
|
<a href="mailto:{{ $soggetto->email }}" class="text-decoration-none">
|
|
{{ $soggetto->email }}
|
|
</a>
|
|
@else
|
|
<span class="text-muted">-</span>
|
|
@endif
|
|
</td>
|
|
<td>
|
|
@if($soggetto->telefono)
|
|
<a href="tel:{{ $soggetto->telefono }}" class="text-decoration-none">
|
|
{{ $soggetto->telefono }}
|
|
</a>
|
|
@else
|
|
<span class="text-muted">-</span>
|
|
@endif
|
|
</td>
|
|
<td class="text-center">
|
|
<div class="btn-group" role="group">
|
|
<a href="{{ route('admin.soggetti.show', $soggetto) }}"
|
|
class="btn btn-sm btn-outline-info"
|
|
title="Visualizza dettagli">
|
|
<i class="fas fa-eye"></i>
|
|
</a>
|
|
@if($userPermissions['soggetti'] !== 'limited')
|
|
<a href="{{ route('admin.soggetti.edit', $soggetto) }}"
|
|
class="btn btn-sm btn-outline-primary"
|
|
title="Modifica">
|
|
<i class="fas fa-edit"></i>
|
|
</a>
|
|
<form method="POST"
|
|
action="{{ route('admin.soggetti.destroy', $soggetto) }}"
|
|
class="d-inline"
|
|
onsubmit="return confirmDelete('Sei sicuro di voler eliminare questa anagrafica?')">
|
|
@csrf
|
|
@method('DELETE')
|
|
<button type="submit"
|
|
class="btn btn-sm btn-outline-danger"
|
|
title="Elimina">
|
|
<i class="fas fa-trash"></i>
|
|
</button>
|
|
</form>
|
|
@endif
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="6" class="text-center py-4">
|
|
<div class="text-muted">
|
|
<i class="fas fa-users fa-3x mb-3 d-block"></i>
|
|
<h5>Nessuna anagrafica trovata</h5>
|
|
<p class="mb-0">Non ci sono anagrafiche registrate nel sistema.</p>
|
|
@if($userPermissions['soggetti'] !== 'limited')
|
|
<a href="{{ route('admin.soggetti.create') }}" class="btn btn-netgescon-primary mt-2">
|
|
<i class="fas fa-plus me-1"></i>Crea Prima Anagrafica
|
|
</a>
|
|
@endif
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
{{-- Paginazione --}}
|
|
@if($soggetti->hasPages())
|
|
<div class="d-flex justify-content-center mt-4">
|
|
{{ $soggetti->links() }}
|
|
</div>
|
|
@endif
|
|
</div>
|
|
|
|
{{-- Footer card con statistiche --}}
|
|
<div class="card-footer bg-light">
|
|
<div class="row text-center">
|
|
<div class="col-md-3">
|
|
<strong>{{ $soggetti->total() }}</strong>
|
|
<br><small class="text-muted">Totale Anagrafiche</small>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<strong>{{ $soggetti->where('tipo', 'persona_fisica')->count() }}</strong>
|
|
<br><small class="text-muted">Persone Fisiche</small>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<strong>{{ $soggetti->where('tipo', 'persona_giuridica')->count() }}</strong>
|
|
<br><small class="text-muted">Persone Giuridiche</small>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<strong>{{ $soggetti->whereNotNull('email')->count() }}</strong>
|
|
<br><small class="text-muted">Con Email</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endsection
|
|
|
|
@push('scripts')
|
|
<script>
|
|
// Filtri di ricerca in tempo reale
|
|
document.getElementById('search-input').addEventListener('keyup', function() {
|
|
const searchTerm = this.value.toLowerCase();
|
|
const rows = document.querySelectorAll('tbody tr');
|
|
|
|
rows.forEach(row => {
|
|
const text = row.textContent.toLowerCase();
|
|
if (text.includes(searchTerm)) {
|
|
row.style.display = '';
|
|
} else {
|
|
row.style.display = 'none';
|
|
}
|
|
});
|
|
});
|
|
|
|
// Filtro per tipo
|
|
document.getElementById('tipo-filter').addEventListener('change', function() {
|
|
const filterValue = this.value;
|
|
const rows = document.querySelectorAll('tbody tr');
|
|
|
|
rows.forEach(row => {
|
|
if (filterValue === '') {
|
|
row.style.display = '';
|
|
} else {
|
|
const badges = row.querySelectorAll('.badge');
|
|
let shouldShow = false;
|
|
badges.forEach(badge => {
|
|
if ((filterValue === 'persona_fisica' && badge.textContent.includes('Persona Fisica')) ||
|
|
(filterValue === 'persona_giuridica' && badge.textContent.includes('Persona Giuridica'))) {
|
|
shouldShow = true;
|
|
}
|
|
});
|
|
row.style.display = shouldShow ? '' : 'none';
|
|
}
|
|
});
|
|
});
|
|
|
|
// Reset filtri
|
|
function resetFilters() {
|
|
document.getElementById('search-input').value = '';
|
|
document.getElementById('tipo-filter').value = '';
|
|
|
|
const rows = document.querySelectorAll('tbody tr');
|
|
rows.forEach(row => {
|
|
row.style.display = '';
|
|
});
|
|
}
|
|
</script>
|
|
@endpush
|