@extends('layouts.master') @section('css') @endsection @section('title') {{ __('home.home') }} @stop @section('page-header')
@endsection @section('content') @can('Home')

{{ __('home.salesdoday') }}

{{ $todayInvoicesCount }} {{ __('home.invoice') }}

{{ __('home.TODAYEARNINGS') }}

{{ number_format($todayEarnings, 2) }} {{ __('home.SAR') }}

{{ __('home.purchasesdoday') }}

{{ $todayPurchasesCount }} {{ __('home.invoice') }}

{{ __('home.TODAYpurchases') }}

{{ number_format($todayPurchasesTotal, 2) }} {{ __('home.SAR') }}

{{ __('home.sales_purchases_comparison_current_month') }}
{{ __('home.customers_and_suppliers') }}
{{ __('home.total_customers') }} {{ $customersCount }}
{{ __('home.total_suppliers') }} {{ $suppliersCount }}
{{ __('home.returns_and_delivery') }}
{{ __('home.sel_product_withoud_tax') }} ({{ __('home.today') }})
{{ $todayDeliveryCount }} {{ __('home.invoice') }} ({{ number_format($todayDeliveryNet, 2) }})
{{ __('home.numberodreturnsSale') }}
{{ $uniqueReturnSalesCount }} {{ __('home.invoice') }}
{{ __('home.numberodreturnsPurchases') }}
{{ $resourcePurchasesCount }} {{ __('home.invoice') }}
{{ __('home.latest_transactions_today') }}
{{ __('home.view_all') }}
@forelse($latestInvoices as $invoice) @php // 1. حساب إجمالي الفاتورة $totalAmount = ($invoice->cashamount ?? 0) + ($invoice->bankamount ?? 0) + ($invoice->creaditamount ?? 0) + ($invoice->Bank_transfer ?? 0); if($totalAmount == 0 && isset($invoice->Price)) { $totalAmount = $invoice->Price; } // 2. التحقق مما إذا كانت الفاتورة مرتجع $isReturned = $invoice->returnSales && $invoice->returnSales->isNotEmpty(); if ($isReturned) { $paymentMethod = __('home.sales_return'); $badgeStyle = 'background-color: #fee2e2; color: #dc2626; border: 1px solid #fca5a5;'; } else { $payValue = strtolower(trim($invoice->Pay ?? '')); switch ($payValue) { case 'cash': $paymentMethod = __('home.cash'); $badgeStyle = 'background-color: #dcfce7; color: #166534; border: 1px solid #86efac;'; break; case 'shabka': case 'card': case 'bank': case 'network': case 'span': $paymentMethod = __('home.card_span'); $badgeStyle = 'background-color: #e0f2fe; color: #0369a1; border: 1px solid #7dd3fc;'; break; case 'bank_transfer': case 'transfer': $paymentMethod = __('home.bank_transfer'); $badgeStyle = 'background-color: #fef3c7; color: #b45309; border: 1px solid #fde047;'; break; case 'partition': case 'more': case 'multi': $paymentMethod = __('home.split_payment'); $badgeStyle = 'background-color: #f3e8ff; color: #6b21a8; border: 1px solid #d8b4fe;'; break; case 'credit': case 'creadit': case 'dept': $paymentMethod = __('home.credit'); $badgeStyle = 'background-color: #ffe4e6; color: #be123c; border: 1px solid #fda4af;'; break; default: if ($invoice->morepayment_way == 1) { $paymentMethod = __('home.split_payment'); $badgeStyle = 'background-color: #f3e8ff; color: #6b21a8; border: 1px solid #d8b4fe;'; } elseif (($invoice->bankamount ?? 0) > 0) { $paymentMethod = __('home.card_span'); $badgeStyle = 'background-color: #e0f2fe; color: #0369a1; border: 1px solid #7dd3fc;'; } elseif (($invoice->Bank_transfer ?? 0) > 0) { $paymentMethod = __('home.bank_transfer'); $badgeStyle = 'background-color: #fef3c7; color: #b45309; border: 1px solid #fde047;'; } elseif (($invoice->creaditamount ?? 0) > 0) { $paymentMethod = __('home.credit'); $badgeStyle = 'background-color: #ffe4e6; color: #be123c; border: 1px solid #fda4af;'; } else { $paymentMethod = $invoice->Pay ?? __('home.cash'); $badgeStyle = 'background-color: #dcfce7; color: #166534; border: 1px solid #86efac;'; } break; } } @endphp @empty @endforelse
{{ __('home.invoice_number') }} {{ __('home.customer') }} {{ __('home.total_amount') }} {{ __('home.payment_method') }} {{ __('home.status') }} {{ __('home.time') }}
#{{ $invoice->invoice_number ?? $invoice->id }} {{ $invoice->customer->name ?? $invoice->customer->customer_name ?? __('home.cash_customer') }} {{ $isReturned ? '-' : '' }}{{ number_format($totalAmount, 2) }} {{ __('home.SAR') }} {{ $paymentMethod }} @if($isReturned) {{ __('home.returned') }} @elseif($invoice->status == 1 || $invoice->save == 1) {{ __('home.completed') }} @else {{ __('home.pending') }} @endif {{ $invoice->created_at ? $invoice->created_at->diffForHumans() : '-' }}

{{ __('home.no_transactions_today') }}

@endcan @endsection @section('js') @endsection