Files
mesreleves-php/resources/views/recherche/index.blade.php
T
yann64 d064f8d28e Étapes 6-9 + types de lieux + picker + filtres
- Étape 6 : formulaire de saisie dynamique des relevés (piloté par source_type_fields, calendriers grégorien/julien/républicain)
- Étape 7 : workflow de statut des sources + notifications mail+DB (SourceAValider, SourceRejetee)
- Étape 8 : recherche fulltext PostgreSQL avec filtres type/lieu/années et CTE récursive pour les subdivisions de lieux
- Étape 9 : export GEDCOM 5.5.1 (GedcomExportService + DateConversionService)
- Types de lieux : CRUD admin (LieuTypeController) avec champ ordre
- Composant lieu-picker : modale Alpine.js avec recherche AJAX + debounce
- Filtres sources : statut, type, lieu (CTE récursive), période annee_debut/annee_fin
- Filtres lieux : type, texte, lieu parent avec descendants (CTE récursive)
- Migration : lieu_id + annee_debut + annee_fin sur sources

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-04 17:17:53 +02:00

204 lines
12 KiB
PHP

<x-app-layout>
<x-slot name="header">
<h2 class="text-xl font-semibold text-gray-800">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 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" 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 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 text-gray-600 text-sm rounded-md hover:bg-gray-50">
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 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 mb-1">Type de source</label>
<select name="source_type_id"
class="block w-full rounded-md border-gray-300 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 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 shadow-sm text-sm focus:border-indigo-500 focus:ring-indigo-500">
</div>
<div>
<label class="block text-xs font-medium text-gray-600 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 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">
Inclut toutes les subdivisions de {{ $lieuSelectionne->nom_long ?? $lieuSelectionne->nom }}.
</p>
@endif
</div>
</div>
</div>
</form>
</div>
{{-- Résultats --}}
@if($resultats !== null)
<div>
<p class="text-sm text-gray-500 mb-3">
@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
<a href="{{ route('export.recherche', request()->query()) }}"
class="text-indigo-600 hover:underline">
Exporter en GEDCOM
</a>
@endif
</p>
@if($resultats->isNotEmpty())
<div class="bg-white shadow rounded-lg overflow-hidden">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200 text-sm">
<thead class="bg-gray-50">
<tr>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Nom</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Prénom</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Date</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Source</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Type</th>
<th class="px-4 py-3"></th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
@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">
<td class="px-4 py-3 font-medium text-gray-900">
@if(request('q') && $releve->nom)
{!! preg_replace('/(' . preg_quote(request('q'), '/') . ')/i', '<mark class="bg-yellow-100 rounded px-0.5">$1</mark>', e($releve->nom)) !!}
@else
{{ $releve->nom ?? '—' }}
@endif
</td>
<td class="px-4 py-3 text-gray-700">
@if(request('q') && $releve->prenom)
{!! preg_replace('/(' . preg_quote(request('q'), '/') . ')/i', '<mark class="bg-yellow-100 rounded px-0.5">$1</mark>', e($releve->prenom)) !!}
@else
{{ $releve->prenom ?? '—' }}
@endif
</td>
<td class="px-4 py-3 text-gray-600 whitespace-nowrap">
{{ $dateAffichee }}
</td>
<td class="px-4 py-3 text-gray-600">
<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 text-gray-600">
{{ $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>
@if($resultats->hasPages())
<div class="px-6 py-4 border-t border-gray-200">
{{ $resultats->links() }}
</div>
@endif
</div>
@endif
</div>
@else
{{-- État initial --}}
<div class="text-center py-16 text-gray-400">
<svg class="mx-auto w-12 h-12 mb-4 text-gray-300" 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>