@extends('admin.layouts.app') @section('title', get_setting('site_name').' | '.__('Asset assignments')) @include('admin.asset.partials.page_styles') @php use App\Support\Asset\AssetType; @endphp @push('css') @endpush @section('content')

{{ __('Active asset assignments') }}

{{ __('Track who holds each asset, employee acknowledgment, and consumable usage.') }}

@if (session()->has('message'))
{{ session('message') }}
@endif
@php $ackFilter = request('ack'); $statCards = [ 'all' => [__('All active'), $stats['total'] ?? 0, null], 'acknowledged' => [__('Acknowledged'), $stats['acknowledged'] ?? 0, 'acknowledged'], 'pending' => [__('Pending ack.'), $stats['pending_ack'] ?? 0, 'pending'], ]; @endphp @foreach($statCards as $key => [$label, $count, $ackValue]) @php $isActive = ($key === 'all' && ! request()->filled('ack')) || ($ackValue !== null && $ackFilter === $ackValue); $statUrl = $key === 'all' ? route('asset.assign.list', request()->except(['ack', 'page'])) : route('asset.assign.list', array_merge(request()->except('page'), ['ack' => $ackValue])); @endphp @endforeach
{{ __('Assignment list') }}
@if($assign_assets->total() > 0) {{ __('Showing') }} {{ $assign_assets->firstItem() }}–{{ $assign_assets->lastItem() }} {{ __('of') }} {{ $assign_assets->total() }} @endif
{{ __('Reset') }}
@forelse($assign_assets as $item) @php $parentCategory = $item->asset_category?->parentCategory; $categoryName = $parentCategory?->name ?? $item->asset_category?->name ?? '—'; $assetName = $item->asset_item?->name ?? ($parentCategory ? ($item->asset_category?->name ?? '—') : '—'); $identity = $item->asset_item?->identity ?? $item->asset_item?->code ?? $item->issue_barcode ?? '—'; $assetType = $item->resolvedAssetType(); $qty = (float) $item->qty; $unit = $item->asset_item?->qtyUnitLabel() ?? ''; $qtyFmt = fmod($qty, 1.0) === 0.0 ? (string) (int) $qty : number_format($qty, 2); $qtyDisplay = $unit !== '' ? trim($qtyFmt.' '.$unit) : $qtyFmt; $consumed = $item->qtyConsumed(); $remaining = $item->qtyRemaining(); $usagePct = $qty > 0 ? min(100, round(($consumed / $qty) * 100)) : 0; $isAck = (bool) $item->staff_acknowledgement; $canReturn = $item->canReturn(); $fullyConsumed = $item->isFullyConsumed(); @endphp @if($item->isConsumable() && $item->usageLogs->isNotEmpty()) @endif @empty @endforelse
{{ __('Date') }} {{ __('Employee') }} {{ __('Type') }} {{ __('Category') }} {{ __('Asset') }} {{ __('Serial / code') }} {{ __('Qty') }} {{ __('Acknowledgment') }} {{ __('Usage') }} {{ __('Action') }}
{{ optional($item->assign_date)->format('Y-m-d') ?? optional($item->created_at)->format('Y-m-d') }} {{ $item->staff?->user?->name ?? '—' }} @if($item->staff?->warehouse?->name)
{{ $item->staff->warehouse->name }}
@endif
{{ AssetType::label($assetType) }} {{ $categoryName }} {{ $assetName }} {{ $identity }} {{ $qtyDisplay }} @if($isAck) {{ __('Acknowledged') }} @if($item->acknowledged_at)
{{ $item->acknowledged_at->format('Y-m-d') }}
@endif @else {{ __('Pending') }} @endif
@if($item->isConsumable())
{{ __('Used') }}: {{ number_format($consumed, 2) }} {{ $unit }}
{{ __('Remaining') }}: {{ number_format($remaining, 2) }} {{ $unit }}
@if($item->usageLogs->isNotEmpty()) @endif @else @endif
@if($fullyConsumed) {{ __('Fully used') }} @elseif($canReturn) @else @endif
{{ __('No active assignments found.') }}
@if($assign_assets->hasPages())
{{ $assign_assets->links() }}
@endif
@endsection @section('modal') @endsection @section('script') @include('admin.asset.partials.scripts') @endsection