1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
options.php
См. документацию.
1<?php
2
3namespace Bitrix\Main\UI\Filter;
4
5use Bitrix\Main\Application;
6use Bitrix\Main\Context;
7use Bitrix\Main\HttpRequest;
8use Bitrix\Main\Type\Date;
9use Bitrix\Main\UI\Filter;
10
16{
17 const DEFAULT_FILTER = "default_filter";
18 const TMP_FILTER = "tmp_filter";
19
20 protected $id;
21 protected $options;
22 protected $commonPresets;
25 protected $request;
26 protected ?string $currentFilterPresetId = null;
27
34 public function __construct($filterId, $filterPresets = [], $commonPresetsId = null)
35 {
36 $this->id = $filterId;
37 $this->options = $this->fetchOptions($this->id);
38 $this->useCommonPresets = false;
39
40 if (!empty($commonPresetsId) && is_string($commonPresetsId))
41 {
42 $this->commonPresets = static::fetchCommonPresets($commonPresetsId);
43 $this->useCommonPresets = true;
44 $this->commonPresetsId = $commonPresetsId;
45 $this->options["filters"] = $this->commonPresets["filters"] ?? null;
46 $this->options["deleted_presets"] = $this->commonPresets["deleted_presets"] ?? null;
47 }
48
49 if (!isset($this->options["use_pin_preset"]))
50 {
51 $this->options["use_pin_preset"] = true;
52 }
53
54 if (!isset($this->options["deleted_presets"]) || !is_array($this->options["deleted_presets"]))
55 {
56 $this->options["deleted_presets"] = [];
57 }
58
59 if (!empty($filterPresets) && is_array($filterPresets))
60 {
61 $this->options["default_presets"] = $filterPresets;
62 }
63 else
64 {
65 $this->options["default_presets"] = [];
66 }
67
68 if (!isset($this->options["default"]) || empty($this->options["default"]) ||
69 ($this->options["default"] === self::DEFAULT_FILTER && $this->options["use_pin_preset"]))
70 {
71 $this->options["default"] = self::findDefaultPresetId($this->options["default_presets"]);
72 }
73
74 if (!isset($this->options["filter"]) || empty($this->options["filter"]) || !is_string($this->options["filter"]))
75 {
76 $this->options["filter"] = $this->options["default"];
77 }
78
79 if (!isset($this->options["filters"]) || !is_array($this->options["filters"]))
80 {
81 $this->options["filters"] = $this->options["default_presets"];
82 }
83
84 // Move additional fields from options to session
85 if (is_array($this->options["filters"]))
86 {
87 foreach ($this->options["filters"] as $presetId => $options)
88 {
89 if (isset($options["additional"]) && is_array($options["additional"]))
90 {
91 $this->setAdditionalPresetFields($presetId, $options["additional"]);
92 unset($this->options["filters"][$presetId]["additional"]);
93 }
94 }
95 }
96
97 if (!empty($this->options["update_default_presets"]) &&
98 !empty($filterPresets) &&
99 is_array($filterPresets))
100 {
101 $this->options["update_default_presets"] = false;
102 $sort = 0;
103
104 foreach ($filterPresets as $key => $defaultPreset)
105 {
106 $this->options["filters"][$key] = $defaultPreset;
107 $this->options["filters"][$key]["sort"] = $sort;
108 $sort++;
109 }
110
111 foreach ($this->options["filters"] as $key => $preset)
112 {
113 if (!array_key_exists($key, $filterPresets))
114 {
115 $this->options["filters"][$key]["sort"] = $sort;
116 $sort++;
117 }
118 }
119 }
120 }
121
125 public function getCommonPresetsId()
126 {
128 }
129
133 public function isUseCommonPresets()
134 {
136 }
137
142 public function getId()
143 {
144 return $this->id;
145 }
146
151 public function setPresets($presets = [])
152 {
153 $this->options["filters"] = $presets;
154 }
155
160 public function setCurrentPreset($presetId = "default_filter")
161 {
162 $this->options["filter"] = $presetId;
163 }
164
169 public function getDefaultPresets()
170 {
171 return $this->options["default_presets"];
172 }
173
178 public function getPresets()
179 {
180 return $this->options["filters"];
181 }
182
187 public function setDefaultPreset($presetId = "default_filter")
188 {
189 $this->options["default"] = $presetId;
190 }
191
196 public function isUsePinPreset()
197 {
198 return $this->options["use_pin_preset"];
199 }
200
205 public function setDefaultPresets($presets = [])
206 {
207 $this->options["default_presets"] = $presets;
208 }
209
214 public function setDeletedPresets($deletedPresets = [])
215 {
216 $this->options["deleted_presets"] = $deletedPresets;
217 }
218
223 public function setUsePinPreset($value = true)
224 {
225 $this->options["use_pin_preset"] = $value;
226 }
227
233 public static function fetchCommonPresets($id)
234 {
235 global $USER;
236
237 $options = \CUserOptions::getOption("main.ui.filter.presets", $id, [], (int)$USER?->getID());
238
239 return $options;
240 }
241
247 public function fetchOptions($id)
248 {
249 global $USER;
250
251 $storage = $this->getStorage();
252 $userId = (int)$USER?->getID();
253
254 if ($userId > 0 || !isset($storage[$this->getId()]["options"]))
255 {
256 $options = [];
257
258 if ($userId > 0)
259 {
260 $options = \CUserOptions::getOption("main.ui.filter", $id, [], $userId);
261 }
262
263 if (empty($options))
264 {
265 $options = \CUserOptions::getOption("main.ui.filter.common", $id, [], 0);
266 }
267 }
268 else
269 {
270 $options = $storage[$this->getId()]["options"];
271 }
272
273 return $options;
274 }
275
276 protected function getRequest()
277 {
278 return Context::getCurrent()->getRequest();
279 }
280
281 protected function getStorage()
282 {
283 return Application::getInstance()->getLocalSession('main.ui.filter');
284 }
285
291 public static function findDefaultPresetId($presets = [])
292 {
293 $result = "default_filter";
294
295 if (!empty($presets) && is_array($presets))
296 {
297 foreach ($presets as $presetId => $preset)
298 {
299 if (isset($preset["default"]) && $preset["default"])
300 {
301 $result = $presetId;
302 }
303 }
304 }
305
306 return $result;
307 }
308
313 public function getOptions()
314 {
315 return $this->options;
316 }
317
322 public function pinPreset($presetId = "default_filter")
323 {
324 if ($presetId === "default_filter")
325 {
326 $this->options["use_pin_preset"] = false;
327 }
328 else
329 {
330 $this->options["use_pin_preset"] = true;
331 }
332
333 $this->options["default"] = $presetId;
334 }
335
342 public static function isSetFromRequest(HttpRequest $request)
343 {
344 $applyFilter = $request->get("apply_filter");
345 $isAjaxRequest = $request->get("ajax_request");
346
347 return $applyFilter !== null && $isAjaxRequest === null && !$request->isAjaxRequest();
348 }
349
358 {
359 $result = ["fields" => [], "rows" => []];
360
361 foreach ($fields as $field)
362 {
363 $id = $field["id"];
364 $fromId = $id . "_from";
365 $toId = $id . "_to";
366 $quarterId = $id . "_quarter";
367 $yearId = $id . "_year";
368 $monthId = $id . "_month";
369 $daysId = $id . "_days";
370 $nameId = $id . "_name";
371 $labelId = $id . "_label";
372 $dateselId = $id . "_datesel";
373 $numselId = $id . "_numsel";
374 $type = $field["type"] ?? null;
375 $isEmpty = $id . "_isEmpty";
376 $hasAnyValue = $id . "_hasAnyValue";
377
378 if ($type == "date")
379 {
380 if ($request[$dateselId] !== null && ($request[$fromId] !== null ||
381 $request[$toId] !== null ||
382 $request[$quarterId] !== null ||
383 $request[$yearId] !== null ||
384 $request[$daysId] !== null ||
385 $request[$monthId] !== null))
386 {
387 $result["fields"][$dateselId] = $request[$dateselId];
388 $result["fields"][$fromId] = $request[$fromId] !== null ? $request[$fromId] : "";
389 $result["fields"][$toId] = $request[$toId] !== null ? $request[$toId] : "";
390 $result["fields"][$yearId] = $request[$yearId] !== null ? $request[$yearId] : "";
391 $result["fields"][$monthId] = $request[$monthId] !== null ? $request[$monthId] : "";
392 $result["fields"][$daysId] = $request[$daysId] !== null ? $request[$daysId] : "";
393 $result["rows"][] = $id;
394 }
395 }
396 else
397 {
398 if ($type == "number")
399 {
400 if ($request[$numselId] !== null && ($request[$fromId] !== null || $request[$toId]))
401 {
402 $result["fields"][$numselId] = $request[$numselId];
403 $result["fields"][$fromId] = $request[$fromId] !== null ? $request[$fromId] : "";
404 $result["fields"][$toId] = $request[$toId] !== null ? $request[$toId] : "";
405 $result["rows"][] = $id;
406 }
407 }
408 else
409 {
410 if ($type == "custom_entity")
411 {
412 if ($request[$id] !== null)
413 {
414 if ($request[$id] !== null || $request[$labelId] !== null)
415 {
416 $result["fields"][$labelId] = ($request[$nameId] !== null ?
417 $request[$nameId] : $request[$labelId]);
418 }
419 $result["fields"][$id] = $request[$id];
420 $result["rows"][] = $id;
421 }
422 }
423 else
424 {
425 if ($type == "dest_selector" || $type == "entity_selector")
426 {
427 if ($request[$id] !== null)
428 {
429 $result["fields"][$id] = $request[$id];
430 if (isset($request[$labelId]))
431 {
432 $result["fields"][$labelId] = $request[$labelId];
433 }
434 $result["rows"][] = $id;
435 }
436 }
437 else
438 {
439 if ($request[$id] !== null)
440 {
441 $result["fields"][$id] = $request[$id];
442 $result["rows"][] = $id;
443 }
444 }
445 }
446 }
447 }
448
449 if (isset($request[$isEmpty]))
450 {
451 $result['fields'][$isEmpty] = $request[$isEmpty];
452 $result["rows"][] = $id;
453 }
454
455 if (isset($request[$hasAnyValue]))
456 {
457 $result['fields'][$hasAnyValue] = $request[$hasAnyValue];
458 $result["rows"][] = $id;
459 }
460 }
461
462 if ($request["FIND"] !== null)
463 {
464 $result["fields"]["FIND"] = $request["FIND"];
465 }
466
467 if (empty($result["fields"]) && empty($result["rows"]))
468 {
469 $result = null;
470 }
471
472 return $result;
473 }
474
479 public function getSessionFilterId()
480 {
481 $storage = $this->getStorage();
482
483 return $storage[$this->getId()]["filter"] ?? null;
484 }
485
486 public function isSetOutside(): bool
487 {
488 $storage = $this->getStorage();
489
490 return filter_var(
491 $storage[$this->getId()]["isSetOutside"] ?? false,
492 FILTER_VALIDATE_BOOLEAN
493 );
494 }
495
501 public function getAdditionalPresetFields($presetId)
502 {
503 $storage = $this->getStorage();
504
505 $additional = $storage[$this->getId()]["filters"][$presetId]["additional"] ?? [];
506
507 return is_array($additional) ? $additional : [];
508 }
509
515 public function setAdditionalPresetFields($presetId, $additional = [])
516 {
517 $storage = $this->getStorage();
518
519 $storage[$this->getId()]["filters"][$presetId]["additional"] = $additional;
520 }
521
526 public function getDefaultFilterId()
527 {
528 return $this->options["default"];
529 }
530
535 public function getCurrentFilterId()
536 {
537 $sessionFilterId = ($this->getCurrentFilterPresetId() ?? $this->getSessionFilterId());
538 $defaultFilterId = $this->getDefaultFilterId();
539 return !empty($sessionFilterId) ? $sessionFilterId : $defaultFilterId;
540 }
541
542 protected function trySetFilterFromRequest($fields = [])
543 {
544 $request = $this->getRequest();
545
546 if (self::isSetFromRequest($request))
547 {
549 $clear = strtoupper($request->get("clear_filter")) == "Y";
550
551 if ($settings !== null || $clear)
552 {
553 $presetId = $clear ? self::DEFAULT_FILTER : self::TMP_FILTER;
554
555 $this->setFilterSettings($presetId, $settings);
556 $this->save();
557 }
558 }
559 }
560
566 public function getFilterSettings($presetId)
567 {
568 return $this->options["filters"][$presetId] ?? null;
569 }
570
577 protected static function fetchFieldsFromFilterSettings($filterSettings = [], $additionalFields = [])
578 {
579 $filterFields = [];
580
581 if (is_array($filterSettings))
582 {
583 if (is_array($filterSettings["fields"]))
584 {
585 $filterFields = $filterSettings["fields"];
586 }
587
588 if (is_array($additionalFields))
589 {
590 $filterFields = array_merge($filterFields, $additionalFields);
591 }
592 }
593
594 return $filterFields;
595 }
596
601 public static function isDateField($key = "")
602 {
603 return is_string($key) && str_ends_with($key, "_datesel");
604 }
605
613 public static function fetchDateFieldValue($key = "", $filterFields = [])
614 {
615 $date = [];
616 $date[$key] = $filterFields[$key];
617
618 $cleanKey = str_replace("_datesel", "", $key);
619
620 self::calcDates($cleanKey, $filterFields, $date);
621
622 if (!isset($date[$cleanKey . "_from"]) && !isset($date[$cleanKey . "_to"]))
623 {
624 unset($date[$cleanKey . "_datesel"]);
625 unset($date[$cleanKey . "_to"]);
626 unset($date[$cleanKey . "_from"]);
627 }
628
629 return $date;
630 }
631
639 public static function fetchNumberFieldValue($key = "", $filterFields = [])
640 {
641 $number = [];
642 $number[$key] = $filterFields[$key];
643 $cleanKey = str_replace("_numsel", "", $key);
644
645 if (array_key_exists($cleanKey . "_from", $filterFields))
646 {
647 $number[$cleanKey . "_from"] = $filterFields[$cleanKey . "_from"];
648 }
649
650 if (array_key_exists($cleanKey . "_to", $filterFields))
651 {
652 $number[$cleanKey . "_to"] = $filterFields[$cleanKey . "_to"];
653 }
654
655 if ($number[$cleanKey . "_from"] === "" && $number[$cleanKey . "_to"] === "")
656 {
657 unset($number[$cleanKey . "_from"]);
658 unset($number[$cleanKey . "_to"]);
659 unset($number[$cleanKey . "_numsel"]);
660 }
661
662 return $number;
663 }
664
665 public static function isNumberField($key = "")
666 {
667 return is_string($key) && str_ends_with($key, "_numsel");
668 }
669
670 public static function fetchFieldValuesFromFilterSettings($filterSettings = [], $additionalFields = [], $sourceFields = [])
671 {
672 $filterFields = self::fetchFieldsFromFilterSettings($filterSettings, $additionalFields);
673 $resultFields = [];
674 foreach ($filterFields as $key => $field)
675 {
676 $isStrictField = false;
677
678 foreach ($sourceFields as $sourceField)
679 {
680 if (isset($sourceField["id"]) && $key === $sourceField["id"] && isset($sourceField["strict"]))
681 {
682 $isStrictField = true;
683 }
684 }
685
686 if ($field !== "")
687 {
688 if (self::isDateField($key))
689 {
691 $resultFields = array_merge($resultFields, $date);
692 }
693
694 elseif (self::isNumberField($key))
695 {
697 $resultFields = array_merge($resultFields, $number);
698 }
699
700 elseif (!str_ends_with($key, "_from") && !str_ends_with($key, "_to"))
701 {
702 if (str_ends_with($key, "_isEmpty"))
703 {
704 $resultFields[substr($key, 0, -8)] = false;
705 }
706 elseif (str_ends_with($key, "_hasAnyValue"))
707 {
708 $resultFields['!' . substr($key, 0, -12)] = false;
709 }
710 else
711 {
712 $resultFields[$key] = $field;
713 }
714 }
715 }
716 }
717
718 return $resultFields;
719 }
720
725 public static function isDefaultFilter($presetId = "")
726 {
727 return $presetId === self::DEFAULT_FILTER;
728 }
729
735 public function getFilter($sourceFields = [])
736 {
737 $result = [];
738 $this->trySetFilterFromRequest($sourceFields);
739 $currentPresetId = $this->getCurrentFilterId();
740
741 if (!self::isDefaultFilter($currentPresetId))
742 {
743 $filterSettings = $this->getFilterSettings($currentPresetId);
744 $additionalFields = $this->getAdditionalPresetFields($currentPresetId);
745 $fieldsValues = self::fetchFieldValuesFromFilterSettings($filterSettings, $additionalFields, $sourceFields);
746
747 $result = $fieldsValues;
748 $searchString = $this->getSearchString();
749
750 if (!empty($result) || $searchString !== "")
751 {
752 $result["PRESET_ID"] = $currentPresetId;
753 $result["FILTER_ID"] = $currentPresetId;
754 $result["FILTER_APPLIED"] = true;
755 $result["FIND"] = $searchString;
756 }
757 }
758 return $result;
759 }
760
766 public function getFilterLogic($sourceFields = [])
767 {
768 $filter = $this->getFilter($sourceFields);
769 $applied = ($filter["FILTER_APPLIED"] ?? false);
770 if ($applied === true)
771 {
772 return Type::getLogicFilter($filter, $sourceFields);
773 }
774 return [];
775 }
776
781 public function getSearchString()
782 {
783 $storage = $this->getStorage();
784
785 $search = $storage[$this->id]["filter_search"] ?? '';
786
787 return is_string($search) ? $search : "";
788 }
789
793 public function save()
794 {
795 global $USER;
796
797 if ($this->isUseCommonPresets())
798 {
799 $presets = [
800 "filters" => $this->options["filters"],
801 "deleted_presets" => $this->options["deleted_presets"],
802 ];
803
804 if ($USER->isAuthorized())
805 {
806 \CUserOptions::setOption("main.ui.filter.presets", $this->getCommonPresetsId(), $presets);
807 }
808 }
809
810 if ($USER->isAuthorized())
811 {
812 \CUserOptions::setOption("main.ui.filter", $this->getId(), $this->options);
813 }
814 else
815 {
816 $storage = $this->getStorage();
817 $storage[$this->getId()]["options"] = $this->options;
818 }
819 }
820
825 public function getAllUserOptions()
826 {
827 return \CUserOptions::getList(null, ["CATEGORY" => "main.ui.filter", "NAME" => $this->getId()]);
828 }
829
833 public static function isCurrentUserEditOtherSettings()
834 {
835 global $USER;
836 return $USER->CanDoOperation("edit_other_settings");
837 }
838
842 public function saveForAll()
843 {
844 global $USER;
845
846 if (self::isCurrentUserEditOtherSettings())
847 {
848 $allUserOptions = $this->getAllUserOptions();
849
850 if ($allUserOptions)
851 {
852 $currentOptions = $this->options;
853
854 $forAllPresets = [];
855
856 foreach ($currentOptions["filters"] as $key => $preset)
857 {
858 if ($preset["for_all"])
859 {
860 $forAllPresets[$key] = $preset;
861 }
862 }
863
864 while ($userOptions = $allUserOptions->fetch())
865 {
866 $currentUserOptions = unserialize($userOptions["VALUE"], ['allowed_classes' => false]);
867
868 if (is_array($currentUserOptions))
869 {
870 if (!self::isCommon($userOptions))
871 {
872 $currentUserOptions["deleted_presets"] = $currentOptions["deleted_presets"];
873 $currentUserOptions["filters"] = $forAllPresets;
874
875 if (!$USER->CanDoOperation("edit_other_settings", $userOptions["USER_ID"]))
876 {
877 $currentUserOptions["default_presets"] = $forAllPresets;
878 }
879 }
880
881 $this->saveOptionsForUser($currentUserOptions, $userOptions["USER_ID"]);
882 }
883 }
884
885 $this->saveCommon();
886 }
887 }
888 }
889
895 public static function isCommon($options)
896 {
897 return isset($options["USER_ID"]) && $options["USER_ID"] == 0;
898 }
899
906 {
907 if ($this->isUseCommonPresets())
908 {
909 $presets = [
910 "filters" => $options["filters"],
911 "deleted_presets" => $options["deleted_presets"],
912 ];
913
914 \CUserOptions::SetOption("main.ui.filter.presets", $this->getCommonPresetsId(), $presets, null, $userId);
915 }
916
917 $userOptions = \CUserOptions::GetOption("main.ui.filter", $this->getId(), ["filters" => [], "default_presets" => []], $userId);
918
919 if (is_array($options["deleted_presets"]))
920 {
921 foreach ($options["deleted_presets"] as $key => $isDeleted)
922 {
923 if (array_key_exists($key, $userOptions["filters"]))
924 {
925 unset($userOptions["filters"][$key]);
926 }
927 }
928 }
929
930 $options["filters"] = array_merge($userOptions["filters"], $options["filters"]);
931 \CUserOptions::SetOption("main.ui.filter", $this->getId(), $options, null, $userId);
932 }
933
937 public function saveCommon()
938 {
939 $presets = [];
940 $options = $this->getOptions();
941
942 foreach ($options["filters"] as $key => $preset)
943 {
944 if ($preset["for_all"])
945 {
946 $presets[$key] = $preset;
947 }
948 }
949
950 $options["filters"] = $presets;
951
952 \CUserOptions::setOption("main.ui.filter.common", $this->id, $options, true);
953 }
954
960 public function setFilterRows($presetId, $rows)
961 {
962 $aColsTmp = explode(",", $rows);
963 $aCols = [];
964 foreach ($aColsTmp as $col)
965 {
966 if (($col = trim($col)) <> "")
967 {
968 $aCols[] = $col;
969 }
970 }
971 if ($presetId <> '')
972 {
973 $this->options["filters"][$presetId]["filter_rows"] = implode(",", $aCols);
974 }
975 else
976 {
977 $this->options["filter_rows"] = implode(",", $aCols);
978 }
979 }
980
981 public function removeRowFromPreset(string $presetId, string $rowName): bool
982 {
983 $rowsString = $this->options["filters"][$presetId]["filter_rows"] ?? '';
984 if ($rowsString === '')
985 {
986 return false;
987 }
988 $rows = explode(",", $rowsString);
989 $pos = array_search($rowName, $rows, true);
990 if ($pos !== false)
991 {
992 unset($rows[$pos]);
993 $this->options["filters"][$presetId]["filter_rows"] = implode(",", $rows);
994
995 return true;
996 }
997
998 return false;
999 }
1000
1005 public function restore($settings = [])
1006 {
1007 if (!empty($settings))
1008 {
1009 foreach ($settings as $key => $preset)
1010 {
1011 $this->setFilterSettings($key, $preset, false);
1012
1013 if (array_key_exists($key, $this->options["deleted_presets"]))
1014 {
1015 unset($this->options["deleted_presets"][$key]);
1016 }
1017 }
1018
1019 $this->options["default"] = self::findDefaultPresetId($this->options["default_presets"]);
1020 $this->options["use_pin_preset"] = true;
1021 $this->options["filter"] = $this->options["default"];
1022
1023 $storage = $this->getStorage();
1024 unset($storage[$this->id]["filter"]);
1025 }
1026 }
1027
1031 public function setFilterSettingsArray($settings = [])
1032 {
1033 if (!empty($settings))
1034 {
1035 foreach ($settings as $key => $preset)
1036 {
1037 if ($key !== "current_preset" && $key !== "common_presets_id")
1038 {
1039 $this->setFilterSettings($key, $preset, false);
1040 }
1041 }
1042
1043 $this->options["filter"] = $settings["current_preset"];
1044 $request = $this->getRequest();
1045
1046 if (
1047 isset($request["params"]["forAll"])
1048 && (
1049 $request["params"]["forAll"] === "true"
1050 || $request["params"]["forAll"] === true
1051 )
1052 )
1053 {
1054 $this->saveForAll();
1055 }
1056 }
1057 }
1058
1065 public function setFilterSettings($presetId, $settings, $currentPreset = true, $useRequest = true)
1066 {
1067 if (!empty($presetId))
1068 {
1069 $storage = $this->getStorage();
1070
1071 if ($currentPreset)
1072 {
1073 $request = $this->getRequest();
1074 $params = $request->getPost('params');
1075 $params = is_array($params) ? $params : [];
1076
1077 $isApplyFilter = (
1078 ($request->get("apply_filter") == "Y" || $request->get("apply_filter") == "y") ||
1079 (isset($params["apply_filter"]) && ($params["apply_filter"] == "Y" || $params["apply_filter"] == "y"))
1080 );
1081 $isClearFilter = (
1082 ($request->get("clear_filter") == "Y" || $request->get("clear_filter") == "y") ||
1083 (isset($params["clear_filter"]) && ($params["clear_filter"] == "Y" || $params["clear_filter"] == "y"))
1084 );
1085 $isWithPreset = (
1086 ($request->get("with_preset") == "Y" || $request->get("with_preset") == "y") ||
1087 (isset($params["with_preset"]) && ($params["with_preset"] == "Y" || $params["with_preset"] == "y"))
1088 );
1089 $currentPresetId = $this->getCurrentFilterId();
1090
1091 if (
1092 ($useRequest
1093 && ($isApplyFilter || $isClearFilter)
1094 && (!$isWithPreset || $currentPresetId === static::DEFAULT_FILTER)
1095 )
1096 || $useRequest === false
1097 )
1098 {
1099 $storage[$this->id]["filter"] = $presetId;
1100 $storage[$this->id]["isSetOutside"] = $params["isSetOutside"] ?? false;
1101 }
1102 }
1103
1104 if (!isset($this->options["filters"][$presetId]) || !is_array($this->options["filters"][$presetId]))
1105 {
1106 $this->options["filters"][$presetId] = [];
1107 }
1108
1109 if (!empty($settings["name"]))
1110 {
1111 $this->options["filters"][$presetId]["name"] = $settings["name"];
1112 }
1113
1114 if (isset($settings["for_all"]))
1115 {
1116 $this->options["filters"][$presetId]["for_all"] = $settings["for_all"] === "true";
1117 }
1118
1119 if (isset($settings["sort"]) && is_numeric($settings["sort"]))
1120 {
1121 $this->options["filters"][$presetId]["sort"] = $settings["sort"];
1122 }
1123
1124 if (isset($settings["fields"]) && is_array($settings["fields"]))
1125 {
1126 if (array_key_exists("FIND", $settings["fields"]))
1127 {
1128 $storage[$this->id]["filter_search"] = $settings["fields"]["FIND"];
1129 unset($settings["fields"]["FIND"]);
1130 }
1131
1132 if ($presetId == "default_filter")
1133 {
1134 $this->options["filters"][$presetId]["fields"] = [];
1135 }
1136 else
1137 {
1138 $this->options["filters"][$presetId]["fields"] = $settings["fields"];
1139
1140 $additionalFields = isset($settings["additional"]) && is_array($settings["additional"]) ? $settings["additional"] : [];
1141 $this->setAdditionalPresetFields($presetId, $additionalFields);
1142 }
1143 }
1144
1145 if (!isset($settings["fields"]) && isset($settings["clear_filter"]) && $settings["clear_filter"] === 'Y')
1146 {
1147 $this->options["filters"][$presetId]["fields"] = [];
1148 }
1149
1150 if (!empty($settings["name"]))
1151 {
1152 $this->options["filters"][$presetId]["name"] = $settings["name"];
1153 }
1154
1155 if (isset($settings["rows"]))
1156 {
1157 $rows = $settings["rows"];
1158 if (is_array($rows))
1159 {
1160 $result = [];
1161 foreach ($rows as $id)
1162 {
1163 $id = trim($id);
1164 if ($id !== "")
1165 {
1166 $result[] = $id;
1167 }
1168 }
1169 $this->options["filters"][$presetId]["filter_rows"] = implode(",", $result);
1170 }
1171 elseif (is_string($settings["rows"]))
1172 {
1173 $this->options["filters"][$presetId]["filter_rows"] = $settings["rows"];
1174 }
1175 }
1176 }
1177 }
1178
1184 public function deleteFilter($presetId, $isDefault = false)
1185 {
1186 if ($isDefault)
1187 {
1188 $this->options["deleted_presets"][$presetId] = true;
1189 }
1190
1191 unset($this->options["filters"][$presetId]);
1192 }
1193
1199 public function isDeletedPreset($presetId)
1200 {
1201 return array_key_exists($presetId, $this->options["deleted_presets"]);
1202 }
1203
1210 {
1211 $this->setFilterSettings("tmp_filter", ["fields" => $fields, "rows" => $rows], true, false);
1212 $this->save();
1213 }
1214
1223 public static function calcDates($fieldId, $source, &$result)
1224 {
1225 switch ($source[$fieldId . "_datesel"])
1226 {
1227 case DateType::YESTERDAY :
1228 {
1229 $dateTime = Filter\DateTimeFactory::createToday();
1230
1231 $result[$fieldId . "_datesel"] = DateType::YESTERDAY;
1232 $result[$fieldId . "_month"] = $dateTime->month();
1233 $result[$fieldId . "_quarter"] = $dateTime->quarter();
1234 $result[$fieldId . "_year"] = $dateTime->year();
1235 $result[$fieldId . "_from"] = $dateTime->offset("- 1 days");
1236 $result[$fieldId . "_to"] = $dateTime->offset("- 1 second");
1237 break;
1238 }
1239
1241 {
1242 $dateTime = Filter\DateTimeFactory::createToday();
1243
1244 $result[$fieldId . "_datesel"] = DateType::CURRENT_DAY;
1245 $result[$fieldId . "_month"] = $dateTime->month();
1246 $result[$fieldId . "_quarter"] = $dateTime->quarter();
1247 $result[$fieldId . "_year"] = $dateTime->year();
1248 $result[$fieldId . "_from"] = $dateTime->toString();
1249 $result[$fieldId . "_to"] = $dateTime->offset("+ 1 days - 1 second");
1250 break;
1251 }
1252
1253 case DateType::TOMORROW :
1254 {
1255 $dateTime = Filter\DateTimeFactory::createToday();
1256
1257 $result[$fieldId . "_datesel"] = DateType::TOMORROW;
1258 $result[$fieldId . "_month"] = $dateTime->month();
1259 $result[$fieldId . "_year"] = $dateTime->year();
1260 $result[$fieldId . "_quarter"] = $dateTime->quarter();
1261 $result[$fieldId . "_from"] = $dateTime->offset("+ 1 days");
1262 $result[$fieldId . "_to"] = $dateTime->offset("+ 2 days - 1 second");
1263 break;
1264 }
1265
1267 {
1268 $dateTime = Filter\DateTimeFactory::createCurrentWeekMonday();
1269
1270 $result[$fieldId . "_datesel"] = DateType::CURRENT_WEEK;
1271 $result[$fieldId . "_month"] = $dateTime->month();
1272 $result[$fieldId . "_year"] = $dateTime->year();
1273 $result[$fieldId . "_quarter"] = $dateTime->quarter();
1274 $result[$fieldId . "_from"] = $dateTime->toString();
1275 $result[$fieldId . "_to"] = $dateTime->offset("7 days - 1 second");
1276 break;
1277 }
1278
1279 case DateType::NEXT_WEEK :
1280 {
1281 $dateTime = Filter\DateTimeFactory::createNextWeekMonday();
1282
1283 $result[$fieldId . "_datesel"] = DateType::NEXT_WEEK;
1284 $result[$fieldId . "_month"] = $dateTime->month();
1285 $result[$fieldId . "_year"] = $dateTime->year();
1286 $result[$fieldId . "_quarter"] = $dateTime->quarter();
1287 $result[$fieldId . "_from"] = $dateTime->toString();
1288 $result[$fieldId . "_to"] = $dateTime->offset("7 days - 1 second");
1289 break;
1290 }
1291
1293 {
1294 $dateTime = Filter\DateTimeFactory::createFirstDayOfCurrentMonth();
1295
1296 $result[$fieldId . "_datesel"] = DateType::CURRENT_MONTH;
1297 $result[$fieldId . "_month"] = $dateTime->month();
1298 $result[$fieldId . "_year"] = $dateTime->year();
1299 $result[$fieldId . "_quarter"] = $dateTime->quarter();
1300 $result[$fieldId . "_from"] = $dateTime->toString();
1301 $result[$fieldId . "_to"] = $dateTime->offset("1 month - 1 second");
1302 break;
1303 }
1304
1306 {
1307 $dateTime = Filter\DateTimeFactory::createFirstDayOfNextMonth();
1308
1309 $result[$fieldId . "_datesel"] = DateType::NEXT_MONTH;
1310 $result[$fieldId . "_month"] = $dateTime->month();
1311 $result[$fieldId . "_year"] = $dateTime->year();
1312 $result[$fieldId . "_quarter"] = $dateTime->quarter();
1313 $result[$fieldId . "_from"] = $dateTime->toString();
1314 $result[$fieldId . "_to"] = $dateTime->offset("1 month - 1 second");
1315 break;
1316 }
1317
1319 {
1320 $dateTime = Filter\DateTimeFactory::createToday();
1321
1322 $result[$fieldId . "_datesel"] = DateType::QUARTER;
1323 $result[$fieldId . "_month"] = $dateTime->month();
1324 $result[$fieldId . "_quarter"] = $dateTime->quarter();
1325 $result[$fieldId . "_year"] = $dateTime->year();
1326 $result[$fieldId . "_from"] = $dateTime->quarterStart();
1327 $result[$fieldId . "_to"] = $dateTime->quarterEnd();
1328 break;
1329 }
1330
1332 {
1333 $dateTime = Filter\DateTimeFactory::createToday();
1334
1335 $result[$fieldId . "_datesel"] = DateType::LAST_7_DAYS;
1336 $result[$fieldId . "_month"] = $dateTime->month();
1337 $result[$fieldId . "_quarter"] = $dateTime->quarter();
1338 $result[$fieldId . "_year"] = $dateTime->year();
1339 $result[$fieldId . "_from"] = $dateTime->offset("- 7 days");
1340 $result[$fieldId . "_to"] = $dateTime->offset("1 days - 1 second");
1341 break;
1342 }
1343
1345 {
1346 $dateTime = Filter\DateTimeFactory::createToday();
1347
1348 $result[$fieldId . "_datesel"] = DateType::LAST_30_DAYS;
1349 $result[$fieldId . "_month"] = $dateTime->month();
1350 $result[$fieldId . "_quarter"] = $dateTime->quarter();
1351 $result[$fieldId . "_year"] = $dateTime->year();
1352 $result[$fieldId . "_from"] = $dateTime->offset("- 30 days");
1353 $result[$fieldId . "_to"] = $dateTime->offset("1 days - 1 second");
1354 break;
1355 }
1356
1358 {
1359 $dateTime = Filter\DateTimeFactory::createToday();
1360
1361 $result[$fieldId . "_datesel"] = DateType::LAST_60_DAYS;
1362 $result[$fieldId . "_month"] = $dateTime->month();
1363 $result[$fieldId . "_quarter"] = $dateTime->quarter();
1364 $result[$fieldId . "_year"] = $dateTime->year();
1365 $result[$fieldId . "_from"] = $dateTime->offset("- 60 days");
1366 $result[$fieldId . "_to"] = $dateTime->offset("1 days - 1 second");
1367 break;
1368 }
1369
1371 {
1372 $dateTime = Filter\DateTimeFactory::createToday();
1373
1374 $result[$fieldId . "_datesel"] = DateType::LAST_90_DAYS;
1375 $result[$fieldId . "_month"] = $dateTime->month();
1376 $result[$fieldId . "_quarter"] = $dateTime->quarter();
1377 $result[$fieldId . "_year"] = $dateTime->year();
1378 $result[$fieldId . "_from"] = $dateTime->offset("- 90 days");
1379 $result[$fieldId . "_to"] = $dateTime->offset("1 days - 1 second");
1380 break;
1381 }
1382
1383 case DateType::MONTH :
1384 {
1385 $month = $source[$fieldId . "_month"];
1386 $year = $source[$fieldId . "_year"];
1387
1388 if (!empty($month) && !empty($year))
1389 {
1390 $dateTime = new Filter\DateTime(mktime(0, 0, 0, $month, 1, $year));
1391
1392 $result[$fieldId . "_datesel"] = DateType::MONTH;
1393 $result[$fieldId . "_month"] = $dateTime->month();
1394 $result[$fieldId . "_quarter"] = $dateTime->quarter();
1395 $result[$fieldId . "_year"] = $dateTime->year();
1396 $result[$fieldId . "_from"] = $dateTime->toString();
1397 $result[$fieldId . "_to"] = $dateTime->offset("1 month - 1 second");
1398 }
1399
1400 break;
1401 }
1402
1403 case DateType::NEXT_DAYS :
1404 {
1405 if (is_numeric($source[$fieldId . "_days"]))
1406 {
1407 $dateTime = Filter\DateTimeFactory::createToday();
1408 $days = (int)$source[$fieldId . "_days"];
1409 $days = $days > 0 ? ($days + 1) : $days;
1410
1411 $result[$fieldId . "_datesel"] = DateType::NEXT_DAYS;
1412 $result[$fieldId . "_month"] = $dateTime->month();
1413 $result[$fieldId . "_quarter"] = $dateTime->quarter();
1414 $result[$fieldId . "_days"] = $source[$fieldId . "_days"];
1415 $result[$fieldId . "_year"] = $dateTime->year();
1416 $result[$fieldId . "_from"] = $dateTime->offset("1 days");
1417 $result[$fieldId . "_to"] = $dateTime->offset($days . " days - 1 second");
1418 }
1419
1420 break;
1421 }
1422
1423 case DateType::PREV_DAYS :
1424 {
1425 if (is_numeric($source[$fieldId . "_days"]))
1426 {
1427 $dateTime = Filter\DateTimeFactory::createToday();
1428 $days = (int)$source[$fieldId . "_days"];
1429 $days = max($days, 0);
1430
1431 $result[$fieldId . "_datesel"] = DateType::PREV_DAYS;
1432 $result[$fieldId . "_month"] = $dateTime->month();
1433 $result[$fieldId . "_quarter"] = $dateTime->quarter();
1434 $result[$fieldId . "_days"] = $source[$fieldId . "_days"];
1435 $result[$fieldId . "_year"] = $dateTime->year();
1436 $result[$fieldId . "_from"] = $dateTime->offset("- " . $days . " days");
1437 $result[$fieldId . "_to"] = $dateTime->offset("1 days -1 second");
1438 }
1439
1440 break;
1441 }
1442
1444 {
1445 if (is_numeric($source[$fieldId . "_days"]))
1446 {
1447 $dateTime = Filter\DateTimeFactory::createToday();
1448 $days = (int)$source[$fieldId . "_days"];
1449
1450 $result[$fieldId . "_days"] = $source[$fieldId . "_days"];
1451 $result[$fieldId . "_from"] = $dateTime->offset(-$days . " days");
1452 $result[$fieldId . "_to"] = $dateTime->offset(-($days - 1) . " days -1 second");
1453 }
1454
1455 break;
1456 }
1457
1460 {
1461 if (is_numeric($source[$fieldId . "_days"]))
1462 {
1463 $dateTime = Filter\DateTimeFactory::createToday();
1464 $days = (int)$source[$fieldId . "_days"];
1465
1466 $result[$fieldId . "_days"] = $source[$fieldId . "_days"];
1467 $result[$fieldId . "_from"] = $dateTime->offset($days . " days");
1468 $result[$fieldId . "_to"] = $dateTime->offset(($days + 1) . " days -1 second");
1469 }
1470
1471 break;
1472 }
1473
1475 {
1476 if (is_numeric($source[$fieldId . "_days"]))
1477 {
1478 $dateTime = Filter\DateTimeFactory::createToday();
1479 $days = (int)$source[$fieldId . "_days"];
1480
1481 $result[$fieldId . "_days"] = $source[$fieldId . "_days"];
1482 $result[$fieldId . "_from"] = $dateTime->offset(-($days + 1) . " days");
1483 $result[$fieldId . "_to"] = $dateTime->offset(-$days . " days -1 second");
1484 }
1485
1486 break;
1487 }
1488
1489 case DateType::QUARTER :
1490 {
1491 $quarter = $source[$fieldId . "_quarter"];
1492 $year = $source[$fieldId . "_year"];
1493
1494 if (!empty($quarter) && !empty($year))
1495 {
1496 $dateTime = new Filter\DateTime(MakeTimeStamp(Quarter::getStartDate($quarter, $year)));
1497
1498 $result[$fieldId . "_datesel"] = DateType::QUARTER;
1499 $result[$fieldId . "_quarter"] = $dateTime->quarter();
1500 $result[$fieldId . "_year"] = $dateTime->year();
1501 $result[$fieldId . "_month"] = $dateTime->month();
1502 $result[$fieldId . "_from"] = $dateTime->quarterStart();
1503 $result[$fieldId . "_to"] = $dateTime->quarterEnd();
1504 }
1505
1506 break;
1507 }
1508
1509 case DateType::YEAR :
1510 {
1511 $year = $source[$fieldId . "_year"];
1512
1513 if (!empty($year))
1514 {
1515 $dateTime = new Filter\DateTime(mktime(0, 0, 0, 1, 1, $year));
1516
1517 $result[$fieldId . "_datesel"] = DateType::YEAR;
1518 $result[$fieldId . "_year"] = $dateTime->year();
1519 $result[$fieldId . "_from"] = $dateTime->toString();
1520 $result[$fieldId . "_to"] = $dateTime->offset("1 year - 1 second");
1521 }
1522
1523 break;
1524 }
1525
1526 case DateType::EXACT :
1527 {
1528 $sourceDate = $source[$fieldId . "_from"];
1529
1530 if (!empty($sourceDate))
1531 {
1532 $date = new Date($sourceDate);
1533 $dateTime = new Filter\DateTime(MakeTimeStamp($sourceDate));
1534
1535 $result[$fieldId . "_datesel"] = DateType::EXACT;
1536
1537 if ($dateTime->getTimestamp() > $date->getTimestamp())
1538 {
1539 $result[$fieldId . "_from"] = $dateTime->toString();
1540 $result[$fieldId . "_to"] = $dateTime->toString();
1541 }
1542 else
1543 {
1544 $result[$fieldId . "_from"] = $dateTime->toString();
1545 $result[$fieldId . "_to"] = $dateTime->offset("1 days - 1 second");
1546 }
1547 }
1548
1549 break;
1550 }
1551
1552 case DateType::LAST_WEEK :
1553 {
1554 $dateTime = Filter\DateTimeFactory::createLastWeekMonday();
1555
1556 $result[$fieldId . "_datesel"] = DateType::LAST_WEEK;
1557 $result[$fieldId . "_from"] = $dateTime->toString();
1558 $result[$fieldId . "_to"] = $dateTime->offset("7 days - 1 second");
1559 break;
1560 }
1561
1563 {
1564 $dateTime = Filter\DateTimeFactory::createFirstDayOfLastMonth();
1565
1566 $result[$fieldId . "_datesel"] = DateType::LAST_MONTH;
1567 $result[$fieldId . "_year"] = $dateTime->year();
1568 $result[$fieldId . "_month"] = $dateTime->month();
1569 $result[$fieldId . "_from"] = $dateTime->toString();
1570 $result[$fieldId . "_to"] = $dateTime->offset("1 month - 1 second");
1571 break;
1572 }
1573
1574 case DateType::RANGE :
1575 {
1576 $startSourceDate = $source[$fieldId . "_from"];
1577 $endSourceDate = $source[$fieldId . "_to"];
1578
1579 $result[$fieldId . "_from"] = "";
1580 $result[$fieldId . "_to"] = "";
1581
1582 if (!empty($startSourceDate))
1583 {
1584 $startDateTime = new Filter\DateTime(MakeTimeStamp($startSourceDate));
1585
1586 $result[$fieldId . "_datesel"] = DateType::RANGE;
1587 $result[$fieldId . "_from"] = $startDateTime->toString();
1588 }
1589
1590 if (!empty($endSourceDate))
1591 {
1592 $endDate = Date::createFromTimestamp(MakeTimeStamp($endSourceDate));
1593 $endDateTime = new Filter\DateTime(MakeTimeStamp($endSourceDate));
1594
1595 $result[$fieldId . "_datesel"] = DateType::RANGE;
1596
1597 if ($endDateTime->getTimestamp() > $endDate->getTimestamp())
1598 {
1599 $result[$fieldId . "_to"] = $endDateTime->toString();
1600 }
1601 else
1602 {
1603 $result[$fieldId . "_to"] = $endDateTime->offset("1 days - 1 second");
1604 }
1605 }
1606
1607 break;
1608 }
1609 }
1610 }
1611
1615 public function reset()
1616 {
1617 $storage = $this->getStorage();
1618 $storage[$this->id] = null;
1619 }
1620
1624 public function destroy()
1625 {
1626 $filterId = $this->getId();
1627
1628 \CUserOptions::deleteOption("main.ui.filter", $filterId);
1629 \CUserOptions::deleteOption("main.ui.filter.presets", $filterId);
1630
1631 $storage = $this->getStorage();
1632 unset($storage[$filterId]);
1633 }
1634
1635 public static function getRowsFromFields($fields = [])
1636 {
1637 $rows = [];
1638
1639 foreach ($fields as $key => $field)
1640 {
1641 $rows[] = str_replace(
1642 [
1643 "_datesel",
1644 "_numsel",
1645 "_from",
1646 "_to",
1647 "_days",
1648 "_month",
1649 "_quarter",
1650 "_id",
1651 "_year",
1652 "_name",
1653 "_label",
1654 "_value",
1655 "_days",
1656 "_months",
1657 "_years",
1658 "_isEmpty",
1659 "_hasAnyValue",
1660 ],
1661 "",
1662 $key
1663 );
1664 }
1665
1666 return array_unique($rows);
1667 }
1668
1674 public static function fetchPresetFields($preset)
1675 {
1676 if (isset($preset["filter_rows"]) && is_string($preset["filter_rows"]))
1677 {
1678 $fields = explode(",", $preset["filter_rows"]);
1679 return array_unique($fields);
1680 }
1681
1682 return static::getRowsFromFields($preset["fields"]);
1683 }
1684
1689 public function getUsedFields()
1690 {
1691 $fields = [];
1692
1693 // Fetch fields from user presets
1694 foreach ($this->getPresets() as $preset)
1695 {
1696 $presetFields = static::fetchPresetFields($preset);
1697 $fields = array_merge($fields, $presetFields);
1698 }
1699
1700 $defaultPresetFieldsOrder = [];
1701 // Fetch fields from default presets
1702 foreach ($this->getDefaultPresets() as $preset)
1703 {
1704 $presetFields = static::fetchPresetFields($preset);
1705 $fields = array_merge($fields, $presetFields);
1706 if (isset($preset['default']))
1707 {
1708 $defaultPresetFieldsOrder = $presetFields;
1709 }
1710 }
1711
1712 $fields = array_unique($fields);
1713
1714 if (!empty($defaultPresetFieldsOrder))
1715 {
1716 // fields order should be defined by default filter preset
1717 $fields = array_unique(array_merge($defaultPresetFieldsOrder, $fields));
1718 }
1719
1720 return $fields;
1721 }
1722
1726 public function getCurrentFilterPresetId(): ?string
1727 {
1729 }
1730
1735 public function setCurrentFilterPresetId(?string $presetId): Options
1736 {
1737 $this->currentFilterPresetId = $presetId;
1738 return $this;
1739 }
1740}
$type
Определения options.php:106
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getInstance()
Определения application.php:98
Определения date.php:9
const NEXT_DAYS
Определения datetype.php:26
const LAST_90_DAYS
Определения datetype.php:24
const NEXT_WEEK
Определения datetype.php:34
const LAST_60_DAYS
Определения datetype.php:23
const LAST_30_DAYS
Определения datetype.php:22
const YESTERDAY
Определения datetype.php:15
const CURRENT_DAY
Определения datetype.php:16
const PREV_DAYS
Определения datetype.php:25
const TOMORROW
Определения datetype.php:17
const LAST_WEEK
Определения datetype.php:31
const CURRENT_QUARTER
Определения datetype.php:20
const QUARTER
Определения datetype.php:28
const EXACT
Определения datetype.php:30
const CURRENT_MONTH
Определения datetype.php:19
const LAST_7_DAYS
Определения datetype.php:21
const LAST_MONTH
Определения datetype.php:32
const NEXT_MONTH
Определения datetype.php:35
const RANGE
Определения datetype.php:33
const CURRENT_WEEK
Определения datetype.php:18
const MONTH
Определения datetype.php:27
__construct($filterId, $filterPresets=[], $commonPresetsId=null)
Определения options.php:34
getAdditionalPresetFields($presetId)
Определения options.php:501
const DEFAULT_FILTER
Определения options.php:17
setUsePinPreset($value=true)
Определения options.php:223
fetchOptions($id)
Определения options.php:247
static isSetFromRequest(HttpRequest $request)
Определения options.php:342
isDeletedPreset($presetId)
Определения options.php:1199
pinPreset($presetId="default_filter")
Определения options.php:322
const TMP_FILTER
Определения options.php:18
static isCommon($options)
Определения options.php:895
removeRowFromPreset(string $presetId, string $rowName)
Определения options.php:981
getFilterLogic($sourceFields=[])
Определения options.php:766
isUseCommonPresets()
Определения options.php:133
setupDefaultFilter(array $fields, array $rows)
Определения options.php:1209
getFilterSettings($presetId)
Определения options.php:566
getDefaultFilterId()
Определения options.php:526
setFilterRows($presetId, $rows)
Определения options.php:960
setDefaultPresets($presets=[])
Определения options.php:205
getDefaultPresets()
Определения options.php:169
setDefaultPreset($presetId="default_filter")
Определения options.php:187
setPresets($presets=[])
Определения options.php:151
setCurrentPreset($presetId="default_filter")
Определения options.php:160
static fetchDateFieldValue($key="", $filterFields=[])
Определения options.php:613
saveOptionsForUser($options, $userId)
Определения options.php:905
getCurrentFilterPresetId()
Определения options.php:1726
static findDefaultPresetId($presets=[])
Определения options.php:291
deleteFilter($presetId, $isDefault=false)
Определения options.php:1184
static fetchSettingsFromQuery($fields, HttpRequest $request)
Определения options.php:357
getSearchString()
Определения options.php:781
static isDefaultFilter($presetId="")
Определения options.php:725
getFilter($sourceFields=[])
Определения options.php:735
static isCurrentUserEditOtherSettings()
Определения options.php:833
setAdditionalPresetFields($presetId, $additional=[])
Определения options.php:515
setDeletedPresets($deletedPresets=[])
Определения options.php:214
getCurrentFilterId()
Определения options.php:535
trySetFilterFromRequest($fields=[])
Определения options.php:542
static fetchCommonPresets($id)
Определения options.php:233
setFilterSettings($presetId, $settings, $currentPreset=true, $useRequest=true)
Определения options.php:1065
getAllUserOptions()
Определения options.php:825
static fetchFieldsFromFilterSettings($filterSettings=[], $additionalFields=[])
Определения options.php:577
static fetchFieldValuesFromFilterSettings($filterSettings=[], $additionalFields=[], $sourceFields=[])
Определения options.php:670
getSessionFilterId()
Определения options.php:479
string $currentFilterPresetId
Определения options.php:26
setCurrentFilterPresetId(?string $presetId)
Определения options.php:1735
static getRowsFromFields($fields=[])
Определения options.php:1635
static isDateField($key="")
Определения options.php:601
static fetchPresetFields($preset)
Определения options.php:1674
restore($settings=[])
Определения options.php:1005
setFilterSettingsArray($settings=[])
Определения options.php:1031
static isNumberField($key="")
Определения options.php:665
static fetchNumberFieldValue($key="", $filterFields=[])
Определения options.php:639
static calcDates($fieldId, $source, &$result)
Определения options.php:1223
getCommonPresetsId()
Определения options.php:125
static getStartDate($quarter, $year)
Определения quarter.php:74
</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
$filter
Определения iblock_catalog_list.php:54
$filterFields
Определения iblock_catalog_list.php:55
global $USER
Определения csv_new_run.php:40
MakeTimeStamp($datetime, $format=false)
Определения tools.php:538
$year
Определения payment.php:9
$settings
Определения product_settings.php:43
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if(empty($signedUserToken)) $key
Определения quickway.php:257
if(empty($decryptedData)) $storage
Определения quickway.php:270
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$rows
Определения options.php:264
$fields
Определения yandex_run.php:501