@extends('index') @section('content')
{{-- Material Stock --}}
@if($stock->count()) @php $loopIndex = 1; @endphp @foreach($stock as $item) @unless($item->material_type_id == 101) @endunless @endforeach @endif
Sr. Code Material Name Quantity
{{$loopIndex++}} {{$item->material_no}} {{$item->name}} @if($item->location) {{$item->location}} @endif {{number_format($item->total_received + $item->stockIn - $item->stockOut - $item->total_returned)}} {{$item->uname}}
Sr. Code Material Name Quantity
{{-- Product Stock (Grouped by Product/Size with Stage Modal) --}}
@if($pstock->count()) @php // Group stock by product_type_id to show one row per product/size $groupedPstock = $pstock->groupBy('product_type_id'); $rowIndex = 1; $prevProductId = 0; @endphp @foreach($groupedPstock as $productTypeId => $stageItems) @php $firstItem = $stageItems->first(); // Calculate total stock across all stages, excluding rejection stock (head_id = 105) $totalStock = $stageItems->sum(function($item) { // Exclude rejection stock from total count if(($item->sthead_id ?? $item->stage_id) == 105) return 0; return $item->stockIn - $item->stockOut; }); // Show all products including zero stock @endphp @if($firstItem->product_id == $prevProductId) @else @endif @php $prevProductId = $firstItem->product_id; @endphp @endforeach @endif
Sr. Article No Item / Product Size Total Stock Actions
{{ $rowIndex++ }}{{ $firstItem->article_no }} {{ $firstItem->name }}{{ $firstItem->sname }} @if($totalStock > 0) {{ number_format($totalStock) }} {{ $firstItem->uname }} @else 0 {{ $firstItem->uname }} @endif
Sr. Article No Item / Product Size Total Stock Actions
{{-- Material Stock --}}
@if($stock->count()) @php $loopIndex = 1; @endphp @foreach($stock as $item) @unless($item->material_type_id != 101) @endunless @endforeach @endif
Sr. Code Material Name Quantity
{{$loopIndex++}} {{$item->material_no}} {{$item->name}} @if($item->location) {{$item->location}} @endif {{number_format($item->total_received + $item->stockIn - $item->stockOut - $item->total_returned)}} {{$item->uname}}
Sr. Code Material Name Quantity
@if($pstock->count()) @php $groupedPstockForModals = $pstock->groupBy('product_type_id'); @endphp @foreach($groupedPstockForModals as $productTypeId => $stageItems) @php $firstItem = $stageItems->first(); // Calculate total stock excluding rejection stock (head_id = 105) $totalStock = $stageItems->sum(function($item) { if(($item->sthead_id ?? $item->stage_id) == 105) return 0; return $item->stockIn - $item->stockOut; }); // Calculate rejection stock separately for display $rejectionStock = $stageItems->sum(function($item) { if(($item->sthead_id ?? $item->stage_id) == 105) return $item->stockIn - $item->stockOut; return 0; }); // Show all products including zero stock @endphp @endforeach @endif @endsection