@if ($sales->count() <= 30)
{{-- ============================================================== --}}
{{-- SINGLE TABLE MODE (Fits easily on one page without splitting) --}}
{{-- ============================================================== --}}
@php
$singleTodayTotal = 0;
$singlePaidTotal = 0;
$singleBalanceTotal = 0;
@endphp
| وصولی |
فروخت وغیرہ |
سابقہ بیلنس |
پارٹی |
@foreach ($sales as $sale)
@php
$singlePaidTotal += $sale->recovery;
$singleTodayTotal += $sale->today_sale;
$singleBalanceTotal += $sale->previous_balance;
$party = $sale->customer?->customer_name_urdu ?: ($sale->customer?->customer_name ?? 'خریدار');
@endphp
| {{ $sale->recovery > 0 ? number_format($sale->recovery, 0) : '-' }} |
{{ $sale->today_sale > 0 ? number_format($sale->today_sale, 0) : '-' }} |
{{ number_format($sale->previous_balance, 0) }} |
{{ $party }} |
@endforeach
| {{ $singlePaidTotal > 0 ? number_format($singlePaidTotal, 0) : '-' }} |
{{ $singleTodayTotal > 0 ? number_format($singleTodayTotal, 0) : '-' }} |
{{ number_format($singleBalanceTotal, 0) }} |
ٹوٹل |
@else
{{-- ========================================================================= --}}
{{-- DOUBLE TABLE MODE (Split into 2 side-by-side columns when > 30 customers) --}}
{{-- ========================================================================= --}}
@php
$half = (int) ceil($sales->count() / 2);
$firstPart = $sales->slice($half); // LEFT column (2nd half of customers)
$secondPart = $sales->slice(0, $half); // RIGHT column (1st half of customers)
$diff = $secondPart->count() - $firstPart->count();
@endphp
{{-- LEFT COLUMN --}}
@php
$leftTodayTotal = 0;
$leftPaidTotal = 0;
$leftBalanceTotal = 0;
@endphp
| وصولی |
فروخت وغیرہ |
سابقہ بیلنس |
پارٹی |
@foreach ($firstPart as $sale)
@php
$leftPaidTotal += $sale->recovery;
$leftTodayTotal += $sale->today_sale;
$leftBalanceTotal += $sale->previous_balance;
$party = $sale->customer?->customer_name_urdu ?: ($sale->customer?->customer_name ?? 'خریدار');
@endphp
| {{ $sale->recovery > 0 ? number_format($sale->recovery, 0) : '-' }} |
{{ $sale->today_sale > 0 ? number_format($sale->today_sale, 0) : '-' }} |
{{ number_format($sale->previous_balance, 0) }} |
{{ $party }} |
@endforeach
{{-- Balance rows height if left column has fewer items --}}
@for ($i = 0; $i < $diff; $i++)
| - |
- |
- |
|
@endfor
| {{ $leftPaidTotal > 0 ? number_format($leftPaidTotal, 0) : '-' }} |
{{ $leftTodayTotal > 0 ? number_format($leftTodayTotal, 0) : '-' }} |
{{ number_format($leftBalanceTotal, 0) }} |
ٹوٹل |
{{-- RIGHT COLUMN --}}
@php
$rightTodayTotal = 0;
$rightPaidTotal = 0;
$rightBalanceTotal = 0;
@endphp
| وصولی |
فروخت وغیرہ |
سابقہ بیلنس |
پارٹی |
@foreach ($secondPart as $sale)
@php
$rightPaidTotal += $sale->recovery;
$rightTodayTotal += $sale->today_sale;
$rightBalanceTotal += $sale->previous_balance;
$party = $sale->customer?->customer_name_urdu ?: ($sale->customer?->customer_name ?? 'خریدار');
@endphp
| {{ $sale->recovery > 0 ? number_format($sale->recovery, 0) : '-' }} |
{{ $sale->today_sale > 0 ? number_format($sale->today_sale, 0) : '-' }} |
{{ number_format($sale->previous_balance, 0) }} |
{{ $party }} |
@endforeach
| {{ $rightPaidTotal > 0 ? number_format($rightPaidTotal, 0) : '-' }} |
{{ $rightTodayTotal > 0 ? number_format($rightTodayTotal, 0) : '-' }} |
{{ number_format($rightBalanceTotal, 0) }} |
ٹوٹل |
@endif