@extends('index') @section('content')

Material Requirements for Order

Customer No: {{$order['customer_no']}}
Customer Name: {{$order['fname']}} {{$order['lname']}}
Order No {{$order['order_no']}}
Job No: {{$order['job_no']}}
Date: {{\Carbon\Carbon::parse($order['order_date'])->format('d-m-Y')}}
Order Status: @if($order['order_status'] == 1) Pending @elseif($order['order_status'] == 2) Processing @elseif($order['order_status'] == 3) On Hold @elseif($order['order_status'] == 4) Partially Delivered @elseif($order['order_status'] == 5) Delivered @elseif($order['order_status'] == 6) Completed @elseif($order['order_status'] == 7) Canceled @elseif($order['order_status'] == 8) Returned @elseif($order['delivery_status'] == 9) Disputed @else @endif
Materials Required
@if($estimate->count()) @php $srNo = 1; @endphp @foreach($estimate as $item) @if(!isset($item->is_component_product) || !$item->is_component_product) @php $stockItem = $stock[$item->material_id] ?? (object)[ 'total_qty' => 0, 'stockIn' => 0, 'total_received' => '0', 'total_returned' => 0, 'stockOut' => 0 ]; $available = $stockItem->total_received + $stockItem->stockIn - $stockItem->total_returned - $stockItem->stockOut; $purchaseItem = $purchase[$item->material_id] ?? null; $purchased = $purchaseItem ? $purchaseItem['total_qty'] : 0; @endphp @php $srNo++; @endphp @endif @endforeach @endif
Sr. Code Material Name Current Vendor Total Require Qty Available Qty Purchased Qty Required Qty Unit
{{ $srNo }} {{ $item->material_no }} {{ $item->name }} {{ $item->vendor_no }} - {{ $item->fname }} {{ number_format($item->total_qty, 2) }} {{ number_format($available) }} {{ number_format($purchased) }} {{ number_format(max($item->total_qty - $available, 0)) }} {{ $item->hname }}
Sr. Code Material Name Current Vendor Total Require Qty Available Qty Purchased Qty Required Qty Unit
@php $componentProducts = $estimate->filter(function($item) { return isset($item->is_component_product) && $item->is_component_product; }); @endphp @if($componentProducts->count() > 0)
Component Products Required
@php $srNo = 1; @endphp @foreach($componentProducts as $item) @php $productStockItem = $productStock[$item->product_type_id] ?? null; $available = 0; if ($productStockItem) { // Handle both array and object access $stockIn = is_array($productStockItem) ? $productStockItem['stockIn'] : $productStockItem->stockIn; $stockOut = is_array($productStockItem) ? $productStockItem['stockOut'] : $productStockItem->stockOut; $available = $stockIn - $stockOut; } @endphp @php $srNo++; @endphp @endforeach
Sr. Article No Product Name Size Total Require Qty Available Qty Required Qty Unit
{{ $srNo }} {{ $item->article_no }} {{ $item->name }} {{ $item->size_name }} {{ number_format($item->total_qty, 2) }} {{ number_format(max($available, 0)) }} {{ number_format(max($item->total_qty - $available, 0)) }} {{ $item->hname }}
Sr. Article No Product Name Size Total Require Qty Available Qty Required Qty Unit
@endif
@endsection