@extends('index')
@section('content')
Available Stock Table
@if($stock->count())
@php $loopIndex = 1; @endphp
@foreach($stock as $item)
@unless($item->material_type_id == 101)
Sr.
Code
Material Name
Quantity
@endunless
@endforeach
@endif
{{$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
// 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
Sr.
Article No
Item / Product
Size
Total Stock
Actions
@php $prevProductId = $firstItem->product_id; @endphp
@endforeach
@endif
{{ $rowIndex++ }}
@if($firstItem->product_id == $prevProductId)
@else
{{ $firstItem->article_no }}
{{ $firstItem->name }}
@endif
{{ $firstItem->sname }}
@if($totalStock > 0)
{{ number_format($totalStock) }} {{ $firstItem->uname }}
@else
0 {{ $firstItem->uname }}
@endif
Sr.
Article No
Item / Product
Size
Total Stock
Actions
@if($stock->count())
@php $loopIndex = 1; @endphp
@foreach($stock as $item)
@unless($item->material_type_id != 101)
Sr.
Code
Material Name
Quantity
@endunless
@endforeach
@endif
{{$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