6a73a2f001
- Admin : CRUD complet utilisateurs (créer, modifier nom/email/mdp/rôle, supprimer) avec garde-fous (dernier admin, compte propre) - Recherche : limite configurable par l'admin (défaut 200), bannière d'avertissement quand la limite est atteinte, plus de pagination (résultats en bloc) - Lieux : liste non chargée sans filtre actif (performance sur grands volumes) - Sources : idem pour admin/responsables ; membres voient toujours leurs sources - Logo 404 prod : +FollowSymLinks dans .htaccess, storage:link dans l'assistant d'installation, bouton "Recréer le lien" dans Administration → Paramètres Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
208 lines
13 KiB
PHP
208 lines
13 KiB
PHP
<x-app-layout>
|
|
<x-slot name="header">
|
|
<h2 class="text-xl font-semibold text-gray-800 dark:text-gray-200">Recherche dans les relevés</h2>
|
|
</x-slot>
|
|
|
|
<div class="py-8 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 space-y-6">
|
|
|
|
{{-- Formulaire de recherche --}}
|
|
<div class="bg-white dark:bg-gray-800 shadow rounded-lg p-6">
|
|
<form method="GET" action="{{ route('recherche') }}" class="space-y-4">
|
|
|
|
{{-- Barre principale --}}
|
|
<div class="flex gap-3">
|
|
<div class="flex-1 relative">
|
|
<div class="absolute inset-y-0 left-3 flex items-center pointer-events-none">
|
|
<svg class="w-5 h-5 text-gray-400 dark:text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M21 21l-4.35-4.35M17 11A6 6 0 1 1 5 11a6 6 0 0 1 12 0z"/>
|
|
</svg>
|
|
</div>
|
|
<input type="text" name="q" value="{{ request('q') }}"
|
|
placeholder="Nom, prénom, lieu, note…"
|
|
autofocus
|
|
class="block w-full pl-10 pr-4 py-2.5 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm
|
|
text-sm focus:border-indigo-500 focus:ring-indigo-500">
|
|
</div>
|
|
<button type="submit"
|
|
class="px-6 py-2.5 bg-indigo-600 text-white text-sm font-medium rounded-md hover:bg-indigo-700">
|
|
Rechercher
|
|
</button>
|
|
@if(request()->anyFilled(['q', 'source_type_id', 'annee_debut', 'annee_fin']))
|
|
<a href="{{ route('recherche') }}"
|
|
class="px-4 py-2.5 border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 text-sm rounded-md hover:bg-gray-50 dark:hover:bg-gray-700">
|
|
Effacer
|
|
</a>
|
|
@endif
|
|
</div>
|
|
|
|
{{-- Filtres avancés --}}
|
|
@php
|
|
$hasAdvanced = request()->anyFilled(['source_type_id', 'lieu_id', 'annee_debut', 'annee_fin']);
|
|
@endphp
|
|
<div x-data="{ open: {{ $hasAdvanced ? 'true' : 'false' }} }">
|
|
<button type="button" @click="open = !open"
|
|
class="text-sm text-indigo-600 hover:underline flex items-center gap-1">
|
|
<span x-text="open ? '▲ Masquer les filtres' : '▼ Filtres avancés'"></span>
|
|
@if($hasAdvanced)
|
|
<span class="ml-1 inline-flex items-center px-1.5 py-0.5 rounded-full text-xs bg-indigo-100 dark:bg-indigo-900/50 text-indigo-700">
|
|
actifs
|
|
</span>
|
|
@endif
|
|
</button>
|
|
|
|
<div x-show="open" x-cloak class="mt-4 space-y-4">
|
|
<div class="grid grid-cols-3 gap-4">
|
|
<div>
|
|
<label class="block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1">Type de source</label>
|
|
<select name="source_type_id"
|
|
class="block w-full rounded-md border-gray-300 dark:border-gray-600 shadow-sm text-sm focus:border-indigo-500 focus:ring-indigo-500">
|
|
<option value="">— Tous les types —</option>
|
|
@foreach($sourceTypes as $st)
|
|
<option value="{{ $st->id }}" {{ request('source_type_id') == $st->id ? 'selected' : '' }}>
|
|
{{ $st->nom }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1">Année de début</label>
|
|
<input type="number" name="annee_debut" value="{{ request('annee_debut') }}"
|
|
min="1000" max="2100" placeholder="ex : 1820"
|
|
class="block w-full rounded-md border-gray-300 dark:border-gray-600 shadow-sm text-sm focus:border-indigo-500 focus:ring-indigo-500">
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1">Année de fin</label>
|
|
<input type="number" name="annee_fin" value="{{ request('annee_fin') }}"
|
|
min="1000" max="2100" placeholder="ex : 1830"
|
|
class="block w-full rounded-md border-gray-300 dark:border-gray-600 shadow-sm text-sm focus:border-indigo-500 focus:ring-indigo-500">
|
|
</div>
|
|
</div>
|
|
|
|
{{-- Filtre par lieu --}}
|
|
<div class="max-w-sm">
|
|
<x-lieu-picker
|
|
name="lieu_id"
|
|
label="Lieu (et ses subdivisions)"
|
|
:value="request('lieu_id')"
|
|
:display-value="$lieuSelectionne?->nom_long ?? $lieuSelectionne?->nom ?? ''"
|
|
placeholder="— Tous les lieux —"
|
|
/>
|
|
@if($lieuSelectionne)
|
|
<p class="mt-1 text-xs text-gray-400 dark:text-gray-500">
|
|
Inclut toutes les subdivisions de {{ $lieuSelectionne->nom_long ?? $lieuSelectionne->nom }}.
|
|
</p>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
{{-- Résultats --}}
|
|
@if($resultats !== null)
|
|
<div>
|
|
<div class="flex items-center justify-between mb-3">
|
|
<p class="text-sm text-gray-500 dark:text-gray-400">
|
|
@if($total === 0)
|
|
Aucun relevé trouvé.
|
|
@else
|
|
<strong>{{ number_format($total) }}</strong> relevé{{ $total > 1 ? 's' : '' }} trouvé{{ $total > 1 ? 's' : '' }}
|
|
@if(request('q')) pour <em>« {{ request('q') }} »</em> @endif
|
|
@endif
|
|
</p>
|
|
</div>
|
|
|
|
@if($limited)
|
|
<div class="mb-4 p-4 bg-amber-50 dark:bg-amber-900/30 border border-amber-200 dark:border-amber-700 rounded-md flex items-start gap-3">
|
|
<svg class="w-5 h-5 text-amber-500 shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/>
|
|
</svg>
|
|
<p class="text-sm text-amber-800 dark:text-amber-200">
|
|
Seuls les <strong>{{ number_format($resultats->count()) }} premiers résultats</strong> sur {{ number_format($total) }} sont affichés.
|
|
Affinez vos critères de recherche pour obtenir des résultats plus précis.
|
|
</p>
|
|
</div>
|
|
@endif
|
|
|
|
@if($resultats->isNotEmpty())
|
|
<div class="bg-white dark:bg-gray-800 shadow rounded-lg overflow-hidden">
|
|
<div class="overflow-x-auto">
|
|
<table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700 text-sm">
|
|
<thead class="bg-gray-50 dark:bg-gray-700">
|
|
<tr>
|
|
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Nom</th>
|
|
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Prénom</th>
|
|
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Date</th>
|
|
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Source</th>
|
|
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Type</th>
|
|
<th class="px-4 py-3"></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-200 dark:divide-gray-700">
|
|
@foreach($resultats as $releve)
|
|
@php
|
|
$data = $releve->data;
|
|
$dateEvt = $data['date_evenement'] ?? null;
|
|
$dateAffichee = is_array($dateEvt)
|
|
? ($dateEvt['valeur'] ?? '—') . ($dateEvt['calendrier'] !== 'gregorien' ? ' (' . $dateEvt['calendrier'] . ')' : '')
|
|
: ($releve->date_evenement ?? '—');
|
|
@endphp
|
|
<tr class="hover:bg-gray-50 dark:hover:bg-gray-700">
|
|
<td class="px-4 py-3 font-medium text-gray-900 dark:text-white">
|
|
@if(request('q') && $releve->nom)
|
|
{!! preg_replace('/(' . preg_quote(request('q'), '/') . ')/i', '<mark class="bg-yellow-100 dark:bg-yellow-900/50 rounded px-0.5">$1</mark>', e($releve->nom)) !!}
|
|
@else
|
|
{{ $releve->nom ?? '—' }}
|
|
@endif
|
|
</td>
|
|
<td class="px-4 py-3 text-gray-700 dark:text-gray-300">
|
|
@if(request('q') && $releve->prenom)
|
|
{!! preg_replace('/(' . preg_quote(request('q'), '/') . ')/i', '<mark class="bg-yellow-100 dark:bg-yellow-900/50 rounded px-0.5">$1</mark>', e($releve->prenom)) !!}
|
|
@else
|
|
{{ $releve->prenom ?? '—' }}
|
|
@endif
|
|
</td>
|
|
<td class="px-4 py-3 text-gray-600 dark:text-gray-400 whitespace-nowrap">
|
|
{{ $dateAffichee }}
|
|
</td>
|
|
<td class="px-4 py-3 text-gray-600 dark:text-gray-400">
|
|
<a href="{{ route('sources.show', $releve->source) }}"
|
|
class="hover:text-indigo-600 hover:underline">
|
|
{{ $releve->source->nom }}
|
|
</a>
|
|
</td>
|
|
<td class="px-4 py-3">
|
|
<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-400">
|
|
{{ $releve->source->sourceType->nom }}
|
|
</span>
|
|
</td>
|
|
<td class="px-4 py-3 text-right">
|
|
<a href="{{ route('releves.show', $releve) }}"
|
|
class="text-indigo-600 hover:underline text-xs">
|
|
Voir →
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
</div>
|
|
@endif
|
|
</div>
|
|
@else
|
|
{{-- État initial --}}
|
|
<div class="text-center py-16 text-gray-400 dark:text-gray-500">
|
|
<svg class="mx-auto w-12 h-12 mb-4 text-gray-300 dark:text-gray-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"
|
|
d="M21 21l-4.35-4.35M17 11A6 6 0 1 1 5 11a6 6 0 0 1 12 0z"/>
|
|
</svg>
|
|
<p class="text-sm">Saisissez un nom, prénom, lieu ou tout autre terme pour rechercher dans les relevés.</p>
|
|
</div>
|
|
@endif
|
|
|
|
</div>
|
|
</x-app-layout>
|