Import/export CSV utilisateurs, filtre statut et titre du site modifiable
Utilisateurs :
- Filtre actif/inactif dans la liste (status=active|inactive)
- Export CSV avec les filtres actifs — séparateur ;, BOM UTF-8 (compatible Excel)
- Import CSV : détection auto du séparateur, validation ligne par ligne,
mot de passe temporaire généré + affiché une seule fois dans les résultats
- Téléchargement d'un fichier modèle CSV
Paramètres du site :
- Champ "Titre du site" (site_name dans site_settings.json)
- Titre partagé via SiteSettingsService::siteName() et injecté dans config('app.name')
au boot — s'applique partout sans modifier .env
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header">
|
||||
<div class="flex items-center justify-between">
|
||||
<h2 class="text-xl font-semibold text-gray-800">Importer des utilisateurs</h2>
|
||||
<a href="{{ route('admin.utilisateurs.index') }}"
|
||||
class="text-sm text-indigo-600 hover:underline">← Retour à la liste</a>
|
||||
</div>
|
||||
</x-slot>
|
||||
|
||||
<div class="py-8 max-w-3xl mx-auto px-4 sm:px-6 lg:px-8 space-y-6">
|
||||
|
||||
{{-- Résultats d'import --}}
|
||||
@if(isset($results))
|
||||
<div class="bg-white shadow rounded-lg p-6 space-y-4">
|
||||
<div class="flex items-center gap-4">
|
||||
@if($created > 0)
|
||||
<span class="text-green-700 font-semibold text-sm">
|
||||
✓ {{ $created }} compte{{ $created > 1 ? 's' : '' }} créé{{ $created > 1 ? 's' : '' }}
|
||||
</span>
|
||||
@endif
|
||||
@if($errors > 0)
|
||||
<span class="text-red-600 font-semibold text-sm">
|
||||
✗ {{ $errors }} ligne{{ $errors > 1 ? 's' : '' }} en erreur
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@if($created > 0)
|
||||
<div class="p-3 bg-amber-50 border border-amber-200 rounded-lg text-xs text-amber-800">
|
||||
Les mots de passe temporaires ci-dessous sont affichés <strong>une seule fois</strong>.
|
||||
Notez-les et communiquez-les aux utilisateurs concernés. Ils pourront les changer via leur profil.
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full text-sm divide-y divide-gray-200">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Ligne</th>
|
||||
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Nom</th>
|
||||
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">E-mail</th>
|
||||
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Rôle</th>
|
||||
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Mot de passe temporaire</th>
|
||||
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Statut</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-200 bg-white">
|
||||
@foreach($results as $r)
|
||||
<tr class="{{ $r['ok'] ? '' : 'bg-red-50' }}">
|
||||
<td class="px-4 py-2 text-gray-400">{{ $r['line'] }}</td>
|
||||
<td class="px-4 py-2 font-medium text-gray-900">{{ $r['name'] }}</td>
|
||||
<td class="px-4 py-2 text-gray-600">{{ $r['email'] }}</td>
|
||||
<td class="px-4 py-2 text-gray-500">{{ $r['role'] ?? '' }}</td>
|
||||
<td class="px-4 py-2 font-mono text-indigo-700">
|
||||
{{ $r['ok'] ? $r['password'] : '' }}
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
@if($r['ok'])
|
||||
<span class="text-green-700 font-medium">✓ Créé</span>
|
||||
@else
|
||||
<span class="text-red-600 text-xs">{{ $r['error'] }}</span>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="pt-2">
|
||||
<a href="{{ route('admin.utilisateurs.index') }}"
|
||||
class="px-5 py-2 bg-indigo-600 text-white text-sm font-medium rounded-md hover:bg-indigo-700 inline-block">
|
||||
Voir la liste des utilisateurs
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{-- Formulaire d'import --}}
|
||||
<div class="bg-white shadow rounded-lg p-6 space-y-5">
|
||||
<h3 class="text-sm font-semibold text-gray-700 uppercase tracking-wide">Importer un fichier CSV</h3>
|
||||
|
||||
@if($errors->any())
|
||||
<div class="p-4 bg-red-50 border border-red-200 text-red-700 text-sm rounded-md space-y-1">
|
||||
@foreach($errors->all() as $e)<p>{{ $e }}</p>@endforeach
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="p-4 bg-blue-50 border border-blue-200 rounded-lg text-sm text-blue-800 space-y-1">
|
||||
<p class="font-semibold">Format attendu du fichier CSV :</p>
|
||||
<ul class="list-disc list-inside text-xs space-y-0.5">
|
||||
<li>Séparateur : <code class="bg-blue-100 px-1 rounded">;</code> ou <code class="bg-blue-100 px-1 rounded">,</code></li>
|
||||
<li>Encodage : UTF-8 (avec ou sans BOM)</li>
|
||||
<li>Colonnes obligatoires : <code class="bg-blue-100 px-1 rounded">name</code>, <code class="bg-blue-100 px-1 rounded">email</code>, <code class="bg-blue-100 px-1 rounded">role</code></li>
|
||||
<li>Colonne optionnelle : <code class="bg-blue-100 px-1 rounded">is_active</code> (1 ou 0, défaut : 1)</li>
|
||||
<li>Valeurs acceptées pour <code class="bg-blue-100 px-1 rounded">role</code> :
|
||||
<code class="bg-blue-100 px-1 rounded">member</code>,
|
||||
<code class="bg-blue-100 px-1 rounded">section_manager</code>,
|
||||
<code class="bg-blue-100 px-1 rounded">admin</code>
|
||||
</li>
|
||||
<li>Un mot de passe temporaire aléatoire sera généré pour chaque compte importé.</li>
|
||||
</ul>
|
||||
<a href="{{ route('admin.utilisateurs.import.modele') }}"
|
||||
class="inline-block mt-2 text-xs text-indigo-700 font-medium hover:underline">
|
||||
↓ Télécharger le fichier modèle (CSV)
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<form method="POST" action="{{ route('admin.utilisateurs.import.store') }}"
|
||||
enctype="multipart/form-data" class="space-y-4">
|
||||
@csrf
|
||||
<div>
|
||||
<label for="file" class="block text-sm font-medium text-gray-700 mb-1">
|
||||
Fichier CSV <span class="text-red-500">*</span>
|
||||
</label>
|
||||
<input type="file" id="file" name="file" accept=".csv,.txt" required
|
||||
class="block w-full text-sm text-gray-500
|
||||
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">
|
||||
<p class="mt-1 text-xs text-gray-400">Taille maximale : 2 Mo.</p>
|
||||
@error('file') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
|
||||
</div>
|
||||
|
||||
<button type="submit"
|
||||
class="px-5 py-2 bg-indigo-600 text-white text-sm font-medium rounded-md hover:bg-indigo-700">
|
||||
Importer
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
Reference in New Issue
Block a user