CoolCMS API

StockInventoryTrait

Stocktake screen (`stock-document/inventory`): choose a warehouse, then a filtered, paginated table of items with the current quantity (snapshot) and a "counted" input, submitted to `adjust()`.

IMPORTANT: an empty input skips the item (partial stocktake); it never means counted = 0, otherwise one submit would zero the warehouse. The quantity snapshot is rendered as hidden and read back from the raw POST, so adjust() rejects a line whose stock changed in the meantime (TOCTOU per line); other lines pass. Counts are read from the raw POST (counted[id] / snapshot[id]), not through Nette controls: the number of items on a page varies and rebuilding dynamic fields would be fragile. The form holds only CSRF + note + submit.

Table of Contents

Constants

INVENTORY_PER_PAGE  : mixed = 30

Methods

actionInventory()  : void
renderInventory()  : void
createComponentInventoryForm()  : Form
inventoryLevelQuantities()  : array<int, string>
inventoryRows()  : array{0: list, 1: int}
A page of items and their current quantity in the chosen warehouse (snapshot for TOCTOU).
inventoryWarehouseOptions()  : array<int, string>
processInventory()  : bool
Posts the stocktake batch through the Api; redirects after the call, returns false (with a flash) when nothing was sent.

Constants

Methods

actionInventory()

public actionInventory([int|null $wid = null ][, string|null $q = null ][, int $page = 1 ]) : void
Parameters
$wid : int|null = null
$q : string|null = null
$page : int = 1

inventoryLevelQuantities()

private inventoryLevelQuantities(int $warehouseId, array<int, int> $itemIds) : array<int, string>
Parameters
$warehouseId : int
$itemIds : array<int, int>
Return values
array<int, string> —

stockItemId => quantity

inventoryRows()

A page of items and their current quantity in the chosen warehouse (snapshot for TOCTOU).

private inventoryRows(int $warehouseId, string|null $query, int $page) : array{0: list, 1: int}
Parameters
$warehouseId : int
$query : string|null
$page : int
Return values
array{0: list, 1: int}

inventoryWarehouseOptions()

private inventoryWarehouseOptions() : array<int, string>
Return values
array<int, string> —

warehouseId => "code - name"

processInventory()

Posts the stocktake batch through the Api; redirects after the call, returns false (with a flash) when nothing was sent.

private processInventory(Form $form) : bool
Parameters
$form : Form
Return values
bool
On this page

Search results