{{-- resources/views/admin/orders/invoice.blade.php --}} Order Invoice {{-- Top Print Button (screen only) --}}
{{-- ===== Normalize: $items or $item/$order -> $orders (collection) ===== --}} @php $orders = collect(); if (isset($items)) { $orders = collect($items); } elseif (isset($item)) { $orders = collect([$item]); } elseif (isset($order)) { $orders = collect([$order]); } @endphp @forelse($orders as $item) @php $subTotal = 0; @endphp
{{-- Header / Logo --}}
logo
{{ $info->site_name ?? config('app.name') }}
{{ $info->address ?? '' }}
Invoice
ID: #{{ $item->invoice_no }}
Order Summary
{{-- Bill To / Meta --}}
Invoice To
{{ $item->first_name }} {{ $item->last_name }}
{{ $item->shipping_address }}
Phone: {{ $item->mobile }}
Invoice#{{ $item->invoice_no }}
Date{{ dateFormate($item->date) }}
Created{{ $item->created_at->diffForHumans() }}
{{-- Items --}}
@foreach($item->details as $idx => $detail) @php $var = optional($detail->variation); // Unit price precedence: order_details.unit_price > variation.after_discount_price > variation.price $unitPrice = $detail->unit_price ?? ($var->after_discount_price ?? ($var->price ?? 0)); $qty = (int)($detail->quantity ?? 0); $rowTotal = $unitPrice * $qty; $subTotal += $rowTotal; $colorLabel = optional($var->color)->name; $sizeLabel = optional($var->size)->title; if($colorLabel === 'Default'){ $colorLabel = ''; } if($sizeLabel === 'free'){ $sizeLabel = ''; } $desc = trim( ($detail->product->name ?? '').' '.($detail->productsize->title ?? '') ); @endphp @endforeach
SL. Item Description Color Size Price Qty Total
{{ $idx+1 }} {{ $desc }} {{ $colorLabel }} {{ $sizeLabel }} {{ priceFormate($unitPrice) }} {{ $qty }} {{ priceFormate($rowTotal) }}
{{-- Note + Totals --}}
@php $orderNote = trim($item->note ?? ''); @endphp @if($orderNote !== '')
Note
{{ $orderNote }}
@endif
{{-- ✅✅✅ MODIFIED TOTAL SECTION START ✅✅✅ --}}
@php // ডেলিভারি চার্জ বের করা $deliveryAmount = optional($item->delivery_charge)->amount ?? ($item->shipping_charge ?? 0); // ডাটাবেসে সেভ হওয়া মোট ডিসকাউন্ট $totalDiscount = $item->discount ?? 0; // প্রতিটি প্রোডাক্টের নিজস্ব ডিসকাউন্ট বের করা $productLevelDiscount = 0; foreach($item->details as $d) { // order_details টেবিলে থাকা per-unit discount এর সাথে quantity গুণ করা হলো $productLevelDiscount += ($d->discount ?? 0) * ($d->quantity ?? 0); } // কুপন ডিসকাউন্ট = মোট ডিসকাউন্ট - প্রোডাক্ট লেভেল ডিসকাউন্ট $couponDiscount = $totalDiscount - $productLevelDiscount; if($couponDiscount < 0) { $couponDiscount = 0; } // সেফটি চেক // গ্র্যান্ড টোটাল: ডাটাবেস থেকে final_amount নিবে, যদি না থাকে তবে ক্যালকুলেট করবে $grandTotal = $item->final_amount ?? (($subTotal + $deliveryAmount) - $totalDiscount); @endphp
Sub Total
{{ priceFormate($subTotal) }}
Delivery Charge
{{ priceFormate($deliveryAmount) }}
{{-- ✅ শুধুমাত্র কুপন ব্যবহার করলেই এই অংশটি দেখাবে --}} @if($couponDiscount > 0)
Coupon Discount
- {{ priceFormate($couponDiscount) }}
@endif
Total
{{ priceFormate($grandTotal) }}
{{-- ✅✅✅ MODIFIED TOTAL SECTION END ✅✅✅ --}}
{{-- Signature & Footer --}}
Phone:
{{ $info->owner_phone ?? '' }}
Company: {{ $info->site_name ?? config('app.name') }} | Address: {{ $info->address ?? '' }}
{{-- Page break between orders (print only) --}} @if(!$loop->last)
@endif @empty
No order found.
@endforelse