@extends('layouts.app') @section('title', 'Achat') @section('breadcrumb', 'Commercial / Achat') @section('content') @php $aTypes = ['' => 'Tous', 'demande_achat' => 'D. Achat', 'commande_achat' => 'Commande', 'br' => 'Bon Réc.', 'facture_achat' => 'Facture', 'avoir_achat' => 'Avoir']; $tabIcons = ['' => 'fa-th-list', 'demande_achat' => 'fa-file-alt', 'commande_achat' => 'fa-shopping-basket', 'br' => 'fa-boxes', 'facture_achat' => 'fa-file-invoice', 'avoir_achat' => 'fa-undo-alt']; $activeTab = request('type', ''); $tabBase = request()->except(['type', 'page']); $achatColors = ['demande_achat'=>'btn-secondary','commande_achat'=>'btn-primary','br'=>'btn-success','facture_achat'=>'btn-warning']; $achatLabels = ['demande_achat'=>'D. Achat','commande_achat'=>'Commande','br'=>'Bon Réc.','facture_achat'=>'Facture']; // Pre-compute JS data — @json() cannot span multiple lines in Blade $amFournisseurs = $fournisseurs->map(fn($f) => ['id' => $f->id, 'nom' => $f->nom])->values(); $amProduits = $produits->map(fn($p) => ['id' => $p->id, 'nom' => $p->nom, 'code_article' => $p->code_article, 'prix_achat_ht' => (float) $p->prix_achat_ht, 'tva_id' => (string) ($p->tva_achat_id ?? '')])->values(); $amTvaList = $tvaList->map(fn($t) => ['id' => $t->id, 'taux' => (float) $t->taux])->values(); $amChantiers = $chantiers->map(fn($c) => ['id' => $c->id, 'nom' => $c->nom])->values(); $amEmplacements = $emplacements->map(fn($e) => ['id' => $e->id, 'label' => $e->label, 'children' => $e->enfants->map(fn($c) => ['id' => $c->id, 'label' => $c->label])->values()])->values(); @endphp {{-- ── Page data injected once for Alpine ── --}} {{-- ── Page header ── --}}
{{ $docs->total() }} document(s){{ $activeTab ? ' — ' . ($aTypes[$activeTab] ?? $activeTab) : '' }}
| Numéro | Type | Fournisseur | Date | Total TTC | Statut | Actions |
|---|---|---|---|---|---|---|
| {{ $doc->numero }} | {{ $doc->type_libelle }} | {{ $doc->fournisseur?->nom ?? '-' }} | {{ $doc->date->format('d/m/Y') }} | {{ number_format($doc->total_ttc,3,',',' ') }} | {{ ucfirst($doc->statut) }} |
@if($doc->statut !== 'annule')
@endif
@php
$achatRowAllowed = ['demande_achat'=>['commande_achat'=>'Commande Achat','br'=>'Bon de Réception','facture_achat'=>'Facture Achat'],'commande_achat'=>['br'=>'Bon de Réception','facture_achat'=>'Facture Achat'],'br'=>['facture_achat'=>'Facture Achat'],'facture_achat'=>['avoir_achat'=>'Avoir Achat']];
$rowCibles = !$doc->converted ? ($achatRowAllowed[$doc->type] ?? []) : [];
@endphp
@if(count($rowCibles) > 0)
@endif
@if($doc->type === 'commande_achat' && !in_array($doc->statut, ['annule', 'recu']))
@endif
|
| Aucun document | ||||||
| # | Désignation | Qté | PU HT | Rem% | TVA | Total HT | |
|---|---|---|---|---|---|---|---|
|
|
Le document original sera marqué comme traité.