feat: dashboard amélioré, exports budgets, alertes expiration et correctifs

## Dashboard
- Refonte complète du tableau de bord avec widgets budgets, commandes, contrats
- Intégration des données d'exécution budgétaire en temps réel

## Exports & Rapports
- BudgetExecutionExport : export Excel de l'exécution budgétaire
- Template PDF budgets (budgets_pdf.blade.php)
- Routes d'export PDF et Excel

## Alertes & Notifications
- Commande CheckExpirations : détection des contrats/assets arrivant à échéance
- Mail ExpiringElementsMail avec template Blade
- Planification via routes/console.php

## Correctifs
- CommandePolicy et ContratPolicy : ajustements des règles d'autorisation
- ContratController : corrections mineures
- Commande model : ajustements relations/casts
- AuthenticatedLayout : refonte navigation avec icônes budgets
- Assets/Form.vue : corrections formulaire
- Seeder rôles/permissions mis à jour
- Dépendances composer mises à jour (barryvdh/laravel-dompdf, maatwebsite/excel)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jeremy bayse
2026-04-11 20:20:49 +02:00
parent 0ad77de412
commit 04fc56cd70
18 changed files with 1403 additions and 229 deletions

View File

@@ -11,13 +11,14 @@ const userInitials = computed(() => {
?.split(' ').map(n => n[0]).join('').toUpperCase().slice(0, 2) ?? '??'
})
const roleLabels = { admin: 'Administrateur', responsable: 'Responsable', acheteur: 'Acheteur', lecteur: 'Lecteur' }
const roleLabels = { admin: 'Administrateur', responsable: 'Responsable', acheteur: 'Acheteur', lecteur: 'Lecteur', raf: 'Responsable Administratif et Financier' }
const userRole = computed(() => {
const role = user.value?.roles?.[0]?.name
return roleLabels[role] ?? role ?? ''
})
const isAdmin = computed(() => user.value?.roles?.some(r => r.name === 'admin'))
const isRAF = computed(() => user.value?.roles?.some(r => r.name === 'raf'))
const canCreate = computed(() => user.value?.roles?.some(r => ['admin', 'responsable', 'acheteur'].includes(r.name)))
function isActive(...names) {
@@ -42,6 +43,8 @@ function isActive(...names) {
<!-- Navigation -->
<nav class="flex-1 overflow-y-auto px-3 py-4 space-y-6">
<!-- Dashboard -->
<div>
<Link :href="route('dashboard')"
@@ -55,6 +58,42 @@ function isActive(...names) {
</Link>
</div>
<!-- Calendrier -->
<div>
<Link :href="route('calendar.index')"
:class="['flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors',
isActive('calendar') ? 'bg-blue-600 text-white' : 'text-gray-300 hover:bg-gray-800 hover:text-white']">
<svg class="h-5 w-5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" />
</svg>
Calendrier
</Link>
</div>
<!-- Budgets -->
<div>
<p class="mb-1 px-3 text-xs font-semibold uppercase tracking-wider text-gray-500">Budgets</p>
<div class="space-y-1">
<Link :href="route('budgets.index')"
:class="['flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors',
route().current('budgets.index') || route().current('budgets.show') ? 'bg-indigo-600 text-white' : 'text-gray-300 hover:bg-gray-800 hover:text-white']">
<svg class="h-5 w-5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
Planification
</Link>
<Link :href="route('budgets.execution')"
:class="['flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors',
route().current('budgets.execution') ? 'bg-indigo-600 text-white' : 'text-gray-300 hover:bg-gray-800 hover:text-white']">
<svg class="h-5 w-5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" />
</svg>
Exécution réelle
</Link>
</div>
</div>
<!-- Commandes -->
<div>
<p class="mb-1 px-3 text-xs font-semibold uppercase tracking-wider text-gray-500">Commandes</p>
@@ -66,15 +105,9 @@ function isActive(...names) {
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M4 6h16M4 10h16M4 14h16M4 18h16" />
</svg>
Toutes les commandes
</Link>
<Link v-if="canCreate" :href="route('commandes.create')"
class="flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-800 hover:text-white transition-colors">
<svg class="h-5 w-5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
</svg>
Nouvelle commande
Commandes
</Link>
</div>
</div>
@@ -88,13 +121,22 @@ function isActive(...names) {
<svg class="h-5 w-5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
</svg>
Tous les contrats
Contrats
</Link>
<Link :href="route('licences.index')"
:class="['flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors',
isActive('licences') ? 'bg-blue-600 text-white' : 'text-gray-300 hover:bg-gray-800 hover:text-white']">
<svg class="h-5 w-5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z" />
</svg>
Licences
</Link>
</div>
</div>
<!-- Domaines -->
<div>
<div v-if="!isRAF">
<p class="mb-1 px-3 text-xs font-semibold uppercase tracking-wider text-gray-500">Infrastructures</p>
<div class="space-y-1">
<Link :href="route('domaines.index')"
@@ -111,13 +153,13 @@ function isActive(...names) {
<svg class="h-5 w-5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01" />
</svg>
Assets (Matériels)
Matériels
</Link>
</div>
</div>
<!-- Catalogue -->
<div>
<div v-if="!isRAF">
<p class="mb-1 px-3 text-xs font-semibold uppercase tracking-wider text-gray-500">Catalogue</p>
<div class="space-y-1">
<Link :href="route('fournisseurs.index')"
@@ -172,24 +214,7 @@ function isActive(...names) {
</svg>
Services
</Link>
<Link :href="route('licences.index')"
:class="['flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors',
isActive('licences') ? 'bg-blue-600 text-white' : 'text-gray-300 hover:bg-gray-800 hover:text-white']">
<svg class="h-5 w-5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z" />
</svg>
Licences
</Link>
<Link :href="route('calendar.index')"
:class="['flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors',
isActive('calendar') ? 'bg-blue-600 text-white' : 'text-gray-300 hover:bg-gray-800 hover:text-white']">
<svg class="h-5 w-5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" />
</svg>
Calendrier
</Link>
<Link :href="route('communes.index')"
:class="['flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors',
isActive('communes') ? 'bg-blue-600 text-white' : 'text-gray-300 hover:bg-gray-800 hover:text-white']">

View File

@@ -1,7 +1,8 @@
<script setup>
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue'
import { Head, Link, useForm } from '@inertiajs/vue3'
import { ref } from 'vue'
import { ref, computed } from 'vue'
import SearchableSelect from '@/Components/SearchableSelect.vue'
const props = defineProps({
asset: Object,
@@ -27,6 +28,13 @@ const form = useForm({
notes: props.asset?.notes || '',
})
const commandesOptions = computed(() => {
return props.commandes.map(cmd => ({
value: cmd.id,
label: `${cmd.numero_commande ?? 'Sans-N'} - ${cmd.objet}`
}))
})
const isSearchingEan = ref(false)
const eanError = ref('')
const eanSuccess = ref('')
@@ -220,12 +228,11 @@ function submit() {
<h2 class="mb-5 text-sm font-semibold uppercase tracking-wide text-gray-500 font-bold">Achat & Commande</h2>
<div>
<label class="block text-sm font-medium text-gray-700">Commande associée (optionnel)</label>
<select v-model="form.commande_id" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm">
<option value="">Aucune commande liée</option>
<option v-for="cmd in commandes" :key="cmd.id" :value="cmd.id">
N° {{ cmd.numero_commande ?? 'Sans-N' }} - {{ cmd.objet }}
</option>
</select>
<SearchableSelect
v-model="form.commande_id"
:options="commandesOptions"
placeholder="Rechercher par numéro ou objet..."
/>
<p class="mt-1 text-xs text-gray-500">Permet de retrouver l'origine de l'achat et les justificatifs.</p>
</div>
</div>

View File

@@ -1,31 +1,39 @@
<script setup>
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue'
import StatCard from '@/Components/StatCard.vue'
import StatutBadge from '@/Components/Commandes/StatutBadge.vue'
import PrioriteBadge from '@/Components/Commandes/PrioriteBadge.vue'
import { Link } from '@inertiajs/vue3'
import { Head } from '@inertiajs/vue3'
import { Link, Head } from '@inertiajs/vue3'
const props = defineProps({
stats: Object,
commandesRecentes: Array,
commandesEnRetard: Array,
commandesUrgentes: Array,
statsParStatut: Object,
statsParService: Array,
montantParMois: Array,
statsContrats: Object,
statsDomaines: Object,
budgetsStats: Object,
})
function formatDate(d) {
const formatDate = (d) => {
if (!d) return '—'
return new Intl.DateTimeFormat('fr-FR').format(new Date(d))
}
function formatCurrency(v) {
if (v == null) return ''
return new Intl.NumberFormat('fr-FR', { style: 'currency', currency: 'EUR' }).format(v)
const formatCurrency = (v) => {
if (v == null) return '0 €'
return new Intl.NumberFormat('fr-FR', { style: 'currency', currency: 'EUR', maximumFractionDigits: 0 }).format(v)
}
const calculatePercent = (consumed, total) => {
if (!total || total <= 0) return 0
return Math.min(Math.round((consumed / total) * 100), 100)
}
const getProgressBarHexColor = (percent) => {
if (percent < 50) return '#3b82f6' // Blue 500
if (percent < 80) return '#eab308' // Yellow 500
if (percent < 100) return '#f97316' // Orange 500
return '#ef4444' // Red 500
}
</script>
@@ -34,179 +42,240 @@ function formatCurrency(v) {
<AuthenticatedLayout>
<template #header>
<h1 class="text-xl font-semibold text-gray-900">Tableau de bord</h1>
<div class="flex items-center justify-between">
<h1 class="text-2xl font-bold text-gray-900 tracking-tight">Tableau de bord <span class="text-gray-400 font-normal">/ {{ new Date().getFullYear() }}</span></h1>
<div class="flex items-center gap-2">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
Système Opérationnel
</span>
</div>
</div>
</template>
<div class="space-y-6">
<!-- Stat cards -->
<div class="grid grid-cols-2 gap-4 sm:grid-cols-4">
<StatCard label="Total commandes" :value="stats.total" color="blue" />
<StatCard label="En cours" :value="stats.en_cours" color="indigo" />
<StatCard label="En retard" :value="stats.en_retard" color="red" />
<StatCard label="Urgentes actives" :value="stats.commandees + stats.validees" color="amber" />
<div class="space-y-8 pb-10">
<!-- Top Stats Row -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
<div class="bg-white p-6 rounded-2xl shadow-sm border border-gray-100">
<p class="text-sm font-medium text-gray-500">Commandes en cours</p>
<div class="mt-2 flex items-baseline gap-2">
<span class="text-3xl font-bold text-gray-900">{{ stats.en_cours }}</span>
<span class="text-sm text-red-600 font-medium" v-if="stats.en_retard > 0">{{ stats.en_retard }} en retard</span>
</div>
</div>
<div class="bg-white p-6 rounded-2xl shadow-sm border border-gray-100">
<p class="text-sm font-medium text-gray-500">Budget Consommé (Agglo)</p>
<div class="mt-2 flex items-baseline gap-2">
<span class="text-3xl font-bold text-blue-600">{{ formatCurrency(budgetsStats.agglo.consomme) }}</span>
<span class="text-xs text-gray-400">/ {{ formatCurrency(budgetsStats.agglo.total_arbitre) }}</span>
</div>
</div>
<div class="bg-white p-6 rounded-2xl shadow-sm border border-gray-100">
<p class="text-sm font-medium text-gray-500">Budget Consommé (Mutualisé)</p>
<div class="mt-2 flex items-baseline gap-2">
<span class="text-3xl font-bold text-indigo-600">{{ formatCurrency(budgetsStats.mutualise.consomme) }}</span>
<span class="text-xs text-gray-400">/ {{ formatCurrency(budgetsStats.mutualise.total_arbitre) }}</span>
</div>
</div>
<div class="bg-white p-6 rounded-2xl shadow-sm border border-gray-100">
<p class="text-sm font-medium text-gray-500">Contrats à renouveler</p>
<div class="mt-2 flex items-baseline gap-2">
<span class="text-3xl font-bold text-orange-600">{{ statsContrats.proches + statsContrats.en_retard }}</span>
<span class="text-sm text-gray-400">échéances</span>
</div>
</div>
</div>
<!-- Contrats & Domaines Stats -->
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
<!-- Contrats -->
<div class="rounded-xl bg-white p-5 shadow-sm border border-gray-100 flex items-center justify-between">
<div>
<h2 class="text-sm font-semibold uppercase tracking-wide text-gray-500 mb-2">Contrats en cours</h2>
<div class="flex gap-6">
<Link :href="route('contrats.index')" class="flex flex-col">
<span class="text-xs text-gray-400">Total</span>
<span class="font-bold text-gray-900">{{ statsContrats.total }}</span>
</Link>
<Link :href="route('contrats.index')" class="flex flex-col">
<span class="text-xs text-gray-400">À renouveler ()</span>
<span class="font-bold text-orange-600">{{ statsContrats.proches }}</span>
</Link>
<Link :href="route('contrats.index')" class="flex flex-col">
<span class="text-xs text-gray-400">Expirés ()</span>
<span class="font-bold text-red-600">{{ statsContrats.en_retard }}</span>
</Link>
<!-- Budget Gauges -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<!-- Agglo Card -->
<div class="bg-white p-6 rounded-3xl shadow-sm border border-gray-100">
<h3 class="font-bold text-gray-900 mb-6 flex items-center gap-2">
<span class="w-2 h-2 rounded-full bg-blue-500"></span>
Exécution Agglomération
</h3>
<div class="grid grid-cols-2 gap-8">
<!-- Fonctionnement -->
<div class="flex flex-col items-center">
<div class="relative w-full h-24 flex items-center justify-center">
<svg class="w-full h-full" viewBox="0 0 100 60">
<path d="M 12 55 A 38 38 0 0 1 88 55" fill="#edf2f7" stroke="#2d3748" stroke-width="1.5" />
<path d="M 12 55 A 38 38 0 0 1 31 22 L 50 55 Z" fill="#48bb78" />
<path d="M 31 22 A 38 38 0 0 1 69 22 L 50 55 Z" fill="#ecc94b" />
<path d="M 69 22 A 38 38 0 0 1 88 55 L 50 55 Z" fill="#f6ad55" />
<g :style="{ transform: `rotate(${(calculatePercent(budgetsStats.agglo.fonctionnement.consomme, budgetsStats.agglo.fonctionnement.total_arbitre) * 1.8) - 90}deg)`, transformOrigin: '50px 55px' }" class="transition-transform duration-1000 ease-out">
<path d="M 48.5 55 L 50 20 L 51.5 55 Z" fill="#e53e3e" stroke="#2d3748" stroke-width="0.3" />
<circle cx="50" cy="55" r="2" fill="#2d3748" />
</g>
</svg>
<div class="absolute -bottom-1 left-0 flex items-baseline gap-1">
<span class="text-xl font-black text-gray-900">{{ calculatePercent(budgetsStats.agglo.fonctionnement.consomme, budgetsStats.agglo.fonctionnement.total_arbitre) }}%</span>
</div>
</div>
<div class="mt-4 w-full">
<p class="text-[10px] uppercase font-black text-gray-400 tracking-widest leading-none mb-1">Fonctionnement</p>
<p class="text-sm font-bold text-gray-900">{{ formatCurrency(budgetsStats.agglo.fonctionnement.consomme) }}</p>
</div>
</div>
<!-- Investissement -->
<div class="flex flex-col items-center">
<div class="relative w-full h-24 flex items-center justify-center">
<svg class="w-full h-full" viewBox="0 0 100 60">
<path d="M 12 55 A 38 38 0 0 1 88 55" fill="#edf2f7" stroke="#2d3748" stroke-width="1.5" />
<path d="M 12 55 A 38 38 0 0 1 31 22 L 50 55 Z" fill="#48bb78" />
<path d="M 31 22 A 38 38 0 0 1 69 22 L 50 55 Z" fill="#ecc94b" />
<path d="M 69 22 A 38 38 0 0 1 88 55 L 50 55 Z" fill="#f6ad55" />
<g :style="{ transform: `rotate(${(calculatePercent(budgetsStats.agglo.investissement.consomme, budgetsStats.agglo.investissement.total_arbitre) * 1.8) - 90}deg)`, transformOrigin: '50px 55px' }" class="transition-transform duration-1000 ease-out">
<path d="M 48.5 55 L 50 20 L 51.5 55 Z" fill="#e53e3e" stroke="#2d3748" stroke-width="0.3" />
<circle cx="50" cy="55" r="2" fill="#2d3748" />
</g>
</svg>
<div class="absolute -bottom-1 left-0 flex items-baseline gap-1">
<span class="text-xl font-black text-gray-900">{{ calculatePercent(budgetsStats.agglo.investissement.consomme, budgetsStats.agglo.investissement.total_arbitre) }}%</span>
</div>
</div>
<div class="mt-4 w-full">
<p class="text-[10px] uppercase font-black text-gray-400 tracking-widest leading-none mb-1">Investissement</p>
<p class="text-sm font-bold text-gray-900">{{ formatCurrency(budgetsStats.agglo.investissement.consomme) }}</p>
</div>
</div>
</div>
<Link :href="route('contrats.index')" class="text-gray-400 hover:text-indigo-600 transition-colors">
<svg class="h-8 w-8" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" /></svg>
</Link>
</div>
<!-- Domaines -->
<div class="rounded-xl bg-white p-5 shadow-sm border border-gray-100 flex items-center justify-between">
<div>
<h2 class="text-sm font-semibold uppercase tracking-wide text-gray-500 mb-2">Noms de domaine</h2>
<div class="flex gap-6">
<Link :href="route('domaines.index')" class="flex flex-col">
<span class="text-xs text-gray-400">Total</span>
<span class="font-bold text-gray-900">{{ statsDomaines.total }}</span>
</Link>
<Link :href="route('domaines.index')" class="flex flex-col">
<span class="text-xs text-gray-400">À renouveler ()</span>
<span class="font-bold text-orange-600">{{ statsDomaines.proches }}</span>
</Link>
<Link :href="route('domaines.index')" class="flex flex-col">
<span class="text-xs text-gray-400">Expirés ()</span>
<span class="font-bold text-red-600">{{ statsDomaines.en_retard }}</span>
</Link>
<!-- Mutualise Card -->
<div class="bg-white p-6 rounded-3xl shadow-sm border border-gray-100">
<h3 class="font-bold text-gray-900 mb-6 flex items-center gap-2">
<span class="w-2 h-2 rounded-full bg-indigo-500"></span>
Exécution Mutualisation
</h3>
<div class="grid grid-cols-2 gap-8">
<!-- Fonctionnement -->
<div class="flex flex-col items-center">
<div class="relative w-full h-24 flex items-center justify-center">
<svg class="w-full h-full" viewBox="0 0 100 60">
<path d="M 12 55 A 38 38 0 0 1 88 55" fill="#edf2f7" stroke="#2d3748" stroke-width="1.5" />
<path d="M 12 55 A 38 38 0 0 1 31 22 L 50 55 Z" fill="#48bb78" />
<path d="M 31 22 A 38 38 0 0 1 69 22 L 50 55 Z" fill="#ecc94b" />
<path d="M 69 22 A 38 38 0 0 1 88 55 L 50 55 Z" fill="#f6ad55" />
<g :style="{ transform: `rotate(${(calculatePercent(budgetsStats.mutualise.fonctionnement.consomme, budgetsStats.mutualise.fonctionnement.total_arbitre) * 1.8) - 90}deg)`, transformOrigin: '50px 55px' }" class="transition-transform duration-1000 ease-out">
<path d="M 48.5 55 L 50 20 L 51.5 55 Z" fill="#e53e3e" stroke="#2d3748" stroke-width="0.3" />
<circle cx="50" cy="55" r="2" fill="#2d3748" />
</g>
</svg>
<div class="absolute -bottom-1 left-0 flex items-baseline gap-1">
<span class="text-xl font-black text-gray-900">{{ calculatePercent(budgetsStats.mutualise.fonctionnement.consomme, budgetsStats.mutualise.fonctionnement.total_arbitre) }}%</span>
</div>
</div>
<div class="mt-4 w-full">
<p class="text-[10px] uppercase font-black text-gray-400 tracking-widest leading-none mb-1">Fonctionnement</p>
<p class="text-sm font-bold text-gray-900">{{ formatCurrency(budgetsStats.mutualise.fonctionnement.consomme) }}</p>
</div>
</div>
<!-- Investissement -->
<div class="flex flex-col items-center">
<div class="relative w-full h-24 flex items-center justify-center">
<svg class="w-full h-full" viewBox="0 0 100 60">
<path d="M 12 55 A 38 38 0 0 1 88 55" fill="#edf2f7" stroke="#2d3748" stroke-width="1.5" />
<path d="M 12 55 A 38 38 0 0 1 31 22 L 50 55 Z" fill="#48bb78" />
<path d="M 31 22 A 38 38 0 0 1 69 22 L 50 55 Z" fill="#ecc94b" />
<path d="M 69 22 A 38 38 0 0 1 88 55 L 50 55 Z" fill="#f6ad55" />
<g :style="{ transform: `rotate(${(calculatePercent(budgetsStats.mutualise.investissement.consomme, budgetsStats.mutualise.investissement.total_arbitre) * 1.8) - 90}deg)`, transformOrigin: '50px 55px' }" class="transition-transform duration-1000 ease-out">
<path d="M 48.5 55 L 50 20 L 51.5 55 Z" fill="#e53e3e" stroke="#2d3748" stroke-width="0.3" />
<circle cx="50" cy="55" r="2" fill="#2d3748" />
</g>
</svg>
<div class="absolute -bottom-1 left-0 flex items-baseline gap-1">
<span class="text-xl font-black text-gray-900">{{ calculatePercent(budgetsStats.mutualise.investissement.consomme, budgetsStats.mutualise.investissement.total_arbitre) }}%</span>
</div>
</div>
<div class="mt-4 w-full">
<p class="text-[10px] uppercase font-black text-gray-400 tracking-widest leading-none mb-1">Investissement</p>
<p class="text-sm font-bold text-gray-900">{{ formatCurrency(budgetsStats.mutualise.investissement.consomme) }}</p>
</div>
</div>
</div>
<Link :href="route('domaines.index')" class="text-gray-400 hover:text-indigo-600 transition-colors">
<svg class="h-8 w-8" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9" /></svg>
</Link>
</div>
</div>
<!-- Statut breakdown -->
<div class="grid grid-cols-2 gap-4 sm:grid-cols-4">
<div class="rounded-xl bg-white p-4 shadow-sm border border-gray-100">
<p class="text-xs font-medium text-gray-500 uppercase">Brouillons</p>
<p class="mt-1 text-2xl font-bold text-gray-700">{{ stats.brouillons }}</p>
</div>
<div class="rounded-xl bg-white p-4 shadow-sm border border-gray-100">
<p class="text-xs font-medium text-yellow-600 uppercase">En validation</p>
<p class="mt-1 text-2xl font-bold text-yellow-700">{{ stats.en_attente_validation }}</p>
</div>
<div class="rounded-xl bg-white p-4 shadow-sm border border-gray-100">
<p class="text-xs font-medium text-blue-600 uppercase">Validées</p>
<p class="mt-1 text-2xl font-bold text-blue-700">{{ stats.validees }}</p>
</div>
<div class="rounded-xl bg-white p-4 shadow-sm border border-gray-100">
<p class="text-xs font-medium text-indigo-600 uppercase">Commandées</p>
<p class="mt-1 text-2xl font-bold text-indigo-700">{{ stats.commandees }}</p>
</div>
</div>
<!-- Alertes retard + Services -->
<div class="grid gap-6 lg:grid-cols-2">
<!-- En retard -->
<div class="rounded-xl bg-white shadow-sm border border-gray-100">
<div class="flex items-center justify-between border-b border-gray-100 px-5 py-4">
<h2 class="font-semibold text-gray-900">Commandes en retard</h2>
<span class="rounded-full bg-red-100 px-2.5 py-1 text-xs font-medium text-red-700">{{ stats.en_retard }}</span>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- Main Content: Recent Orders -->
<div class="lg:col-span-2 space-y-6">
<div class="bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden">
<div class="px-6 py-4 border-b border-gray-50 flex items-center justify-between">
<h3 class="font-bold text-gray-900">Dernières commandes</h3>
<Link :href="route('commandes.index')" class="text-sm text-blue-600 font-medium hover:underline">Voir tout</Link>
</div>
<div class="divide-y divide-gray-50">
<div v-for="cmd in commandesRecentes" :key="cmd.id" class="px-6 py-4 hover:bg-gray-50 transition-colors flex items-center justify-between">
<div class="flex items-center gap-4">
<div class="p-2 rounded-lg bg-gray-50">
<svg class="h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z" /></svg>
</div>
<div>
<Link :href="route('commandes.show', cmd.id)" class="text-sm font-bold text-gray-900 hover:text-blue-600">{{ cmd.numero_commande }}</Link>
<p class="text-xs text-gray-500 truncate max-w-[200px]">{{ cmd.objet }}</p>
</div>
</div>
<div class="flex items-center gap-4">
<StatutBadge :statut="cmd.statut" size="sm" />
<span class="text-sm font-bold text-gray-900 min-w-[80px] text-right">{{ formatCurrency(cmd.montant_ttc) }}</span>
</div>
</div>
</div>
</div>
<div class="divide-y divide-gray-50">
<div v-for="cmd in commandesEnRetard" :key="cmd.id"
class="flex items-center justify-between px-5 py-3 hover:bg-gray-50 transition-colors">
<div class="min-w-0">
<Link :href="route('commandes.show', cmd.id)"
class="truncate text-sm font-medium text-blue-600 hover:underline">
{{ cmd.numero_commande }}
</div>
<!-- Sidebar: Action alerts -->
<div class="space-y-6">
<!-- Urgent/Late Orders -->
<div class="bg-white rounded-2xl shadow-sm border border-gray-100 border-l-4 border-l-red-500 overflow-hidden">
<div class="px-5 py-4 border-b border-gray-50">
<h3 class="font-bold text-gray-900 text-sm">Alertes prioritaires</h3>
</div>
<div class="p-2">
<div v-for="cmd in commandesEnRetard" :key="cmd.id" class="p-3 mb-1 rounded-xl bg-red-50 hover:bg-red-100 transition-colors">
<Link :href="route('commandes.show', cmd.id)" class="block">
<div class="flex justify-between items-start mb-1">
<span class="text-xs font-bold text-red-700">{{ cmd.numero_commande }}</span>
<span class="text-[10px] uppercase font-bold text-red-600">Retard</span>
</div>
<p class="text-xs text-red-800 line-clamp-1">{{ cmd.objet }}</p>
</Link>
<p class="truncate text-xs text-gray-500">{{ cmd.objet }}</p>
</div>
<div class="ml-4 flex-shrink-0 text-right">
<p class="text-xs text-red-600 font-medium">{{ formatDate(cmd.date_souhaitee) }}</p>
<p class="text-xs text-gray-400">{{ cmd.service?.nom }}</p>
<div v-if="!commandesEnRetard.length" class="p-10 text-center">
<div class="inline-flex p-3 rounded-full bg-green-50 text-green-600 mb-2">
<svg class="h-6 w-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" /></svg>
</div>
<p class="text-sm text-gray-500 font-medium">Tout est à jour !</p>
</div>
</div>
<p v-if="!commandesEnRetard.length" class="px-5 py-6 text-center text-sm text-gray-400">
Aucune commande en retard.
</p>
</div>
</div>
<!-- Par service -->
<div class="rounded-xl bg-white shadow-sm border border-gray-100">
<div class="border-b border-gray-100 px-5 py-4">
<h2 class="font-semibold text-gray-900">Par service</h2>
</div>
<div class="divide-y divide-gray-50">
<div v-for="service in statsParService" :key="service.id" class="px-5 py-4">
<!-- Contract Expiry -->
<div class="bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden">
<div class="px-5 py-4 border-b border-gray-50">
<h3 class="font-bold text-gray-900 text-sm">Échéancier Contrats</h3>
</div>
<div class="p-5 space-y-4">
<div class="flex items-center justify-between">
<div class="flex items-center gap-3">
<div class="h-3 w-3 rounded-full" :style="{ backgroundColor: service.couleur || '#6B7280' }" />
<span class="text-sm font-medium text-gray-900">{{ service.nom }}</span>
</div>
<div class="text-right">
<p class="text-sm font-bold text-gray-900">{{ service.commandes_count }}</p>
<p class="text-xs text-gray-500">{{ service.commandes_en_cours_count }} en cours</p>
</div>
<span class="text-xs text-gray-500">Expirés</span>
<span class="px-2 py-0.5 rounded-full bg-red-100 text-red-700 text-xs font-bold">{{ statsContrats.en_retard }}</span>
</div>
<div class="mt-2 h-1.5 rounded-full bg-gray-100 overflow-hidden">
<div class="h-full rounded-full transition-all"
:style="{ width: stats.total ? (service.commandes_count / stats.total * 100) + '%' : '0%', backgroundColor: service.couleur || '#6B7280' }" />
<div class="flex items-center justify-between">
<span class="text-xs text-gray-500">À renouveler (90j)</span>
<span class="px-2 py-0.5 rounded-full bg-orange-100 text-orange-700 text-xs font-bold">{{ statsContrats.proches }}</span>
</div>
<Link :href="route('contrats.index')" class="block text-center py-2 text-xs font-bold text-indigo-600 bg-indigo-50 rounded-lg hover:bg-indigo-100">Gérer les contrats</Link>
</div>
</div>
</div>
</div>
<!-- Commandes récentes -->
<div class="rounded-xl bg-white shadow-sm border border-gray-100">
<div class="flex items-center justify-between border-b border-gray-100 px-5 py-4">
<h2 class="font-semibold text-gray-900">Commandes récentes</h2>
<Link :href="route('commandes.index')" class="text-sm text-blue-600 hover:underline">Voir tout</Link>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-100 text-sm">
<thead class="bg-gray-50">
<tr>
<th class="px-5 py-3 text-left text-xs font-medium text-gray-500 uppercase">N°</th>
<th class="px-5 py-3 text-left text-xs font-medium text-gray-500 uppercase">Objet</th>
<th class="px-5 py-3 text-left text-xs font-medium text-gray-500 uppercase">Service</th>
<th class="px-5 py-3 text-left text-xs font-medium text-gray-500 uppercase">Statut</th>
<th class="px-5 py-3 text-left text-xs font-medium text-gray-500 uppercase">Priorité</th>
<th class="px-5 py-3 text-right text-xs font-medium text-gray-500 uppercase">Montant TTC</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-50">
<tr v-for="cmd in commandesRecentes" :key="cmd.id" class="hover:bg-gray-50 transition-colors">
<td class="px-5 py-3 font-medium">
<Link :href="route('commandes.show', cmd.id)" class="text-blue-600 hover:underline">
{{ cmd.numero_commande }}
</Link>
</td>
<td class="px-5 py-3 max-w-xs truncate text-gray-700">{{ cmd.objet }}</td>
<td class="px-5 py-3 text-gray-500">{{ cmd.service?.nom }}</td>
<td class="px-5 py-3"><StatutBadge :statut="cmd.statut" /></td>
<td class="px-5 py-3"><PrioriteBadge :priorite="cmd.priorite" /></td>
<td class="px-5 py-3 text-right font-medium text-gray-900">{{ formatCurrency(cmd.montant_ttc) }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</AuthenticatedLayout>
</template>