4use Bitrix\Main\Entity\ReferenceField;
86 return 'b_catalog_store_docs';
101 'autocomplete' =>
true,
108 'validation' => [__CLASS__,
'validateTitle'],
116 'values' => static::getTypeList(),
117 'title' =>
Loc::getMessage(
'INVENTORY_DOCUMENT_ENTITY_DOC_TYPE_FIELD'),
123 'validation' => [__CLASS__,
'validateDocNumber'],
124 'title' =>
Loc::getMessage(
'INVENTORY_DOCUMENT_ENTITY_DOC_NUMBER_FIELD'),
130 'validation' => [__CLASS__,
'validateSiteId'],
136 ContractorTable::class,
137 Main\ORM\
Query\Join::on(
'this.CONTRACTOR_ID',
'ref.ID')
142 'title' =>
Loc::getMessage(
'INVENTORY_DOCUMENT_ENTITY_CONTRACTOR_ID_FIELD'),
148 'default_value' =>
function()
152 'title' =>
Loc::getMessage(
'INVENTORY_DOCUMENT_ENTITY_DATE_MODIFY_FIELD'),
158 'default_value' =>
function()
162 'title' =>
Loc::getMessage(
'INVENTORY_DOCUMENT_ENTITY_DATE_CREATE_FIELD'),
168 'title' =>
Loc::getMessage(
'INVENTORY_DOCUMENT_ENTITY_CREATED_BY_FIELD'),
174 Main\ORM\
Query\Join::on(
'this.CREATED_BY',
'ref.ID')
179 'title' =>
Loc::getMessage(
'INVENTORY_DOCUMENT_ENTITY_MODIFIED_BY_FIELD'),
185 Main\ORM\
Query\Join::on(
'this.MODIFIED_BY',
'ref.ID')
190 'title' =>
Loc::getMessage(
'INVENTORY_DOCUMENT_ENTITY_RESPONSIBLE_ID_FIELD')
196 Main\ORM\
Query\Join::on(
'this.RESPONSIBLE_ID',
'ref.ID')
201 'validation' => [__CLASS__,
'validateCurrency'],
202 'title' =>
Loc::getMessage(
'INVENTORY_DOCUMENT_ENTITY_CURRENCY_FIELD'),
208 'values' => [
'N',
'Y'],
216 'values' => array(
'N',
'Y'),
218 'title' =>
Loc::getMessage(
'INVENTORY_DOCUMENT_ENTITY_WAS_CANCELLED_FIELD'),
224 'default_value' =>
null,
225 'title' =>
Loc::getMessage(
'INVENTORY_DOCUMENT_ENTITY_DATE_STATUS_FIELD'),
231 'default_value' =>
function()
235 'title' =>
Loc::getMessage(
'INVENTORY_DOCUMENT_ENTITY_DATE_DOCUMENT_FIELD'),
241 'title' =>
Loc::getMessage(
'INVENTORY_DOCUMENT_ENTITY_STATUS_BY_FIELD'),
247 Main\ORM\
Query\Join::on(
'this.STATUS_BY',
'ref.ID')
258 'validation' => [__CLASS__,
'validateCommentary'],
259 'title' =>
Loc::getMessage(
'INVENTORY_DOCUMENT_ENTITY_COMMENTARY_FIELD'),
265 'title' =>
Loc::getMessage(
'INVENTORY_DOCUMENT_ENTITY_ITEMS_ORDER_DATE_FIELD')
269 'ITEMS_RECEIVED_DATE',
271 'title' =>
Loc::getMessage(
'INVENTORY_DOCUMENT_ENTITY_ITEMS_RECEIVED_DATE_FIELD')
276 StoreDocumentElementTable::class,
278 ))->configureJoinType(
'left'),
342 public static function getTypeList(
bool $description =
false): array
347 self::TYPE_ARRIVAL =>
Loc::getMessage(
'INVENTORY_DOCUMENT_TYPE_ARRIVAL'),
348 self::TYPE_STORE_ADJUSTMENT =>
Loc::getMessage(
'INVENTORY_DOCUMENT_TYPE_STORE_ADJUSTMENT'),
349 self::TYPE_MOVING =>
Loc::getMessage(
'INVENTORY_DOCUMENT_TYPE_MOVING'),
350 self::TYPE_RETURN =>
Loc::getMessage(
'INVENTORY_DOCUMENT_TYPE_RETURN'),
351 self::TYPE_DEDUCT =>
Loc::getMessage(
'INVENTORY_DOCUMENT_TYPE_DEDUCT'),
352 self::TYPE_UNDO_RESERVE =>
Loc::getMessage(
'INVENTORY_DOCUMENT_TYPE_UNDO_RESERVE'),
371 self::STATUS_CONDUCTED =>
Loc::getMessage(
'INVENTORY_DOCUMENT_STATUS_CONDUCTED'),
372 self::STATUS_DRAFT =>
Loc::getMessage(
'INVENTORY_DOCUMENT_STATUS_DRAFT'),
373 self::STATUS_CANCELLED =>
Loc::getMessage(
'INVENTORY_DOCUMENT_STATUS_CANCELLED'),
379 $statusList = static::getStatusList();
381 return $statusList[$status] ??
null;
396 '=WAS_CANCELLED' =>
'N',
402 '=WAS_CANCELLED' =>
'Y',
423 $productId = (int)$productId;
429 $query->registerRuntimeField(
431 'FILTER_ELEMENT_DOC_ID',
433 Join::on(
'ref.DOC_ID',
'this.ID')->where(
'ref.ELEMENT_ID', $productId),
434 [
'join_type' =>
'INNER']
438 $query->addGroup(
'ID');
443 Main\Type\Collection::normalizeArrayValuesByInt($productIds);
444 if (empty($productIds))
449 $query->registerRuntimeField(
451 'FILTER_ELEMENT_DOC_ID',
453 Join::on(
'ref.DOC_ID',
'this.ID')->whereIn(
'ref.ELEMENT_ID', $productIds),
454 [
'join_type' =>
'INNER']
458 $query->addGroup(
'ID');
463 $storeId = (int)$storeId;
472 ->where(
'ref.STORE_FROM', $storeId)
473 ->where(
'ref.STORE_TO', $storeId)
475 $query->registerRuntimeField(
477 'FILTER_STORE_DOC_ID',
479 Join::on(
'ref.DOC_ID',
'this.ID')->where($filter),
480 [
'join_type' =>
'INNER']
484 $query->addGroup(
'ID');
489 Main\Type\Collection::normalizeArrayValuesByInt($storeIds);
490 if (empty($storeIds))
498 ->whereIn(
'ref.STORE_FROM', $storeIds)
499 ->whereIn(
'ref.STORE_TO', $storeIds)
501 $query->registerRuntimeField(
503 'FILTER_STORE_DOC_ID',
505 Join::on(
'ref.DOC_ID',
'this.ID')->where($filter),
506 [
'join_type' =>
'INNER']
510 $query->addGroup(
'ID');
515 static::addSingleStoreFilterToQuery($query,
'STORE_FROM', $storeIds);
520 static::addSingleStoreFilterToQuery($query,
'STORE_TO', $storeIds);
525 Main\Type\Collection::normalizeArrayValuesByInt($storeIds);
526 if (empty($storeIds))
533 ->whereIn(
'ref.' . $fieldName, $storeIds)
535 $query->registerRuntimeField(
537 'FILTER_' . $fieldName .
'_DOC_ID',
539 Join::on(
'ref.DOC_ID',
'this.ID')->where($filter),
540 [
'join_type' =>
'INNER']
543 $query->addGroup(
'ID');
static addSingleStoreFilterToQuery(Main\ORM\Query\Query $query, string $fieldName, array $storeIds)
static getOrmFilterByStatus(string $status)
static withStoreToList(Main\ORM\Query\Query $query, array $storeIds)
const TYPE_STORE_ADJUSTMENT
static withStoreList(Main\ORM\Query\Query $query, array $storeIds)
static withStoreFromList(Main\ORM\Query\Query $query, array $storeIds)
static validateDocNumber()
static withProductList(Main\ORM\Query\Query $query, array $productIds)
static validateCurrency()
static withStore(Main\ORM\Query\Query $query, $storeId)
static withProduct(Main\ORM\Query\Query $query, $productId)
static getStatusName(string $status)
static validateCommentary()
static getTypeList(bool $description=false)
static getMessage($code, $replace=null, $language=null)