@php $total_sewing_balance = 0; $total_production_min_balance = 0; @endphp
@php // Group sewing data by color and size $groupedData = []; foreach ($sewingData as $balance) { $key = $balance->color . '|' . $balance->size; if (!isset($groupedData[$key])) { $groupedData[$key] = [ 'color' => $balance->color, 'size' => $balance->size, 'total_sewing_balance' => 0, 'total_production_min_balance' => 0 ]; } $groupedData[$key]['total_sewing_balance'] += $balance->sewing_balance; $groupedData[$key]['total_production_min_balance'] += $balance->production_min_balance; } @endphp @forelse($groupedData as $key => $balance) @php $order_qty = App\Models\Job::where('job_no', $jobNo) ->where('color', $balance['color']) ->where('size', $balance['size']) ->value('color_quantity') ?? 0; $balance_qty = $order_qty - $balance['total_sewing_balance']; $total_sewing_balance += $balance['total_sewing_balance']; $total_production_min_balance += $balance['total_production_min_balance']; @endphp @empty @endforelse @if(!empty($groupedData)) @endif
Color Size Order Qty Total Sewing Qty Balance Qty Production Min Balance Actions
{{ $balance['color'] }} {{ $balance['size'] }} {{ number_format($order_qty) }} {{ number_format($balance['total_sewing_balance']) }} {{ number_format($balance_qty) }} {{ number_format($balance['total_production_min_balance']) }} min History
No Sewing Data Found

No sewing records exist for this job

Totals: {{ number_format(array_sum(array_column($groupedData, 'order_qty'))) }} {{ number_format($total_sewing_balance) }} {{ number_format(array_sum(array_column($groupedData, 'balance_qty'))) }} {{ number_format($total_production_min_balance) }} min