La richiesta era per la pagina Assegna, non per la scheda del territorio:
annullata la modifica di f1f3408 (storico nascosto nella scheda) e ora il
link "Assegna ->" della Home porta ?dalla_home=1, con cui Assegna non
mostra ne' carica l'elenco "Territori Assegnati".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
217 lines
13 KiB
PHP
217 lines
13 KiB
PHP
<div>
|
|
<div class="mb-6 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
|
|
<div>
|
|
<a href="{{ $ritorno ?? route('territori.index') }}" class="inline-flex items-center gap-1 text-sm text-gray-500 hover:text-indigo-600 transition-colors mb-1">
|
|
<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="M15 19l-7-7 7-7"/></svg>
|
|
{{ $ritorno ? 'Torna indietro' : 'Torna alla lista' }}
|
|
</a>
|
|
<h1 class="text-2xl font-bold text-gray-900">Territorio {{ $territorio->numero }}</h1>
|
|
</div>
|
|
<div class="flex items-center gap-2 flex-wrap">
|
|
@can('territori.assign')
|
|
@if(!$territorio->assegnazioneCorrente && $territorio->attivo)
|
|
<x-btn data-ritorno variante="primary" :href="route('assegnazioni.assegna', ['territorioId' => $territorio->id])">
|
|
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/></svg>
|
|
Assegna
|
|
</x-btn>
|
|
@endif
|
|
@endcan
|
|
@can('territori.return')
|
|
@if($territorio->assegnazioneCorrente)
|
|
{{-- Rientra era rosso pieno quanto un Elimina. Non cancella
|
|
niente: è l'azione principale di un territorio assegnato,
|
|
quindi primary come Assegna, che è la sua alternativa. --}}
|
|
<x-btn data-ritorno variante="primary" :href="route('assegnazioni.rientra', ['assegnazione' => $territorio->assegnazioneCorrente->id])">
|
|
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"/></svg>
|
|
Rientra
|
|
</x-btn>
|
|
@endif
|
|
@endcan
|
|
@can('territori.manage')
|
|
<x-btn data-ritorno variante="secondary" :href="route('territori.edit', $territorio)">
|
|
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"><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>
|
|
Modifica
|
|
</x-btn>
|
|
@endcan
|
|
</div>
|
|
</div>
|
|
|
|
{{-- L'invio del link dopo l'assegnazione non si è concluso --}}
|
|
@if($territorio->assegnazioneCorrente?->link_in_sospeso)
|
|
<div class="mb-6 flex flex-wrap items-center justify-between gap-3 rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800" role="status">
|
|
<span class="font-semibold">Il link della piantina è ancora da inviare a {{ $territorio->assegnazioneCorrente->proclamatore?->nome_completo }}.</span>
|
|
@can('territori.assign')
|
|
<x-btn data-ritorno variante="secondary" dimensione="sm" :href="route('assegnazioni.assegna', ['invia' => $territorio->assegnazioneCorrente->id])">Invia link</x-btn>
|
|
@endcan
|
|
</div>
|
|
@endif
|
|
|
|
{{-- Info card --}}
|
|
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6 mb-6">
|
|
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
|
<div>
|
|
<p class="text-xs font-medium text-gray-500 uppercase">Stato</p>
|
|
@php $stato = $territorio->stato; @endphp
|
|
<span class="inline-flex items-center mt-1 px-2.5 py-0.5 rounded-full text-xs font-medium
|
|
{{ match($stato) {
|
|
'in_reparto' => 'bg-green-100 text-green-800',
|
|
'in_gruppo' => 'bg-purple-100 text-purple-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'
|
|
} }}">
|
|
{{ $territorio->stato_etichetta }}
|
|
</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">★ Prioritario</span>
|
|
@endif
|
|
</div>
|
|
<div>
|
|
<p class="text-xs font-medium text-gray-500 uppercase">Zona</p>
|
|
<p class="mt-1 text-sm text-gray-900">{{ $territorio->zona?->nome ?? '-' }}</p>
|
|
</div>
|
|
<div>
|
|
<p class="text-xs font-medium text-gray-500 uppercase">Tipologia</p>
|
|
<p class="mt-1 text-sm text-gray-900">{{ $territorio->tipologia?->nome ?? '-' }}</p>
|
|
</div>
|
|
<div>
|
|
<p class="text-xs font-medium text-gray-500 uppercase">Assegnatario</p>
|
|
<p class="mt-1 text-sm text-gray-900">{{ $territorio->assegnatario?->nome_completo ?? 'Nessuno' }}</p>
|
|
</div>
|
|
</div>
|
|
|
|
@if($territorio->note)
|
|
<div class="mt-4 pt-4 border-t">
|
|
<p class="text-xs font-medium text-gray-500 uppercase">Note</p>
|
|
<p class="mt-1 text-sm text-gray-700">{{ $territorio->note }}</p>
|
|
</div>
|
|
@endif
|
|
|
|
@if($territorio->confini)
|
|
<div class="mt-4 pt-4 border-t">
|
|
<p class="text-xs font-medium text-gray-500 uppercase">Confini</p>
|
|
<p class="mt-1 text-sm text-gray-700">{{ $territorio->confini }}</p>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
|
|
@if($activeAssignment)
|
|
@php($temporaryPdfUrl = $activeAssignment->shortPdfUrl())
|
|
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6 mb-6" x-data="{ copied: false }">
|
|
<div class="flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between">
|
|
<div>
|
|
<h2 class="text-lg font-semibold text-gray-900">Assegnazione attiva</h2>
|
|
<p class="mt-1 text-sm text-gray-600">
|
|
{{ $activeAssignment->proclamatore?->nome_completo ?? 'N/A' }}
|
|
— assegnato il {{ $activeAssignment->assigned_at->format('d/m/Y') }}
|
|
— {{ $activeAssignment->giorni }} giorni
|
|
</p>
|
|
</div>
|
|
<div class="flex flex-wrap gap-2">
|
|
@can('territori.return')
|
|
<x-btn data-ritorno variante="primary" :href="route('assegnazioni.rientra', ['assegnazione' => $activeAssignment->id])">Rientra</x-btn>
|
|
@endcan
|
|
</div>
|
|
</div>
|
|
|
|
@if($temporaryPdfUrl)
|
|
<div class="mt-4 rounded-xl border border-indigo-100 bg-indigo-50/70 p-4">
|
|
<div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
|
<div>
|
|
<div class="text-sm font-medium text-indigo-900">Link PDF temporaneo</div>
|
|
<div class="mt-1 text-xs text-indigo-700">Valido fino al {{ optional($assignmentScadenza)->format('d/m/Y') ?? '—' }} (soglia rientro) o fino al rientro del territorio.</div>
|
|
</div>
|
|
<x-btn variante="secondary" :href="$temporaryPdfUrl" target="_blank" rel="noopener noreferrer">Apri viewer</x-btn>
|
|
</div>
|
|
<div class="mt-3 flex flex-col gap-2 sm:flex-row">
|
|
<input x-ref="assignmentPdfLink" type="text" readonly value="{{ $temporaryPdfUrl }}" class="block w-full rounded-lg border border-indigo-200 bg-white px-3 py-2 text-sm text-gray-700 focus:border-indigo-500 focus:ring-indigo-500">
|
|
<x-btn variante="primary" @click="navigator.clipboard.writeText($refs.assignmentPdfLink.value); copied = true; setTimeout(() => copied = false, 1800);">Copia link</x-btn>
|
|
</div>
|
|
<p x-show="copied" x-cloak class="mt-2 text-xs font-medium text-green-700">Link copiato.</p>
|
|
</div>
|
|
@elseif($territorio->pdf_path)
|
|
<div class="mt-4 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800">
|
|
Il link PDF temporaneo è disponibile solo per assegnazioni attive con PDF associato.
|
|
</div>
|
|
@endif
|
|
</div>
|
|
@endif
|
|
|
|
{{-- PDF viewer --}}
|
|
@if($territorio->pdf_path)
|
|
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-4 mb-6">
|
|
<h3 class="text-sm font-semibold text-gray-700 mb-3">PDF Territorio</h3>
|
|
<div class="w-full" style="min-height: 500px;">
|
|
<embed src="{{ $territorio->pdfUrl() }}" type="application/pdf" width="100%" height="500px">
|
|
<p class="mt-2 text-sm text-gray-500">
|
|
Se il PDF non è visibile:
|
|
<a href="{{ $territorio->pdfUrl() }}" target="_blank" class="text-indigo-600 hover:underline">Scarica PDF</a>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
@endif
|
|
|
|
{{-- Assignment history --}}
|
|
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6">
|
|
<div class="flex items-center gap-3 mb-4">
|
|
<div class="h-8 w-8 rounded-lg flex items-center justify-center" style="background:#eef2ff">
|
|
<svg class="h-4 w-4" style="color:#6366f1" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
|
|
</div>
|
|
<h3 class="text-lg font-semibold text-gray-900">Storico Assegnazioni</h3>
|
|
</div>
|
|
|
|
{{-- Una tabella sola, colonne a larghezza fissa: con una tabella per
|
|
anno ciascuna si dimensionava sul suo contenuto e le colonne non
|
|
erano in linea. L'anno è una riga di separazione (tm-riga-gruppo).
|
|
Ordine: dal più recente, per anno e per data di assegnazione. --}}
|
|
@if($assegnazioniPerAnno->isEmpty())
|
|
<p class="text-gray-500 text-sm">Nessuna assegnazione registrata.</p>
|
|
@else
|
|
<div class="overflow-x-auto">
|
|
<table class="min-w-full table-fixed text-sm table-cards">
|
|
<thead class="bg-gray-50">
|
|
<tr>
|
|
<th class="w-[36%] px-3 py-2 text-left text-xs font-medium text-gray-500">Proclamatore</th>
|
|
<th class="w-[15%] px-3 py-2 text-left text-xs font-medium text-gray-500">Assegnato</th>
|
|
<th class="w-[15%] px-3 py-2 text-left text-xs font-medium text-gray-500">Rientrato</th>
|
|
<th class="w-[9%] px-3 py-2 text-right text-xs font-medium text-gray-500">Giorni</th>
|
|
<th class="w-[25%] px-3 py-2 text-left text-xs font-medium text-gray-500">Campagna</th>
|
|
</tr>
|
|
</thead>
|
|
@foreach($assegnazioniPerAnno as $annoLabel => $assegnazioni)
|
|
<tbody class="divide-y divide-gray-100">
|
|
<tr class="tm-riga-gruppo">
|
|
<th colspan="5" scope="colgroup" class="px-3 pt-5 pb-2 text-left text-sm font-semibold text-indigo-600 bg-white">Anno Teocratico {{ $annoLabel }}</th>
|
|
</tr>
|
|
@foreach($assegnazioni as $assegnazione)
|
|
<tr>
|
|
<td data-label="Proclamatore" class="px-3 py-2">{{ $assegnazione->proclamatore?->nome_completo ?? 'N/A' }}@if($assegnazione->gruppo_nome)<span class="ml-1 inline-flex rounded-full bg-purple-50 px-2 py-0.5 text-xs text-purple-700">via gruppo {{ $assegnazione->gruppo_nome }}</span>@endif</td>
|
|
<td data-label="Assegnato" class="px-3 py-2 tabular-nums">{{ $assegnazione->assigned_at->format('d/m/Y') }}</td>
|
|
<td data-label="Rientrato" class="px-3 py-2 tabular-nums">
|
|
@if($assegnazione->returned_at)
|
|
{{ $assegnazione->returned_at->format('d/m/Y') }}
|
|
@else
|
|
<span class="text-amber-600 font-medium">In corso</span>
|
|
@endif
|
|
</td>
|
|
<td data-label="Giorni" class="px-3 py-2 text-right tabular-nums">{{ $assegnazione->giorni }}</td>
|
|
<td data-label="Campagna" class="px-3 py-2">
|
|
@if($assegnazione->counted_in_campaign)
|
|
<span class="text-green-600">Sì — {{ $assegnazione->campagna?->descrizione }}</span>
|
|
@elseif($assegnazione->counted_in_campaign === false)
|
|
<span class="text-gray-400">No</span>
|
|
@else
|
|
<span class="text-gray-300">-</span>
|
|
@endif
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
@endforeach
|
|
</table>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
</div>
|