@extends('layouts.app') @section('title', 'Sous-traitants') @section('breadcrumb', 'Opérations / Sous-traitants') @section('content')
{{-- En-tête --}} @if(session('success'))
{{ session('success') }}
@endif {{-- Tabs --}}
{{-- ═══════════════════════════════════ TAB : STATISTIQUES ═══════════════════════════════════ --}}
{{-- KPI Cards --}}
{{ $stats['total'] }}
Dans le catalogue
{{ $stats['utilises'] }}
Affectés à des chantiers
{{ number_format($stats['montant_total'],3,","," ") }}
Montant total TND
{{ number_format($stats['montant_regle'],3,","," ") }}
Montant réglé TND
{{-- Répartition par statut --}}

Répartition par statut

@php $nbTotal = $stats['nb_regle'] + $stats['nb_encours'] + $stats['nb_attente']; @endphp @if($nbTotal > 0)
{{-- Réglé --}}
Réglé {{ $stats['nb_regle'] }} — {{ number_format($stats['montant_regle'],3,',',' ') }} TND
{{-- En cours --}}
En cours {{ $stats['nb_encours'] }} — {{ number_format($stats['montant_encours'],3,',',' ') }} TND
{{-- En attente --}}
En attente {{ $stats['nb_attente'] }} — {{ number_format($stats['montant_attente'],3,',',' ') }} TND
@else
Aucune affectation
@endif
{{-- Répartition par corps de métier --}}

Corps de métier

@if($prestations->count())
@foreach($prestations as $p)
{{ $p->prestation }}
{{ $p->nb }}
@endforeach
@else
Aucune prestation renseignée
@endif
{{-- Top sous-traitants --}} @if($topSoustraitants->count())

Top sous-traitants par utilisation

@foreach($topSoustraitants as $i => $sst) @endforeach
# Société / Nom Corps de métier Téléphone Nb chantiers Montant total TND
{{ $i + 1 }} {{ $sst->nom }} {{ $sst->prestation ?: '—' }} {{ $sst->tel ?: '—' }} {{ $sst->chantier_soustraitants_count }} {{ number_format($sst->chantier_soustraitants_sum_montant ?? 0, 3, ',', ' ') }}
@else

Aucun sous-traitant affecté à un chantier pour l'instant.

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

Nouveau sous-traitant

@csrf
@error('nom')
{{ $message }}
@enderror
@error('email')
{{ $message }}
@enderror
{{-- Filtres --}}
{{-- Table --}}
@forelse($soustraitants as $sst) @empty @endforelse
Société / Nom Corps de métier Téléphone Email Chantiers Montant total Actions
{{ $sst->nom }} {{ $sst->prestation ?: '—' }} {{ $sst->tel ?: '—' }} {{ $sst->email ?: '—' }} @if($sst->chantier_soustraitants_count > 0) {{ $sst->chantier_soustraitants_count }} @else @endif @if(($sst->chantier_soustraitants_sum_montant ?? 0) > 0) {{ number_format($sst->chantier_soustraitants_sum_montant, 3, ',', ' ') }} TND @else — @endif
@csrf @method('DELETE')
@csrf @method('PUT')

Catalogue vide

Cliquez sur « Nouveau sous-traitant » pour en ajouter un.

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