1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
StoreDocumentProvider.php
См. документацию.
1<?php
2
3namespace Bitrix\Catalog\v2\Integration\UI\EntityEditor;
4
5use Bitrix\Catalog\Access\AccessController;
6use Bitrix\Catalog\Access\ActionDictionary;
7use Bitrix\Catalog\Document\DocumentFieldsManager;
8use Bitrix\Catalog\Document\StoreDocumentTableManager;
9use Bitrix\Catalog\Document\Type\StoreDocumentSpecificTable;
10use Bitrix\Catalog\StoreDocumentFileTable;
11use Bitrix\Catalog\StoreDocumentTable;
12use Bitrix\Catalog\v2\Contractor;
13use Bitrix\Catalog\v2\Integration\UI\EntityEditor\Product\StoreDocumentProductPositionRepository;
14use Bitrix\Currency\CurrencyManager;
15use Bitrix\Currency\CurrencyTable;
16use Bitrix\Main;
17use Bitrix\Main\Engine\CurrentUser;
18use Bitrix\Main\Localization\Loc;
19use Bitrix\Main\UserTable;
20use Bitrix\UI\EntityEditor\BaseProvider;
21use Bitrix\UI\EntityEditor\ProviderWithUserFieldsTrait;
22use CCurrencyLang;
23
25{
26 use ProviderWithUserFieldsTrait {
27 getUfComponentFields as getUfComponentFieldsParent;
28 }
29
31 protected const GUID_PREFIX = 'STORE_DOCUMENT_DETAIL_';
32 protected const ENTITY_TYPE_NAME = 'store_document';
33 protected const PATH_TO_USER_PROFILE = '/company/personal/user/#user_id#/';
34
35 protected $document;
36 protected $config;
37 protected $userFieldInfos = null;
38 protected $createUfUrl = '';
39 protected $requiredFieldNames = [];
40
43
44 protected static array $users = [];
45
46 protected function __construct(array $documentFields, array $config = [])
47 {
48 $this->document = $documentFields;
49 $this->config = $config;
50 $this->contractorsProvider = Contractor\Provider\Manager::getActiveProvider(
51 Contractor\Provider\Manager::PROVIDER_STORE_DOCUMENT
52 );
53 $this->requiredFieldNames = DocumentFieldsManager::getRequiredFields($this->getDocumentType());
54 }
55
59 public function getConfigId(): string
60 {
61 return 'store_document_details';
62 }
63
69 public static function createByArray(array $documentFields, array $config = []): self
70 {
71 return new static($documentFields, $config);
72 }
73
79 public static function createById(int $id, array $config = []): self
80 {
81 $provider = new static(['ID' => $id], $config);
82 $provider->loadDocument();
83
84 return $provider;
85 }
86
92 public static function createByType(string $type, array $config = []): self
93 {
94 return new static(['DOC_TYPE' => $type], $config);
95 }
96
97 protected function getDocumentId(): ?int
98 {
99 return $this->document['ID'] ?? null;
100 }
101
102 protected function getDocumentType(): string
103 {
104 return $this->document['DOC_TYPE'] ?? static::DEFAULT_TYPE;
105 }
106
107 protected function isNewDocument(): bool
108 {
109 return $this->getDocumentId() === null;
110 }
111
112 protected function loadDocument(): void
113 {
114 if (!$this->isNewDocument())
115 {
116 $documentType = StoreDocumentTable::getRow(['select' => ['DOC_TYPE'], 'filter' => ['=ID' => $this->getDocumentId()]]);
117 if (!$documentType)
118 {
119 $this->document = [];
120 return;
121 }
122
123 $documentType = $documentType['DOC_TYPE'];
124
125 $tableClass = StoreDocumentTableManager::getTableClassByType($documentType) ?: StoreDocumentTable::class;
126 $document = $tableClass::getRow([
127 'select' => [
128 '*',
129 'UF_*',
130 'CONTRACTOR_REF_' => 'CONTRACTOR',
131 ],
132 'filter' => [
133 '=ID' => $this->getDocumentId(),
134 ],
135 ]);
136
137 $this->document = $document ? array_merge($this->document, $document) : [];
138 }
139 }
140
141 public function getGUID(): string
142 {
143 return static::GUID_PREFIX . $this->getDocumentType();
144 }
145
146 public function getEntityId(): ?int
147 {
148 return $this->getDocumentId();
149 }
150
151 public function getEntityTypeName(): string
152 {
153 return static::ENTITY_TYPE_NAME;
154 }
155
156 public function getEntityFields(): array
157 {
158 static $fields = [];
159
160 $documentType = $this->getDocumentType();
161 if (!isset($fields[$documentType]))
162 {
163 $documentTypeFields = $this->getDocumentFields();
164 $fields[$documentType] = $this->getAdditionalFieldKeys($documentTypeFields);
165 }
166
167 return $fields[$documentType];
168 }
169
170 protected function getDocumentFields(): array
171 {
172 return array_merge($this->getDocumentCommonFields(), $this->getDocumentSpecificFields());
173 }
174
175 protected function getDocumentCommonFields(): array
176 {
177 return [
178 [
179 'name' => 'ID',
180 'title' => static::getFieldTitle('ID'),
181 'type' => 'number',
182 'editable' => false,
183 'required' => false,
184 ],
185 [
186 'name' => 'TITLE',
187 'title' => static::getFieldTitle('TITLE'),
188 'type' => 'text',
189 'editable' => true,
190 'required' => in_array('TITLE', $this->requiredFieldNames, true),
191 'isHeading' => true,
192 'visibilityPolicy' => 'edit',
193 'placeholders' => [
194 'creation' => $this->getDefaultDocumentTitle(),
195 ],
196 'data' => [
197 'requiredIsEditable' => true,
198 ],
199 ],
200 [
201 'name' => 'DATE_CREATE',
202 'title' => static::getFieldTitle('DATE_CREATE'),
203 'type' => 'datetime',
204 'editable' => false,
205 'visibilityPolicy' => 'view',
206 ],
207 [
208 'name' => 'CREATED_BY',
209 'title' => static::getFieldTitle('CREATED_BY'),
210 'type' => 'user',
211 'editable' => false,
212 ],
213 [
214 'name' => 'RESPONSIBLE_ID',
215 'title' => static::getFieldTitle('RESPONSIBLE_ID'),
216 'type' => 'user',
217 'editable' => true,
218 'required' => true,
219 ],
220 array_merge(
221 [
222 'name' => 'TOTAL_WITH_CURRENCY',
223 'editable' => in_array(
224 $this->getDocumentType(),
225 [
228 ],
229 true
230 ),
231 ],
232 $this->isNewDocument()
235 ),
236 [
237 'name' => 'DATE_MODIFY',
238 'title' => static::getFieldTitle('DATE_MODIFY'),
239 'type' => 'datetime',
240 'editable' => false,
241 'visibilityPolicy' => 'view',
242 ],
243 [
244 'name' => 'MODIFIED_BY',
245 'title' => static::getFieldTitle('MODIFIED_BY'),
246 'type' => 'user',
247 'editable' => false,
248 'visibilityPolicy' => 'view',
249 ],
250 [
251 'name' => 'DATE_STATUS',
252 'title' => static::getFieldTitle('DATE_STATUS'),
253 'type' => 'datetime',
254 'editable' => false,
255 'visibilityPolicy' => 'view',
256 ],
257 [
258 'name' => 'STATUS_BY',
259 'title' => static::getFieldTitle('STATUS_BY'),
260 'type' => 'user',
261 'editable' => false,
262 'visibilityPolicy' => 'view',
263 ],
264 [
265 'name' => 'DOCUMENT_PRODUCTS',
266 'title' => Loc::getMessage('CATALOG_STORE_DOCUMENT_DETAIL_FIELD_DOCUMENT_PRODUCTS_2'),
267 'type' => 'product_row_summary',
268 'editable' => false,
269 ],
270 ];
271 }
272
274 {
275 return [
276 'title' => static::getFieldTitle('CURRENCY'),
277 'type' => 'list',
278 'data' => [
279 'items' => $this->prepareCurrencyList(),
280 ]
281 ];
282 }
283
285 {
286 return [
287 'title' => static::getFieldTitle('TOTAL_WITH_CURRENCY'),
288 'type' => 'money',
289 'data' => [
290 'largeFormat' => true,
291 'affectedFields' => ['CURRENCY', 'TOTAL'],
292 'amount' => 'TOTAL',
293 'amountReadOnly' => true,
294 'currency' => [
295 'name' => 'CURRENCY',
296 'items' => $this->prepareCurrencyList(),
297 ],
298 'formatted' => 'FORMATTED_TOTAL',
299 'formattedWithCurrency' => 'FORMATTED_TOTAL_WITH_CURRENCY',
300 ],
301 ];
302 }
303
304 protected function getDocumentSpecificFields(): array
305 {
306 $fields = [];
307
308 switch ($this->getDocumentType())
309 {
311 $fields = [
312 [
313 'name' => 'DOC_NUMBER',
314 'title' => static::getFieldTitle('DOC_NUMBER'),
315 'type' => 'text',
316 'editable' => true,
317 'showAlways' => true,
318 'required' => in_array('DOC_NUMBER', $this->requiredFieldNames, true),
319 'data' => [
320 'requiredIsEditable' => true,
321 ],
322 ],
323 [
324 'name' => 'DATE_DOCUMENT',
325 'title' => static::getFieldTitle('DATE_DOCUMENT'),
326 'type' => 'datetime',
327 'editable' => true,
328 'data' => [
329 'enableTime' => false,
330 'requiredIsEditable' => true,
331 ],
332 'required' => in_array('DATE_DOCUMENT', $this->requiredFieldNames, true),
333 ],
334 $this->getContractorField(),
335 [
336 'name' => 'ITEMS_ORDER_DATE',
337 'title' => static::getFieldTitle('ITEMS_ORDER_DATE'),
338 'type' => 'datetime',
339 'editable' => true,
340 'data' => [
341 'enableTime' => false,
342 'requiredIsEditable' => true,
343 ],
344 'required' => in_array('ITEMS_ORDER_DATE', $this->requiredFieldNames, true),
345 ],
346 [
347 'name' => 'ITEMS_RECEIVED_DATE',
348 'title' => static::getFieldTitle('ITEMS_RECEIVED_DATE'),
349 'type' => 'datetime',
350 'editable' => true,
351 'data' => [
352 'enableTime' => false,
353 'requiredIsEditable' => true,
354 ],
355 'required' => in_array('ITEMS_RECEIVED_DATE', $this->requiredFieldNames, true),
356 ],
357 [
358 'name' => 'DOCUMENT_FILES',
359 'title' => static::getFieldTitle('DOCUMENT_FILES'),
360 'type' => 'file',
361 'editable' => true,
362 'showAlways' => true,
363 'data' => [
364 'multiple' => true,
365 'maxFileSize' => \CUtil::Unformat(ini_get('upload_max_filesize')),
366 'requiredIsEditable' => true,
367 ],
368 'required' => in_array('DOCUMENT_FILES', $this->requiredFieldNames, true),
369 ],
370 ];
371 break;
374 $fields = [
375 [
376 'name' => 'DOC_NUMBER',
377 'title' => static::getFieldTitle('DOC_NUMBER'),
378 'type' => 'text',
379 'editable' => true,
380 'showAlways' => false,
381 'required' => in_array('DOC_NUMBER', $this->requiredFieldNames, true),
382 'data' => [
383 'requiredIsEditable' => true,
384 ],
385 ],
386 [
387 'name' => 'DATE_DOCUMENT',
388 'title' => static::getFieldTitle('DATE_DOCUMENT'),
389 'type' => 'datetime',
390 'editable' => true,
391 'showAlways' => false,
392 'data' => [
393 'enableTime' => false,
394 'requiredIsEditable' => true,
395 ],
396 'required' => in_array('DATE_DOCUMENT', $this->requiredFieldNames, true),
397 ],
398 ];
399 break;
400 }
401
402 $fields = $this->fillUfEntityFields($fields);
403
404 return $fields;
405 }
406
407 protected function getUfComponentFields(): array
408 {
409 $result = $this->getUfComponentFieldsParent();
410 $result['USER_FIELD_CREATE_PAGE_URL'] = $this->createUfUrl;
411
412 return $result;
413 }
414
415 public function setCreateUfUrl(string $url): void
416 {
417 $this->createUfUrl = $url;
418 }
419
423 public function getUfEntityId(): string
424 {
425 /* @var StoreDocumentSpecificTable $tableClass */
426 $tableClass = StoreDocumentTableManager::getTableClassByType($this->getDocumentType());
427
428 if ($tableClass)
429 {
430 return $tableClass::getUfId();
431 }
432
433 return '';
434 }
435
439 public function getUfPrefix(): string
440 {
441 return 'CATALOG';
442 }
443
444 protected function getDefaultDocumentTitle(string $documentNumber = '')
445 {
446 return Loc::getMessage('CATALOG_STORE_DOCUMENT_DETAIL_TITLE_DEFAULT_NAME_'
447 . $this->getDocumentType(), ['%DOCUMENT_NUMBER%' => $documentNumber]);
448 }
449
451 {
452 $resultFields = [];
453
454 foreach ($fields as $field)
455 {
456 $fieldName = $field['name'];
457 $fieldType = $field['type'];
458
459 if ($fieldType === 'user')
460 {
461 $field['data'] = [
462 'enableEditInView' => $field['editable'],
463 'formated' => $fieldName . '_FORMATTED_NAME',
464 'photoUrl' => $fieldName . '_PHOTO_URL',
465 'showUrl' => 'PATH_TO_' . $fieldName,
466 'pathToProfile' => static::PATH_TO_USER_PROFILE,
467 ];
468 }
469
470 $resultFields[] = $field;
471 }
472
473 return $resultFields;
474 }
475
476 public function getEntityConfig(): array
477 {
478 $sectionElements = [
479 [
480 'name' => 'main',
481 'title' => Loc::getMessage('CATALOG_STORE_DOCUMENT_DETAIL_MAIN_SECTION'),
482 'type' => 'section',
483 'elements' => $this->getMainSectionElements(),
484 'data' => [
485 'isRemovable' => 'false',
486 ],
487 'sort' => 100,
488 ],
489 ];
490
491 $sectionElements[] = [
492 'name' => 'products',
493 'title' => Loc::getMessage('CATALOG_STORE_DOCUMENT_DETAIL_PRODUCTS_SECTION'),
494 'type' => 'section',
495 'elements' => [
496 ['name' => 'DOCUMENT_PRODUCTS'],
497 ],
498 'data' => [
499 'isRemovable' => 'false',
500 ],
501 'sort' => 200,
502 ];
503
504 $sectionElements[] = [
505 'name' => 'extra',
506 'title' => Loc::getMessage('CATALOG_STORE_DOCUMENT_DETAIL_EXTRA_SECTION'),
507 'type' => 'section',
508 'elements' => [
509 ['name' => 'RESPONSIBLE_ID'],
510 ],
511 'data' => [
512 'isRemovable' => 'false',
513 ],
514 'sort' => 300,
515 ];
516
517 Main\Type\Collection::sortByColumn($sectionElements, ['sort' => SORT_ASC]);
518
519 return [
520 [
521 'name' => 'left',
522 'type' => 'column',
523 'data' => [
524 'width' => 40,
525 ],
526 'elements' => $sectionElements,
527 ],
528 ];
529 }
530
531 public function getMainSectionElements()
532 {
533 $ufSectionElements = [];
534 $ufInfos = $this->getUfEntityFields();
535 foreach ($ufInfos as $userField)
536 {
537 $ufSectionElements[] = ['name' => $userField['name']];
538 }
539
540 switch ($this->getDocumentType())
541 {
543 return [
544 ['name' => 'TITLE'],
545 ['name' => 'TOTAL_WITH_CURRENCY'],
546 ['name' => 'CONTRACTOR_ID'],
547 ['name' => 'DOC_NUMBER'],
548 ['name' => 'DATE_DOCUMENT'],
549 ['name' => 'ITEMS_RECEIVED_DATE'],
550 ['name' => 'DOCUMENT_FILES'],
551 ...$ufSectionElements,
552 ];
554 return [
555 ['name' => 'TITLE'],
556 ['name' => 'TOTAL_WITH_CURRENCY'],
557 ...$ufSectionElements,
558 ];
560 return [
561 ['name' => 'TITLE'],
562 ['name' => 'TOTAL_WITH_CURRENCY'],
563 ...$ufSectionElements,
564 ];
566 return [
567 ['name' => 'TITLE'],
568 ['name' => 'TOTAL_WITH_CURRENCY'],
569 ...$ufSectionElements,
570 ];
571 default:
572 return $ufSectionElements;
573 }
574 }
575
576 public function getEntityData(): array
577 {
578 if ($this->isNewDocument())
579 {
580 $document = array_fill_keys(array_column($this->getEntityFields(), 'name'), null);
581 $document = array_merge($document, [
582 'DOC_TYPE' => $this->document['DOC_TYPE'],
583 'RESPONSIBLE_ID' => CurrentUser::get()->getId(),
584 ]);
585 }
586 else
587 {
589 }
590
591 $currency = $this->document['CURRENCY'] ?? null;
592 if (!$currency)
593 {
594 $currency = CurrencyManager::getBaseCurrency();
595 }
596
597 if (!isset($document['TOTAL']))
598 {
599 $document['TOTAL'] = 0;
600 $document['CURRENCY'] = $currency;
601 }
602
603 $document['FORMATTED_TOTAL'] = CCurrencyLang::CurrencyFormat($document['TOTAL'], $currency, false);
604 $document['FORMATTED_TOTAL_WITH_CURRENCY'] = CCurrencyLang::CurrencyFormat($document['TOTAL'],
605 $currency);
606
607 if (empty($this->config['skipProducts']))
608 {
609 $document['DOCUMENT_PRODUCTS'] = $this->getDocumentProductsPreview($document);
610 }
611 if (empty($this->config['skipFiles']))
612 {
613 $document['DOCUMENT_FILES'] = $this->getDocumentFiles($document);
614 }
615
616 if ($this->shouldPrepareDateFields())
617 {
618 $dateFields = ['DATE_DOCUMENT', 'ITEMS_ORDER_DATE', 'ITEMS_RECEIVED_DATE'];
619 foreach ($dateFields as $dateField)
620 {
621 if (isset($document[$dateField]) && $document[$dateField] instanceof Main\Type\DateTime)
622 {
623 $document[$dateField] = new Main\Type\Date($document[$dateField]);
624 }
625 }
626 }
627
628 $document = $this->fillUfEntityData($document);
629
631 }
632
633 protected function getDocumentFiles(array $document)
634 {
635 if ($this->isNewDocument())
636 {
637 return [];
638 }
639
640 $files = StoreDocumentFileTable::getList(['select' => ['FILE_ID'], 'filter' => ['DOCUMENT_ID' => $this->document['ID']]])->fetchAll();
641
642 return array_column($files, 'FILE_ID');
643 }
644
646 {
647 $documentProductSummaryInfo = $this->getProductSummaryInfo($document);
648 $documentProductSummaryInfo['isReadOnly'] = $this->isReadOnly();
649
650 return $documentProductSummaryInfo;
651 }
652
653 private function getProductSummaryInfo(array $document): array
654 {
655 $isNewDocument = $document['ID'] === null;
656 if ($isNewDocument)
657 {
658 return [
659 'count' => 0,
660 'total' => \CCurrencyLang::CurrencyFormat(0, $document['CURRENCY']),
661 'totalRaw' => [
662 'amount' => 0,
663 'currency' => $document['CURRENCY'],
664 ],
665 'items' => [],
666 ];
667 }
668
669 $storeDocumentProductPositionRepository = StoreDocumentProductPositionRepository::getInstance();
670 $productPositionList = $storeDocumentProductPositionRepository->getList($document['ID']);
671 foreach ($productPositionList as &$productPosition)
672 {
673 $productPosition['SUM'] = \CCurrencyLang::CurrencyFormat($productPosition['SUM'], $document['CURRENCY']);
674 }
675
676 return [
677 'count' => $storeDocumentProductPositionRepository->getCount($document['ID']),
678 'total' => \CCurrencyLang::CurrencyFormat($document['TOTAL'], $document['CURRENCY']),
679 'totalRaw' => [
680 'amount' => $document['TOTAL'],
681 'currency' => $document['CURRENCY'],
682 ],
683 'items' => $productPositionList,
684 ];
685 }
686
688 {
689 $userFields = [];
690
691 foreach ($this->getEntityFields() as $field)
692 {
693 $fieldName = $field['name'];
694 $fieldType = $field['type'];
695
696 if ($fieldType === 'user')
697 {
698 $userId = $document[$field['name']] ?? null;
699 if (!$userId && $fieldName === 'CREATED_BY')
700 {
701 $userId = CurrentUser::get()->getId();
702 }
703
704 $userFields[$fieldName] = $userId;
705 }
706 }
707
708 $document['PATH_TO_USER_PROFILE'] = static::PATH_TO_USER_PROFILE;
709
711 {
712 $document = array_merge($document, $this->getContractorData($document));
713 }
714
715 $uniqueUserIds = array_filter(array_unique(array_values($userFields)));
716 if (!empty($uniqueUserIds) && empty($this->config['skipUsers']))
717 {
718 $document = $this->getAdditionalUserData($document, $userFields, $this->getUsersInfo($uniqueUserIds));
719 }
720 elseif(!empty($uniqueUserIds) && !empty($document['USER_INFO']))
721 {
722 $document = $this->getAdditionalUserData($document, $userFields, $document['USER_INFO']);
723 }
724
725 return $document;
726 }
727
731 protected function getContractorField(): array
732 {
733 return [
734 'name' => 'CONTRACTOR_ID',
735 'title' => static::getFieldTitle('CONTRACTOR_ID'),
736 'type' => $this->contractorsProvider
737 ? $this->contractorsProvider::getEditorFieldType()
738 : 'contractor',
739 'editable' => true,
740 'required' => true,
741 'data' => $this->contractorsProvider
742 ? $this->contractorsProvider::getEditorFieldData()
743 : [
744 'contractorName' => 'CONTRACTOR_NAME',
745 ],
746 ];
747 }
748
754 {
755 return $this->contractorsProvider
756 ? $this->contractorsProvider::getEditorEntityData((int)$document['ID'])
757 : ['CONTRACTOR_NAME' => $this->getContractorName()];
758 }
759
763 protected function getContractorName(): string
764 {
765 if (!empty($this->document['CONTRACTOR_REF_COMPANY']))
766 {
767 return $this->document['CONTRACTOR_REF_COMPANY'];
768 }
769
770 if (!empty($this->document['CONTRACTOR_REF_PERSON_NAME']))
771 {
772 return $this->document['CONTRACTOR_REF_PERSON_NAME'];
773 }
774
775 return '';
776 }
777
778 protected function getUsersInfo(array $userIds): array
779 {
781 if (empty($userIds))
782 {
783 return [];
784 }
785
786 $usersInfo = [];
787
788 $newUsers = [];
789 foreach ($userIds as $id)
790 {
791 if (isset(static::$users[$id]))
792 {
793 $usersInfo[$id] = static::$users[$id];
794 }
795 else
796 {
797 $newUsers[] = $id;
798 }
799 }
800
801 if (empty($newUsers))
802 {
803 return $usersInfo;
804 }
805
806 foreach (array_chunk($newUsers, CATALOG_PAGE_SIZE) as $pageIds)
807 {
808 $userList = UserTable::getList([
809 'select' => [
810 'ID',
811 'LOGIN',
812 'NAME',
813 'SECOND_NAME',
814 'LAST_NAME',
815 'PERSONAL_PHOTO',
816 'WORK_POSITION',
817 ],
818 'filter' => [
819 '@ID' => $pageIds,
820 ],
821 ]);
822 while ($user = $userList->fetch())
823 {
824 $id = (int)$user['ID'];
825 $usersInfo[$id] = $user;
826 static::$users[$id] = $user;
827 }
828 unset($userList);
829 }
830
831 return $usersInfo;
832 }
833
834 protected function getAdditionalUserData(array $document, array $userFields, array $usersInfo): array
835 {
836 foreach ($userFields as $fieldName => $userId)
837 {
838 if (!$userId)
839 {
840 continue;
841 }
842
843 $user = $usersInfo[$userId];
844 $document['PATH_TO_' . $fieldName] = \CComponentEngine::MakePathFromTemplate(
845 static::PATH_TO_USER_PROFILE,
846 ['user_id' => $user['ID']]
847 );
848
849 $document[$fieldName . '_FORMATTED_NAME'] = \CUser::FormatName(
850 \CSite::GetNameFormat(),
851 [
852 'ID' => $user['ID'] ?? '',
853 'LOGIN' => $user['LOGIN'],
854 'NAME' => $user['NAME'],
855 'LAST_NAME' => $user['LAST_NAME'],
856 'SECOND_NAME' => $user['SECOND_NAME'],
857 ],
858 true,
859 false
860 );
861
862 $personalPhoto = (int)($user['PERSONAL_PHOTO'] ?? 0);
863 if ($personalPhoto > 0)
864 {
865 $fileInfo = \CFile::ResizeImageGet(
866 $personalPhoto,
867 [
868 'width' => 60,
869 'height' => 60,
870 ],
872 );
873 if (isset($fileInfo['src']))
874 {
875 $document[$fieldName . '_PHOTO_URL'] = $fileInfo['src'];
876 }
877 }
878 }
879
880 return $document;
881 }
882
883 public function getEntityControllers(): array
884 {
885 return [
886 [
887 'name' => 'PRODUCT_LIST_CONTROLLER',
888 'type' => 'catalog_store_document_product_list',
889 'config' => [],
890 ],
891 [
892 'name' => 'DOCUMENT_CARD_CONTROLLER',
893 'type' => 'document_card',
894 'config' => [],
895 ],
896 ];
897 }
898
899 public function isReadOnly(): bool
900 {
902 $accessController = AccessController::getCurrent();
903
904 return
905 !$accessController->checkByValue(
906 ActionDictionary::ACTION_STORE_DOCUMENT_MODIFY,
907 $this->getDocumentType()
908 )
909 || (
910 isset($this->document['STATUS']) && $this->document['STATUS'] === 'Y'
911 )
912 ;
913 }
914
915 public function isEntityConfigEditable(): bool
916 {
918 $accessController = AccessController::getCurrent();
919
920 return AccessController::getCurrent()->check(ActionDictionary::ACTION_STORE_DOCUMENT_CARD_EDIT);
921 }
922
926 protected function prepareCurrencyList(): array
927 {
928 $result = [];
929
930 $existingCurrencies = CurrencyTable::getList([
931 'select' => [
932 'CURRENCY',
933 'FULL_NAME' => 'CURRENT_LANG_FORMAT.FULL_NAME',
934 'SORT',
935 'BASE',
936 ],
937 'order' => [
938 'BASE' => 'DESC',
939 'SORT' => 'ASC',
940 'CURRENCY' => 'ASC',
941 ],
942 'cache' => [
943 'ttl' => 86400,
944 'cache_joins' => true,
945 ]
946 ])->fetchAll();
947 foreach ($existingCurrencies as $currency)
948 {
949 $currency['FULL_NAME'] ??= $currency['CURRENCY'];
950 $result[] = $this->prepareCurrencyListItem($currency);
951 }
952
953 return $result;
954 }
955
961 {
962 return [
963 'NAME' => $currency['FULL_NAME'],
964 'VALUE' => $currency['CURRENCY'],
965 ];
966 }
967
968 public static function getFieldTitle($fieldName)
969 {
970 switch ($fieldName)
971 {
972 case 'ID':
973 return Loc::getMessage('CATALOG_STORE_DOCUMENT_DETAIL_FIELD_ID');
974 case 'TITLE':
975 return Loc::getMessage('CATALOG_STORE_DOCUMENT_DETAIL_TITLE_ID');
976 case 'TOTAL_WITH_CURRENCY':
977 return Loc::getMessage('CATALOG_STORE_DOCUMENT_DETAIL_FIELD_TOTAL');
978 case 'CURRENCY':
979 return Loc::getMessage('CATALOG_STORE_DOCUMENT_DETAIL_FIELD_CURRENCY');
980 case 'ITEMS_ORDER_DATE':
981 return Loc::getMessage('CATALOG_STORE_DOCUMENT_DETAIL_ITEMS_ORDER_DATE_DOCUMENT');
982 case 'ITEMS_RECEIVED_DATE':
983 return Loc::getMessage('CATALOG_STORE_DOCUMENT_DETAIL_ITEMS_RECEIVED_DATE_DOCUMENT');
984 case 'DOCUMENT_FILES':
985 return Loc::getMessage('CATALOG_STORE_DOCUMENT_DETAIL_FIELD_DOCUMENT_FILES_2');
986 default:
987 return Loc::getMessage('CATALOG_STORE_DOCUMENT_DETAIL_FIELD_' . $fieldName);
988 }
989 }
990
991 protected function shouldPrepareDateFields(): bool
992 {
993 return true;
994 }
995}
$type
Определения options.php:106
if(!Loader::includeModule('messageservice')) $provider
Определения callback_ednaruimhpx.php:21
const CATALOG_PAGE_SIZE
Определения include.php:111
$accessController
Определения options.php:23
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getActiveProvider(string $providerName)
Определения Manager.php:26
getAdditionalUserData(array $document, array $userFields, array $usersInfo)
Определения StoreDocumentProvider.php:834
__construct(array $documentFields, array $config=[])
Определения StoreDocumentProvider.php:46
static createByArray(array $documentFields, array $config=[])
Определения StoreDocumentProvider.php:69
static createByType(string $type, array $config=[])
Определения StoreDocumentProvider.php:92
static getRow(array $parameters)
Определения datamanager.php:398
static getList(array $parameters=array())
Определения datamanager.php:431
static normalizeArrayValuesByInt(&$map, $sorted=true)
Определения collection.php:150
static sortByColumn(array &$array, $columns, $callbacks='', $defaultValueIfNotSetValue=null, $preserveKeys=false)
Определения collection.php:24
Определения date.php:9
$userList
Определения discount_coupon_list.php:276
</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
const BX_RESIZE_IMAGE_EXACT
Определения constants.php:12
Определения collection.php:2
$user
Определения mysql_to_pgsql.php:33
$files
Определения mysql_to_pgsql.php:30
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$currency
Определения template.php:266
$url
Определения iframe.php:7
$fields
Определения yandex_run.php:501