@if (isset($data) && !empty($data) && count($data) > 0)
{{-- --}} @php $avtSetting = App\Models\Avt::find(1); $saleavt = $avtSetting ? $avtSetting->AVT : 0.15; // جلب الدومين الأساسي من APP_URL في ملف .env $baseUrl = rtrim(config('app.url'), '/'); @endphp @foreach ($data as $product) @php // حساب الإجمالي مع الضريبة $netPrice = $product->cashamount + $product->Bank_transfer + $product->bankamount + $product->creaditamount; $totalWithTax = round($netPrice, 2); // تحديد نص طريقة الدفع $payText = match($product->Pay) { 'Cash' => __('report.cash'), 'Shabka' => __('report.shabka'), 'Credit' => __('report.credit'), 'Bank_transfer' => __('home.Bank_transfer'), default => __('home.Partition of the amount'), }; // تجهيز رقم الهاتف والتحقق من كود الدولة $rawPhone = $product->customer->phone ?? ''; $cleanPhone = preg_replace('/[^0-9]/', '', $rawPhone); $cleanPhone = ltrim($cleanPhone, '0'); if (!empty($cleanPhone) && !str_starts_with($cleanPhone, '966')) { $cleanPhone = '966' . $cleanPhone; } // تجهيز رابط الـ PDF معتمداً على APP_URL $pdfLink = $baseUrl . '/ar/generate_pdf/' . $product->id; // نص رسالة الواتساب $waMessage = "يسرنا خدمتك مرفق لكم فاتورتكم\n" . "فضلاً لتحميل فاتورتك رقم {$product->id}: {$pdfLink}\n\n" . "For download your invoice number {$product->id} press here:\n{$pdfLink}"; $waFullUrl = "https://api.whatsapp.com/send?phone={$cleanPhone}&text=" . rawurlencode($waMessage); @endphp {{-- --}} @endforeach
{{ __('home.Invoice_no') }} {{ __('home.sallerName') }} {{ __('home.clietName') }} {{ __('home.date') }} {{ __('home.branch') }} {{ __('home.total') }} {{ __('home.paymentmethod') }}الربط مع زكاة (Zatca){{ __('home.operations') }}
{{ $product->id }} {{ $product->user->name ?? '---' }} {{ $product->customer->name ?? '---' }} {{ $product->created_at ? $product->created_at->format('Y-m-d H:i') : '---' }} {{ $product->branch->name ?? '---' }} @if(\Illuminate\Support\Facades\DB::table('return_sales')->where('invoice_id', $product->id)->exists()) {{ __('home.return') }} @else {{ number_format($totalWithTax, 2) }} @endif {{ $payText }} @if($product->Pay == "Partition")
{{ __('report.shabka') }}: {{ $product->bankamount }} | {{ __('home.Bank_transfer') }}: {{ $product->Bank_transfer }}
@endif
@if($product->sent_to_zatca == 1) مرسلة @else مسودة @endif
{{ csrf_field() }}
@else @endif