@extends('layouts.master') @section('css') @endsection @section('title') {{ __('home.Historyـofـproductـsales') }} @endsection @section('page-header') @endsection @section('content') @if ($errors->any()) @endif
{{ csrf_field() }}
@if (isset($Invoices))
@php $userId = 0; $count = 0; $startat = ''; $endat = ''; $total = 0; $totaldiscount = 0; $avt = App\Models\Avt::find(1); $saleavt = $avt ? $avt->AVT : 0; @endphp
@foreach ($Invoices as $product) @php $totaldiscount += $product->discount; $cashAmount = $product->cashamount; $networkAmount = $product->bankamount + $product->Bank_transfer; $creditAmount = $product->creaditamount; $invoiceTotal = $cashAmount + $networkAmount + $creditAmount; $total += $invoiceTotal; // مجاميع لعرضها أسفل الجدول $totalCashAmount = ($totalCashAmount ?? 0) + $cashAmount; $totalNetworkAmount = ($totalNetworkAmount ?? 0) + $networkAmount; $totalCreditAmount = ($totalCreditAmount ?? 0) + $creditAmount; if ($count == 0) { $userId = $product->user_id; $startat = $product->created_at; } $endat = $product->created_at; $count++; $pays = match($product->Pay) { 'Cash' => __('report.cash'), 'Shabka' => __('report.shabka'), 'Credit' => __('report.credit'), 'Bank_transfer' => __('home.Bank_transfer'), default => __('home.Partition of the amount'), }; @endphp @endforeach
{{ __('home.Invoice_no') }} {{ __('home.sallerName') }} {{ __('home.clietName') }} {{ __('home.date') }} {{ __('home.branch') }} {{ __('home.total') }} {{ __('home.paymentmethod') }} {{ __('report.cash') }} {{ __('report.network_or_transfer') }} {{ __('report.credit') }} {{ __('home.operations') }}
{{ $product->id }} {{ $product->user->name ?? '-' }} {{ $product->customer->name ?? '-' }} {{ $product->created_at }} {{ $product->branch->name ?? '-' }} {{ round($invoiceTotal, 2) }} {{ $pays }} {{ $cashAmount > 0 ? number_format($cashAmount) : '-' }} {{ $networkAmount > 0 ? number_format($networkAmount) : '-' }} {{ $creditAmount > 0 ? number_format($creditAmount) : '-' }} {{ __('home.show') }}
# {{ __('report.totalprice') }} {{ __('home.the amount') }}
1 {{ __('report.totalallprice') }} {{ round($total, 2) }}
@php // معالجة آمنة لتفادي أخطاء الـ Array في روابط الطباعة إذا لم يتم تمريرهم بشكل مصفوفة $printPay = is_array($pay ?? null) ? $pay : [0 => ($pay ?? '-'), 1 => '-']; $printCustomerId = $customer_id ?? ($UserId ?? '-'); @endphp
@endif
@endsection @section('js') @endsection