@extends('layouts.app') @section('title', __('dashboard.sidebar_purchases')) @section('page_heading', __('dashboard.sidebar_purchases')) @section('content') @php $currentState = $state ?? request('state', 'active'); $hasFilter = request()->hasAny(['supplier_id','from_date','to_date']); @endphp {{-- KPIs --}}
@foreach([ ['fa-solid fa-truck', '#eff6ff','#2563eb', $purchases->total(), 'إجمالي المشتريات'], ['fa-solid fa-coins', '#fffbeb','#d97706', number_format($purchases->sum('final_total'),2), 'إجمالي المبالغ (ج.م)'], ['fa-solid fa-rotate-left', '#fef2f2','#dc2626', \App\Models\PurchaseReturn::count(), 'مرتجعات المشتريات'], ['fa-solid fa-users', '#f0fdf4','#16a34a', $suppliers->count(), 'الموردون'], ] as [$ic,$bg,$cl,$val,$lbl])
{{ $val }}
{{ $lbl }}
@endforeach
{{ __('dashboard.All Purchases') }} {{ number_format($purchases->total()) }}
@foreach(['active'=>'النشط','trashed'=>'المحذوف','all'=>'الكل'] as $val=>$lbl) {{ $lbl }} @endforeach
{{ __('dashboard.Purchase Returns') }} @can('create purchases') {{ __('dashboard.Add New Purchase') }} @endcan
@if($hasFilter) @endif
@if($purchases->isEmpty())
@include('layouts.partials.index-empty-state',['icon'=>'fa-solid fa-bag-shopping','title'=>__('dashboard.No purchases found.'),'message'=>''])
@else
@foreach(['#',__('dashboard.Supplier'),__('dashboard.Invoice File'),__('dashboard.Total'),__('dashboard.Discount'),__('dashboard.Final Total')] as $h) @endforeach @foreach($purchases as $p) @endforeach
{{ $h }}{{ __('dashboard.Actions') }}
{{ $p->id }}
@if($p->trashed()) محذوف @endif
{{ $p->supplier->name ?? '—' }}
{{ $p->created_at->format('Y-m-d') }}
@if($p->invoice_file) عرض الفاتورة @else @endif
{{ number_format($p->total, 2) }}
ج.م
@if($p->discount > 0) {{ $p->discount }} @else @endif
{{ number_format($p->final_total, 2) }}
ج.م
@canany(['view purchases','edit purchases','delete purchases','create purchase returns','view purchase returns'])
@if($p->trashed())
@csrf
@else @can('edit purchases') {{ __('dashboard.Edit') }} @endcan @can('create purchase returns') {{ __('dashboard.Add Return') }} @endcan @can('view purchase returns') {{ __('dashboard.View Returns') }} @endcan @can('delete purchases')
@csrf @method('DELETE')
@endcan @endif
@endcanany
@if($purchases->hasPages())
{{ $purchases->appends(request()->query())->links() }}
@endif @endif
@endsection