1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
property.php
См. документацию.
1<?php
3
5use Bitrix\Main\Page\Asset;
9use Bitrix\Main\UI\Filter\Options as FilterOptions;
10
11Loc::loadMessages(__FILE__);
12
20class Property
21{
30 public static function render($filterId, $propertyType, array $listProperty)
31 {
32 $result = '';
38 if(method_exists(__CLASS__, 'renderBy'.$propertyType))
39 {
40 $renderMethod = 'renderBy'.$propertyType;
41 $result = self::$renderMethod($filterId, $listProperty);
42 }
43
44 return $result;
45 }
46
56 public static function addFilter($property, $controlSettings, &$filter, &$filtered)
57 {
58 if(isset($property['PROPERTY_USER_TYPE']['USER_TYPE'])
59 && method_exists(__CLASS__, 'addFilterBy'.$property['PROPERTY_USER_TYPE']['USER_TYPE']))
60 {
61 $renderMethod = 'addFilterBy'.$property['PROPERTY_USER_TYPE']['USER_TYPE'];
62 self::$renderMethod($property, $controlSettings, $filter, $filtered);
63 }
64 elseif($property['PROPERTY_TYPE'] != '')
65 {
66 $renderMethod = 'addFilterBy'.$property['PROPERTY_TYPE'];
67 if(method_exists(__CLASS__, $renderMethod))
68 {
69 self::$renderMethod($property, $controlSettings, $filter, $filtered);
70 }
71 }
72 elseif($property['TYPE'] != '')
73 {
74 $renderMethod = 'addFilterBy'.str_replace('_', '', $property['TYPE']);
75 if(method_exists(__CLASS__, $renderMethod))
76 {
77 self::$renderMethod($property, $controlSettings, $filter, $filtered);
78 }
79 }
80 }
81
82 protected static function renderByECrm($filterId, $listProperty)
83 {
84 if(!Loader::includeModule('crm'))
85 return '';
86
87 \Bitrix\Main\UI\Extension::load('ui.fonts.opensans');
88 Asset::getInstance()->addCss('/bitrix/js/crm/css/crm.css');
89 Asset::getInstance()->addJs('/bitrix/js/crm/crm.js');
90
91 $html = self::getJsHandlerECrm();
92
93 if(!empty($listProperty)):
94 ob_start(); ?>
95 <script>
96 BX.ready(function() {
97 BX.FilterCrmEntitySelector.messages =
98 {
99 'contact': '<?= GetMessageJS('FIP_CRM_FF_CONTACT') ?>',
100 'company': '<?= GetMessageJS('FIP_CRM_FF_COMPANY') ?>',
101 'quote': '<?= GetMessageJS('FIP_CRM_FF_QUOTE_MSGVER_1') ?>',
102 'lead': '<?= GetMessageJS('FIP_CRM_FF_LEAD') ?>',
103 'deal': '<?= GetMessageJS('FIP_CRM_FF_DEAL') ?>',
104 'selectButton': '<?= GetMessageJS('CRM_ENTITY_SEL_BTN') ?>',
105 'noresult': '<?= GetMessageJS('CRM_SEL_SEARCH_NO_RESULT') ?>',
106 'search': '<?= GetMessageJS('CRM_ENTITY_SEL_SEARCH') ?>',
107 'last': '<?= GetMessageJS('CRM_ENTITY_SEL_LAST') ?>'
108 };
109 <?php
110 $listAvailableEntity = array('DEAL', 'CONTACT', 'COMPANY', 'LEAD');
111 foreach($listProperty as $property)
112 {
113 $fieldId = $property['FIELD_ID'];
114 $entityTypeNames = array();
115 foreach($property['USER_TYPE_SETTINGS'] as $entityType => $useMarker)
116 {
117 if($useMarker == 'Y' && in_array($entityType, $listAvailableEntity))
118 {
119 $entityTypeNames[] = $entityType;
120 }
121 }
122 $isMultiple = $property['MULTIPLE'] == 'Y' ? true : false;
123 $title = '';
124 ?>
125 BX.FilterHandlerECrm.create(
126 '<?= \CUtil::JSEscape($filterId.'_'.$fieldId) ?>',
127 {
128 fieldId: '<?= \CUtil::JSEscape($fieldId) ?>',
129 entityTypeNames: <?= Json::encode($entityTypeNames) ?>,
130 isMultiple: <?= $isMultiple ? 'true' : 'false' ?>,
131 title: '<?= \CUtil::JSEscape($title) ?>'
132 }
133 );
134 <?php
135 }
136 ?>
137 });
138 </script>
139 <?php
140 $html .= ob_get_contents();
141 ob_end_clean();
142 endif;
143
144 return $html;
145 }
146
147 protected static function renderByE($filterId, array $listProperty)
148 {
149 $html = '';
150
151 if(!empty($listProperty))
152 {
153 $html .= self::getJsHandlerE();
154 global $APPLICATION;
155
156 $filterOption = new FilterOptions($filterId);
157 $filterData = $filterOption->getFilter();
158 foreach($listProperty as $property)
159 {
160 $currentElements = array();
161 if(!empty($filterData[$property['FIELD_ID']]))
162 {
163 try
164 {
165 $currentValues = Json::decode($filterData[$property['FIELD_ID']]);
166 }
167 catch(SystemException $e)
168 {
169 return $e->getMessage();
170 }
171 if(is_array($currentValues))
172 {
173 foreach($currentValues as $value)
174 {
175 $currentElements[] = current($value);
176 }
177 }
178 else
179 {
180 $currentElements[] = $currentValues;
181 }
182 }
183 ob_start();
184 $APPLICATION->includeComponent('bitrix:iblock.element.selector', '',
185 array(
186 'SELECTOR_ID' => $filterId.'_'.$property['FIELD_ID'],
187 'SEARCH_INPUT_ID' => $filterId.'_'.$property['FIELD_ID'],
188 'IBLOCK_ID' => $property['LINK_IBLOCK_ID'],
189 'MULTIPLE' => 'Y',
190 'PANEL_SELECTED_VALUES' => 'N',
191 'CURRENT_ELEMENTS_ID' => $currentElements
192 ),
193 null, array('HIDE_ICONS' => 'Y')
194 );
195 ?>
196 <script>
197 BX.ready(function(){
198 BX.FilterHandlerE.create(
199 '<?= \CUtil::JSEscape($filterId.'_'.$property['FIELD_ID']) ?>',
200 {
201 fieldId: '<?= \CUtil::JSEscape($property['FIELD_ID']) ?>',
202 controlId: '<?= \CUtil::JSEscape($filterId.'_'.$property['FIELD_ID']) ?>',
203 multiple: 'Y'
204 }
205 );
206 });
207 </script>
208 <?php
209 $html .= ob_get_contents();
210 ob_end_clean();
211 }
212 }
213
214 return $html;
215 }
216
217 protected static function renderByEmployee($filterId, array $listProperty)
218 {
219 if(!Loader::includeModule('intranet'))
220 return '';
221
222 $html = '';
223 if(!empty($listProperty))
224 {
225 $html .= self::getJsHandlerEmployee();
226 global $APPLICATION;
227 ob_start();
228 foreach($listProperty as $property):
229 $APPLICATION->includeComponent('bitrix:intranet.user.selector.new', '',
230 array(
231 'MULTIPLE' => 'N',
232 'NAME' => $filterId.'_'.$property['FIELD_ID'],
233 'INPUT_NAME' => mb_strtolower($filterId.'_'.$property['FIELD_ID']),
234 'POPUP' => 'Y',
235 'SITE_ID' => SITE_ID,
236 'SHOW_EXTRANET_USERS' => 'NONE',
237 ),
238 null, array('HIDE_ICONS' => 'Y')
239 );
240 ?>
241 <script>
242 BX.ready(function(){
243 BX.FilterHandlerEmployee.create(
244 '<?= \CUtil::JSEscape($filterId.'_'.$property['FIELD_ID']) ?>',
245 {
246 fieldId: '<?= \CUtil::JSEscape($property['FIELD_ID']) ?>',
247 controlId: '<?= \CUtil::JSEscape($filterId.'_'.$property['FIELD_ID']) ?>'
248 }
249 );
250 });
251 </script>
252 <?php
254 $html .= ob_get_contents();
255 ob_end_clean();
256 }
257
258 return $html;
259 }
260
261 protected static function getJsHandlerECrm()
262 {
263 ob_start();
264 ?>
265 <script>
266 (function () {
267 'use strict';
268 if(typeof(BX.FilterHandlerECrm) === 'undefined')
269 {
270 BX.FilterHandlerECrm = function()
271 {
272 this._id = '';
273 this._settings = {};
274 this._fieldId = '';
275 this._control = null;
276 this._entitySelector = null;
277 };
278
279 BX.FilterHandlerECrm.prototype =
280 {
281 initialize: function(id, settings)
282 {
283 this._id = id;
284 this._settings = settings ? settings : {};
285 this._fieldId = this.getSetting('fieldId', '');
286
287 BX.addCustomEvent(window, 'BX.Main.Filter:customEntityFocus',
288 BX.delegate(this.onCustomEntitySelectorOpen, this));
289 BX.addCustomEvent(window, 'BX.Main.Filter:customEntityBlur',
290 BX.delegate(this.onCustomEntitySelectorClose, this));
291 },
292 getId: function()
293 {
294 return this._id;
295 },
296 getSetting: function (name, defaultval)
297 {
298 return this._settings.hasOwnProperty(name) ? this._settings[name] : defaultval;
299 },
300 getSearchInput: function()
301 {
302 return this._control ? this._control.getLabelNode() : null;
303 },
304 onCustomEntitySelectorOpen: function(control)
305 {
306 if(control.getId() !== this._fieldId)
307 {
308 this._control = null;
309 this.close();
310 }
311 else
312 {
313 this._control = control;
314 this.closeSiblings();
315 this.open();
316 }
317 },
318 onCustomEntitySelectorClose: function(control)
319 {
320 if(this._fieldId === control.getId())
321 {
322 this._control = null;
323 this.close();
324 }
325 },
326 onSelect: function(sender, data)
327 {
328 if(!this._control || this._control.getId() !== this._fieldId)
329 {
330 return;
331 }
332
333 var labels = [];
334 var values = {};
335 for(var typeName in data)
336 {
337 if(!data.hasOwnProperty(typeName))
338 {
339 continue;
340 }
341
342 var infos = data[typeName];
343 for(var i = 0, l = infos.length; i < l; i++)
344 {
345 var info = infos[i];
346 labels.push(info['title']);
347 if(typeof(values[typeName]) === 'undefined')
348 {
349 values[typeName] = [];
350 }
351
352 values[typeName].push(info['entityId']);
353 }
354 }
355 this._control.setData(labels.join(', '), JSON.stringify(values));
356 },
357 open: function()
358 {
359 if(!this._entitySelector)
360 {
361 this._entitySelector = BX.FilterCrmEntitySelector.create(
362 this._id,
363 {
364 control: this._control,
365 entityTypeNames: this.getSetting('entityTypeNames', []),
366 isMultiple: this.getSetting('isMultiple', false),
367 anchor: this.getSearchInput(),
368 title: this.getSetting('title', '')
369 }
370 );
371
372 BX.addCustomEvent(this._entitySelector, 'BX.FilterCrmEntitySelector:select',
373 BX.delegate(this.onSelect, this));
374 }
375
376 this._entitySelector.open();
377 if(this._control)
378 {
379 if(this._entitySelector.getPopup())
380 {
381 this._control.setPopupContainer(this._entitySelector.getPopup()['contentContainer']);
382 }
383 }
384 },
385 close: function()
386 {
387 if(this._entitySelector)
388 {
389 this._entitySelector.close();
390 if(this._control)
391 {
392 this._control.setPopupContainer(null);
393 }
394 }
395 },
396 closeSiblings: function()
397 {
398 var siblings = BX.FilterCrmEntitySelector.items;
399 for(var k in siblings)
400 {
401 if(siblings.hasOwnProperty(k) && siblings[k] !== this)
402 {
403 siblings[k].close();
404 }
405 }
406 }
407 };
408
409 BX.FilterHandlerECrm.items = {};
410 BX.FilterHandlerECrm.create = function(id, settings)
411 {
412 var self = new BX.FilterHandlerECrm(id, settings);
413 self.initialize(id, settings);
414 BX.FilterHandlerECrm.items[self.getId()] = self;
415 return self;
416 }
417 }
418
419 if(typeof(BX.FilterCrmEntitySelector) === 'undefined')
420 {
421 BX.FilterCrmEntitySelector = function()
422 {
423 this._id = '';
424 this._settings = {};
425 this._entityTypeNames = [];
426 this._isMultiple = false;
427 this._entityInfos = null;
428 this._entitySelectHandler = BX.delegate(this.onEntitySelect, this);
429 };
430 BX.FilterCrmEntitySelector.prototype =
431 {
432 initialize: function(id, settings)
433 {
434 this._id = id;
435 this._settings = settings ? settings : {};
436 this._entityTypeNames = this.getSetting('entityTypeNames', []);
437 this._isMultiple = this.getSetting('isMultiple', false);
438 this._entityInfos = [];
439 this._control = this.getSetting('control', null)
440 },
441 getId: function()
442 {
443 return this._id;
444 },
445 getSetting: function (name, defaultval)
446 {
447 return this._settings.hasOwnProperty(name) ? this._settings[name] : defaultval;
448 },
449 getMessage: function(name)
450 {
451 var msg = BX.FilterCrmEntitySelector.messages;
452 return msg.hasOwnProperty(name) ? msg[name] : name;
453 },
454 getPopup: function()
455 {
456 return typeof(obCrm[this._id]) !== 'undefined' ? obCrm[this._id].popup : null;
457 },
458 isOpened: function()
459 {
460 return ((obCrm[this._id].popup instanceof BX.PopupWindow) && obCrm[this._id].popup.isShown());
461 },
462 getSearchInput: function()
463 {
464 return this._control ? this._control.getLabelNode() : null;
465 },
466 open: function()
467 {
468 if(typeof(obCrm[this._id]) === 'undefined')
469 {
470 var entityTypes = [];
471 for(var i = 0, l = this._entityTypeNames.length; i < l; i++)
472 {
473 entityTypes.push(this._entityTypeNames[i].toLowerCase());
474 }
475
476 obCrm[this._id] = new CRM(
477 this._id,
478 null,
479 this.getSearchInput(),
480 this._id,
481 this._entityInfos,
482 false,
483 this._isMultiple,
484 entityTypes,
485 {
486 'contact': this.getMessage('contact'),
487 'company': this.getMessage('company'),
488 'quote': this.getMessage('quote'),
489 'lead': this.getMessage('lead'),
490 'deal': this.getMessage('deal'),
491 'ok': this.getMessage('selectButton'),
492 'cancel': BX.message('JS_CORE_WINDOW_CANCEL'),
493 'close': BX.message('JS_CORE_WINDOW_CLOSE'),
494 'wait': BX.message('JS_CORE_LOADING'),
495 'noresult': this.getMessage('noresult'),
496 'search' : this.getMessage('search'),
497 'last' : this.getMessage('last')
498 },
499 true
500 );
501 obCrm[this._id].Init();
502 obCrm[this._id].AddOnSaveListener(this._entitySelectHandler);
503 }
504
505 if(!((obCrm[this._id].popup instanceof BX.PopupWindow) && obCrm[this._id].popup.isShown()))
506 {
507 obCrm[this._id].Open(
508 {
509 closeIcon: { top: '10px', right: '15px' },
510 closeByEsc: true,
511 autoHide: false,
512 gainFocus: false,
513 anchor: this.getSearchInput(),
514 titleBar: this.getSetting('title')
515 }
516 );
517 }
518 },
519 close: function()
520 {
521 if(typeof(obCrm[this._id]) !== 'undefined')
522 {
523 obCrm[this._id].RemoveOnSaveListener(this._entitySelectHandler);
524 obCrm[this._id].Clear();
525 delete obCrm[this._id];
526 }
527
528 },
529 onEntitySelect: function(settings)
530 {
531 this.close();
532
533 var data = {};
534 for(var type in settings)
535 {
536 if(!settings.hasOwnProperty(type))
537 {
538 continue;
539 }
540
541 var entityInfos = settings[type];
542 if(!BX.type.isPlainObject(entityInfos))
543 {
544 continue;
545 }
546
547 var typeName = type.toUpperCase();
548 for(var key in entityInfos)
549 {
550 if(!entityInfos.hasOwnProperty(key))
551 {
552 continue;
553 }
554
555 var entityInfo = entityInfos[key];
556 this._entityInfos.push(
557 {
558 'id': entityInfo['id'],
559 'type': entityInfo['type'],
560 'title': entityInfo['title'],
561 'desc': entityInfo['desc'],
562 'url': entityInfo['url'],
563 'image': entityInfo['image'],
564 'selected': entityInfo['selected']
565 }
566 );
567
568 var entityId = BX.type.isNotEmptyString(entityInfo['id']) ?
569 parseInt(entityInfo['id']) : 0;
570 if(entityId > 0)
571 {
572 if(typeof(data[typeName]) === 'undefined')
573 {
574 data[typeName] = [];
575 }
576
577 data[typeName].push(
578 {
579 entityTypeName: typeName,
580 entityId: entityId,
581 title: BX.type.isNotEmptyString(entityInfo['title']) ?
582 entityInfo['title'] : ('[' + entityId + ']')
583 }
584 );
585 }
586 }
587 }
588
589 BX.onCustomEvent(this, 'BX.FilterCrmEntitySelector:select', [this, data]);
590 }
591 };
592
593 if(typeof(BX.FilterCrmEntitySelector.messages) === 'undefined')
594 {
595 BX.FilterCrmEntitySelector.messages = {};
596 }
597
598 BX.FilterCrmEntitySelector.items = {};
599 BX.FilterCrmEntitySelector.create = function(id, settings)
600 {
601 var self = new BX.FilterCrmEntitySelector(id, settings);
602 self.initialize(id, settings);
603 BX.FilterCrmEntitySelector.items[self.getId()] = self;
604 return self;
605 }
606 }
607 })();
608 </script>
609 <?php
610 $script = ob_get_contents();
611 ob_end_clean();
612 return $script;
613 }
614
615 protected static function getJsHandlerEmployee()
616 {
617 ob_start();
618 ?>
619 <script>
620 (function () {
621 'use strict';
622 if(typeof(BX.FilterHandlerEmployee) === 'undefined')
623 {
624 BX.FilterHandlerEmployee = function() {
625 this._id = '';
626 this._settings = {};
627 this._fieldId = '';
628 this._control = null;
629
630 this._currentUser = null;
631 this._controlId = null;
632 this._controlObj = null;
633 this._controlContainer = null;
634 this._serviceContainer = null;
635
636 this._zIndex = 1100;
637 this._isDialogDisplayed = false;
638 this._dialog = null;
639
640 this._inputKeyPressHandler = BX.delegate(this.onInputKeyPress, this);
641 };
642 BX.FilterHandlerEmployee.prototype =
643 {
644 initialize: function(id, settings)
645 {
646 this._id = id;
647 this._settings = settings ? settings : {};
648 this._fieldId = this.getSetting('fieldId', '');
649 this._controlId = this.getSetting('controlId', '');
650 this._controlContainer = BX(this._controlId + '_selector_content');
651
652 this._serviceContainer = this.getSetting('serviceContainer', null);
653 if(!BX.type.isDomNode(this._serviceContainer))
654 {
655 this._serviceContainer = document.body;
656 }
657
658 BX.addCustomEvent(window, 'BX.Main.Filter:customEntityFocus',
659 BX.delegate(this.onCustomEntitySelectorOpen, this));
660 BX.addCustomEvent(window, 'BX.Main.Filter:customEntityBlur',
661 BX.delegate(this.onCustomEntitySelectorClose, this));
662 },
663 getId: function()
664 {
665 return this._id;
666 },
667 getSetting: function (name, defaultval)
668 {
669 return this._settings.hasOwnProperty(name) ? this._settings[name] : defaultval;
670 },
671 getSearchInput: function()
672 {
673 return this._control ? this._control.getLabelNode() : null;
674 },
675 isOpened: function()
676 {
677 return this._isDialogDisplayed;
678 },
679 open: function()
680 {
681 if(this._controlObj === null)
682 {
683 var objName = 'O_' + this._controlId;
684 if(!window[objName])
685 {
686 throw 'BX.FilterHandlerEmployee: Could not find '+ objName +' user selector.';
687 }
688 this._controlObj = window[objName];
689 }
690
691 var searchInput = this.getSearchInput();
692 if(this._controlObj.searchInput)
693 {
694 BX.unbind(this._controlObj.searchInput, 'keyup',
695 BX.proxy(this._controlObj.search, this._controlObj));
696 }
697 this._controlObj.searchInput = searchInput;
698 BX.bind(this._controlObj.searchInput, 'keyup',
699 BX.proxy(this._controlObj.search, this._controlObj));
700 this._controlObj.onSelect = BX.delegate(this.onSelect, this);
701 BX.bind(searchInput, 'keyup', this._inputKeyPressHandler);
702
703 if(this._currentUser)
704 {
705 this._controlObj.setSelected([ this._currentUser ]);
706 }
707 else
708 {
709 var selected = this._controlObj.getSelected();
710 if(selected)
711 {
712 for(var key in selected)
713 {
714 if(selected.hasOwnProperty(key))
715 {
716 this._controlObj.unselect(key);
717 }
718 }
719 }
720 }
721
722 if(this._dialog === null)
723 {
724 this._controlContainer.style.display = '';
725 this._dialog = new BX.PopupWindow(
726 this._id,
727 this.getSearchInput(),
728 {
729 autoHide: false,
730 draggable: false,
731 closeByEsc: true,
732 offsetLeft: 0,
733 offsetTop: 0,
734 zIndex: this._zIndex,
735 bindOptions: { forceBindPosition: true },
736 content : this._controlContainer,
737 events:
738 {
739 onPopupShow: BX.delegate(this.onDialogShow, this),
740 onPopupClose: BX.delegate(this.onDialogClose, this),
741 onPopupDestroy: BX.delegate(this.onDialogDestroy, this)
742 }
743 }
744 );
745 }
746
747 this._dialog.show();
748 this._controlObj._onFocus();
749 if(this._control)
750 {
751 this._control.setPopupContainer(this._controlContainer);
752 }
753 },
754 close: function()
755 {
756 var searchInput = this.getSearchInput();
757 if(searchInput)
758 {
759 BX.bind(searchInput, 'keyup', this._inputKeyPressHandler);
760 }
761
762 if(this._dialog)
763 {
764 this._dialog.close();
765 }
766
767 if(this._control)
768 {
769 this._control.setPopupContainer(null);
770 }
771 },
772 onCustomEntitySelectorOpen: function(control)
773 {
774 if(control.getId() !== this._fieldId)
775 {
776 this._control = null;
777 this.close();
778 }
779 else
780 {
781 this._control = control;
782 var currentValues = this._control.getCurrentValues();
783 this._currentUser = {'id':currentValues.value,'name':currentValues.label};
784 this.open();
785 }
786 },
787 onCustomEntitySelectorClose: function(control)
788 {
789 if(control.getId() !== this._fieldId)
790 {
791 return;
792 }
793 this.close();
794 },
795 onDialogShow: function()
796 {
797 this._isDialogDisplayed = true;
798 },
799 onDialogClose: function()
800 {
801 this._isDialogDisplayed = false;
802 this._controlContainer.parentNode.removeChild(this._controlContainer);
803 this._serviceContainer.appendChild(this._controlContainer);
804 this._controlContainer.style.display = 'none';
805 this._dialog.destroy();
806 },
807 onDialogDestroy: function()
808 {
809 this._dialog = null;
810 },
811 onInputKeyPress: function(e)
812 {
813 if(!this._dialog || !this._isDialogDisplayed)
814 {
815 this.open();
816 }
817
818 if(this._controlObj)
819 {
820 this._controlObj.search();
821 }
822 },
823 onSelect: function(user)
824 {
825 this._currentUser = user;
826 if(this._control)
827 {
828 var node = this._control.getLabelNode();
829 node.value = '';
830 this._control.setData(user['name'], user['id']);
831 }
832 this.close();
833 }
834 };
835 BX.FilterHandlerEmployee.closeAll = function()
836 {
837 for(var k in this.items)
838 {
839 if(this.items.hasOwnProperty(k))
840 {
841 this.items[k].close();
842 }
843 }
844 };
845 BX.FilterHandlerEmployee.items = {};
846 BX.FilterHandlerEmployee.create = function(id, settings)
847 {
848 var self = new BX.FilterHandlerEmployee(id, settings);
849 self.initialize(id, settings);
850 BX.FilterHandlerEmployee.items[self.getId()] = self;
851 return self;
852 }
853 }
854 })();
855 </script>
856 <?php
857 $script = ob_get_contents();
858 ob_end_clean();
859 return $script;
860 }
861
862 protected static function getJsHandlerE()
863 {
864 ob_start();
865 ?>
866 <script>
867 (function () {
868 'use strict';
869 if(typeof(BX.FilterHandlerE) === 'undefined')
870 {
871 BX.FilterHandlerE = function() {
872 this._id = '';
873 this._settings = {};
874 this._fieldId = '';
875 this._control = null;
876
877 this._currentElements = [];
878 this._controlId = null;
879 this._controlObj = null;
880 this._controlContainer = null;
881 this._serviceContainer = null;
882
883 this._zIndex = 1100;
884 this._isDialogDisplayed = false;
885 this._dialog = null;
886
887 this._inputKeyPressHandler = BX.proxy(this.onInputKeyPress, this);
888 };
889 BX.FilterHandlerE.prototype =
890 {
891 initialize: function(id, settings)
892 {
893 this._id = id;
894 this._settings = settings ? settings : {};
895 this._fieldId = this.getSetting('fieldId', '');
896 this._controlId = this.getSetting('controlId', '');
897 this._multiple = this.getSetting('multiple', 'Y') === 'Y';
898 this._controlContainer = BX(this._controlId);
899
900 this._serviceContainer = this.getSetting('serviceContainer', null);
901 if(!BX.type.isDomNode(this._serviceContainer))
902 {
903 this._serviceContainer = document.body;
904 }
905
906 BX.addCustomEvent(window, 'BX.Main.Filter:customEntityFocus',
907 BX.proxy(this.onCustomEntitySelectorOpen, this));
908 BX.addCustomEvent(window, 'BX.Main.Filter:customEntityBlur',
909 BX.proxy(this.onCustomEntitySelectorClose, this));
910 },
911 getId: function()
912 {
913 return this._id;
914 },
915 getSetting: function (name, defaultval)
916 {
917 return this._settings.hasOwnProperty(name) ? this._settings[name] : defaultval;
918 },
919 getSearchInput: function()
920 {
921 return this._control ? this._control.getLabelNode() : null;
922 },
923 isOpened: function()
924 {
925 return this._isDialogDisplayed;
926 },
927 open: function()
928 {
929 if(this._controlObj === null)
930 {
931 var objName = BX.Iblock[this._controlId];
932 if(!objName)
933 {
934 throw 'BX.FilterHandlerE: Could not find '+ objName +' element selector.';
935 }
936 this._controlObj = objName;
937 }
938
939 this._multiple = this._controlObj.multiple;
940 var searchInput = this.getSearchInput();
941 if(this._controlObj.searchInput)
942 {
943 BX.unbind(this._controlObj.searchInput, 'keyup',
944 BX.proxy(this._controlObj.search, this._controlObj));
945 }
946 this._controlObj.searchInput = searchInput;
947 BX.bind(this._controlObj.searchInput, 'keyup',
948 BX.proxy(this._controlObj.search, this._controlObj));
949 this._controlObj.onSelect = BX.proxy(this.onSelect, this);
950 BX.bind(searchInput, 'keyup', this._inputKeyPressHandler);
951 if(this._multiple)
952 {
953 this._controlObj.onUnSelect = BX.proxy(this.onSelect, this);
954 }
955
956 if(this._currentElements)
957 {
958 this._controlObj.setSelected(this._currentElements);
959 }
960 else
961 {
962 var selected = this._controlObj.getSelected();
963 if(selected)
964 {
965 for(var key in selected)
966 {
967 if(selected.hasOwnProperty(key))
968 {
969 this._controlObj.unselect(key);
970 }
971 }
972 }
973 }
974
975 if(this._dialog === null)
976 {
977 this._controlContainer.style.display = '';
978 this._dialog = new BX.PopupWindow(
979 this._id,
980 this.getSearchInput(),
981 {
982 autoHide: false,
983 draggable: false,
984 closeByEsc: true,
985 offsetLeft: 0,
986 offsetTop: 0,
987 zIndex: this._zIndex,
988 bindOptions: { forceBindPosition: true },
989 content : this._controlContainer,
990 events:
991 {
992 onPopupShow: BX.delegate(this.onDialogShow, this),
993 onPopupClose: BX.delegate(this.onDialogClose, this),
994 onPopupDestroy: BX.delegate(this.onDialogDestroy, this)
995 }
996 }
997 );
998 }
999
1000 this._dialog.show();
1001 this._controlObj._onFocus();
1002 if(this._control)
1003 {
1004 this._control.setPopupContainer(this._controlContainer);
1005 }
1006 },
1007 close: function()
1008 {
1009 var searchInput = this.getSearchInput();
1010 if(searchInput)
1011 {
1012 BX.bind(searchInput, 'keyup', this._inputKeyPressHandler);
1013 }
1014
1015 if(this._dialog)
1016 {
1017 this._dialog.close();
1018 }
1019
1020 if(this._control)
1021 {
1022 this._control.setPopupContainer(null);
1023 }
1024 },
1025 onCustomEntitySelectorOpen: function(control)
1026 {
1027 if(control.getId() !== this._fieldId)
1028 {
1029 this._control = null;
1030 this.close();
1031 }
1032 else
1033 {
1034 this._control = control;
1035 var currentValues = this._control.getCurrentValues();
1036 if(!!currentValues.value)
1037 {
1038 this._currentElements = [];
1039 if(this._multiple)
1040 {
1041 var values = JSON.parse(currentValues.value);
1042 for(var k in values)
1043 {
1044 this._currentElements.push(
1045 {"id": values[k][0], "name": values[k][1]});
1046 }
1047 }
1048 else
1049 {
1050 this._currentElements.push(
1051 {"id": currentValues.value, "name": currentValues.label});
1052 }
1053 }
1054 this.open();
1055 }
1056 },
1057 onCustomEntitySelectorClose: function(control)
1058 {
1059 if (control.getId() !== this._fieldId)
1060 {
1061 return;
1062 }
1063
1064 var currentValues = control.getCurrentValues();
1065 if (!currentValues.value && control.getLabelNode())
1066 {
1067 var value = control.getLabelNode().value;
1068 if (parseInt(value))
1069 {
1070 control.getLabelNode().value = "";
1071 control.setData(value, value);
1072 }
1073 }
1074
1075 this.close();
1076 },
1077 onDialogShow: function()
1078 {
1079 this._isDialogDisplayed = true;
1080 },
1081 onDialogClose: function()
1082 {
1083 this._isDialogDisplayed = false;
1084 this._controlContainer.parentNode.removeChild(this._controlContainer);
1085 this._serviceContainer.appendChild(this._controlContainer);
1086 this._controlContainer.style.display = 'none';
1087 this._dialog.destroy();
1088 },
1089 onDialogDestroy: function()
1090 {
1091 this._dialog = null;
1092 },
1093 onInputKeyPress: function()
1094 {
1095 if(!this._dialog || !this._isDialogDisplayed)
1096 {
1097 this.open();
1098 }
1099 if(this._controlObj)
1100 {
1101 this._controlObj.search();
1102 }
1103 },
1104 onSelect: function(element)
1105 {
1106 if(!this._control || this._control.getId() !== this._fieldId)
1107 {
1108 return;
1109 }
1110 var node = this._control.getLabelNode();
1111 node.value = '';
1112
1113 if(this._multiple)
1114 {
1115 this._currentElements = element;
1116 var labels = [];
1117 var values = {};
1118 for(var k in this._currentElements)
1119 {
1120 if(!this._currentElements.hasOwnProperty(k) || !this._currentElements[k])
1121 {
1122 continue;
1123 }
1124 labels.push(this._currentElements[k].name);
1125 if(typeof(values[this._currentElements[k].id]) === 'undefined')
1126 {
1127 values[this._currentElements[k].id] = [];
1128 }
1129 values[this._currentElements[k].id].push(this._currentElements[k].id);
1130 values[this._currentElements[k].id].push(this._currentElements[k].name);
1131 }
1132 if (labels.join(', '))
1133 {
1134 this._control.setData(labels.join(', '), JSON.stringify(values));
1135 }
1136 else
1137 {
1138 this._control.removeSquares();
1139 }
1140 }
1141 else
1142 {
1143 this._currentElements.push(element);
1144 this._control.setData(element.name, element.id);
1145 this.close();
1146 }
1147 }
1148 };
1149 BX.FilterHandlerE.closeAll = function()
1150 {
1151 for(var k in this.items)
1152 {
1153 if(this.items.hasOwnProperty(k))
1154 {
1155 this.items[k].close();
1156 }
1157 }
1158 };
1159 BX.FilterHandlerE.items = {};
1160 BX.FilterHandlerE.create = function(id, settings)
1161 {
1162 var self = new BX.FilterHandlerE(id, settings);
1163 self.initialize(id, settings);
1164 BX.FilterHandlerE.items[self.getId()] = self;
1165 return self;
1166 }
1167 }
1168 })();
1169 </script>
1170 <?php
1171 $script = ob_get_contents();
1172 ob_end_clean();
1173 return $script;
1174 }
1175
1176 protected static function addFilterByE($property, $controlSettings, &$filter, &$filtered)
1177 {
1178 $filtered = false;
1179
1180 $filterOption = new \Bitrix\Main\UI\Filter\Options($controlSettings["FILTER_ID"]);
1181 $filterData = $filterOption->getFilter();
1182 if(!empty($filterData[$controlSettings['VALUE']]))
1183 $currentValue = $filterData[$controlSettings['VALUE']];
1184
1185 if(!empty($currentValue))
1186 {
1187 try
1188 {
1189 $values = array();
1190 global $APPLICATION;
1191 $currentValues = Json::decode($currentValue);
1192 if(is_array($currentValues))
1193 {
1194 foreach($currentValues as $value)
1195 {
1196 $values[] = current($value);
1197 }
1198 }
1199 else
1200 {
1201 $values[] = $currentValues;
1202 }
1203 if(!empty($values))
1204 {
1205 $filter[$controlSettings['VALUE']] = array();
1206 foreach($values as $value)
1207 {
1208 $filter[$controlSettings['VALUE']][] = intval($value);
1209 }
1210 $filtered = true;
1211 }
1212 }
1213 catch(SystemException $e)
1214 {
1215 return;
1216 }
1217 }
1218 }
1219}
<?=$taskID?> selected
Определения access_edit.php:348
global $APPLICATION
Определения include.php:80
static renderByE($filterId, array $listProperty)
Определения property.php:147
static render($filterId, $propertyType, array $listProperty)
Определения property.php:30
static getJsHandlerECrm()
Определения property.php:261
static addFilterByE($property, $controlSettings, &$filter, &$filtered)
Определения property.php:1176
static renderByEmployee($filterId, array $listProperty)
Определения property.php:217
static renderByECrm($filterId, $listProperty)
Определения property.php:82
static getJsHandlerEmployee()
Определения property.php:615
static addFilter($property, $controlSettings, &$filter, &$filtered)
Определения property.php:56
static getJsHandlerE()
Определения property.php:862
Определения loader.php:13
static includeModule($moduleName)
Определения loader.php:67
static load($extNames)
Определения extension.php:16
Определения json.php:9
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
bx_acc_lim_group_list limitGroupList[] multiple<?=$group[ 'ID']?> ID selected margin top
Определения file_new.php:657
$result
Определения get_property_values.php:14
if($request->isPost() && $currentAction !==null &&check_bitrix_sessid()) $currentValues
Определения options.php:198
$filter
Определения iblock_catalog_list.php:54
endif
Определения csv_new_setup.php:990
global_menu_<?echo $menu["menu_id"]?> adm main menu item icon adm main menu item text text adm main menu hover adm submenu menucontainer menu_id menu_id items_id items_id desktop menu_id block none adm global submenu<?=($subMenuDisplay=="block" ? " adm-global-submenu-active" :"")?> global_submenu_<?echo $menu["menu_id"]?> text MAIN_PR_ADMIN_FAV items adm submenu items wrap adm submenu items stretch wrap BX adminMenu itemsStretchScroll()"> <table class if (!empty( $menu["items"])) elseif ( $menu[ 'menu_id']=='desktop') if ( $menu[ 'menu_id']=='desktop') endforeach
Определения prolog_main_admin.php:255
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
<? endif;?> window document title
Определения prolog_main_admin.php:76
$title
Определения pdf.php:123
margin right
Определения options_user_settings.php:273
const SITE_ID
Определения sonet_set_content_view.php:12