Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/InventoryAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,16 @@ public function render(string $csrf = '', ?string $notice = null, ?string $q = n

$html = '<div class="nb-page-head"><h1>Inventory</h1></div>' . $banner
. '<p class="nb-muted" style="margin:-8px 0 20px">Stock as an append-only ledger — on-hand, reserved and available per location. '
. 'Receive, adjust, count or transfer below, or drive it over MCP.</p>'
. $this->datalists($skus, array_values($locations))
. $this->forms($csrf);
. 'Filter it below, record a movement, or drive it all over MCP.</p>'
. $this->datalists($skus, array_values($locations));

// Lead with the stock overview — the operator wants to *see* inventory
// first; the movement forms come after.
$html .= '<h2 style="margin-top:1.5rem">Stock on hand</h2>';
$html .= $this->filterForm($q);
if ($stock === []) {
$html .= $q === ''
? '<p class="nb-muted">No stock yet. Receive some above, or with the <code>inventory_receive</code> tool.</p>'
? '<p class="nb-muted">No stock yet. Record a receipt below, or use the <code>inventory_receive</code> tool.</p>'
: '<p class="nb-muted">No stock matches “' . $this->e($q) . '”.</p>';
} else {
$html .= '<div class="nb-table-wrap nb-stack"><table class="nb-table"><thead><tr>'
Expand All @@ -108,6 +110,10 @@ public function render(string $csrf = '', ?string $notice = null, ?string $q = n
$html .= '</tbody></table></div>';
}

// The movement forms, after the overview.
$html .= '<h2 style="margin-top:2rem">Record a movement</h2>';
$html .= $this->forms($csrf);

$html .= '<h2 style="margin-top:2rem">Recent movements</h2>';
if ($movements === []) {
$html .= '<p class="nb-muted">None yet.</p>';
Expand Down Expand Up @@ -155,7 +161,7 @@ private function forms(string $csrf): string
{
$t = '<input type="hidden" name="_token" value="' . $this->e($csrf) . '">';

return '<div style="display:flex;gap:1rem;flex-wrap:wrap;margin-bottom:1.5rem">'
return '<div style="display:flex;gap:1.5rem;flex-wrap:wrap;margin-bottom:1.5rem">'
. '<form class="nb-form-card" method="post" action="/admin/inventory/receive" style="flex:1 1 240px">'
. '<h2>Receive stock</h2>' . $t
. $this->field('SKU', 'sku', 'e.g. house-blend', 'inv-skus')
Expand Down
Loading