CoolCMS API

StockItemLinePickerTrait

Picker of a stock item on a document line (multiplier `lines`, each line has its own instance).

Like NewsletterAddressPickerTrait (picker in a multiplier); the modal targets the StockItem show grid (with picker mode). The line label is held by the text control stockItemLabel (survives an AJAX re-render); the item_code/item_name snapshot on the movement is filled by save from the selected stockItemId (the journal survives deleting the item).

$this->stockItemManager is injected by the constructor of StockDocumentPresenter.

Table of Contents

Methods

addStockItemLineControls()  : void
Picker fields on a multiplier line: hidden `stockItemId` + text label `stockItemLabel`.
stockItemLinePicker()  : PickerConfig
resolveStockItemLineLabel()  : string|null
stockItemLineLabel()  : string
stockItemName()  : string
Item name in the current language, falling back to the first non-empty translation.
suggestStockItemLines()  : array<int, array{id: int, label: string}>

Methods

addStockItemLineControls()

Picker fields on a multiplier line: hidden `stockItemId` + text label `stockItemLabel`.

protected addStockItemLineControls(Container $parent[, string $targetField = 'stockItemId' ][, string $displayField = 'stockItemLabel' ]) : void
Parameters
$parent : Container
$targetField : string = 'stockItemId'
$displayField : string = 'stockItemLabel'

stockItemLinePicker()

protected stockItemLinePicker([string $formName = 'editForm' ][, string $container = 'lines' ][, string $targetField = 'stockItemId' ][, string $displayField = 'stockItemLabel' ]) : PickerConfig
Parameters
$formName : string = 'editForm'
$container : string = 'lines'
$targetField : string = 'stockItemId'
$displayField : string = 'stockItemLabel'
Return values
PickerConfig

resolveStockItemLineLabel()

private resolveStockItemLineLabel(int $id) : string|null
Parameters
$id : int
Return values
string|null

stockItemName()

Item name in the current language, falling back to the first non-empty translation.

private stockItemName(StockItem $item) : string

Iterates the typed getTranslations() (Collection<StockItemText>); shared by the form and stocktake traits.

Parameters
$item : StockItem
Return values
string

suggestStockItemLines()

private suggestStockItemLines(string $query) : array<int, array{id: int, label: string}>
Parameters
$query : string
Return values
array<int, array{id: int, label: string}>
On this page

Search results