@extends('layouts.location') @section('title', 'Short Picklist / Packlist') @section('page-title', 'Short Picklist / Packlist') @push('styles') @endpush @section('content')
Short Picklist (Hold Items)
Items from so_picklist with status = 'hold', grouped by PIC ID.
@php $shortGroups = collect($shortPicklist ?? [])->groupBy('pic_id'); @endphp @if($shortGroups->isEmpty())
No short picklist items in hold status.
@else
@foreach($shortGroups as $picId => $rows) @php $soList = $rows->pluck('sales_order_number')->unique()->implode(', '); $itemCount = $rows->count(); @endphp @foreach($rows as $r) @endforeach @endforeach
PIC ID Sales Orders Items (Count) Bulk Actions
{{ $picId }} {{ $soList }} {{ $itemCount }}
SO: {{ $r->sales_order_number }}
SKU: {{ $r->sku }} | Rack: {{ $r->rack }}
Picked: {{ $r->picked_qty }} | Pick Qty: {{ $r->pick_qty ?? 0 }}
Status: {{ $r->status }}
@endif
Short Packlist (Hold SOs)
@php $shortPackGroups = collect($shortPacklist ?? [])->groupBy('so_no'); @endphp @if($shortPackGroups->isEmpty())
No short packlist entries in hold status.
@else
@foreach($shortPackGroups as $soNo => $rows) @php $boxCount = $rows->count(); $totalQty = 0; foreach ($rows as $row) { try { $items = json_decode($row->items, true); if (is_array($items)) { foreach ($items as $it) { if (is_string($it)) { $it = json_decode($it, true); } if (is_array($it) && isset($it['qty'])) { $totalQty += (float) $it['qty']; } } } } catch (\Throwable $e) { } } $diffsForSo = collect($shortPackDiffs[$soNo] ?? []); $normalizePackName = function ($name) { $name = trim((string) $name); if ($name === '') { return $name; } $parts = preg_split('/\s+/', $name); if (count($parts) > 1) { $last = end($parts); $cleanLast = preg_replace('/[^A-Z0-9-]/', '', strtoupper($last)); $looksLikeSku = ( $cleanLast !== '' && preg_match('/^[A-Z0-9-]+$/', $cleanLast) && (str_contains($cleanLast, '-') || (preg_match('/[A-Z]/', $cleanLast) && preg_match('/[0-9]/', $cleanLast))) ); if ($looksLikeSku) { array_pop($parts); $name = implode(' ', $parts); } } $name = str_replace(["*", "/", "\\", "×"], ' ', $name); $name = preg_replace('/\s+/', ' ', trim($name)); return $name; }; $boxKeysByPackId = []; $allBoxKeys = collect(); foreach ($rows as $row) { $keys = collect(); try { $items = json_decode($row->items, true); if (is_array($items)) { foreach ($items as $it) { if (is_string($it)) { $decoded = json_decode($it, true); $it = is_array($decoded) ? $decoded : $it; } if (is_array($it) && isset($it['item'])) { $rawName = (string) ($it['item'] ?? ''); $sku = trim((string) ($it['sku'] ?? '')); $key = $sku !== '' ? ('SKU:' . $sku) : ('NAME:' . $normalizePackName($rawName)); if ($key !== 'NAME:' && $key !== 'SKU:') { $keys->push($key); } } } } } catch (\Throwable $e) { } $keys = $keys->filter()->unique()->values(); $boxKeysByPackId[(string) $row->id] = $keys; $allBoxKeys = $allBoxKeys->merge($keys); } $allBoxKeys = $allBoxKeys->filter()->unique()->values(); @endphp @foreach($rows as $r) @php $boxVal = $r->box; $boxDecoded = null; try { $boxDecoded = json_decode($r->box, true); } catch (\Throwable $e) { } if (is_array($boxDecoded)) { $boxVal = implode(', ', $boxDecoded); } $packId = (string) $r->id; $keysForBox = isset($boxKeysByPackId[$packId]) ? $boxKeysByPackId[$packId] : collect(); if (!$keysForBox instanceof \Illuminate\Support\Collection) { $keysForBox = collect($keysForBox); } $diffsForBox = $diffsForSo->filter(function ($d) use ($keysForBox) { $k = isset($d['item_key']) ? (string) $d['item_key'] : ''; return $k !== '' && $keysForBox->contains($k); })->values(); @endphp @endforeach @php $unboxedDiffs = $diffsForSo->filter(function ($d) use ($allBoxKeys) { $k = isset($d['item_key']) ? (string) $d['item_key'] : ''; return $k !== '' && !$allBoxKeys->contains($k); })->values(); @endphp @if($unboxedDiffs->isNotEmpty()) @endif @endforeach
SO No Boxes Items (Total Qty) Actions
{{ $soNo }} {{ $boxCount }} {{ $totalQty }}
Box: {{ $boxVal }}
Dimension: {{ $r->dimension }} | Weight: {{ $r->weight }}
Status: {{ $r->status }}
@if($diffsForBox->isNotEmpty())
Items:
@foreach($diffsForBox as $d) @endforeach
Item SO Qty Packed Qty Diff
{{ $d['item_name'] ?? '' }} {{ $d['so_qty'] ?? 0 }} {{ $d['packed_qty'] ?? 0 }} {{ $d['diff'] ?? 0 }}
@else
No quantity differences for this box.
@endif
Box: -
Items:
@foreach($unboxedDiffs as $d) @endforeach
Item SO Qty Packed Qty Diff
{{ $d['item_name'] ?? '' }} {{ $d['so_qty'] ?? 0 }} {{ $d['packed_qty'] ?? 0 }} {{ $d['diff'] ?? 0 }}
@endif
@endsection @push('scripts') @endpush