aaf0fc2cd9
Export (GET lieux/export/csv) : - Colonnes : nom, code, type, lieu_parent (nom_long), latitude, longitude, note - BOM UTF-8, séparateur point-virgule Import (GET/POST lieux/import) : - Correspondance par nom de colonne (colonne nom obligatoire) - Résolution du parent par nom_long exact - Résolution du type par nom exact - Détection automatique du séparateur ; ou , - nom_long recalculé automatiquement par le modèle Boutons ↓ CSV, ↑ Importer CSV et + Nouveau lieu dans la liste des lieux. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
81 lines
4.5 KiB
PHP
81 lines
4.5 KiB
PHP
<x-app-layout>
|
|
<x-slot name="header">
|
|
<h2 class="text-xl font-semibold text-gray-800 dark:text-gray-200">Importer des lieux</h2>
|
|
</x-slot>
|
|
|
|
<div class="py-8 max-w-2xl mx-auto px-4 sm:px-6 lg:px-8 space-y-6">
|
|
|
|
@if(session('error'))
|
|
<div class="p-4 bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-700 text-red-800 dark:text-red-200 rounded-md">
|
|
{{ session('error') }}
|
|
</div>
|
|
@endif
|
|
|
|
<div class="bg-white dark:bg-gray-800 shadow rounded-lg p-6">
|
|
<form method="POST" action="{{ route('lieux.import.store') }}" enctype="multipart/form-data">
|
|
@csrf
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
|
|
Fichier CSV <span class="text-red-500">*</span>
|
|
</label>
|
|
<input type="file" name="fichier" accept=".csv,.txt" required
|
|
class="block w-full text-sm text-gray-700 dark:text-gray-300
|
|
file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0
|
|
file:text-sm file:font-medium file:bg-indigo-50 file:text-indigo-700
|
|
hover:file:bg-indigo-100 dark:file:bg-indigo-900/30 dark:file:text-indigo-300">
|
|
@error('fichier')
|
|
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
|
|
@enderror
|
|
</div>
|
|
<div class="mt-5">
|
|
<button type="submit"
|
|
class="px-5 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 text-sm">
|
|
Importer
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="bg-gray-50 dark:bg-gray-700 rounded-lg p-5 text-sm space-y-3">
|
|
<p class="font-medium text-gray-700 dark:text-gray-300">Format attendu</p>
|
|
<ul class="text-gray-600 dark:text-gray-400 space-y-1 list-disc list-inside">
|
|
<li>Encodage <strong>UTF-8</strong>, séparateur <strong>point-virgule</strong> (<code>;</code>) ou virgule (<code>,</code>)</li>
|
|
<li>Première ligne = en-têtes (noms exacts ci-dessous)</li>
|
|
<li>Le parent est identifié par son <strong>nom long complet</strong> (ex : <code>Gironde, France</code>)</li>
|
|
<li>Le type est identifié par son <strong>nom exact</strong> tel que défini dans les types de lieux</li>
|
|
</ul>
|
|
|
|
<div class="mt-3 overflow-x-auto">
|
|
<table class="text-xs border-collapse w-full">
|
|
<thead>
|
|
<tr class="bg-gray-200 dark:bg-gray-600">
|
|
@foreach(['nom *', 'code', 'type', 'lieu_parent', 'latitude', 'longitude', 'note'] as $col)
|
|
<th class="border border-gray-300 dark:border-gray-500 px-2 py-1 text-left font-mono text-gray-700 dark:text-gray-200">{{ $col }}</th>
|
|
@endforeach
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr class="text-gray-500 dark:text-gray-400">
|
|
<td class="border border-gray-300 dark:border-gray-500 px-2 py-1">Bordeaux</td>
|
|
<td class="border border-gray-300 dark:border-gray-500 px-2 py-1">33063</td>
|
|
<td class="border border-gray-300 dark:border-gray-500 px-2 py-1">Commune</td>
|
|
<td class="border border-gray-300 dark:border-gray-500 px-2 py-1">Gironde, France</td>
|
|
<td class="border border-gray-300 dark:border-gray-500 px-2 py-1">44.8378</td>
|
|
<td class="border border-gray-300 dark:border-gray-500 px-2 py-1">-0.5792</td>
|
|
<td class="border border-gray-300 dark:border-gray-500 px-2 py-1"></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<p class="text-gray-500 dark:text-gray-400 text-xs mt-2">
|
|
Astuce : utilisez
|
|
<a href="{{ route('lieux.export.csv') }}" class="text-indigo-600 hover:underline">l'export CSV</a>
|
|
de la liste des lieux comme modèle.
|
|
</p>
|
|
</div>
|
|
|
|
<a href="{{ route('lieux.index') }}" class="text-sm text-indigo-600 hover:underline">← Retour aux lieux</a>
|
|
</div>
|
|
</x-app-layout>
|