@extends('layouts.admin-simple')

@section('title', 'Pending Allocation')

@section('breadcrumb')
    <li class="breadcrumb-item">Warehouse</li>
    <li class="breadcrumb-item">Fixed Assets</li>
    <li class="breadcrumb-item"><a href="{{ route('warehouse.fixed-assets.allocations.index') }}">Allocations</a></li>
    <li class="breadcrumb-item active">Pending Allocation</li>
@endsection

@section('page-title')
    <div class="d-flex justify-content-between align-items-center w-100">
        <div class="page-title-left">
            <h3 class="mb-1">Pending Allocation</h3>
            <p class="text-muted mb-0" style="font-size: 13px;">Allocations waiting to be assigned to projects</p>
        </div>
        <div class="page-actions-right">
            <a href="{{ route('warehouse.fixed-assets.allocations.index') }}" class="btn btn-sm btn-outline-secondary"><i class="material-icons mr-1" style="font-size: 16px;">arrow_back</i> Back</a>
        </div>
    </div>
@endsection

@section('content')
    <div class="card">
        <div class="card-body p-0">
            <div class="table-responsive">
                <table class="table table-hover mb-0">
                    <thead class="thead-light">
                        <tr><th>#</th><th>Allocation #</th><th>Project</th><th>Assets</th><th>Requested By</th><th>Date</th><th>Actions</th></tr>
                    </thead>
                    <tbody>
                        @forelse($allocations as $i => $alloc)
                        <tr>
                            <td>{{ $allocations->firstItem() + $i }}</td>
                            <td><a href="{{ route('warehouse.fixed-assets.allocations.show', $alloc->id) }}"><code>{{ $alloc->allocation_number }}</code></a></td>
                            <td>{{ $alloc->project ? $alloc->project->project_name : '-' }}</td>
                            <td><span class="badge badge-info">{{ $alloc->items->count() }}</span></td>
                            <td>{{ $alloc->requester ? $alloc->requester->name : '-' }}</td>
                            <td>{{ $alloc->created_at ? $alloc->created_at->format('M d, Y') : '-' }}</td>
                            <td>
                                <a href="{{ route('warehouse.fixed-assets.allocations.show', $alloc->id) }}" class="btn btn-sm btn-primary">Review</a>
                            </td>
                        </tr>
                        @empty
                        <tr><td colspan="7" class="text-center text-muted py-4">No pending allocations.</td></tr>
                        @endforelse
                    </tbody>
                </table>
            </div>
        </div>
        @if($allocations->hasPages())
        <div class="card-footer">{{ $allocations->links() }}</div>
        @endif
    </div>
@endsection
