198 lines
15 KiB
PHP
198 lines
15 KiB
PHP
<div>
|
|
<div class="sm:flex sm:items-center sm:justify-between mb-6">
|
|
<div>
|
|
<h1 class="text-2xl font-bold text-gray-900">Territori</h1>
|
|
<p class="text-sm text-gray-500 mt-1">Gestione dei territori della congregazione</p>
|
|
</div>
|
|
<div class="mt-4 sm:mt-0 flex gap-2">
|
|
<a href="{{ route('territori.cestino') }}" class="inline-flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition">
|
|
<svg class="h-4 w-4" style="color:#9ca3af" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/></svg>
|
|
Cestino
|
|
</a>
|
|
<a href="{{ route('territori.create') }}" class="inline-flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-white rounded-lg transition" style="background:#4f46e5" onmouseover="this.style.background='#4338ca'" onmouseout="this.style.background='#4f46e5'">
|
|
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/></svg>
|
|
Nuovo territorio
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
{{-- Filters --}}
|
|
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-4 mb-4">
|
|
<div class="flex items-center gap-2 mb-3">
|
|
<svg class="h-4 w-4" style="color:#9ca3af" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"/></svg>
|
|
<span class="text-xs font-semibold text-gray-500 uppercase tracking-wider">Filtri</span>
|
|
</div>
|
|
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 xl:grid-cols-7 gap-3">
|
|
<input wire:model.live.debounce.300ms="search" type="text" placeholder="Cerca numero, zona, tipologia, note..."
|
|
class="rounded-lg border-gray-300 text-sm focus:border-indigo-500 focus:ring-indigo-500">
|
|
<select wire:model.live="filterZona" class="rounded-lg border-gray-300 text-sm focus:border-indigo-500 focus:ring-indigo-500">
|
|
<option value="">Tutte le zone</option>
|
|
@foreach($zone as $zona)
|
|
<option value="{{ $zona->id }}">{{ $zona->nome }}</option>
|
|
@endforeach
|
|
</select>
|
|
<select wire:model.live="filterTipologia" class="rounded-lg border-gray-300 text-sm focus:border-indigo-500 focus:ring-indigo-500">
|
|
<option value="">Tutte le tipologie</option>
|
|
@foreach($tipologie as $tipologia)
|
|
<option value="{{ $tipologia->id }}">{{ $tipologia->nome }}</option>
|
|
@endforeach
|
|
</select>
|
|
<select wire:model.live="filterStato" class="rounded-lg border-gray-300 text-sm focus:border-indigo-500 focus:ring-indigo-500">
|
|
<option value="">Tutti gli stati</option>
|
|
<option value="in_reparto">In reparto</option>
|
|
<option value="prioritari">Prioritari</option>
|
|
<option value="assegnato">Assegnato</option>
|
|
<option value="da_rientrare">Da rientrare</option>
|
|
<option value="inattivo">Inattivo</option>
|
|
</select>
|
|
<select wire:model.live="filterPriorita" class="rounded-lg border-gray-300 text-sm focus:border-indigo-500 focus:ring-indigo-500">
|
|
<option value="">Tutte le priorita</option>
|
|
<option value="prioritari">Solo prioritari</option>
|
|
<option value="manuali">Prioritari manuali</option>
|
|
<option value="automatici">Prioritari automatici</option>
|
|
<option value="non_prioritari">Solo non prioritari</option>
|
|
</select>
|
|
<select wire:model.live="filterPdf" class="rounded-lg border-gray-300 text-sm focus:border-indigo-500 focus:ring-indigo-500">
|
|
<option value="">PDF e thumbnail</option>
|
|
<option value="con_pdf">Con PDF</option>
|
|
<option value="senza_pdf">Senza PDF</option>
|
|
<option value="con_thumbnail">Con thumbnail</option>
|
|
<option value="senza_thumbnail">Senza thumbnail</option>
|
|
</select>
|
|
<select wire:model.live="filterContenuti" class="rounded-lg border-gray-300 text-sm focus:border-indigo-500 focus:ring-indigo-500">
|
|
<option value="">Note e confini</option>
|
|
<option value="con_note">Con note</option>
|
|
<option value="senza_note">Senza note</option>
|
|
<option value="con_confini">Con confini</option>
|
|
<option value="senza_confini">Senza confini</option>
|
|
</select>
|
|
</div>
|
|
<div class="mt-3 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
|
|
<p class="text-xs text-gray-500">
|
|
@if($usesPriorityOrdering)
|
|
<span style="color:#6366f1">⬆</span> Ordinamento attivo: prioritari prima, poi territori con piu tempo in reparto.
|
|
@else
|
|
Ordinamento predefinito: numero territorio dal piu piccolo al piu grande.
|
|
@endif
|
|
</p>
|
|
<button wire:click="clearFilters"
|
|
type="button"
|
|
class="inline-flex items-center justify-center gap-1.5 rounded-lg border border-gray-300 px-3 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 transition">
|
|
<svg class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/></svg>
|
|
Azzera filtri
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
{{-- Table --}}
|
|
<div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
|
|
<div class="overflow-x-auto">
|
|
<table class="min-w-full divide-y divide-gray-200 table-striped">
|
|
<thead style="background:linear-gradient(180deg,#f9fafb,#f3f4f6)">
|
|
<tr>
|
|
<th wire:click="sortBy('numero')" class="px-4 py-3 text-left text-xs font-semibold text-gray-600 uppercase cursor-pointer hover:text-gray-800 transition-colors">
|
|
N° @if($sortField === 'numero') <span style="color:#6366f1">{{ $sortDirection === 'asc' ? '▲' : '▼' }}</span> @endif
|
|
</th>
|
|
<th class="px-4 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Zona</th>
|
|
<th class="px-4 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Tipologia</th>
|
|
<th class="px-4 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Stato</th>
|
|
<th class="px-4 py-3 text-left text-xs font-semibold text-gray-600 uppercase">Assegnatario</th>
|
|
<th class="px-4 py-3 text-right text-xs font-semibold text-gray-600 uppercase">Azioni</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-100">
|
|
@forelse($territori as $territorio)
|
|
<tr class="hover:bg-indigo-50/30 transition-colors">
|
|
<td class="px-4 py-3 text-sm font-semibold text-gray-900">
|
|
<div class="flex items-center gap-2">
|
|
@if($territorio->thumbnail_path)
|
|
<img src="{{ asset('storage/' . $territorio->thumbnail_path) }}"
|
|
alt="Thumbnail territorio {{ $territorio->numero }}"
|
|
class="h-8 w-6 rounded border border-gray-200 object-cover bg-gray-50 flex-none shadow-sm">
|
|
@endif
|
|
<a href="{{ route('territori.show', $territorio) }}" class="hover:text-indigo-600 transition-colors">{{ $territorio->numero }}</a>
|
|
</div>
|
|
</td>
|
|
<td class="px-4 py-3 text-sm text-gray-600">{{ $territorio->zona?->nome ?? '-' }}</td>
|
|
<td class="px-4 py-3 text-sm text-gray-600">{{ $territorio->tipologia?->nome ?? '-' }}</td>
|
|
<td class="px-4 py-3 text-sm">
|
|
@php $stato = $territorio->stato; @endphp
|
|
<span class="inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-xs font-medium
|
|
{{ match($stato) {
|
|
'in_reparto' => 'bg-green-100 text-green-800',
|
|
'assegnato' => 'bg-blue-100 text-blue-800',
|
|
'da_rientrare' => 'bg-red-100 text-red-800',
|
|
'inattivo' => 'bg-gray-100 text-gray-600',
|
|
default => 'bg-gray-100 text-gray-600'
|
|
} }}">
|
|
{{ str_replace('_', ' ', ucfirst($stato)) }}
|
|
</span>
|
|
@if($territorio->is_prioritario)
|
|
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-amber-100 text-amber-800 ml-1"
|
|
title="{{ $territorio->prioritario ? 'Prioritario (manuale)' : 'Prioritario (giacenza)' }}">
|
|
★ {{ $territorio->prioritario ? 'Man.' : 'Auto' }}
|
|
</span>
|
|
@endif
|
|
</td>
|
|
<td class="px-4 py-3 text-sm text-gray-600">
|
|
{{ $territorio->assegnatario?->nome_completo ?? '-' }}
|
|
</td>
|
|
<td class="px-4 py-3 text-sm">
|
|
<div class="flex items-center justify-end gap-1 flex-wrap">
|
|
{{-- Primary actions: Assegna / Rientra --}}
|
|
@can('territori.assign')
|
|
@if(!$territorio->assegnazioneCorrente && $territorio->attivo)
|
|
<a href="{{ route('assegnazioni.assegna', ['territorioId' => $territorio->id]) }}" class="btn-action btn-primary-green">
|
|
<svg class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/></svg>
|
|
Assegna
|
|
</a>
|
|
@endif
|
|
@endcan
|
|
@can('territori.return')
|
|
@if($territorio->assegnazioneCorrente)
|
|
<a href="{{ route('assegnazioni.rientra', ['assegnazione' => $territorio->assegnazioneCorrente->id]) }}" class="btn-action btn-primary-red">
|
|
<svg class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"/></svg>
|
|
Rientra
|
|
</a>
|
|
@endif
|
|
@endcan
|
|
{{-- Secondary actions --}}
|
|
<a href="{{ route('territori.show', $territorio) }}" class="btn-action btn-action-indigo" title="Dettaglio">
|
|
<svg class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/></svg>
|
|
</a>
|
|
<a href="{{ route('territori.edit', $territorio) }}" class="btn-action btn-action-gray" title="Modifica">
|
|
<svg class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/></svg>
|
|
</a>
|
|
<button wire:click="toggleActive({{ $territorio->id }})" class="btn-action btn-action-amber" title="{{ $territorio->attivo ? 'Disattiva' : 'Attiva' }}">
|
|
@if($territorio->attivo)
|
|
<svg class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"/></svg>
|
|
@else
|
|
<svg class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
|
|
@endif
|
|
</button>
|
|
<button wire:click="deleteTerritorio({{ $territorio->id }})" wire:confirm="Spostare il territorio {{ $territorio->numero }} nel cestino?" class="btn-action btn-action-red" title="Elimina">
|
|
<svg class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/></svg>
|
|
</button>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="6">
|
|
<div class="empty-state">
|
|
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 20l-5.447-2.724A1 1 0 013 16.382V5.618a1 1 0 011.447-.894L9 7m0 13l6-3m-6 3V7m6 10l4.553 2.276A1 1 0 0021 18.382V7.618a1 1 0 00-.553-.894L15 4m0 13V4m0 0L9 7"/></svg>
|
|
<span class="text-sm font-medium">Nessun territorio trovato</span>
|
|
<span class="text-xs">Prova a modificare i filtri di ricerca</span>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="px-4 py-3 border-t border-gray-200">
|
|
{{ $territori->links() }}
|
|
</div>
|
|
</div>
|
|
</div>
|