Étape 10 : interface admin (tableau de bord + gestion utilisateurs)
- DashboardController : stats globales (sources par statut, relevés, utilisateurs, activité mensuelle 6 mois) - UserController : liste filtrée (nom/email/rôle) + édition de rôle avec protections (auto-demotion, dernier admin) - Vue admin/dashboard : compteurs par statut cliquables, graphique barres mensuel, sources à valider, relevés récents - Vue admin/utilisateurs : liste paginée avec sections et sources assignées, page d'édition avec radio-cards - Dashboard principal enrichi : bloc accès admin, mes sources assignées triées par urgence, mes derniers relevés - Navigation : ajout Tableau de bord admin et Utilisateurs dans le menu Administration Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,17 +1,136 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header">
|
||||
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
|
||||
{{ __('Dashboard') }}
|
||||
</h2>
|
||||
<h2 class="text-xl font-semibold text-gray-800">Tableau de bord</h2>
|
||||
</x-slot>
|
||||
|
||||
<div class="py-12">
|
||||
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
||||
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
|
||||
<div class="p-6 text-gray-900">
|
||||
{{ __("You're logged in!") }}
|
||||
<div class="py-8 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 space-y-8">
|
||||
|
||||
@php $user = auth()->user(); @endphp
|
||||
|
||||
{{-- Bloc admin : lien vers le dashboard admin --}}
|
||||
@if($user->isAdmin())
|
||||
<div class="bg-indigo-50 border border-indigo-200 rounded-xl p-5 flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-sm font-semibold text-indigo-800">Accès administrateur</p>
|
||||
<p class="text-xs text-indigo-600 mt-0.5">Statistiques globales, gestion des utilisateurs et des sections.</p>
|
||||
</div>
|
||||
<a href="{{ route('admin.dashboard') }}"
|
||||
class="px-4 py-2 bg-indigo-600 text-white text-sm font-medium rounded-md hover:bg-indigo-700">
|
||||
Tableau de bord admin →
|
||||
</a>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{-- Mes sources assignées --}}
|
||||
@php
|
||||
$mesSources = $user->sourcesAssignees()
|
||||
->with('sourceType')
|
||||
->withCount('releves')
|
||||
->orderByRaw("CASE status
|
||||
WHEN 'en_cours' THEN 0
|
||||
WHEN 'a_valider' THEN 1
|
||||
WHEN 'a_faire' THEN 2
|
||||
WHEN 'termine' THEN 3
|
||||
ELSE 4 END")
|
||||
->get();
|
||||
@endphp
|
||||
|
||||
@if($mesSources->isNotEmpty())
|
||||
<div class="bg-white border border-gray-200 rounded-xl p-6">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<h3 class="text-sm font-semibold text-gray-700 uppercase tracking-wide">Mes sources</h3>
|
||||
<a href="{{ route('sources.index') }}" class="text-xs text-indigo-600 hover:underline">Voir toutes</a>
|
||||
</div>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full text-sm divide-y divide-gray-100">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="pb-2 text-left text-xs font-medium text-gray-500 uppercase">Source</th>
|
||||
<th class="pb-2 text-left text-xs font-medium text-gray-500 uppercase">Type</th>
|
||||
<th class="pb-2 text-left text-xs font-medium text-gray-500 uppercase">Statut</th>
|
||||
<th class="pb-2 text-left text-xs font-medium text-gray-500 uppercase">Relevés</th>
|
||||
<th class="pb-2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-50">
|
||||
@foreach($mesSources as $source)
|
||||
@php
|
||||
$colors = [
|
||||
'a_faire' => 'bg-gray-100 text-gray-600',
|
||||
'en_cours' => 'bg-blue-100 text-blue-700',
|
||||
'a_valider' => 'bg-yellow-100 text-yellow-700',
|
||||
'termine' => 'bg-green-100 text-green-700',
|
||||
];
|
||||
$c = $colors[$source->status->value] ?? 'bg-gray-100 text-gray-600';
|
||||
@endphp
|
||||
<tr class="hover:bg-gray-50">
|
||||
<td class="py-2.5 pr-4">
|
||||
<a href="{{ route('sources.show', $source) }}"
|
||||
class="font-medium text-indigo-600 hover:underline">{{ $source->nom }}</a>
|
||||
</td>
|
||||
<td class="py-2.5 pr-4 text-gray-500">{{ $source->sourceType->nom }}</td>
|
||||
<td class="py-2.5 pr-4">
|
||||
<span class="inline-flex px-2 py-0.5 rounded-full text-xs font-medium {{ $c }}">
|
||||
{{ $source->status->label() }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="py-2.5 pr-4 text-gray-500">{{ $source->releves_count }}</td>
|
||||
<td class="py-2.5 text-right">
|
||||
<a href="{{ route('sources.releves.index', $source) }}"
|
||||
class="text-xs text-indigo-600 hover:underline">Saisir →</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
<div class="bg-white border border-gray-200 rounded-xl p-10 text-center text-gray-400">
|
||||
<svg class="mx-auto w-10 h-10 mb-3 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"
|
||||
d="M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8"/>
|
||||
</svg>
|
||||
<p class="text-sm">Vous n'êtes assigné à aucune source pour l'instant.</p>
|
||||
<a href="{{ route('sources.index') }}" class="mt-2 inline-block text-sm text-indigo-600 hover:underline">
|
||||
Voir les sources disponibles
|
||||
</a>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{-- Mes derniers relevés saisis --}}
|
||||
@php
|
||||
$mesReleves = \App\Models\Releve::with(['source.sourceType'])
|
||||
->where('created_by', $user->id)
|
||||
->orderByDesc('created_at')
|
||||
->take(8)
|
||||
->get();
|
||||
@endphp
|
||||
|
||||
@if($mesReleves->isNotEmpty())
|
||||
<div class="bg-white border border-gray-200 rounded-xl p-6">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<h3 class="text-sm font-semibold text-gray-700 uppercase tracking-wide">Mes derniers relevés</h3>
|
||||
<a href="{{ route('recherche') }}" class="text-xs text-indigo-600 hover:underline">Recherche</a>
|
||||
</div>
|
||||
<div class="space-y-0 divide-y divide-gray-100">
|
||||
@foreach($mesReleves as $releve)
|
||||
<div class="flex items-center justify-between py-2.5">
|
||||
<div class="min-w-0">
|
||||
<a href="{{ route('releves.show', $releve) }}"
|
||||
class="text-sm font-medium text-gray-900 hover:text-indigo-600">
|
||||
{{ $releve->nom ?? '—' }}{{ $releve->prenom ? ', ' . $releve->prenom : '' }}
|
||||
</a>
|
||||
<p class="text-xs text-gray-400">{{ $releve->source->nom }}</p>
|
||||
</div>
|
||||
<span class="text-xs text-gray-400 whitespace-nowrap ml-4">
|
||||
{{ $releve->created_at->diffForHumans() }}
|
||||
</span>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
</x-app-layout>
|
||||
|
||||
Reference in New Issue
Block a user