@extends('layouts.location') @section('title', 'Packlist Result') @section('page-title', 'Result Packlist') @section('content')
{{-- Back Button --}}
Back
Packlist Result
{{ count($packitems) }} Records
@php // Group by SO No $grouped = collect($packitems)->groupBy('so_no'); @endphp @forelse($grouped as $so_no => $boxes) @if(count($boxes) > 1) {{-- Case: All boxes selected, show merged row --}} @php $mergedItems = []; $totalWeight = 0; $dimensions = []; foreach ($boxes as $box) { $totalWeight += (float) $box->weight; if ($box->dimension) { $dimensions[] = $box->dimension; } $items = json_decode($box->items, true); if (is_array($items)) { foreach ($items as $item) { $decoded = is_string($item) ? json_decode($item, true) : $item; if ($decoded && isset($decoded['item'])) { $key = $decoded['item']; if (!isset($mergedItems[$key])) { $mergedItems[$key] = 0; } $mergedItems[$key] += (int) $decoded['qty']; } } } } @endphp @else {{-- Case: Single box --}} @php $pack = $boxes->first(); @endphp @endif @empty @endforelse
SO No Box Dimension Weight Items Action
{{ $so_no }} All Boxes ({{ count($boxes) }}) {{ implode(', ', $dimensions) }} {{ $totalWeight }} Kg
    @foreach($mergedItems as $item => $qty)
  • {{ $item }} x {{ $qty }}
  • @endforeach
Print All
{{ $pack->so_no }} {{ $pack->box }} {{ $pack->dimension ?? 'N/A' }} {{ $pack->weight ?? '0' }} Kg @php $items = json_decode($pack->items, true); @endphp @if(is_array($items))
    @foreach($items as $item) @php $decoded = is_string($item) ? json_decode($item, true) : $item; @endphp @if($decoded && isset($decoded['item']))
  • {{ $decoded['item'] }} x {{ $decoded['qty'] }}
  • @endif @endforeach
@else No items @endif
Print
No packlist data found.
@endsection