@php $util = app(\Modules\Maintenance\Utils\MaintenanceUtil::class); @endphp

@lang('maintenance::lang.material_list')

@can('maintenance.materials.manage')
{!! Form::label('destination_location_id', __('maintenance::lang.mat_destination_location') . ':') !!} {!! Form::select('destination_location_id', $locations->pluck('name', 'id'), $material_list->destination_location_id, ['class' => 'form-control select2 mm_dest_location', 'placeholder' => __('maintenance::lang.select'), 'style' => 'width:100%']) !!}
@if($equipment_id) @endif
@else

@lang('maintenance::lang.mat_destination_location'): {{ $material_list->destinationLocation?->name ?? '—' }}

@endcan @can('maintenance.materials.manage')
{!! Form::open(['url' => action([\Modules\Maintenance\Http\Controllers\MaterialListController::class, 'storeLine'], [$source_type, $source_id]), 'method' => 'post', 'class' => 'mm_add_line_form']) !!}
{!! Form::select('spare_part_id', $spare_parts, null, ['class' => 'form-control select2', 'placeholder' => __('maintenance::lang.select_spare_part'), 'style' => 'width:100%']) !!}
{!! Form::text('part_name', null, ['class' => 'form-control', 'placeholder' => __('maintenance::lang.mat_or_part_name')]) !!}
{!! Form::select('line_type', ['supply' => __('maintenance::lang.line_type_supply'), 'repair' => __('maintenance::lang.line_type_repair')], 'supply', ['class' => 'form-control']) !!}
{!! Form::number('quantity_required', 1, ['class' => 'form-control', 'min' => '0.001', 'step' => '0.001', 'required']) !!}
{!! Form::close() !!}
@endcan
@forelse($material_list->lines->where('line_type', 'supply') as $line) @php $a = $analysis[$line->id] ?? null; @endphp @empty @endforelse
@lang('maintenance::lang.spare_part') @lang('maintenance::lang.mat_qty_required') @lang('maintenance::lang.mat_local_stock') @lang('maintenance::lang.mat_other_warehouses') @lang('maintenance::lang.mat_shortfall') @lang('maintenance::lang.status') @lang('maintenance::lang.actions')
{{ $line->displayName() }} @if($line->part_number)
{{ $line->part_number }}@endif
{{ $a['quantity_required'] ?? $line->quantity_required }} {{ $a['local_qty'] ?? '—' }} @if(!empty($a['other_locations'])) @foreach($a['other_locations'] as $loc)
{{ $loc['entity_name'] ? $loc['entity_name'].' / ' : '' }}{{ $loc['location_name'] }}: {{ $loc['qty'] }}
@endforeach @else @endif
@if(($a['shortfall'] ?? 0) > 0) {{ $a['shortfall'] }} @else 0 @endif {{ $status_labels[$line->status] ?? $line->status }} @can('maintenance.materials.procure') @if(!empty($a['other_locations']) && ($a['remaining'] ?? 0) > 0)
@endif @endcan @can('maintenance.materials.manage') @if(!in_array($line->status, ['transfer_in_transit', 'purchase_ordered'])) @endif @endcan @if($line->procurements->isNotEmpty())
@foreach($line->procurements as $proc) {{ $proc->procurement_type }}: {{ $proc->transaction?->ref_no ?? '#' }} @endforeach @endif
@lang('maintenance::lang.no_records')
@include('maintenance::materials.repair_tab')
@if(empty($purchase_shortfall))

@lang('maintenance::lang.mat_no_purchase_needed')

@else @can('maintenance.materials.procure') {!! Form::open(['url' => action([\Modules\Maintenance\Http\Controllers\MaterialListController::class, 'createPurchaseOrders'], [$source_type, $source_id]), 'method' => 'post', 'id' => 'mm_purchase_form']) !!}
@foreach($purchase_shortfall as $idx => $item) @endforeach
@lang('maintenance::lang.spare_part') @lang('maintenance::lang.mat_shortfall') @lang('maintenance::lang.mat_suggested_supplier') @lang('maintenance::lang.mat_purchase_history')
{{ $item['display_name'] }} {{ $item['shortfall_qty'] }} @if(!empty($item['supplier_suggestions']))
    @foreach(array_slice($item['supplier_suggestions'], 0, 3) as $sug)
  • {{ $sug['supplier_name'] }} — {{ $sug['last_date'] ? $util->formatDate($sug['last_date']) : '—' }}
  • @endforeach
@else @lang('maintenance::lang.mat_no_history') @endif
{!! Form::close() !!} @else

@lang('maintenance::lang.mat_procure_permission_required')

@endcan @endif