@extends('layouts.app') @section('title', 'إدارة المصروفات') @section('content')
FINANCE

إدارة المصروفات

تسجيل وتصنيف ومتابعة جميع المصروفات

@if (session('success'))
✅ {{ session('success') }}
@endif @php $curIcons = ['EGP' => '🇪🇬', 'USD' => '🇺🇸', 'TRY' => '🇹🇷', 'EUR' => '🇪🇺']; $curColors = ['EGP' => 'text-emerald-600', 'USD' => 'text-green-600', 'TRY' => 'text-red-600', 'EUR' => 'text-blue-600']; @endphp @if ($totalsByCashbox->isNotEmpty()) @php $groupedByCashbox = $totalsByCashbox->groupBy('cashbox_id'); $cbCount = $groupedByCashbox->count(); @endphp
@foreach ($groupedByCashbox as $cbId => $rows) @php $cbName = $cashboxes->firstWhere('id', $cbId)->name ?? 'بدون خزنة'; @endphp
🏦

إجمالي مصروفات {{ $cbName }}

@foreach ($rows as $r)
{{ $curIcons[$r->currency] ?? '' }} {{ $r->currency }} {{ number_format($r->total, 2) }}
@endforeach
@endforeach
📊

عدد المعاملات

{{ $totalExpensesCount }}

@else
📊

عدد المعاملات

{{ $totalExpensesCount }}

@endif

📋 قائمة المصروفات

📁
🏦
من
إلى
@if ($categoryFilter || $cashboxFilter || $fromDate || $toDate) إلغاء @endif
@if ($expenses->isEmpty())
📭

لا توجد مصروفات

أضف أول مصروف بالضغط على "إضافة مصروف"

@else @php $catIcons = ['إيجار' => '🏠', 'رواتب' => '👤', 'تسويق' => '📣', 'صيانة' => '🔧', 'مستلزمات' => '📦', 'عدادات' => '⚡', 'عمولات' => '💰', 'أخرى' => '📄']; $catBadge = ['إيجار' => 'bg-blue-50 text-blue-600 border-blue-100', 'رواتب' => 'bg-purple-50 text-purple-600 border-purple-100', 'تسويق' => 'bg-pink-50 text-pink-600 border-pink-100', 'صيانة' => 'bg-amber-50 text-amber-600 border-amber-100', 'مستلزمات' => 'bg-emerald-50 text-emerald-600 border-emerald-100', 'عدادات' => 'bg-red-50 text-red-600 border-red-100', 'عمولات' => 'bg-orange-50 text-orange-600 border-orange-100', 'أخرى' => 'bg-gray-50 text-gray-600 border-gray-100']; @endphp @foreach ($expenses as $expense) @endforeach
العنوان التصنيف المبلغ الخزنة التاريخ
{{ $expense->title ?? '—' }} {{ $catIcons[$expense->category ?? 'أخرى'] ?? '📄' }} {{ $expense->category ?? '—' }} {{ number_format($expense->amount, 2) }} {{ $expense->currency ?? 'EGP' }} {{ $cashboxes->firstWhere('id', $expense->cashbox_id)->name ?? 'بدون خزنة' }} {{ \Carbon\Carbon::parse($expense->created_at)->format('Y-m-d') }}
@endif
@if (method_exists($expenses, 'links') && $expenses->hasPages())

عرض {{ $expenses->firstItem() }} إلى {{ $expenses->lastItem() }} من {{ $expenses->total() }}

@if ($expenses->onFirstPage()) السابق @else السابق @endif @foreach ($expenses->getUrlRange(max(1, $expenses->currentPage() - 2), min($expenses->lastPage(), $expenses->currentPage() + 2)) as $page => $url) @if ($page == $expenses->currentPage()) {{ $page }} @else {{ $page }} @endif @endforeach @if ($expenses->hasMorePages()) التالي @else التالي @endif
@endif

📊 ملخص حسب التصنيف

@if ($totalByCategory->isEmpty())

لا توجد مصروفات مسجلة

@else @php $byCurrency = $totalByCategory->groupBy('currency'); @endphp
@foreach ($byCurrency as $cur => $rows) @php $curTotal = $rows->sum('total'); @endphp

{{ $curIcons[$cur] ?? '' }} {{ $cur }} — {{ number_format($curTotal, 2) }}

@foreach ($rows as $r) @php $pct = $curTotal > 0 ? round(($r->total / $curTotal) * 100, 1) : 0; @endphp
{{ $r->category }} {{ number_format($r->total, 2) }}
@endforeach
@endforeach
@endif

📅 آخر المصروفات

@php $recentExpenses = $expenses->getCollection()->take(5); @endphp @if ($recentExpenses->isEmpty())

لا توجد مصروفات

@else
@foreach ($recentExpenses as $expense)
{{ $catIcons[$expense->category ?? 'أخرى'] ?? '📄' }}

{{ $expense->title ?? '—' }}

{{ $expense->category ?? '—' }}

{{ number_format($expense->amount, 2) }}

{{ $expense->currency ?? 'EGP' }}

@endforeach
@endif
@if ($customCategories->count() > 0)
🏷️

إدارة التصنيفات المضافة

التصنيفات اللي أضفتها بنفسك. تقدر تخفيها لو ضفتها بالغلط.

@foreach ($customCategories as $cat)
{{ $cat }}
@csrf
@endforeach
@endif @endsection