@extends('layouts.admin-simple') @section('title', 'Material Issue Decision - Multi-Source') @push('styles') @endpush @section('breadcrumb') @endsection @section('page-title')

Material Issue

Issue material request from multiple sources

arrow_back Back to List
@endsection @section('content')
assignment Material Request Information
{{ $transaction->material_request_number ?: 'MR-' . str_pad($transaction->id, 6, '0', STR_PAD_LEFT) }}
{{ $transaction->transaction_date->format('d-M-Y') }}
{{ $transaction->project->project_name ?? 'N/A' }}
@if($transaction->division) {{ $transaction->division->name }} @endif
{{ $transaction->requester->name ?? 'N/A' }}
shopping_cart Requested Items Reference
assignment_turned_in Allocation Summary
@foreach($transaction->items as $item) @php // Get fulfillment breakdown by type for this item (fixed to include all fulfillment types) $fulfillments = \App\Models\Warehouse\OutgoingFulfillment::where('outgoing_transaction_id', $transaction->id) ->where('item_id', $item->item_id) ->get() ->groupBy('fulfillment_type'); // Get fulfillment data directly to avoid groupBy issues $allFulfillmentData = \App\Models\Warehouse\OutgoingFulfillment::where('outgoing_transaction_id', $transaction->id) ->where('item_id', $item->item_id) ->get(); // Calculate quantities directly from raw data $inventoryQty = $allFulfillmentData->whereIn('fulfillment_type', ['inventory', 'inventory_dispatch'])->sum('quantity_fulfilled'); $deliveryQty = $allFulfillmentData->where('fulfillment_type', 'direct_delivery')->sum('quantity_fulfilled'); $transferQty = $allFulfillmentData->where('fulfillment_type', 'project_transfer')->sum('quantity_fulfilled'); $totalIssued = $inventoryQty + $deliveryQty + $transferQty; @endphp @endforeach
Item Code Requested Already Issued Inventory Delivery Transfer Total Remaining Status
{{ $item->item->item_code ?? 'N/A' }} {{ number_format($item->quantity_requested, 0) }} @if($totalIssued > 0) {{ number_format($totalIssued, 0) }} @else 0 @endif @if($inventoryQty > 0) {{ number_format($inventoryQty, 0) }} @else 0 @endif @if($deliveryQty > 0) {{ number_format($deliveryQty, 0) }} @else 0 @endif @if($transferQty > 0) {{ number_format($transferQty, 0) }} @else 0 @endif {{ number_format($totalIssued, 0) }} {{ number_format($item->quantity_remaining ?? $item->quantity_requested, 0) }} @if(isset($item->quantity_remaining) && $item->quantity_remaining <= 0) Fully Issued @elseif(isset($item->quantity_fulfilled) && $item->quantity_fulfilled > 0) Partially Issued @else Pending @endif
@if ($errors->any())
@endif @if(session('error'))
{{ session('error') }}
@endif @if(session('success'))
{{ session('success') }}
@endif @php // Calculate if all items are fully issued $allFullyIssued = $transaction->items->every(function($item) { return isset($item->quantity_remaining) && $item->quantity_remaining <= 0; }); @endphp @if($allFullyIssued)
check_circle Material Request Fully Issued: All requested items have been completely issued to the project. No further action required.
@else
@csrf
inventory Inventory Dispatch
local_shipping Direct Delivery
swap_horiz Project Transfer
summarize Issue Summary
@php $totalRequested = 0; $totalFulfilled = 0; $totalRemaining = 0; $totalInventory = 0; $totalDelivery = 0; $totalTransfer = 0; foreach($transaction->items as $item) { $totalRequested += $item->quantity_requested; $totalFulfilled += $item->quantity_fulfilled ?? 0; $totalRemaining += $item->quantity_remaining ?? $item->quantity_requested; // Get fulfillment data directly to avoid groupBy issues (same approach as above) $itemFulfillments = \App\Models\Warehouse\OutgoingFulfillment::where('outgoing_transaction_id', $transaction->id) ->where('item_id', $item->item_id) ->get(); // Calculate totals using direct filtering $totalInventory += $itemFulfillments->whereIn('fulfillment_type', ['inventory', 'inventory_dispatch'])->sum('quantity_fulfilled'); $totalDelivery += $itemFulfillments->where('fulfillment_type', 'direct_delivery')->sum('quantity_fulfilled'); $totalTransfer += $itemFulfillments->where('fulfillment_type', 'project_transfer')->sum('quantity_fulfilled'); } @endphp
{{ number_format($totalRequested, 2) }}
{{ number_format($totalFulfilled, 2) }}
{{ number_format($totalRemaining, 2) }}
0.00
{{ number_format($totalInventory, 2) }}
{{ number_format($totalDelivery, 2) }}
{{ number_format($totalTransfer, 2) }}
{{ number_format($totalFulfilled, 2) }}

cancel Cancel
@endif
@endsection @section('floating-tracker')
track_changes Quick Tracker
@endsection @push('styles') @endpush @push('scripts') @endpush