159 lines
8.3 KiB
PHP
159 lines
8.3 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('title', 'Clienti')
|
|
@section('page-title', 'Gestione Clienti')
|
|
|
|
@section('page-actions')
|
|
<a href="{{ route('customers.create') }}" class="btn btn-primary">
|
|
<i class="bi bi-person-plus me-1"></i>Nuovo Cliente
|
|
</a>
|
|
@endsection
|
|
|
|
@section('content')
|
|
|
|
{{-- ═══ Barra filtri ════════════════════════════════════════════════════ --}}
|
|
<div class="card mb-4">
|
|
<div class="card-body py-3">
|
|
{{-- method="GET": i filtri vengono messi nell'URL (?search=...&type=...) --}}
|
|
<form method="GET" action="{{ route('customers.index') }}" class="row g-2 align-items-end">
|
|
<div class="col-md-4">
|
|
<label class="form-label small fw-semibold text-muted">Cerca</label>
|
|
<div class="input-group">
|
|
<span class="input-group-text"><i class="bi bi-search"></i></span>
|
|
<input type="text" name="search"
|
|
class="form-control"
|
|
placeholder="Nome, email, città, P.IVA..."
|
|
{{-- old(): ripopola il campo con il valore precedente dopo ricarica pagina --}}
|
|
value="{{ request('search') }}">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-2">
|
|
<label class="form-label small fw-semibold text-muted">Tipo</label>
|
|
<select name="type" class="form-select">
|
|
<option value="">Tutti</option>
|
|
<option value="privato" {{ request('type') === 'privato' ? 'selected' : '' }}>Privato</option>
|
|
<option value="azienda" {{ request('type') === 'azienda' ? 'selected' : '' }}>Azienda</option>
|
|
</select>
|
|
</div>
|
|
<div class="col-md-2">
|
|
<label class="form-label small fw-semibold text-muted">Stato</label>
|
|
<select name="status" class="form-select">
|
|
<option value="">Tutti</option>
|
|
<option value="attivo" {{ request('status') === 'attivo' ? 'selected' : '' }}>Attivo</option>
|
|
<option value="prospect" {{ request('status') === 'prospect' ? 'selected' : '' }}>Prospect</option>
|
|
<option value="inattivo" {{ request('status') === 'inattivo' ? 'selected' : '' }}>Inattivo</option>
|
|
</select>
|
|
</div>
|
|
<div class="col-md-2">
|
|
<button type="submit" class="btn btn-primary w-100">
|
|
<i class="bi bi-funnel me-1"></i>Filtra
|
|
</button>
|
|
</div>
|
|
<div class="col-md-2">
|
|
<a href="{{ route('customers.index') }}" class="btn btn-outline-secondary w-100">
|
|
<i class="bi bi-x me-1"></i>Reset
|
|
</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
{{-- ═══ Tabella clienti ════════════════════════════════════════════════ --}}
|
|
<div class="card">
|
|
<div class="card-header bg-white border-0 pt-3">
|
|
<span class="text-muted small">
|
|
{{ $customers->total() }} {{ Str::plural('cliente', $customers->total()) }} trovati
|
|
</span>
|
|
</div>
|
|
<div class="table-responsive">
|
|
<table class="table table-hover align-middle mb-0">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th class="ps-4">Cliente</th>
|
|
<th>Contatto</th>
|
|
<th>Città</th>
|
|
<th>Tipo</th>
|
|
<th>Stato</th>
|
|
<th>Contratto</th>
|
|
<th class="text-end pe-4">Azioni</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@forelse ($customers as $customer)
|
|
<tr>
|
|
<td class="ps-4">
|
|
<div class="fw-semibold">{{ $customer->name }}</div>
|
|
@if ($customer->vat_number)
|
|
<div class="text-muted small">P.IVA: {{ $customer->vat_number }}</div>
|
|
@endif
|
|
</td>
|
|
<td>
|
|
<div>{{ $customer->email }}</div>
|
|
@if ($customer->phone)
|
|
<div class="text-muted small">{{ $customer->phone }}</div>
|
|
@endif
|
|
</td>
|
|
<td class="text-muted">{{ $customer->city ?? '—' }}</td>
|
|
<td>
|
|
<span class="badge bg-light text-dark border">{{ $customer->type_label }}</span>
|
|
</td>
|
|
<td>
|
|
<span class="badge bg-{{ $customer->badge_color }}">
|
|
{{ ucfirst($customer->status) }}
|
|
</span>
|
|
</td>
|
|
<td class="fw-semibold">
|
|
{{ $appSettings['currency_symbol'] }}{{ number_format($customer->contract_value, 0, ',', '.') }}
|
|
</td>
|
|
<td class="text-end pe-4">
|
|
<div class="btn-group btn-group-sm">
|
|
<a href="{{ route('customers.show', $customer) }}"
|
|
class="btn btn-outline-primary" title="Dettaglio">
|
|
<i class="bi bi-eye"></i>
|
|
</a>
|
|
<a href="{{ route('customers.edit', $customer) }}"
|
|
class="btn btn-outline-secondary" title="Modifica">
|
|
<i class="bi bi-pencil"></i>
|
|
</a>
|
|
{{-- Form DELETE: i browser non supportano DELETE nativo,
|
|
Laravel usa il campo _method come workaround --}}
|
|
<form method="POST" action="{{ route('customers.destroy', $customer) }}"
|
|
onsubmit="return confirm('Eliminare {{ addslashes($customer->name) }}?')">
|
|
@csrf
|
|
@method('DELETE')
|
|
<button type="submit" class="btn btn-outline-danger" title="Elimina">
|
|
<i class="bi bi-trash"></i>
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="7" class="text-center text-muted py-5">
|
|
<i class="bi bi-people display-6 d-block mb-2 opacity-25"></i>
|
|
Nessun cliente trovato.<br>
|
|
<a href="{{ route('customers.create') }}" class="btn btn-primary mt-3">
|
|
<i class="bi bi-person-plus me-1"></i>Aggiungi il primo cliente
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
{{-- Paginazione: generata automaticamente da Laravel --}}
|
|
@if ($customers->hasPages())
|
|
<div class="card-footer bg-white d-flex justify-content-between align-items-center">
|
|
<div class="text-muted small">
|
|
Pagina {{ $customers->currentPage() }} di {{ $customers->lastPage() }}
|
|
</div>
|
|
{{-- links() genera i bottoni prev/next con Bootstrap styling --}}
|
|
{{ $customers->links('pagination::bootstrap-5') }}
|
|
</div>
|
|
@endif
|
|
</div>
|
|
|
|
@endsection
|