@extends('pdf.layouts.app') @section('title', 'Quick Service Sales Report') @section('styles') @endsection @section('content')
@php $items = $data ?? []; $summary = $summary ?? []; $isRtl = ($direction ?? 'rtl') === 'rtl'; // خريطة لتعريب أهم أنواع الخدمات في حال تم إرسالها بالإنجليزية $servicesMap = [ 'flight' => 'طيران', 'accommodation' => 'فنادق', 'visa' => 'تأشيرات', 'transportation' => 'مواصلات', 'tourism_program' => 'برنامج سياحي', 'general_service' => 'خدمة عامة', ]; @endphp @if(count($items) > 0)
{{ $isRtl ? 'تفاصيل الفواتير' : 'Invoices Details' }}
{{-- Main Invoices Details Table --}} @foreach($items as $item) @php $purchasePrice = (float)($item['purchase_price'] ?? 0); $purchaseTax = (float)($item['purchase_tax'] ?? 0); $purchaseRate = (float)($item['purchase_exchange_rate'] ?? 1); $sellingPrice = (float)($item['selling_price'] ?? 0); $sellingTax = (float)($item['selling_tax'] ?? 0); $sellingRate = (float)($item['selling_exchange_rate'] ?? 1); $requiredTax = (float)($item['required_tax'] ?? 0); $finalProfit = (float)($item['final_profit'] ?? 0); $serviceTypeStr = $item['service'] ?? '-'; if ($isRtl && isset($servicesMap[strtolower($serviceTypeStr)])) { $serviceTypeStr = $servicesMap[strtolower($serviceTypeStr)]; } $serviceName = !empty($item['service_name']) ? $serviceTypeStr . ' (' . $item['service_name'] . ')' : $serviceTypeStr; $sectionName = $item['section'] ?? ($isRtl ? 'مبيعات' : 'Sales'); if (!$isRtl && $sectionName === 'مبيعات') { $sectionName = 'Sales'; } @endphp @endforeach {{-- Table Total Row --}} @php $totalPurchase = (float)($summary['total_purchase'] ?? 0); $totalPurchaseTax = (float)($summary['total_purchase_tax'] ?? 0); $totalSelling = (float)($summary['total_selling'] ?? 0); $totalSellingTax = (float)($summary['total_selling_tax'] ?? 0); $totalRequiredTax = (float)($summary['total_required_tax'] ?? 0); $totalProfit = (float)($summary['total_profit'] ?? 0); @endphp
{{ $isRtl ? 'رقم الفاتورة' : 'Invoice No.' }} {{ $isRtl ? 'المورد' : 'Supplier' }} {{ $isRtl ? 'القسم' : 'Section' }} {{ $isRtl ? 'الخدمة' : 'Service' }} {{ $isRtl ? 'المرجع' : 'Reference' }} {{ $isRtl ? 'التاريخ' : 'Date' }} {{ $isRtl ? 'سعر الشراء' : 'Purchase Price' }} {{ $isRtl ? 'ضريبة الشراء' : 'Purchase Tax' }} {{ $isRtl ? 'سعر الصرف' : 'Exchange Rate' }} {{ $isRtl ? 'سعر البيع' : 'Selling Price' }} {{ $isRtl ? 'ضريبة البيع' : 'Selling Tax' }} {{ $isRtl ? 'سعر الصرف' : 'Exchange Rate' }} {{ $isRtl ? 'الضريبة المطلوبة' : 'Required Tax' }} {{ $isRtl ? 'الربح النهائي' : 'Final Profit' }}
{{ $item['invoice_num'] ?? '-' }} {{ $item['supplier_name'] ?? '-' }} {{ $sectionName }} {{ $serviceName }} {{ $item['reference'] ?? '-' }} {{ $item['date'] ?? '-' }} {{ number_format($purchasePrice, 2) }} {{ number_format($purchaseTax, 2) }} {{ number_format($purchaseRate, 2) }} {{ number_format($sellingPrice, 2) }} {{ number_format($sellingTax, 2) }} {{ number_format($sellingRate, 2) }} {{ number_format($requiredTax, 2) }} {{ number_format($finalProfit, 2) }}
{{ $isRtl ? 'الإجمالي:' : 'Total:' }} {{ number_format($totalPurchase, 2) }} {{ number_format($totalPurchaseTax, 2) }} -- {{ number_format($totalSelling, 2) }} {{ number_format($totalSellingTax, 2) }} -- {{ number_format($totalRequiredTax, 2) }} {{ number_format($totalProfit, 2) }}
{{-- Summary Table Block at bottom --}}
{{ $isRtl ? 'إجمالي الشراء' : 'Total Purchase' }} {{ $isRtl ? 'إجمالي البيع' : 'Total Selling' }} {{ $isRtl ? 'إجمالي الضريبة المطلوبة' : 'Total Required Tax' }} {{ $isRtl ? 'إجمالي الربح' : 'Total Profit' }}
{{ number_format($totalPurchase, 2) }} {{ number_format($totalSelling, 2) }} {{ number_format($totalRequiredTax, 2) }} {{ number_format($totalProfit, 2) }}
@else

{{ $isRtl ? 'لا توجد بيانات متاحة لهذا التقرير.' : 'No data available for this report.' }}

@endif
@endsection