1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
store_docs_type.php
См. документацию.
1<?php
2
22
24
25/*
26 Document structure
27 ID int
28 DOC_TYPE char(1)
29 SITE_ID char(2)
30 STATUS char(1) Y/N
31 CONTRACTOR_ID
32 TOTAL
33 CURRENCY
34
35 ELEMENTS => [
36 product_id => [
37 PRODUCT_ID int
38 TYPE int
39 QUANTITY float
40 QUANTITY_RESERVED float
41 QUANTITY_TRACE char(1) Y/N
42 CAN_BUY_ZERO char(1) Y/N
43 SUBSCRIBE char(1) Y/N
44 BARCODE_MULTI char(1) Y/N
45
46 OLD_QUANTITY float (=QUANTITY after load)
47 QUANTITY_LIMIT bool (QUANTITY_TRACE === 'Y' && CAN_BUY_ZERO === 'N')
48
49 IBLOCK_ID int
50 ELEMENT_NAME string
51
52 POSITIONS => [
53 document_row_id => [
54 ROW_ID int
55 PRODUCT_ID int
56 STORE_TO ?int
57 STORE_FROM ?int
58 AMOUNT float
59 PURCHASING_PRICE ?float
60 PURCHASING_CURRENCY ?string
61 PURCHASING_INFO => [ // deprecated
62 PURCHASING_PRICE ?float
63 PURCHASING_CURRENCY ?string
64 ]
65 ]
66 ]
67 BARCODES => [
68 barcode => [
69 ROW_ID int
70 DOCUMENT_ROW_ID int
71 PRODUCT_ID int
72 BARCODE string
73 STORE_FROM ?int
74 STORE_TO ?int
75 ]
76 ]
77 CURRENT_STORES => [
78 store_id => [
79 ID int
80 PRODUCT_ID int
81 STORE_ID int
82 AMOUNT float
83 QUANTITY_RESERVED float
84 ]
85 ]
86 CURRENT_BARCODES => [
87 barcode => [
88 ID ?int
89 BARCODE string
90 PRODUCT_ID ?int
91 ORDER_ID ?int
92 STORE_ID ?int
93 ]
94 ]
95 ]
96 ]
97*/
98
99abstract class CCatalogDocsTypes
100{
113 public const TYPE_INVENTORY = 'I';
114
115 protected const ACTION_CONDUCTION = 'Y';
116 protected const ACTION_CANCEL = 'N';
117
118 protected const ALL_STORES = 'ALL';
119 protected const DISABLED_STORES = 'DISABLE';
120 protected const ACTIVE_STORES = 'ACTIVE';
121
122 protected const ERR_STORE_ABSENT = 'ABSENT';
123 protected const ERR_STORE_UNKNOWN = 'UNKNOWN';
124 protected const ERR_STORE_DISABLED = 'DISABLED';
125
126 public static function getFields(): array
127 {
128 $result = static::getDocumentFields();
129 foreach (static::getElementFields() as $field => $description)
130 {
131 $result[$field] = $description;
132 }
133
134 return $result;
135 }
136
137 public static function getDocumentFields(): array
138 {
139 return array_merge(
140 static::getDocumentCommonFields(),
141 static::getDocumentSpecificFields()
142 );
143 }
144
145 protected static function getDocumentCommonFields(): array
146 {
147 return [
148 'ID' => ['required' => 'Y'],
149 'TITLE' => ['required' => 'N'],
150 'DOC_TYPE' => ['required' => 'Y'],
151 'SITE_ID' => ['required' => 'Y'],
152 'DATE_MODIFY' => ['required' => 'Y'],
153 'DATE_CREATE' => ['required' => 'Y'],
154 'CREATED_BY' => ['required' => 'Y'],
155 'MODIFIED_BY' => ['required' => 'Y'],
156 'STATUS' => ['required' => 'Y'],
157 'WAS_CANCELLED' => ['required' => 'Y'],
158 'DATE_STATUS' => ['required' => 'Y'],
159 'STATUS_BY' => ['required' => 'Y'],
160 'COMMENTARY' => ['required' => 'N'],
161 'RESPONSIBLE_ID' => ['required' => 'Y'],
162 ];
163 }
164
165 protected static function getDocumentSpecificFields(): array
166 {
167 return [];
168 }
169
170 public static function getElementFields(): array
171 {
172 return [];
173 }
174
185 public static function conductDocument($documentId, $userId, $currency, $contractorId)
186 {
187 $documentId = (int)$documentId;
188 $userId = (int)$userId;
189 if ($currency !== null)
190 {
191 $currency = (string)$currency;
192 }
193 $contractorId = (int)$contractorId;
194 if (!static::checkParamsForConduction($documentId, $userId, $currency, $contractorId))
195 {
196 return false;
197 }
198
199 $document = static::load($documentId, ['CURRENCY' => $currency]);
200 if ($document === null || !static::checkConductDocument($document))
201 {
202 return false;
203 }
204
205 $actions = static::getDocumentActions(self::ACTION_CONDUCTION, $document, $userId);
206 if (empty($actions) || !static::checkDocumentActions($actions))
207 {
208 return false;
209 }
210
211 return static::executeActions($actions);
212 }
213
222 public static function cancellationDocument($documentId, $userId)
223 {
224 $documentId = (int)$documentId;
225 $userId = (int)$userId;
226
227 if (!static::checkParamsForCancellation($documentId, $userId))
228 {
229 return false;
230 }
231
232 $document = static::load($documentId);
233 if ($document === null || !static::checkCancellationDocument($document))
234 {
235 return false;
236 }
237
238 $actions = static::getDocumentActions(self::ACTION_CANCEL, $document, $userId);
239 if (empty($actions) || !static::checkDocumentActions($actions))
240 {
241 return false;
242 }
243
244 return static::executeActions($actions);
245 }
246
247 protected static function checkConductDocument(array $document): bool
248 {
249 return true;
250 }
251
252 protected static function checkCancellationDocument(array $document): bool
253 {
254 return true;
255 }
256
257 protected static function setErrors(array $errors): void
258 {
259 global $APPLICATION;
260
261 if (!empty($errors))
262 {
263 $APPLICATION->ThrowException(implode('; ', $errors));
264 }
265 }
266
267 abstract public static function getTypeId(): string;
268
269 protected static function load(int $documentId, array $options = []): ?array
270 {
271 $result = static::loadDocument($documentId, $options);
272 if ($result === null)
273 {
274 return null;
275 }
276
277 $result = static::loadProducts($result);
278 if (!static::checkDocumentProducts($result))
279 {
280 return null;
281 }
282
283 $result = static::loadProductStores($result);
284
285 $result = static::loadDocumentBarcodes($result);
286 if (!static::checkDocumentBarcodes($result))
287 {
288 return null;
289 }
290
291 $result = static::loadBarcodes($result);
292 if (!static::checkBarcodes($result))
293 {
294 return null;
295 }
296
297 return $result;
298 }
299
300 protected static function loadDocument(int $documentId, array $options = []): ?array
301 {
302 $select = [
303 'ID',
304 'DOC_TYPE',
305 'SITE_ID',
306 'CONTRACTOR_ID',
307 'CURRENCY',
308 'STATUS',
309 'TOTAL',
310 ];
312 'select' => $select,
313 'filter' => [
314 '=ID' => $documentId,
315 '=DOC_TYPE' => static::getTypeId(),
316 ],
317 ]);
318 $result = $iterator->Fetch();
319 unset($iterator);
320 if (empty($result))
321 {
323 'select' => $select,
324 'filter' => ['=ID' => $documentId],
325 ]);
326 $result = $iterator->Fetch();
327 unset($iterator);
328 if (empty($result))
329 {
330 static::setErrors([
332 'CATALOG_STORE_DOCS_ERR_BAD_DOCUMENT_ID',
333 ['#ID#' => $documentId]
334 )
335 ]);
336 }
337 else
338 {
339 static::setErrors([
341 'CATALOG_STORE_DOCS_ERR_BAD_DOCUMENT_TYPE_ID',
342 ['#ID#' => $documentId]
343 )
344 ]);
345 }
346 return null;
347 }
348 $result['ID'] = (int)$result['ID'];
349 $currency = $result['CURRENCY'] ?? '';
350 if ($currency === '')
351 {
352 $currency = $options['CURRENCY'] ?? '';
353 }
354
355 $result['ELEMENTS'] = [];
356 $productList = &$result['ELEMENTS'];
357 $found = false;
358
360 'select' => [
361 'ID',
362 'DOC_ID',
363 'STORE_FROM',
364 'STORE_TO',
365 'ELEMENT_ID',
366 'AMOUNT',
367 'PURCHASING_PRICE',
368 'BASE_PRICE',
369 ],
370 'filter' => ['=DOC_ID' => $documentId],
371 ]);
372 while ($row = $iterator->fetch())
373 {
374 $found = true;
375 $row['ID'] = (int)$row['ID'];
376 $row['ELEMENT_ID'] = (int)$row['ELEMENT_ID'];
377 $row['AMOUNT'] = (float)$row['AMOUNT'];
378 if ($row['STORE_TO'] !== null)
379 {
380 $row['STORE_TO'] = (int)$row['STORE_TO'];
381 if ($row['STORE_TO'] <= 0)
382 {
383 $row['STORE_TO'] = null;
384 }
385 }
386 if ($row['STORE_FROM'] !== null)
387 {
388 $row['STORE_FROM'] = (int)$row['STORE_FROM'];
389 if ($row['STORE_FROM'] <= 0)
390 {
391 $row['STORE_FROM'] = null;
392 }
393 }
394
395 $elementId = $row['ELEMENT_ID'];
396 $rowId = $row['ID'];
397
398 if (!isset($productList[$elementId]))
399 {
400 $productList[$elementId] = [
401 'PRODUCT_ID' => $elementId,
402 'POSITIONS' => [],
403 'BARCODES' => [],
404 'CURRENT_STORES' => [],
405 'CURRENT_BARCODES' => [],
406 ];
407 }
408
409 $documentRow = [
410 'ROW_ID' => $rowId,
411 'PRODUCT_ID' => $elementId,
412 'STORE_TO' => $row['STORE_TO'],
413 'STORE_FROM' => $row['STORE_FROM'],
414 'AMOUNT' => $row['AMOUNT'],
415 'PURCHASING_PRICE' => $row['PURCHASING_PRICE'],
416 'PURCHASING_CURRENCY' => $currency,
417 'PURCHASING_INFO' => [ // deprecated
418 'PURCHASING_PRICE' => $row['PURCHASING_PRICE'],
419 'PURCHASING_CURRENCY' => $currency,
420 ],
421 ];
422
423 if (isset($row['BASE_PRICE']))
424 {
425 $documentRow['BASE_PRICE_INFO'] = [
426 'BASE_PRICE' => (float)$row['BASE_PRICE'],
427 'BASE_PRICE_CURRENCY' => $currency,
428 ];
429 }
430
431 $productList[$elementId]['POSITIONS'][$rowId] = $documentRow;
432 }
433 unset($row, $iterator);
434
435 unset($productList);
436
437 if (!$found)
438 {
439 static::setErrors([
441 'CATALOG_STORE_DOCS_ERR_ABSENT_DOCUMENT_ELEMENTS',
442 ['#ID#' => $documentId]
443 )
444 ]);
445 return null;
446 }
447
448 return $result;
449 }
450
451 protected static function loadProducts(array $document): array
452 {
453 $productList = &$document['ELEMENTS'];
454 $elements = array_keys($productList);
455 sort($elements);
456 foreach (array_chunk($elements, 500) as $pageIds)
457 {
459 'select' => [
460 'ID',
461 'TYPE',
462 'QUANTITY',
463 'QUANTITY_RESERVED',
464 'QUANTITY_TRACE',
465 'CAN_BUY_ZERO',
466 'SUBSCRIBE',
467 'BARCODE_MULTI',
468 ],
469 'filter' => ['@ID' => $pageIds]
470 ]);
471 while ($row = $iterator->Fetch())
472 {
473 $id = (int)$row['ID'];
474 $productList[$id]['TYPE'] = (int)$row['TYPE'];
475 $productList[$id]['OLD_QUANTITY'] = (float)$row['QUANTITY'];
476 $productList[$id]['QUANTITY_TRACE'] = $row['QUANTITY_TRACE'];
477 $productList[$id]['CAN_BUY_ZERO'] = $row['CAN_BUY_ZERO'];
478 $productList[$id]['SUBSCRIBE'] = $row['SUBSCRIBE'];
479 $productList[$id]['BARCODE_MULTI'] = $row['BARCODE_MULTI'];
480
481 $productList[$id]['QUANTITY'] = (float)$row['QUANTITY'];
482 $productList[$id]['QUANTITY_RESERVED'] = (float)$row['QUANTITY_RESERVED'];
483
484 $productList[$id]['QUANTITY_LIMIT'] = ($row['QUANTITY_TRACE'] === 'Y' && $row['CAN_BUY_ZERO'] === 'N');
485 }
486 unset($row, $iterator);
487
489 'select' => [
490 'ID',
491 'IBLOCK_ID',
492 'NAME',
493 ],
494 'filter' => ['@ID' => $pageIds],
495 ]);
496 while ($row = $iterator->fetch())
497 {
498 $id = (int)$row['ID'];
499 $productList[$id]['IBLOCK_ID'] = (int)$row['IBLOCK_ID'];
500 $productList[$id]['ELEMENT_NAME'] = $row['NAME'];
501 }
502 unset($row, $iterator);
503 }
504 unset($pageIds, $elements);
505
506 unset($productList);
507
508 return $document;
509 }
510
511 protected static function checkDocumentProducts(array $document): bool
512 {
513 $errors = [];
514
515 foreach ($document['ELEMENTS'] as $productId => $data)
516 {
517 if (!isset($data['IBLOCK_ID']))
518 {
520 'CATALOG_STORE_DOCS_ERR_BAD_ELEMENT_ID',
521 ['#ID#' => $productId]
522 );
523 continue;
524 }
525 $description = [
526 '#ID#' => $productId,
527 '#NAME#' => $data['ELEMENT_NAME'],
528 ];
529 if (!isset($data['TYPE']))
530 {
532 'CATALOG_STORE_DOCS_ERR_BAD_PRODUCT_ID',
534 );
535 continue;
536 }
537 if (
540 )
541 {
543 'CATALOG_STORE_DOCS_ERR_BAD_PRODUCT_TYPE',
545 );
546 continue;
547 }
548 foreach ($data['POSITIONS'] as $row)
549 {
550 if ($row['AMOUNT'] <= 0)
551 {
553 'CATALOG_STORE_DOCS_ERR_BAD_POSITION_AMOUNT',
555 );
556 }
557 }
558 }
559
560 if (!empty($errors))
561 {
562 static::setErrors($errors);
563 return false;
564 }
565
566 return true;
567 }
568
569 protected static function loadProductStores(array $document): array
570 {
571 $stores = static::getStoreList();
572 $activeStores = array_keys($stores[self::ACTIVE_STORES]);
573 if (empty($activeStores))
574 {
575 return $document;
576 }
577
578 $productList = &$document['ELEMENTS'];
579 $elements = array_keys($productList);
580 sort($elements);
581 foreach (array_chunk($elements, 500) as $pageIds)
582 {
584 'select' => [
585 'ID',
586 'PRODUCT_ID',
587 'STORE_ID',
588 'AMOUNT',
589 'QUANTITY_RESERVED',
590 ],
591 'filter' => [
592 '@PRODUCT_ID' => $pageIds,
593 '@STORE_ID' => $activeStores,
594 ],
595 ]);
596 while ($row = $iterator->fetch())
597 {
598 $row['ID'] = (int)$row['ID'];
599 $row['PRODUCT_ID'] = (int)$row['PRODUCT_ID'];
600 $row['STORE_ID'] = (int)$row['STORE_ID'];
601 $row['AMOUNT'] = (float)$row['AMOUNT'];
602 $row['QUANTITY_RESERVED'] = (float)$row['QUANTITY_RESERVED'];
603
604 $productId = $row['PRODUCT_ID'];
605 $storeId = $row['STORE_ID'];
606
607 $productList[$productId]['CURRENT_STORES'][$storeId] = $row;
608 }
609 unset($row, $iterator);
610 }
611 unset($pageIds, $elements);
612
613 unset($productList);
614
615 return $document;
616 }
617
618 protected static function loadDocumentBarcodes(array $document): array
619 {
620 $productList = &$document['ELEMENTS'];
621
622 $elements = [];
623 foreach (array_keys($productList) as $elementId)
624 {
625 foreach (array_keys($productList[$elementId]['POSITIONS']) as $rowId)
626 {
627 $elements[$rowId] = $elementId;
628 }
629 }
630
632 'select' => ['*'],
633 'filter' => [
634 '=DOC_ID' => $document['ID'],
635 ],
636 ]);
637 while ($row = $iterator->fetch())
638 {
639 $row['ID'] = (int)$row['ID'];
640 $rowId = $row['ID'];
641 $row['DOC_ELEMENT_ID'] = (int)$row['DOC_ELEMENT_ID'];
642 $documentRowId = $row['DOC_ELEMENT_ID'];
643 $elementId = $elements[$documentRowId];
644
645 $position = $productList[$elementId]['POSITIONS'][$documentRowId];
646
647 $productList[$elementId]['BARCODES'][$row['BARCODE']] = [
648 'ROW_ID' => $rowId,
649 'DOCUMENT_ROW_ID' => $documentRowId,
650 'PRODUCT_ID' => $elementId,
651 'BARCODE' => $row['BARCODE'],
652 'STORE_FROM' => $position['STORE_FROM'],
653 'STORE_TO' => $position['STORE_TO'],
654 ];
655 }
656 unset($row, $iterator);
657 unset($productList);
658
659 return $document;
660 }
661
662 protected static function checkDocumentBarcodes(array $document): bool
663 {
664 $errors = [];
665
666 foreach ($document['ELEMENTS'] as $data)
667 {
668 if ($data['BARCODE_MULTI'] !== 'Y')
669 {
670 continue;
671 }
672 $description = [
673 '#ID#' => $data['PRODUCT_ID'],
674 '#NAME#' => $data['ELEMENT_NAME'],
675 ];
676 if (static::getProductCount($data['POSITIONS']) !== count($data['BARCODES']))
677 {
679 'CATALOG_STORE_DOCS_ERR_BAD_BARCODE_COUNT',
681 );
682 continue;
683 }
684 foreach (array_keys($data['POSITIONS']) as $rowId)
685 {
686 if ($data['POSITIONS'][$rowId]['AMOUNT'] != static::getRowBarcodeCount($rowId, $data['BARCODES']))
687 {
689 'CATALOG_STORE_DOCS_ERR_WRONG_POSITION_BARCODES_COUNT',
691 );
692 }
693 }
694 unset($rowId);
695 }
696 unset($data);
697
698 if (!empty($errors))
699 {
700 static::setErrors($errors);
701 return false;
702 }
703
704 return true;
705 }
706
707 protected static function getDocumentBarcodes(array $document): array
708 {
709 $result = [];
710
711 foreach ($document['ELEMENTS'] as $product)
712 {
713 foreach (array_keys($product['BARCODES']) as $barcode)
714 {
715 $result[$barcode] = $product['PRODUCT_ID'];
716 }
717 unset($barcode);
718 }
719 unset($product);
720
721 return $result;
722 }
723
724 protected static function loadBarcodes(array $document): array
725 {
726 $list = static::getDocumentBarcodes($document);
727 if (empty($list))
728 {
729 return $document;
730 }
731
732 $productList = &$document['ELEMENTS'];
733
734 foreach ($list as $barcode => $productId)
735 {
736 $productList[$productId]['CURRENT_BARCODES'][$barcode] = [
737 'ID' => null,
738 'PRODUCT_ID' => $productId,
739 'BARCODE' => $barcode,
740 'STORE_ID' => null,
741 'ORDER_ID' => null,
742 ];
743 }
744 unset($barcode, $productId);
745
747 'select' => [
748 'ID',
749 'PRODUCT_ID',
750 'BARCODE',
751 'STORE_ID',
752 'ORDER_ID',
753 ],
754 'filter' => [
755 '@BARCODE' => array_keys($list),
756 ],
757 ]);
758 while ($row = $iterator->fetch())
759 {
760 $productId = $list[$row['BARCODE']];
761 $row['ID'] = (int)$row['ID'];
762 $row['PRODUCT_ID'] = (int)$row['PRODUCT_ID'];
763 $row['STORE_ID'] = (int)$row['STORE_ID'];
764 if ($row['STORE_ID'] <= 0)
765 {
766 $row['STORE_ID'] = null;
767 }
768 $row['ORDER_ID'] = (int)$row['ORDER_ID'];
769 if ($row['ORDER_ID'] <= 0)
770 {
771 $row['ORDER_ID'] = null;
772 }
773 $productList[$productId]['CURRENT_BARCODES'][$row['BARCODE']] = $row;
774 }
775 unset($productId, $row, $iterator);
776 unset($list);
777 unset($productList);
778
779 return $document;
780 }
781
782 protected static function checkBarcodes(array $document): bool
783 {
784 $errors = [];
785
786 foreach ($document['ELEMENTS'] as $data)
787 {
788 foreach ($data['CURRENT_BARCODES'] as $barcode)
789 {
790 if ($barcode['PRODUCT_ID'] !== $data['PRODUCT_ID'])
791 {
793 'CATALOG_STORE_DOCS_ERR_WRONG_BARCODES_PRODUCT_ID',
794 [
795 '#ID#' => $data['PRODUCT_ID'],
796 '#NAME#' => $data['ELEMENT_NAME'],
797 '#BARCODE#' => $barcode['BARCODE'],
798 '#OTHER_ID#' => $barcode['PRODUCT_ID']
799 ]
800 );
801 }
802 }
803 }
804
805 if (!empty($errors))
806 {
807 static::setErrors($errors);
808 return false;
809 }
810
811 return true;
812 }
813
814 protected static function getProductCount(array $positions): ?int
815 {
816 $amount = 0;
817 foreach ($positions as $row)
818 {
819 $amount += $row['AMOUNT'];
820 }
821
822 return ($amount > (int)$amount ? null : (int)$amount);
823 }
824
825 protected static function getRowBarcodeCount(int $rowId, array $barcodes): int
826 {
827 $count = 0;
828 foreach ($barcodes as $row)
829 {
830 if ($row['DOCUMENT_ROW_ID'] === $rowId)
831 {
832 $count++;
833 }
834 }
835 unset($row);
836
837 return $count;
838 }
839
840 protected static function getStoreList(): array
841 {
842 $result = [
843 self::ALL_STORES => [],
844 self::DISABLED_STORES => [],
845 self::ACTIVE_STORES => [],
846 ];
847 $iterator = Catalog\StoreTable::getList([
848 'select' => [
849 'ID',
850 'ACTIVE'
851 ],
852 'order' => [
853 'ID' => 'ASC',
854 ],
855 'cache' => [
856 'ttl' => 86400,
857 ],
858 ]);
859 while ($row = $iterator->fetch())
860 {
861 $id = (int)$row['ID'];
862 $result[self::ALL_STORES][$id] = true;
863 if ($row['ACTIVE'] !== 'Y')
864 {
865 $result[self::DISABLED_STORES][$id] = true;
866 }
867 else
868 {
869 $result[self::ACTIVE_STORES][$id] = true;
870 }
871 }
872 unset($row, $iterator);
873
874 return $result;
875 }
876
877 protected static function checkDocumentStores(array $document, array $options): bool
878 {
879 $errorList = [
880 self::ERR_STORE_ABSENT => [],
881 self::ERR_STORE_UNKNOWN => [],
882 self::ERR_STORE_DISABLED => [],
883 ];
884
885 $storeList = static::getStoreList();
886
887 $storeField = $options['STORE_FIELD'];
888
889 foreach ($document['ELEMENTS'] as $product)
890 {
891 $id = $product['PRODUCT_ID'];
892 $name = $product['ELEMENT_NAME'];
893 foreach ($product['POSITIONS'] as $position)
894 {
895 if (!isset($position[$storeField]))
896 {
897 $errorList[self::ERR_STORE_ABSENT][$id] = $name;
898 break;
899 }
900 $storeId = $position[$storeField];
901 if (!isset($storeList[self::ALL_STORES][$storeId]))
902 {
903 $errorList[self::ERR_STORE_UNKNOWN][$id] = $name;
904 break;
905 }
906 if (isset($storeList[self::DISABLED_STORES][$storeId]))
907 {
908 $errorList[self::ERR_STORE_DISABLED][$id] = $name;
909 break;
910 }
911 }
912 unset($position, $name, $id);
913 }
914 unset($product);
915
916 if (
917 !empty($errorList[self::ERR_STORE_ABSENT])
918 || !empty($errorList[self::ERR_STORE_UNKNOWN])
919 || !empty($errorList[self::ERR_STORE_DISABLED])
920 )
921 {
922 $list = [];
923 if (!empty($errorList[self::ERR_STORE_ABSENT]))
924 {
925 $list[] = static::getProductListError(
926 $options['ERR_ABSENT'],
927 $errorList[self::ERR_STORE_ABSENT]
928 );
929 }
930 if (!empty($errorList[self::ERR_STORE_UNKNOWN]))
931 {
932 $list[] = static::getProductListError(
933 $options['ERR_UNKNOWN'],
934 $errorList[self::ERR_STORE_UNKNOWN]
935 );
936 }
937 if (!empty($errorList[self::ERR_STORE_DISABLED]))
938 {
939 $list[] = static::getProductListError(
940 $options['ERR_DISABLED'],
941 $errorList[self::ERR_STORE_DISABLED]
942 );
943 }
944
945 static::setErrors($list);
946 unset($list);
947
948 return false;
949 }
950
951 return true;
952 }
953
954 protected static function getProductListError(array $errors, array $products): string
955 {
956 $list = [];
957 foreach ($products as $id => $name)
958 {
959 $list[] = Loc::getMessage(
960 'CATALOG_STORE_DOCS_TPL_PDODUCT',
961 [
962 '#ID#' => $id,
963 '#NAME#' => $name,
964 ]
965 );
966 }
967
968 $errorCode = (count($list) > 1 && isset($errors[1]) ? $errors[1] : $errors[0]);
969
970 return Loc::getMessage(
971 $errorCode,
972 ['#PRODUCTS#' => implode(', ', $list)]
973 );
974 }
975
976 protected static function getStoreDestinationErrors(): array
977 {
978 return [
979 'ERR_ABSENT' => [],
980 'ERR_UNKNOWN' => [],
981 'ERR_DISABLED' => [],
982 ];
983 }
984
985 protected static function getStoreSourceErrors(): array
986 {
987 return [
988 'ERR_ABSENT' => [],
989 'ERR_UNKNOWN' => [],
990 'ERR_DISABLED' => [],
991 ];
992 }
993
994 protected static function checkStoreDestination(array $document): bool
995 {
996 return static::checkDocumentStores(
997 $document,
998 ['STORE_FIELD' => 'STORE_TO'] + static::getStoreDestinationErrors()
999 );
1000 }
1001
1002 protected static function checkStoreSource(array $document): bool
1003 {
1004 return static::checkDocumentStores(
1005 $document,
1006 ['STORE_FIELD' => 'STORE_FROM'] + static::getStoreSourceErrors()
1007 );
1008 }
1009
1016 protected static function getDocumentActions(string $action, array $document, int $userId): ?array
1017 {
1018 if (
1019 $action !== self::ACTION_CONDUCTION
1020 && $action !== self::ACTION_CANCEL
1021 )
1022 {
1023 static::setErrors([
1024 Loc::getMessage('CATALOG_STORE_DOCS_ERR_BAD_ACTION')
1025 ]);
1026
1027 return null;
1028 }
1029
1030 return [];
1031 }
1032
1040 protected static function checkDocumentActions(array $actions): bool
1041 {
1042 foreach ($actions as $action)
1043 {
1044 $result = $action->canExecute();
1045 if (!$result->isSuccess())
1046 {
1047 static::setErrors(
1048 $result->getErrorMessages()
1049 );
1050 return false;
1051 }
1052 }
1053
1054 return true;
1055 }
1056
1064 protected static function executeActions(array $actions): bool
1065 {
1066 foreach ($actions as $action)
1067 {
1068 $result = $action->execute();
1069 if (!$result->isSuccess())
1070 {
1071 static::setErrors(
1072 $result->getErrorMessages()
1073 );
1074 return false;
1075 }
1076 }
1077
1078 return true;
1079 }
1080
1091 protected static function distributeElementsToStores($arFields, $userId): bool
1092 {
1093 trigger_error("Wrong API usage of use inventory documents", E_USER_WARNING);
1094
1095 return false;
1096 }
1097
1098 private static function isExistPriceRanges(int $productId, int $basePriceId): bool
1099 {
1100 return Catalog\PriceTable::getCount([
1101 '=PRODUCT_ID' => $productId,
1102 '=CATALOG_GROUP_ID' => $basePriceId,
1103 [
1104 'LOGIC' => 'OR',
1105 '!=QUANTITY_FROM' => null,
1106 '!=QUANTITY_TO' => null,
1107 ],
1108 ]) > 0;
1109 }
1110
1116 protected static function applyBarCode($arFields, $userId)
1117 {
1118 global $APPLICATION;
1119
1120 $barCode = $arFields["BARCODE"];
1121 $elementId = $arFields["PRODUCT_ID"];
1122 $storeToId = (isset($arFields["STORE_ID"])) ? $arFields["STORE_ID"] : 0;
1123 $storeFromId = (isset($arFields["STORE_FROM"])) ? $arFields["STORE_FROM"] : 0;
1124 $newStore = 0;
1125 $userId = (int)$userId;
1126 $result = false;
1127 $rsProps = CCatalogStoreBarCode::GetList(array(), array("BARCODE" => $barCode), false, false, array('ID', 'STORE_ID', 'PRODUCT_ID'));
1128 if($arBarCode = $rsProps->Fetch())
1129 {
1130 if($storeFromId > 0) // deduct or moving
1131 {
1132 if($storeToId > 0) // moving
1133 {
1134 if($arBarCode["STORE_ID"] == $storeFromId && $arBarCode["PRODUCT_ID"] == $elementId)
1135 $newStore = $storeToId;
1136 else
1137 {
1138 $storeName = CCatalogStoreControlUtil::getStoreName($storeFromId);
1139 $APPLICATION->ThrowException(Loc::getMessage("CATALOG_STORE_DOCS_ERR_WRONG_STORE_BARCODE", array("#STORE#" => '"'.$storeName.'"', "#PRODUCT#" => '"'.$arFields["ELEMENT_NAME"].'"', "#BARCODE#" => '"'.$barCode.'"')));
1140 return false;
1141 }
1142 }
1143 }
1144 else
1145 {
1146 $APPLICATION->ThrowException(Loc::getMessage("CATALOG_STORE_DOCS_ERR_BARCODE_ALREADY_EXIST", array("#PRODUCT#" => '"'.$arFields["ELEMENT_NAME"].'"', "#BARCODE#" => '"'.$barCode.'"')));
1147 return false;
1148 }
1149 if($newStore > 0)
1150 $result = CCatalogStoreBarCode::update($arBarCode["ID"], array("STORE_ID" => $storeToId, "MODIFIED_BY" => $userId));
1151 else
1152 $result = CCatalogStoreBarCode::delete($arBarCode["ID"]);
1153 }
1154 else
1155 {
1156 if($storeFromId > 0)
1157 {
1158 $storeName = CCatalogStoreControlUtil::getStoreName($storeFromId);
1159 $APPLICATION->ThrowException(Loc::getMessage("CATALOG_STORE_DOCS_ERR_WRONG_STORE_BARCODE", array("#STORE#" => '"'.$storeName.'"', "#PRODUCT#" => '"'.$arFields["ELEMENT_NAME"].'"', "#BARCODE#" => '"'.$barCode.'"')));
1160 return false;
1161 }
1162 elseif($storeToId > 0)
1163 $result = CCatalogStoreBarCode::Add(array("PRODUCT_ID" => $elementId, "STORE_ID" => $storeToId, "BARCODE" => $barCode, "MODIFIED_BY" => $userId, "CREATED_BY" => $userId));
1164 }
1165
1166 return $result;
1167 }
1168
1172 protected static function checkTotalAmount($elementId, $name = ''): array
1173 {
1174 return [];
1175 }
1176
1181 protected static function checkAmountField($arDocElement, $name = '')
1182 {
1183 global $APPLICATION;
1184 $name = (string)$name;
1185 if(doubleval($arDocElement["AMOUNT"]) <= 0)
1186 {
1187 if ($name == '')
1188 {
1189 $dbProduct = CIBlockElement::GetList(
1190 array(),
1191 array("ID" => $arDocElement["ELEMENT_ID"]),
1192 false,
1193 false,
1194 array('ID', 'NAME')
1195 );
1196 if ($arProduct = $dbProduct->Fetch())
1197 {
1198 $name = $arProduct['NAME'];
1199 }
1200 }
1201 if ($name == '')
1202 $name = $arDocElement["ELEMENT_ID"];
1203 $APPLICATION->ThrowException(Loc::getMessage("CATALOG_STORE_DOCS_ERR_WRONG_AMOUNT", array("#PRODUCT#" => '"'.$name.'"')));
1204 return false;
1205 }
1206 return true;
1207 }
1208
1209 protected static function checkParamsForConduction(int $documentId, int $userId, ?string $currency, int $contractorId): bool
1210 {
1211 if ($documentId <= 0)
1212 {
1213 static::setErrors([
1214 Loc::getMessage('CATALOG_STORE_DOCS_ERR_WRONG_DOCUMENT_ID')
1215 ]);
1216 return false;
1217 }
1218
1219 return true;
1220 }
1221
1222 protected static function checkParamsForCancellation(int $documentId, int $userId): bool
1223 {
1224 if ($documentId <= 0)
1225 {
1226 static::setErrors([
1227 Loc::getMessage('CATALOG_STORE_DOCS_ERR_WRONG_DOCUMENT_ID')
1228 ]);
1229 return false;
1230 }
1231
1232 return true;
1233 }
1234}
1235
1237{
1241 public static function getDocumentSpecificFields(): array
1242 {
1243 return [
1244 'DOC_NUMBER' => ['required' => 'N'],
1245 'DATE_DOCUMENT' => ['required' => 'N'],
1246 'ITEMS_ORDER_DATE' => ['required' => 'N'],
1247 'ITEMS_RECEIVED_DATE' => ['required' => 'N'],
1248 'DOCUMENT_FILES' => ['required' => 'N'],
1249 'CONTRACTOR_ID' => ['required' => 'Y'],
1250 'CURRENCY' => ['required' => 'Y'],
1251 'TOTAL' => ['required' => 'N'],
1252 ];
1253 }
1254
1258 public static function getElementFields(): array
1259 {
1260 return [
1261 'AMOUNT' => [
1262 'required' => 'Y',
1263 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_ARRIVAL_AMOUNT'),
1264 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_ARRIVAL_AMOUNT'),
1265 ],
1266 'NET_PRICE' => [
1267 'required' => 'Y',
1268 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_PURCHASING_PRICE'),
1269 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_PURCHASING_PRICE'),
1270 ],
1271 'BASE_PRICE' => [
1272 'required' => 'Y',
1273 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_PRICE'),
1274 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_PRICE'),
1275 ],
1276 'STORE_TO' => [
1277 'required' => 'Y',
1278 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_STORE_TO'),
1279 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_STORE_TO'),
1280 ],
1281 'BAR_CODE' => [
1282 'required' => 'Y',
1283 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_BARCODE'),
1284 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_BARCODE'),
1285 ],
1286 'TOTAL' => [
1287 'required' => 'Y',
1288 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_TOTAL'),
1289 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_TOTAL'),
1290 ],
1291 ];
1292 }
1293
1294 public static function getTypeId(): string
1295 {
1297 }
1298
1299 protected static function checkParamsForConduction(int $documentId, int $userId, ?string $currency, int $contractorId): bool
1300 {
1301 if (!parent::checkParamsForConduction($documentId, $userId, $currency, $contractorId))
1302 {
1303 return false;
1304 }
1305
1306 if (Manager::getActiveProvider(Manager::PROVIDER_STORE_DOCUMENT))
1307 {
1308 $contractor = Manager::getActiveProvider(Manager::PROVIDER_STORE_DOCUMENT)::getContractorByDocumentId($documentId);
1309 $isContractorSpecified = !is_null($contractor);
1310 }
1311 else
1312 {
1313 $isContractorSpecified = $contractorId > 0;
1314 }
1315
1316 if (!$isContractorSpecified)
1317 {
1318 static::setErrors([
1319 Loc::getMessage('CATALOG_STORE_DOCS_ERR_WRONG_CONTRACTOR')
1320 ]);
1321 return false;
1322 }
1323
1324 return true;
1325 }
1326
1330 protected static function getDocumentActions(string $action, array $document, int $userId): ?array
1331 {
1332 $actions = parent::getDocumentActions($action, $document, $userId);
1333 if ($actions === null)
1334 {
1335 return null;
1336 }
1337
1338 $isBatchMetodSelected = State::isProductBatchMethodSelected();
1339
1340 $elements = $document['ELEMENTS'] ?? [];
1341 foreach ($elements as $productId => $element)
1342 {
1343 $positions = (array)($element['POSITIONS'] ?? []);
1344 foreach ($positions as $item)
1345 {
1346 if ($action === self::ACTION_CONDUCTION)
1347 {
1348 $actions[] = new IncreaseStoreQuantityAction(
1349 $item['STORE_TO'],
1350 $item['PRODUCT_ID'],
1351 $item['AMOUNT'],
1352 );
1353
1354 if ($isBatchMetodSelected)
1355 {
1356 $actions[] = new UpsertStoreBatchAction(
1357 $item['STORE_TO'],
1358 $item['PRODUCT_ID'],
1359 $item['AMOUNT'],
1360 $item['ROW_ID'],
1361 $item['PURCHASING_PRICE'] ?? null,
1362 $item['PURCHASING_CURRENCY'] ?? null,
1363 );
1364 }
1365
1366 $actions[] = new UpdateProductPricesAction(
1367 $item['PRODUCT_ID'],
1368 $item['PURCHASING_PRICE'] ?? null,
1369 $item['PURCHASING_CURRENCY'] ?? null,
1370 $item['BASE_PRICE_INFO']['BASE_PRICE'] ?? null,
1371 $item['BASE_PRICE_INFO']['BASE_PRICE_CURRENCY'] ?? null,
1372 );
1373 }
1374 elseif ($action === self::ACTION_CANCEL)
1375 {
1376 if (State::isProductBatchMethodSelected())
1377 {
1378 $actions[] = new ReduceStoreBatchAmountAction($item['ROW_ID']);
1379 }
1380
1381 $actions[] = new DecreaseStoreQuantityAction(
1382 $item['STORE_TO'],
1383 $item['PRODUCT_ID'],
1384 $item['AMOUNT'],
1385 $document['DOC_TYPE'],
1386 );
1387 }
1388 }
1389
1390 $barcodes = (array)($element['BARCODES'] ?? []);
1391 foreach ($barcodes as $item)
1392 {
1393 $storeId = $item['STORE_TO'];
1394 if (!$storeId)
1395 {
1396 $rowId = $item['DOCUMENT_ROW_ID'];
1397 $storeId = $positions[$rowId]['STORE_TO'] ?? null;
1398 }
1399
1400 if ($element['BARCODE_MULTI'] === 'N')
1401 {
1402 $storeId = 0;
1403 }
1404
1405 if ($action === self::ACTION_CONDUCTION)
1406 {
1407 $actions[] = new AddStoreBarcodeAction(
1408 $storeId,
1409 $productId,
1410 $item['BARCODE'],
1411 $userId
1412 );
1413 }
1414 elseif ($action === self::ACTION_CANCEL)
1415 {
1416 if ($element['BARCODE_MULTI'] === 'Y')
1417 {
1418 $actions[] = new DeleteStoreBarcodeAction(
1419 $storeId,
1420 $productId,
1421 $item['BARCODE'],
1422 $userId
1423 );
1424 }
1425 }
1426 }
1427 }
1428
1429 return $actions;
1430 }
1431
1432 protected static function checkConductDocument(array $document): bool
1433 {
1434 if (!parent::checkConductDocument($document))
1435 {
1436 return false;
1437 }
1438
1439 if (!static::checkStoreDestination($document))
1440 {
1441 return false;
1442 }
1443
1444 return true;
1445 }
1446
1447 protected static function checkCancellationDocument(array $document): bool
1448 {
1449 if (!parent::checkCancellationDocument($document))
1450 {
1451 return false;
1452 }
1453
1454 if (!static::checkStoreDestination($document))
1455 {
1456 return false;
1457 }
1458
1459 return true;
1460 }
1461
1462 protected static function getStoreDestinationErrors(): array
1463 {
1464 return [
1465 'ERR_ABSENT' => [
1466 'CATALOG_STORE_DOCS_ERR_ARRIVAL_STORE_DESTINATION_IS_ABSENT_PRODUCT',
1467 'CATALOG_STORE_DOCS_ERR_ARRIVAL_STORE_DESTINATION_IS_ABSENT_PRODUCT_LIST_EXT',
1468 ],
1469 'ERR_UNKNOWN' => [
1470 'CATALOG_STORE_DOCS_ERR_ARRIVAL_STORE_DESTINATION_IS_UNKNOWN_PRODUCT',
1471 'CATALOG_STORE_DOCS_ERR_ARRIVAL_STORE_DESTINATION_IS_UNKNOWN_PRODUCT_LIST',
1472 ],
1473 'ERR_DISABLED' => [
1474 'CATALOG_STORE_DOCS_ERR_ARRIVAL_STORE_DESTINATION_IS_DISABLE_PRODUCT',
1475 'CATALOG_STORE_DOCS_ERR_ARRIVAL_STORE_DESTINATION_IS_DISABLE_PRODUCT_LIST',
1476 ],
1477 ];
1478 }
1479}
1480
1482{
1486 public static function getDocumentSpecificFields(): array
1487 {
1488 return [
1489 'CURRENCY' => ['required' => 'Y'],
1490 'TOTAL' => ['required' => 'N'],
1491 ];
1492 }
1493
1497 public static function getElementFields(): array
1498 {
1499 return [
1500 'AMOUNT' => [
1501 'required' => 'Y',
1502 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_ARRIVAL_AMOUNT'),
1503 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_ARRIVAL_AMOUNT'),
1504 ],
1505 'NET_PRICE' => [
1506 'required' => 'Y',
1507 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_PURCHASING_PRICE'),
1508 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_PURCHASING_PRICE'),
1509 ],
1510 'BASE_PRICE' => [
1511 'required' => 'Y',
1512 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_PRICE'),
1513 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_PRICE'),
1514 ],
1515 'STORE_TO' => [
1516 'required' => 'Y',
1517 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_STORE_TO'),
1518 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_STORE_TO'),
1519 ],
1520 'BAR_CODE' => [
1521 'required' => 'Y',
1522 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_BARCODE'),
1523 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_BARCODE'),
1524 ],
1525 'TOTAL' => [
1526 'required' => 'Y',
1527 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_TOTAL'),
1528 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_TOTAL'),
1529 ],
1530 ];
1531 }
1532
1533 public static function getTypeId(): string
1534 {
1536 }
1537
1538 protected static function checkParamsForConduction(int $documentId, int $userId, ?string $currency, int $contractorId): bool
1539 {
1540 if (!CCatalogDocsTypes::checkParamsForConduction($documentId, $userId, $currency, $contractorId))
1541 {
1542 return false;
1543 }
1544
1545 return true;
1546 }
1547
1548 protected static function getStoreDestinationErrors(): array
1549 {
1550 return [
1551 'ERR_ABSENT' => [
1552 'CATALOG_STORE_DOCS_ERR_ADJUSTMENT_STORE_DESTINATION_IS_ABSENT_PRODUCT',
1553 'CATALOG_STORE_DOCS_ERR_ADJUSTMENT_STORE_DESTINATION_IS_ABSENT_PRODUCT_LIST_EXT',
1554 ],
1555 'ERR_UNKNOWN' => [
1556 'CATALOG_STORE_DOCS_ERR_ADJUSTMENT_STORE_DESTINATION_IS_UNKNOWN_PRODUCT',
1557 'CATALOG_STORE_DOCS_ERR_ADJUSTMENT_STORE_DESTINATION_IS_UNKNOWN_PRODUCT_LIST',
1558 ],
1559 'ERR_DISABLED' => [
1560 'CATALOG_STORE_DOCS_ERR_ADJUSTMENT_STORE_DESTINATION_IS_DISABLE_PRODUCT',
1561 'CATALOG_STORE_DOCS_ERR_ADJUSTMENT_STORE_DESTINATION_IS_DISABLE_PRODUCT_LIST',
1562 ],
1563 ];
1564 }
1565}
1566
1568{
1569 public static function getDocumentSpecificFields(): array
1570 {
1571 return [
1572 'DOC_NUMBER' => ['required' => 'N'],
1573 'DATE_DOCUMENT' => ['required' => 'N'],
1574 ];
1575 }
1576
1580 public static function getElementFields(): array
1581 {
1582 return [
1583 'AMOUNT' => [
1584 'required' => 'Y',
1585 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_AMOUNT'),
1586 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_AMOUNT'),
1587 ],
1588 'STORE_TO' => [
1589 'required' => 'Y',
1590 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_MOVING_STORE_TO'),
1591 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_MOVING_STORE_TO'),
1592 ],
1593 'BAR_CODE' => [
1594 'required' => 'Y',
1595 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_BARCODE'),
1596 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_BARCODE'),
1597 ],
1598 'STORE_FROM' => [
1599 'required' => 'Y',
1600 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_MOVING_STORE_FROM'),
1601 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_MOVING_STORE_FROM'),
1602 ],
1603 ];
1604 }
1605
1606 public static function getTypeId(): string
1607 {
1609 }
1610
1614 protected static function getDocumentActions(string $action, array $document, int $userId): ?array
1615 {
1616 $actions = parent::getDocumentActions($action, $document, $userId);
1617 if ($actions === null)
1618 {
1619 return null;
1620 }
1621
1622 $elements = $document['ELEMENTS'] ?? [];
1623 foreach ($elements as $productId => $element)
1624 {
1625 $positions = (array)($element['POSITIONS'] ?? []);
1626 foreach ($positions as $item)
1627 {
1628 if ($action === self::ACTION_CONDUCTION)
1629 {
1630 if (State::isProductBatchMethodSelected())
1631 {
1632 $actions[] = new MoveStoreBatchAction(
1633 $item['STORE_FROM'],
1634 $item['STORE_TO'],
1635 $item['PRODUCT_ID'],
1636 $item['AMOUNT'],
1637 $item['ROW_ID']
1638 );
1639 }
1640
1641 $actions[] = new DecreaseStoreQuantityAction(
1642 $item['STORE_FROM'],
1643 $item['PRODUCT_ID'],
1644 $item['AMOUNT'],
1645 $document['DOC_TYPE']
1646 );
1647 $actions[] = new IncreaseStoreQuantityAction(
1648 $item['STORE_TO'],
1649 $item['PRODUCT_ID'],
1650 $item['AMOUNT']
1651 );
1652 }
1653 elseif ($action === self::ACTION_CANCEL)
1654 {
1655 if (State::isProductBatchMethodSelected())
1656 {
1657 $actions[] = new ReduceStoreBatchAmountAction($item['ROW_ID']);
1658 $actions[] = new ReturnStoreBatchAction($item['ROW_ID']);
1659 }
1660
1661 $actions[] = new IncreaseStoreQuantityAction(
1662 $item['STORE_FROM'],
1663 $item['PRODUCT_ID'],
1664 $item['AMOUNT']
1665 );
1666 $actions[] = new DecreaseStoreQuantityAction(
1667 $item['STORE_TO'],
1668 $item['PRODUCT_ID'],
1669 $item['AMOUNT'],
1670 $document['DOC_TYPE']
1671 );
1672 }
1673 }
1674
1675 $barcodes = (array)($element['BARCODES'] ?? []);
1676 foreach ($barcodes as $item)
1677 {
1678 if ($action === self::ACTION_CONDUCTION)
1679 {
1680 if ($element['BARCODE_MULTI'] === 'N')
1681 {
1682 $storeId = 0;
1683 }
1684 else
1685 {
1686 $storeId = $item['STORE_TO'];
1687 if (!$storeId)
1688 {
1689 $rowId = $item['DOCUMENT_ROW_ID'];
1690 $storeId = $positions[$rowId]['STORE_TO'] ?? null;
1691 }
1692 }
1693
1694 $actions[] = new AddStoreBarcodeAction(
1695 $storeId,
1696 $productId,
1697 $item['BARCODE'],
1698 $userId
1699 );
1700 }
1701 elseif ($action === self::ACTION_CANCEL)
1702 {
1703 if ($element['BARCODE_MULTI'] === 'N')
1704 {
1705 $storeId = 0;
1706 }
1707 else
1708 {
1709 $storeId = $item['STORE_FROM'];
1710 if (!$storeId)
1711 {
1712 $rowId = $item['DOCUMENT_ROW_ID'];
1713 $storeId = $positions[$rowId]['STORE_FROM'] ?? null;
1714 }
1715 }
1716
1717 $actions[] = new AddStoreBarcodeAction(
1718 $storeId,
1719 $productId,
1720 $item['BARCODE'],
1721 $userId
1722 );
1723 }
1724 }
1725 }
1726
1727 return $actions;
1728 }
1729
1730 protected static function checkConductDocument(array $document): bool
1731 {
1732 if (!parent::checkConductDocument($document))
1733 {
1734 return false;
1735 }
1736
1737 if (!static::checkStoreSource($document))
1738 {
1739 return false;
1740 }
1741
1742 if (!static::checkStoreDestination($document))
1743 {
1744 return false;
1745 }
1746
1747 // check dest and source stores
1748 $elements = (array)($document['ELEMENTS'] ?? []);
1749 foreach ($elements as $element)
1750 {
1751 $positions = (array)($element['POSITIONS'] ?? []);
1752 foreach ($positions as $position)
1753 {
1754 if ((int)$position['STORE_TO'] === (int)$position['STORE_FROM'])
1755 {
1757 Loc::getMessage('CATALOG_STORE_DOCS_ERR_STORE_FROM_EQUALS_STORE_TO')
1758 ]);
1759 return false;
1760 }
1761 }
1762 }
1763
1764 return true;
1765 }
1766
1767 protected static function checkCancellationDocument(array $document): bool
1768 {
1769 if (!parent::checkConductDocument($document))
1770 {
1771 return false;
1772 }
1773
1774 if (!static::checkStoreSource($document))
1775 {
1776 return false;
1777 }
1778
1779 if (!static::checkStoreDestination($document))
1780 {
1781 return false;
1782 }
1783
1784 return true;
1785 }
1786
1787 protected static function getStoreDestinationErrors(): array
1788 {
1789 return [
1790 'ERR_ABSENT' => [
1791 'CATALOG_STORE_DOCS_ERR_MOVING_STORE_DESTINATION_IS_ABSENT_PRODUCT',
1792 'CATALOG_STORE_DOCS_ERR_MOVING_STORE_DESTINATION_IS_ABSENT_PRODUCT_LIST_EXT',
1793 ],
1794 'ERR_UNKNOWN' => [
1795 'CATALOG_STORE_DOCS_ERR_MOVING_STORE_DESTINATION_IS_UNKNOWN_PRODUCT',
1796 'CATALOG_STORE_DOCS_ERR_MOVING_STORE_DESTINATION_IS_UNKNOWN_PRODUCT_LIST',
1797 ],
1798 'ERR_DISABLED' => [
1799 'CATALOG_STORE_DOCS_ERR_MOVING_STORE_DESTINATION_IS_DISABLE_PRODUCT',
1800 'CATALOG_STORE_DOCS_ERR_MOVING_STORE_DESTINATION_IS_DISABLE_PRODUCT_LIST',
1801 ],
1802 ];
1803 }
1804
1805 protected static function getStoreSourceErrors(): array
1806 {
1807 return [
1808 'ERR_ABSENT' => [
1809 'CATALOG_STORE_DOCS_ERR_MOVING_STORE_FROM_IS_ABSENT_PRODUCT',
1810 'CATALOG_STORE_DOCS_ERR_MOVING_STORE_FROM_IS_ABSENT_PRODUCT_LIST',
1811 ],
1812 'ERR_UNKNOWN' => [
1813 'CATALOG_STORE_DOCS_ERR_MOVING_STORE_FROM_IS_UNKNOWN_PRODUCT',
1814 'CATALOG_STORE_DOCS_ERR_MOVING_STORE_FROM_IS_UNKNOWN_PRODUCT_LIST',
1815 ],
1816 'ERR_DISABLED' => [
1817 'CATALOG_STORE_DOCS_ERR_MOVING_STORE_FROM_IS_DISABLE_PRODUCT',
1818 'CATALOG_STORE_DOCS_ERR_MOVING_STORE_FROM_IS_DISABLE_PRODUCT_LIST',
1819 ],
1820 ];
1821 }
1822}
1823
1825{
1829 public static function getElementFields(): array
1830 {
1831 return [
1832 'AMOUNT' => [
1833 'required' => 'Y',
1834 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_AMOUNT'),
1835 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_AMOUNT'),
1836 ],
1837 'STORE_TO' => [
1838 'required' => 'Y',
1839 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_STORE_TO'),
1840 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_STORE_TO'),
1841 ],
1842 'BAR_CODE' => [
1843 'required' => 'Y',
1844 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_BARCODE'),
1845 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_BARCODE'),
1846 ],
1847 ];
1848 }
1849
1850 public static function getTypeId(): string
1851 {
1853 }
1854
1858 protected static function getDocumentActions(string $action, array $document, int $userId): ?array
1859 {
1860 $actions = parent::getDocumentActions($action, $document, $userId);
1861 if ($actions === null)
1862 {
1863 return null;
1864 }
1865
1866 $elements = $document['ELEMENTS'] ?? [];
1867 foreach ($elements as $productId => $element)
1868 {
1869 $positions = (array)($element['POSITIONS'] ?? []);
1870 foreach ($positions as $item)
1871 {
1872 if ($action === self::ACTION_CONDUCTION)
1873 {
1874 $actions[] = new IncreaseStoreQuantityAction(
1875 $item['STORE_TO'],
1876 $item['PRODUCT_ID'],
1877 $item['AMOUNT']
1878 );
1879 if (State::isProductBatchMethodSelected())
1880 {
1881 $actions[] = new UpsertStoreBatchAction(
1882 $item['STORE_TO'],
1883 $item['PRODUCT_ID'],
1884 $item['AMOUNT'],
1885 $item['ROW_ID'],
1886 $item['PURCHASING_PRICE'],
1887 $item['PURCHASING_CURRENCY'],
1888 );
1889 }
1890 }
1891 elseif ($action === self::ACTION_CANCEL)
1892 {
1893 if (State::isProductBatchMethodSelected())
1894 {
1895 $actions[] = new ReduceStoreBatchAmountAction($item['ROW_ID']);
1896 }
1897
1898 $actions[] = new DecreaseStoreQuantityAction(
1899 $item['STORE_TO'],
1900 $item['PRODUCT_ID'],
1901 $item['AMOUNT'],
1902 $document['DOC_TYPE']
1903 );
1904 }
1905 }
1906
1907 $barcodes = (array)($element['BARCODES'] ?? []);
1908 foreach ($barcodes as $item)
1909 {
1910 $storeId = $item['STORE_TO'];
1911 if (!$storeId)
1912 {
1913 $rowId = $item['DOCUMENT_ROW_ID'];
1914 $storeId = $positions[$rowId]['STORE_TO'] ?? null;
1915 }
1916
1917 if ($element['BARCODE_MULTI'] === 'N')
1918 {
1919 $storeId = 0;
1920 }
1921
1922 if ($action === self::ACTION_CONDUCTION)
1923 {
1924 $actions[] = new AddStoreBarcodeAction(
1925 $storeId,
1926 $productId,
1927 $item['BARCODE'],
1928 $userId
1929 );
1930 }
1931 elseif ($action === self::ACTION_CANCEL)
1932 {
1933 $actions[] = new DeleteStoreBarcodeAction(
1934 $storeId,
1935 $productId,
1936 $item['BARCODE'],
1937 $userId
1938 );
1939 }
1940 }
1941 }
1942
1943 return $actions;
1944 }
1945
1946 protected static function checkConductDocument(array $document): bool
1947 {
1948 if (!parent::checkConductDocument($document))
1949 {
1950 return false;
1951 }
1952
1953 if (!static::checkStoreDestination($document))
1954 {
1955 return false;
1956 }
1957
1958 return true;
1959 }
1960
1961 protected static function checkCancellationDocument(array $document): bool
1962 {
1963 if (!parent::checkConductDocument($document))
1964 {
1965 return false;
1966 }
1967
1968 if (!static::checkStoreDestination($document))
1969 {
1970 return false;
1971 }
1972
1973 return true;
1974 }
1975
1976 protected static function getStoreDestinationErrors(): array
1977 {
1978 return [
1979 'ERR_ABSENT' => [
1980 'CATALOG_STORE_DOCS_ERR_RETURNS_STORE_DESTINATION_IS_ABSENT_PRODUCT',
1981 'CATALOG_STORE_DOCS_ERR_RETURNS_STORE_DESTINATION_IS_ABSENT_PRODUCT_LIST_EXT',
1982 ],
1983 'ERR_UNKNOWN' => [
1984 'CATALOG_STORE_DOCS_ERR_RETURNS_STORE_DESTINATION_IS_UNKNOWN_PRODUCT',
1985 'CATALOG_STORE_DOCS_ERR_RETURNS_STORE_DESTINATION_IS_UNKNOWN_PRODUCT_LIST',
1986 ],
1987 'ERR_DISABLED' => [
1988 'CATALOG_STORE_DOCS_ERR_RETURNS_STORE_DESTINATION_IS_DISABLE_PRODUCT',
1989 'CATALOG_STORE_DOCS_ERR_RETURNS_STORE_DESTINATION_IS_DISABLE_PRODUCT_LIST',
1990 ],
1991 ];
1992 }
1993}
1994
1996{
1997 public static function getDocumentSpecificFields(): array
1998 {
1999 return [
2000 'DOC_NUMBER' => ['required' => 'N'],
2001 'DATE_DOCUMENT' => ['required' => 'N'],
2002 ];
2003 }
2004
2008 public static function getElementFields(): array
2009 {
2010 return [
2011 'AMOUNT' => [
2012 'required' => 'Y',
2013 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_AMOUNT'),
2014 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_AMOUNT'),
2015 ],
2016 'BAR_CODE' => [
2017 'required' => 'Y',
2018 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_BARCODE'),
2019 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_BARCODE'),
2020 ],
2021 'STORE_FROM' => [
2022 'required' => 'Y',
2023 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_DEDUCT_STORE_FROM'),
2024 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_DEDUCT_STORE_FROM'),
2025 ],
2026 ];
2027 }
2028
2029 public static function getTypeId(): string
2030 {
2032 }
2033
2037 protected static function getDocumentActions(string $action, array $document, int $userId): ?array
2038 {
2039 $actions = parent::getDocumentActions($action, $document, $userId);
2040 if ($actions === null)
2041 {
2042 return null;
2043 }
2044
2045 $elements = $document['ELEMENTS'] ?? [];
2046 foreach ($elements as $productId => $element)
2047 {
2048 $positions = (array)($element['POSITIONS'] ?? []);
2049 foreach ($positions as $item)
2050 {
2051 if ($action === self::ACTION_CONDUCTION)
2052 {
2053 if (State::isProductBatchMethodSelected())
2054 {
2055 $actions[] = new WriteOffStoreBatchAction(
2056 $item['ROW_ID'],
2057 $item['PRODUCT_ID'],
2058 $item['AMOUNT']
2059 );
2060 }
2061 $actions[] = new DecreaseStoreQuantityAction(
2062 $item['STORE_FROM'],
2063 $item['PRODUCT_ID'],
2064 $item['AMOUNT'],
2065 $document['DOC_TYPE']
2066 );
2067 }
2068 elseif ($action === self::ACTION_CANCEL)
2069 {
2070 $actions[] = new IncreaseStoreQuantityAction(
2071 $item['STORE_FROM'],
2072 $item['PRODUCT_ID'],
2073 $item['AMOUNT']
2074 );
2075 if (State::isProductBatchMethodSelected())
2076 {
2077 $actions[] = new ReturnStoreBatchAction($item['ROW_ID']);
2078 }
2079 }
2080 }
2081
2082 $barcodes = (array)($element['BARCODES'] ?? []);
2083 foreach ($barcodes as $item)
2084 {
2085 $storeId = $item['STORE_TO'];
2086 if (!$storeId)
2087 {
2088 $rowId = $item['DOCUMENT_ROW_ID'];
2089 $storeId = $positions[$rowId]['STORE_TO'] ?? null;
2090 }
2091
2092 if ($element['BARCODE_MULTI'] === 'N')
2093 {
2094 $storeId = 0;
2095 }
2096
2097 if ($action === self::ACTION_CONDUCTION)
2098 {
2099 $actions[] = new DeleteStoreBarcodeAction(
2100 $storeId,
2101 $productId,
2102 $item['BARCODE'],
2103 $userId
2104 );
2105 }
2106 elseif ($action === self::ACTION_CANCEL)
2107 {
2108 $actions[] = new AddStoreBarcodeAction(
2109 $storeId,
2110 $productId,
2111 $item['BARCODE'],
2112 $userId
2113 );
2114 }
2115 }
2116 }
2117
2118 return $actions;
2119 }
2120
2121 protected static function checkConductDocument(array $document): bool
2122 {
2123 if (!parent::checkConductDocument($document))
2124 {
2125 return false;
2126 }
2127
2128 if (!static::checkStoreSource($document))
2129 {
2130 return false;
2131 }
2132
2133 return true;
2134 }
2135
2136 protected static function checkCancellationDocument(array $document): bool
2137 {
2138 if (!parent::checkConductDocument($document))
2139 {
2140 return false;
2141 }
2142
2143 if (!static::checkStoreSource($document))
2144 {
2145 return false;
2146 }
2147
2148 return true;
2149 }
2150
2151 protected static function getStoreSourceErrors(): array
2152 {
2153 return [
2154 'ERR_ABSENT' => [
2155 'CATALOG_STORE_DOCS_ERR_DEDUCT_STORE_SOURCE_IS_ABSENT_PRODUCT',
2156 'CATALOG_STORE_DOCS_ERR_DEDUCT_STORE_SOURCE_IS_ABSENT_PRODUCT_LIST_EXT',
2157 ],
2158 'ERR_UNKNOWN' => [
2159 'CATALOG_STORE_DOCS_ERR_DEDUCT_STORE_SOURCE_IS_UNKNOWN_PRODUCT',
2160 'CATALOG_STORE_DOCS_ERR_DEDUCT_STORE_SOURCE_IS_UNKNOWN_PRODUCT_LIST',
2161 ],
2162 'ERR_DISABLED' => [
2163 'CATALOG_STORE_DOCS_ERR_DEDUCT_STORE_SOURCE_IS_DISABLE_PRODUCT',
2164 'CATALOG_STORE_DOCS_ERR_DEDUCT_STORE_SOURCE_IS_DISABLE_PRODUCT_LIST',
2165 ],
2166 ];
2167 }
2168}
2169
2171{
2175 public static function getElementFields(): array
2176 {
2177 return [
2178 'AMOUNT' => [
2179 'required' => 'Y',
2180 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_AMOUNT'),
2181 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_AMOUNT'),
2182 ],
2183 'RESERVED' => [
2184 'required' => 'Y',
2185 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_RESERVED'),
2186 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_COMMON_RESERVED'),
2187 ],
2188 'STORE_FROM' => [
2189 'required' => 'Y',
2190 'name' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_UNRESERVED_STORE_FROM'),
2191 'title' => Loc::getMessage('CATALOG_STORE_DOCS_ELEMENT_FIELD_UNRESERVED_STORE_FROM'),
2192 ],
2193 ];
2194 }
2195
2196 public static function getTypeId(): string
2197 {
2199 }
2200
2204 protected static function getDocumentActions(string $action, array $document, int $userId): ?array
2205 {
2206 $actions = parent::getDocumentActions($action, $document, $userId);
2207 if ($actions === null)
2208 {
2209 return null;
2210 }
2211
2212 $elements = $document['ELEMENTS'] ?? [];
2213 foreach ($elements as $productId => $element)
2214 {
2215 $positions = (array)($element['POSITIONS'] ?? []);
2216 foreach ($positions as $item)
2217 {
2218 if ($action === self::ACTION_CONDUCTION)
2219 {
2220 $actions[] = new UnReserveStoreProductAction(
2221 $item['STORE_FROM'],
2222 $item['PRODUCT_ID'],
2223 $item['AMOUNT']
2224 );
2225 }
2226 elseif ($action === self::ACTION_CANCEL)
2227 {
2228 $actions[] = new ReserveStoreProductAction(
2229 $item['STORE_FROM'],
2230 $item['PRODUCT_ID'],
2231 $item['AMOUNT']
2232 );
2233 }
2234 }
2235 }
2236
2237 return $actions;
2238 }
2239}
$positions
Определения access_edit.php:237
$count
Определения admin_tab.php:4
global $APPLICATION
Определения include.php:80
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getList(array $parameters)
Определения entity.php:78
const TYPE_OFFER
Определения product.php:73
const TYPE_PRODUCT
Определения product.php:70
static getMessage($code, $replace=null, $language=null)
Определения loc.php:30
static getList(array $parameters=array())
Определения datamanager.php:431
static checkCancellationDocument(array $document)
Определения store_docs_type.php:1447
static checkConductDocument(array $document)
Определения store_docs_type.php:1432
static getDocumentActions(string $action, array $document, int $userId)
Определения store_docs_type.php:1330
static checkParamsForConduction(int $documentId, int $userId, ?string $currency, int $contractorId)
Определения store_docs_type.php:1299
static getElementFields()
Определения store_docs_type.php:1258
static getTypeId()
Определения store_docs_type.php:1294
static getDocumentSpecificFields()
Определения store_docs_type.php:1241
static getStoreDestinationErrors()
Определения store_docs_type.php:1462
static checkCancellationDocument(array $document)
Определения store_docs_type.php:2136
static getStoreSourceErrors()
Определения store_docs_type.php:2151
static checkConductDocument(array $document)
Определения store_docs_type.php:2121
static getDocumentActions(string $action, array $document, int $userId)
Определения store_docs_type.php:2037
static getElementFields()
Определения store_docs_type.php:2008
static getTypeId()
Определения store_docs_type.php:2029
static getDocumentSpecificFields()
Определения store_docs_type.php:1997
static checkCancellationDocument(array $document)
Определения store_docs_type.php:252
const ACTION_CANCEL
Определения store_docs_type.php:116
static executeActions(array $actions)
Определения store_docs_type.php:1064
static getStoreList()
Определения store_docs_type.php:840
static getStoreSourceErrors()
Определения store_docs_type.php:985
const TYPE_RETURN
Определения store_docs_type.php:108
static checkStoreSource(array $document)
Определения store_docs_type.php:1002
static getDocumentCommonFields()
Определения store_docs_type.php:145
static checkStoreDestination(array $document)
Определения store_docs_type.php:994
static checkTotalAmount($elementId, $name='')
Определения store_docs_type.php:1172
static loadDocument(int $documentId, array $options=[])
Определения store_docs_type.php:300
static getRowBarcodeCount(int $rowId, array $barcodes)
Определения store_docs_type.php:825
const TYPE_MOVING
Определения store_docs_type.php:106
const ERR_STORE_DISABLED
Определения store_docs_type.php:124
const TYPE_STORE_ADJUSTMENT
Определения store_docs_type.php:104
static checkConductDocument(array $document)
Определения store_docs_type.php:247
static getProductCount(array $positions)
Определения store_docs_type.php:814
static getDocumentActions(string $action, array $document, int $userId)
Определения store_docs_type.php:1016
static checkParamsForConduction(int $documentId, int $userId, ?string $currency, int $contractorId)
Определения store_docs_type.php:1209
static conductDocument($documentId, $userId, $currency, $contractorId)
Определения store_docs_type.php:185
static applyBarCode($arFields, $userId)
Определения store_docs_type.php:1116
const TYPE_ARRIVAL
Определения store_docs_type.php:102
static getElementFields()
Определения store_docs_type.php:170
const ACTIVE_STORES
Определения store_docs_type.php:120
static checkDocumentBarcodes(array $document)
Определения store_docs_type.php:662
static loadProductStores(array $document)
Определения store_docs_type.php:569
static loadDocumentBarcodes(array $document)
Определения store_docs_type.php:618
static getDocumentBarcodes(array $document)
Определения store_docs_type.php:707
static getTypeId()
const TYPE_DEDUCT
Определения store_docs_type.php:110
const ACTION_CONDUCTION
Определения store_docs_type.php:115
static checkDocumentProducts(array $document)
Определения store_docs_type.php:511
static getFields()
Определения store_docs_type.php:126
static getDocumentSpecificFields()
Определения store_docs_type.php:165
static loadBarcodes(array $document)
Определения store_docs_type.php:724
const DISABLED_STORES
Определения store_docs_type.php:119
static distributeElementsToStores($arFields, $userId)
Определения store_docs_type.php:1091
static checkBarcodes(array $document)
Определения store_docs_type.php:782
static load(int $documentId, array $options=[])
Определения store_docs_type.php:269
static setErrors(array $errors)
Определения store_docs_type.php:257
const ERR_STORE_ABSENT
Определения store_docs_type.php:122
const ALL_STORES
Определения store_docs_type.php:118
const TYPE_UNDO_RESERVE
Определения store_docs_type.php:112
static loadProducts(array $document)
Определения store_docs_type.php:451
static getStoreDestinationErrors()
Определения store_docs_type.php:976
static checkParamsForCancellation(int $documentId, int $userId)
Определения store_docs_type.php:1222
static cancellationDocument($documentId, $userId)
Определения store_docs_type.php:222
static checkAmountField($arDocElement, $name='')
Определения store_docs_type.php:1181
static checkDocumentStores(array $document, array $options)
Определения store_docs_type.php:877
static getDocumentFields()
Определения store_docs_type.php:137
static checkDocumentActions(array $actions)
Определения store_docs_type.php:1040
static getProductListError(array $errors, array $products)
Определения store_docs_type.php:954
const ERR_STORE_UNKNOWN
Определения store_docs_type.php:123
const TYPE_INVENTORY
Определения store_docs_type.php:113
static checkCancellationDocument(array $document)
Определения store_docs_type.php:1767
static getStoreSourceErrors()
Определения store_docs_type.php:1805
static checkConductDocument(array $document)
Определения store_docs_type.php:1730
static getDocumentActions(string $action, array $document, int $userId)
Определения store_docs_type.php:1614
static getElementFields()
Определения store_docs_type.php:1580
static getTypeId()
Определения store_docs_type.php:1606
static getDocumentSpecificFields()
Определения store_docs_type.php:1569
static getStoreDestinationErrors()
Определения store_docs_type.php:1787
static checkCancellationDocument(array $document)
Определения store_docs_type.php:1961
static checkConductDocument(array $document)
Определения store_docs_type.php:1946
static getDocumentActions(string $action, array $document, int $userId)
Определения store_docs_type.php:1858
static getElementFields()
Определения store_docs_type.php:1829
static getTypeId()
Определения store_docs_type.php:1850
static getStoreDestinationErrors()
Определения store_docs_type.php:1976
static checkParamsForConduction(int $documentId, int $userId, ?string $currency, int $contractorId)
Определения store_docs_type.php:1538
static getElementFields()
Определения store_docs_type.php:1497
static getTypeId()
Определения store_docs_type.php:1533
static getDocumentSpecificFields()
Определения store_docs_type.php:1486
static getStoreDestinationErrors()
Определения store_docs_type.php:1548
static getStoreName($storeId)
Определения store_utility.php:12
static getDocumentActions(string $action, array $document, int $userId)
Определения store_docs_type.php:2204
static getElementFields()
Определения store_docs_type.php:2175
static getTypeId()
Определения store_docs_type.php:2196
$options
Определения commerceml2.php:49
$arFields
Определения dblapprove.php:5
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
if(Loader::includeModule( 'bitrix24')) elseif(Loader::includeModule('intranet') &&CIntranetUtils::getPortalZone() !=='ru') $description
Определения .description.php:24
$errors
Определения iblock_catalog_edit.php:74
$select
Определения iblock_catalog_list.php:194
$name
Определения menu_edit.php:35
if(!function_exists("bx_hmac")) $amount
Определения payment.php:30
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$currency
Определения template.php:266
$action
Определения file_dialog.php:21
$rsProps
Определения yandex_run.php:584
$iterator
Определения yandex_run.php:610