Suppression de l'export GEDCOM

- Routes export.source et export.recherche supprimées
- ExportController : méthodes source() et recherche() supprimées,
  imports GedcomExportService/DbCompat/Releve/SourceStatus/DB retirés
- Boutons GEDCOM retirés de sources/show, releves/index et recherche/index

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 20:01:33 +02:00
parent 82e2ae5cd6
commit ff615ca0a1
5 changed files with 3 additions and 118 deletions
+2 -101
View File
@@ -3,21 +3,11 @@
namespace App\Http\Controllers;
use App\Enums\FieldType;
use App\Enums\SourceStatus;
use App\Models\Releve;
use App\Models\Source;
use App\Services\GedcomExportService;
use App\Support\DbCompat;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB;
class ExportController extends Controller
{
public function __construct(
private readonly GedcomExportService $gedcom,
) {}
/** Export CSV de tous les relevés d'une source */
public function sourceCsv(Source $source): Response
{
@@ -38,8 +28,8 @@ class ExportController extends Controller
foreach ($source->releves as $releve) {
$row = [];
foreach ($fields as $field) {
$val = $releve->data[$field->name] ?? null;
$row[] = $this->formatCsvValue($val, $field->type);
$val = $releve->data[$field->name] ?? null;
$row[] = $this->formatCsvValue($val, $field->type);
}
fputcsv($handle, $row, ';');
}
@@ -56,95 +46,6 @@ class ExportController extends Controller
]);
}
/** Export de tous les relevés d'une source */
public function source(Source $source): Response
{
$this->authorize('view', $source);
$gedcomContent = $this->gedcom->exportSource($source);
$filename = $this->sanitizeFilename($source->nom) . '.ged';
return response($gedcomContent, 200, [
'Content-Type' => 'text/plain; charset=UTF-8',
'Content-Disposition' => "attachment; filename=\"{$filename}\"",
]);
}
/** Export depuis les résultats de recherche (avec les mêmes filtres) */
public function recherche(Request $request): Response
{
$user = auth()->user();
$query = Releve::with(['source.sourceType', 'createur'])
->whereHas('source', function ($q) use ($user, $request) {
if (! $user->isSectionManager()) {
$assignedIds = $user->sourcesAssignees()->pluck('sources.id');
$q->where(function ($sq) use ($assignedIds) {
$sq->where('status', SourceStatus::Termine)
->orWhereIn('id', $assignedIds);
});
}
if ($request->filled('source_type_id')) {
$q->where('source_type_id', $request->integer('source_type_id'));
}
}); // $request déjà dans le use()
if ($request->filled('q')) {
$q = trim($request->get('q'));
$like = DbCompat::like();
$fts = DbCompat::ftsRaw();
$query->where(function ($wq) use ($q, $like, $fts) {
$wq->where('nom', $like, "%{$q}%")
->orWhere('prenom', $like, "%{$q}%")
->orWhere('date_evenement', $like, "%{$q}%");
if ($fts) {
$wq->orWhereRaw($fts, [$q]);
}
});
}
if ($request->filled('lieu_id')) {
$rows = DB::select("
WITH RECURSIVE descendants AS (
SELECT id, nom FROM lieux WHERE id = ?
UNION ALL
SELECT l.id, l.nom FROM lieux l
INNER JOIN descendants d ON l.lieu_parent_id = d.id
)
SELECT DISTINCT nom FROM descendants WHERE nom IS NOT NULL
", [$request->integer('lieu_id')]);
$noms = collect($rows)->pluck('nom')->filter();
if ($noms->isNotEmpty()) {
$pattern = $noms->map(fn ($n) => preg_quote($n, '/'))->join('|');
$query->whereRaw(DbCompat::jsonRegexRaw('data'), [$pattern]);
}
}
if ($request->filled('annee_debut')) {
$query->whereRaw('date_evenement >= ?', [$request->integer('annee_debut') . '-01-01']);
}
if ($request->filled('annee_fin')) {
$query->whereRaw('date_evenement <= ?', [$request->integer('annee_fin') . '-12-31']);
}
$releves = $query->orderByRaw(DbCompat::nullsLast('nom'))->get();
if ($releves->isEmpty()) {
return back()->with('error', 'Aucun relevé à exporter.');
}
$titre = $request->filled('q') ? 'Recherche_' . $request->get('q') : 'Export';
$gedcomContent = $this->gedcom->exportReleves($releves, $titre);
$filename = $this->sanitizeFilename($titre) . '.ged';
return response($gedcomContent, 200, [
'Content-Type' => 'text/plain; charset=UTF-8',
'Content-Disposition' => "attachment; filename=\"{$filename}\"",
]);
}
private function formatCsvValue(mixed $val, FieldType $type): string
{
if ($val === null || $val === '') {
@@ -108,11 +108,6 @@
@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>
+1 -6
View File
@@ -10,12 +10,7 @@
</div>
<div class="flex items-center gap-3">
<a href="{{ route('sources.show', $source) }}" class="text-sm text-indigo-600 hover:underline"> Source</a>
<a href="{{ route('export.source', $source) }}"
class="px-4 py-2 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 text-sm rounded-md hover:bg-gray-50 dark:hover:bg-gray-700"
title="Télécharger au format GEDCOM 5.5.1">
GEDCOM
</a>
@can('create', [App\Models\Releve::class, $source])
@can('create', [App\Models\Releve::class, $source])
<a href="{{ route('sources.releves.create', $source) }}"
class="px-4 py-2 bg-indigo-600 text-white text-sm rounded-md hover:bg-indigo-700">
+ Nouveau relevé
-4
View File
@@ -140,10 +140,6 @@
class="px-3 py-1.5 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 text-xs rounded-md hover:bg-gray-50 dark:hover:bg-gray-600">
CSV
</a>
<a href="{{ route('export.source', $source) }}"
class="px-3 py-1.5 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 text-xs rounded-md hover:bg-gray-50 dark:hover:bg-gray-600">
GEDCOM
</a>
@endif
@can('create', [App\Models\Releve::class, $source])
<a href="{{ route('sources.releves.create', $source) }}"
-2
View File
@@ -60,9 +60,7 @@ Route::middleware('auth')->group(function () {
Route::get('recherche', [RechercheController::class, 'index'])->name('recherche');
Route::get('carte', [CarteController::class, 'index'])->name('carte');
Route::get('carte/data', [CarteController::class, 'data'])->name('carte.data');
Route::get('export/source/{source}', [ExportController::class, 'source'])->name('export.source');
Route::get('export/source/{source}/csv', [ExportController::class, 'sourceCsv'])->name('export.source.csv');
Route::get('export/recherche', [ExportController::class, 'recherche'])->name('export.recherche');
Route::get('notifications', [NotificationController::class, 'index'])->name('notifications.index');
Route::post('notifications/{id}/read', [NotificationController::class, 'markAsRead'])->name('notifications.read');