<form id="po-bulk-form" method="post" class="visually-hidden erp-bulk-form" autocomplete="off">
    @csrf
    <input type="hidden" name="confirmation" id="po-bulk-confirm" value="" required>
</form>

<x-ui.table.table :columns="[
    ['label' => '', 'align' => 'center'],
    ['label' => __('procurement.po.columns.number')],
    ['label' => __('procurement.po.columns.status')],
    ['label' => __('procurement.po.columns.lines')],
    ['label' => __('procurement.po.columns.receipts')],
    ['label' => __('procurement.bulk.inline_approve'), 'align' => 'center'],
    ['label' => __('common.view'), 'align' => 'end'],
]">
    @forelse ($purchaseOrders as $po)
        <x-ui.table.row>
            <td class="text-center">
                @if ($po->status === \App\Modules\Procurement\Support\PurchaseOrderLifecycleStatus::Draft->value && Gate::allows('operate', $po))
                    <input class="form-check-input erp-bulk-row" type="checkbox" form="po-bulk-form" name="ids[]" value="{{ $po->id }}">
                @else
                    <span class="text-muted">—</span>
                @endif
            </td>
            <td><strong>{{ $po->po_number }}</strong></td>
            <td>
                <x-ui.operational.status-badge :label="$po->status" variant="neutral" />
            </td>
            <td>{{ $po->items_count }}</td>
            <td>{{ $po->goods_receipts_count }}</td>
            <td class="text-center">
                @if ($po->status === \App\Modules\Procurement\Support\PurchaseOrderLifecycleStatus::Draft->value && Gate::allows('operate', $po))
                    <form method="post" action="{{ route('procurement.purchase-orders.approve.store', $po) }}" class="d-inline" data-operational-confirm="{{ __('procurement.po.transitions.approve') }}">
                        @csrf
                        <input type="hidden" name="confirmation" value="APPROVE_PO">
                        <button type="submit" class="btn btn-sm btn-outline-primary">{{ __('procurement.bulk.inline_approve') }}</button>
                    </form>
                @else
                    —
                @endif
            </td>
            <td class="text-end">
                <x-ui.buttons.secondary :href="route('procurement.purchase-orders.show', $po)">{{ __('common.view') }}</x-ui.buttons.secondary>
            </td>
        </x-ui.table.row>
    @empty
        <x-ui.table.row>
            <td colspan="7" class="p-0">
                <x-ui.operational.empty-state :title="__('operational_ui.index.empty_default')" />
            </td>
        </x-ui.table.row>
    @endforelse
</x-ui.table.table>
