@php if (!function_exists('ConvertToHEX')) { function ConvertToHEX($value) { return pack("H*", sprintf("%02X", $value)); } } // حسابات الـ QR Code الخاصة بك (بناءً على الكود الأصلي) $avt = App\Models\Avt::find(1); $price = $invoice->Pay + $invoice->creaditamount; $tax_rate = $avt->AVT ?? 0.15; $price_befor_tax = $price / (1 + $tax_rate); $tax_val_raw = $price - $price_befor_tax; $sellerName = "يعرب للخياطة"; // اسم البائع $time_formatted = $invoice->created_at->format('Y-m-d\TH:i:s'); $total_val = number_format($price, 2, '.', ''); $tax_val = number_format($tax_val_raw, 2, '.', ''); $data = ConvertToHEX(1) . ConvertToHEX(strlen($sellerName)) . $sellerName . ConvertToHEX(3) . ConvertToHEX(strlen($time_formatted)) . $time_formatted . ConvertToHEX(4) . ConvertToHEX(strlen($total_val)) . $total_val . ConvertToHEX(5) . ConvertToHEX(strlen($tax_val)) . $tax_val; $qrcode = base64_encode($data); @endphp {!! QrCode::size(90)->generate($qrcode) !!}
{{ $invoice->created_at->format('Y-m-d') }} | {{ $invoice->created_at->format('h:i A') }}

{{ __('sales.sales_yarub_tailoring') }}

{{ __('sales.sales_simplified_tax_invoice') }}

{{ __('sales.sales_simplified_tax_invoice') }}
INV #{{ $invoice->id }}
{{-- بداية جدول بيانات العميل --}}
{{ __('sales.sales_customer_name') }}: {{ $invoice->customer->name ?? __('sales.sales_general_customer') }} {{ __('sales.sales_mobile_number') }}: {{ $invoice->customer->phone ?? '-' }}
{{ __('sales.sales_order_date') }}: {{ $invoice->order_date ? \Carbon\Carbon::parse($invoice->order_date)->format('d/m/Y') : $invoice->created_at->format('d/m/Y') }} {{ __('sales.sales_delivery_date') }}: {{ $invoice->delivery_date ? \Carbon\Carbon::parse($invoice->delivery_date)->format('d/m/Y') : '-' }}
{{ __('sales.sales_order_status') }}: @php $orderStatus = $items->first()->status ?? 'NOT_STARTED'; $statusLabels = [ 'NOT_STARTED' => [ 'label' => __('sales.sales_status_not_started'), 'color' => '#856404', 'bg' => '#fff3cd' ], 'IN_PROGRESS' => [ 'label' => __('sales.sales_status_in_progress'), 'color' => '#0c5460', 'bg' => '#d1ecf1' ], 'COMPLETED' => [ 'label' => __('sales.sales_status_completed'), 'color' => '#155724', 'bg' => '#d4edda' ], ]; $currentStatus = $statusLabels[$orderStatus] ?? $statusLabels['NOT_STARTED']; @endphp {{ $currentStatus['label'] }}
{{-- نهاية جدول بيانات العميبل --}} {{-- بداية اول سكشن --}} @if(isset($order) && $order->total_measurements > 0) @if(!empty($measurements)) @else @endif
{{ __('sales.front_length') }} {{ __('sales.back_length') }} {{ __('sales.shoulder_width') }} {{ __('sales.sleeve_length') }} {{ __('sales.arm_width') }} {{ __('sales.arm_mid_width') }} {{ __('sales.arm_bottom_width') }} {{ __('sales.chest_width') }} {{ __('sales.neck_size') }} {{ __('sales.collar_size') }} {{ __('sales.step_width') }} {{ __('sales.neck_plain') }} {{ __('sales.total') }}
{{ $measurements['front_length'] ?? '0' }} {{ $measurements['back_length'] ?? '0' }} {{ $measurements['shoulder_width'] ?? '0' }} {{ $measurements['sleeve_length'] ?? '0' }} {{ $measurements['arm_width'] ?? '0' }} {{ $measurements['arm_mid_width'] ?? '0' }} {{ $measurements['arm_bottom_width'] ?? '0' }} {{ $measurements['chest_width'] ?? '0' }} {{ $measurements['neck_size'] ?? '0' }} {{ $measurements['collar_size'] ?? '0' }} {{ $measurements['step_width'] ?? '0' }} {{ $measurements['neck_plain'] ?? '0' }} {{ $order->total_measurements ?? '0' }} لا توجد مقاسات مسجلة
{{-- نهاية اول سكشن --}} @endif {{-- بداية تاني سكشن --}} @if(isset($order) && $order->total_measurements > 0) {{-- نلف على الخصائص، ولو قيمتها 1 نعرض اسمها من ملف الترجمة --}} @foreach($features as $key => $value) @if($value == 1) @endif @endforeach {{-- نعرض علامة صح تحت كل عمود --}} @foreach($features as $key => $value) @if($value == 1) @endif @endforeach
{{ __('sales.' . $key) }}
@endif {{-- بداية تالت سكشن --}} @php $totalItemsPrice = 0; $globalDiscount = (float)($invoice->discount ?? 0); // التأكد من تحويل 0.15 إلى 15 للعمليات الحسابية $rawTax = (float)($taxRate ?? 0); $taxPercent = ($rawTax < 1) ? ($rawTax * 100) : $rawTax; @endphp @foreach($items as $index => $item) @php $qty = (float)$item->qty; $price = (float)$item->price; // 1. الإجمالي للسطر قبل الخصم $subTotal = $qty * $price; // 2. توزيع الخصم $itemDiscount = ($index === 0) ? $globalDiscount : 0; // 3. الصافي قبل الضريبة (الـ 280 ريال في مثالك) $rowNetPrice = $subTotal - $itemDiscount; // 4. حساب قيمة الضريبة (المبلغ * 0.15) = 42 ريال $itemTaxAmount = $rowNetPrice * ($taxPercent / 100); // 5. الإجمالي النهائي للسطر شامل الضريبة (280 + 42) = 322 ريال $rowTotalInclusive = $rowNetPrice + $itemTaxAmount; $totalItemsPrice += $rowTotalInclusive; @endphp {{-- الآن يظهر مبلغ الضريبة (مثلاً 42.00) بدلاً من النسبة --}} {{-- الإجمالي هنا هو الصافي الشامل (السعر + الضريبة) --}} @endforeach {{-- إضافة tfoot للأناقة وضبط المحاذاة --}} @if($invoice->discount > 0) @endif
{{ __('sales.sales_no') }} {{ __('sales.sales_section') }} {{ __('sales.sales_item_name') }} {{ __('sales.sales_quantity') }} {{ __('sales.sales_unit_price') }} {{ __('sales.sales_discount') }} {{ __('sales.sales_tax') }} {{ __('sales.sales_total') }}
{{ $index + 1 }} {{ $item->group_ar }} {{ $item->product->product_name ?? 'صنف' }} {{ number_format($qty, 2) }} {{ number_format($price, 2) }} {{ number_format($itemDiscount, 2) }} {{ number_format($itemTaxAmount, 2) }} {{ number_format($rowTotalInclusive, 2) }}
{{ __('sales.sales_total_discount') }}: -{{ number_format($invoice->discount, 2) }}
{{ __('sales.sales_grand_total') }}: {{ number_format($invoice->Price, 2) }}
{{-- نهاية تالت سكشن --}}
{{-- بداية موديلات الخياطة --}} @if(isset($order) && $order->total_measurements > 0)

{{ __('sales.sales_styling_details') }}

{{-- الجزء الأيمن: الشكل التقديري (تجميع الصور فوق بعض) --}}

الشكل التقديري

@php $firstItem = $items->first(); $allStyles = $firstItem ? json_decode($firstItem->order_styles, true) : []; // دالة مساعدة لجلب رقم الموديل فقط للصور التقديرية function getModelNum($data) { return is_array($data) ? ($data['model'] ?? 1) : $data; } @endphp @if(!empty($allStyles))
@if(isset($allStyles['neck'])) @endif @if(isset($allStyles['janzour'])) @endif @if(isset($allStyles['front_p'])) @endif @if(isset($allStyles['sleeve'])) @endif
@endif
{{-- الجزء الأيسر: تفاصيل كل موديل مع الملاحظة --}}
@foreach($allStyles as $key => $style) @php // استخراج الموديل والملاحظة بأمان $imgNum = is_array($style) ? ($style['model'] ?? 1) : $style; $note = is_array($style) ? ($style['note'] ?? '') : ''; @endphp
{{ __('sales.' . $key) ?? $key }}
موديل {{ $imgNum }}
{{-- عرض الملاحظة إذا كانت موجودة --}} @if(!empty($note))
{{ $note }}
@endif
@endforeach
@endif {{-- نهاية موديلات الخياطة --}} @if(isset($order) && $order->total_measurements > 0)
@php $finalPrice = (float)$invoice->Price; $discount = (float)($invoice->discount ?? 0); $currentTaxRate = 0; // كما في كودك $taxAmount = $finalPrice - ($finalPrice / (1 + ($currentTaxRate / 100))); $subtotalBeforeEverything = ($finalPrice - $taxAmount) + $discount; @endphp
{{ __('sales.sales_total_before') }}: {{ number_format($subtotalBeforeEverything, 2) }}
@if($discount > 0)
{{ __('sales.sales_special_discount') }}: -{{ number_format($discount, 2) }}
@endif
{{ __('sales.sales_vat') }} ({{ $currentTaxRate }}%): {{ number_format($taxAmount, 2) }}
{{ __('sales.sales_grand_total') }}: {{ number_format($finalPrice, 2) }}
{{ __('sales.sales_paid') }}: {{ number_format($invoice->Pay, 2) }}
{{ __('sales.sales_remaining') }}: {{ number_format($invoice->Price - $invoice->Pay ) }}
@endif {{-- بداية سكشن سند القبض --}} @if($invoice->creaditamount > 0)

{{ __('sales.sales_promissory_note') }}

{{ __('sales.sales_customer_name') }}: {{ $invoice->customer->name ?? __('sales.sales_cash_customer') }}
{{ __('sales.sales_mobile_number') }}: {{ $invoice->customer->phone ?? '---' }}
{{ __('sales.sales_paid_amount') }}: {{ number_format($invoice->Pay, 2) }} {{ __('sales.sales_currency') }}
{{ __('sales.sales_remaining_amount') }}: {{ number_format($invoice->Price -$invoice->Pay , 2) }} {{ __('sales.sales_currency') }}

{{ __('sales.sales_customer_signature') }}

_________________

{{ __('sales.sales_company_stamp') }}

_________________

{{ __('sales.sales_payment_commitment_note') }}

@endif {{-- نهاية سكشن سند القبض --}}