@extends('layouts.app') @section('title', 'Matériels') @section('breadcrumb', 'Opérations / Matériels') @section('content')
{{-- En-tête --}} @if(session('success'))
{{ session('success') }}
@endif {{-- Tabs --}}
{{-- ═══════════════════════════════════ TAB : STATISTIQUES ═══════════════════════════════════ --}}
{{-- KPI Cards --}}
{{ $stats['total'] }}
Dans le catalogue
{{ $stats['nb_affectations'] }}
Affectations chantiers
{{ $stats['qte_totale'] }}
Unités déployées
{{ number_format($stats['cout_loc_total'],3,","," ") }}
Coût location/j TND
{{-- Répartition par état --}}

Répartition par état

@php $nbEtat = $stats['nb_bon'] + $stats['nb_loue'] + $stats['nb_usure']; @endphp @if($nbEtat > 0)
Propriété — Bon état {{ $stats['nb_bon'] }} affectation{{ $stats['nb_bon'] > 1 ? 's' : '' }}
Location {{ $stats['nb_loue'] }} affectation{{ $stats['nb_loue'] > 1 ? 's' : '' }}
Propriété — Usure {{ $stats['nb_usure'] }} affectation{{ $stats['nb_usure'] > 1 ? 's' : '' }}
{{-- Barre composite --}}
@if($stats['nb_bon'] > 0)
@endif @if($stats['nb_loue'] > 0)
@endif @if($stats['nb_usure'] > 0)
@endif
@else
Aucune affectation
@endif
{{-- Résumé catalogue --}}

État du catalogue

Total références catalogue {{ $stats['total'] }}
Références utilisées {{ $stats['utilises'] }}
Références non utilisées {{ $stats['total'] - $stats['utilises'] }}
@if($stats['cout_loc_total'] > 0)
Coût location journalier {{ number_format($stats['cout_loc_total'],3,',',' ') }} TND
@endif
{{-- Top matériels --}} @if($topMateriels->count())

Top matériels par utilisation

@foreach($topMateriels as $i => $mat) @endforeach
# Désignation Référence Nb chantiers Qté totale déployée
{{ $i + 1 }} {{ $mat->nom }} {{ $mat->ref ?: '—' }} {{ $mat->chantier_materiels_count }} {{ $mat->chantier_materiels_sum_qte ?? 0 }} unités
@else

Aucun matériel affecté à un chantier pour l'instant.

@endif
{{-- ═══════════════════════════════════ TAB : CATALOGUE ═══════════════════════════════════ --}}
{{-- Formulaire d'ajout --}}

Nouveau matériel

@csrf
@error('nom')
{{ $message }}
@enderror
{{-- Filtres --}}
{{-- Table --}}
@forelse($materiels as $mat) @empty @endforelse
Désignation Référence Chantiers Qté totale Notes Actions
{{ $mat->nom }} {{ $mat->ref ?: '—' }} @if($mat->chantier_materiels_count > 0) {{ $mat->chantier_materiels_count }} @else @endif {{ ($mat->chantier_materiels_sum_qte ?? 0) > 0 ? $mat->chantier_materiels_sum_qte.' u.' : '—' }} {{ $mat->notes ? Str::limit($mat->notes, 55) : '—' }}
@csrf @method('DELETE')
@csrf @method('PUT')

Catalogue vide

Cliquez sur « Nouveau matériel » pour en ajouter un.

@if($materiels->hasPages())
{{ $materiels->links() }}
@endif
{{-- /tab catalogue --}}
{{-- /x-data --}} @endsection