@extends('layouts.master')
@section('title', 'Processing - Suppliers')

@section('content')
<div class="container mt-4">
    <div class="card-header bg-primary text-white py-3">
        <h5 class="mb-0"><i class="fas fa-truck me-2"></i>Processing - Suppliers</h5>
    </div>

    <div class="table-responsive">
        <table class="table table-bordered table-hover">
            <thead class="table-light">
                <tr>
                    <th>#</th>
                    <th>Supplier Code</th>
                    <th>Supplier Name</th>
                    <th>Category</th>
                    <th class="text-end">Outstanding Balance</th>
                    <th width="180px">Actions</th>
                </tr>
            </thead>
            <tbody>
                @forelse($suppliers as $row)
                    <tr>
                        <td>{{ ($suppliers->currentPage() - 1) * $suppliers->perPage() + $loop->iteration }}</td>
                        <td>{{ $row->supplier_code }}</td>
                        <td>{{ $row->supplier_account }}</td>
                        <td>{{ $row->category_name }}</td>
                        <td class="text-end">{{ number_format((float) $row->outstanding_balance, 2) }}</td>
                        <td>
                            <a href="{{ route('supplierStatementReport.index') }}" class="btn btn-secondary btn-sm">View</a>
                            <a href="{{ route('supplierStatementReport.index') }}" class="btn btn-outline-primary btn-sm">Link Document</a>
                        </td>
                    </tr>
                @empty
                    <tr><td colspan="6">No suppliers found.</td></tr>
                @endforelse
            </tbody>
        </table>
    </div>

    {{ $suppliers->links() }}
</div>
@endsection

